Commit c86d62cc authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

mlxsw: spectrum: Reset FW after flash

Recent FW fixes a bug and allows to load newly flashed FW image after
reset. So make sure the reset happens after flash. Indicate the need
down to PCI layer by -EAGAIN.
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a716d55e
...@@ -362,6 +362,7 @@ struct mlxsw_fw_rev { ...@@ -362,6 +362,7 @@ struct mlxsw_fw_rev {
u16 major; u16 major;
u16 minor; u16 minor;
u16 subminor; u16 subminor;
u16 can_reset_minor;
}; };
struct mlxsw_bus_info { struct mlxsw_bus_info {
......
...@@ -1750,6 +1750,7 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1750,6 +1750,7 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{ {
const char *driver_name = pdev->driver->name; const char *driver_name = pdev->driver->name;
struct mlxsw_pci *mlxsw_pci; struct mlxsw_pci *mlxsw_pci;
bool called_again = false;
int err; int err;
mlxsw_pci = kzalloc(sizeof(*mlxsw_pci), GFP_KERNEL); mlxsw_pci = kzalloc(sizeof(*mlxsw_pci), GFP_KERNEL);
...@@ -1806,10 +1807,18 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1806,10 +1807,18 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
mlxsw_pci->bus_info.dev = &pdev->dev; mlxsw_pci->bus_info.dev = &pdev->dev;
mlxsw_pci->id = id; mlxsw_pci->id = id;
again:
err = mlxsw_core_bus_device_register(&mlxsw_pci->bus_info, err = mlxsw_core_bus_device_register(&mlxsw_pci->bus_info,
&mlxsw_pci_bus, mlxsw_pci, false, &mlxsw_pci_bus, mlxsw_pci, false,
NULL); NULL);
if (err) { /* -EAGAIN is returned in case the FW was updated. FW needs
* a reset, so lets try to call mlxsw_core_bus_device_register()
* again.
*/
if (err == -EAGAIN && !called_again) {
called_again = true;
goto again;
} else if (err) {
dev_err(&pdev->dev, "cannot register bus device\n"); dev_err(&pdev->dev, "cannot register bus device\n");
goto err_bus_device_register; goto err_bus_device_register;
} }
......
...@@ -79,11 +79,13 @@ ...@@ -79,11 +79,13 @@
#define MLXSW_SP1_FWREV_MAJOR 13 #define MLXSW_SP1_FWREV_MAJOR 13
#define MLXSW_SP1_FWREV_MINOR 1702 #define MLXSW_SP1_FWREV_MINOR 1702
#define MLXSW_SP1_FWREV_SUBMINOR 6 #define MLXSW_SP1_FWREV_SUBMINOR 6
#define MLXSW_SP1_FWREV_CAN_RESET_MINOR 1702
static const struct mlxsw_fw_rev mlxsw_sp1_fw_rev = { static const struct mlxsw_fw_rev mlxsw_sp1_fw_rev = {
.major = MLXSW_SP1_FWREV_MAJOR, .major = MLXSW_SP1_FWREV_MAJOR,
.minor = MLXSW_SP1_FWREV_MINOR, .minor = MLXSW_SP1_FWREV_MINOR,
.subminor = MLXSW_SP1_FWREV_SUBMINOR, .subminor = MLXSW_SP1_FWREV_SUBMINOR,
.can_reset_minor = MLXSW_SP1_FWREV_CAN_RESET_MINOR,
}; };
#define MLXSW_SP1_FW_FILENAME \ #define MLXSW_SP1_FW_FILENAME \
...@@ -380,7 +382,16 @@ static int mlxsw_sp_fw_rev_validate(struct mlxsw_sp *mlxsw_sp) ...@@ -380,7 +382,16 @@ static int mlxsw_sp_fw_rev_validate(struct mlxsw_sp *mlxsw_sp)
err = mlxsw_sp_firmware_flash(mlxsw_sp, firmware); err = mlxsw_sp_firmware_flash(mlxsw_sp, firmware);
release_firmware(firmware); release_firmware(firmware);
return err; if (err)
dev_err(mlxsw_sp->bus_info->dev, "Could not upgrade firmware\n");
/* On FW flash success, tell the caller FW reset is needed
* if current FW supports it.
*/
if (rev->minor >= req_rev->can_reset_minor)
return err ? err : -EAGAIN;
else
return 0;
} }
int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp, int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,
...@@ -3734,10 +3745,8 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core, ...@@ -3734,10 +3745,8 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
mlxsw_sp->bus_info = mlxsw_bus_info; mlxsw_sp->bus_info = mlxsw_bus_info;
err = mlxsw_sp_fw_rev_validate(mlxsw_sp); err = mlxsw_sp_fw_rev_validate(mlxsw_sp);
if (err) { if (err)
dev_err(mlxsw_sp->bus_info->dev, "Could not upgrade firmware\n");
return err; return err;
}
err = mlxsw_sp_base_mac_get(mlxsw_sp); err = mlxsw_sp_base_mac_get(mlxsw_sp);
if (err) { if (err) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment