Commit 03bffcad authored by Shalom Toledo's avatar Shalom Toledo Committed by David S. Miller

mlxsw: core: Reset firmware after flash during driver initialization

After flashing new firmware during the driver initialization flow (reload
or not), the driver should do a firmware reset when it gets -EAGAIN in
order to load the new one.
Signed-off-by: default avatarShalom Toledo <shalomt@mellanox.com>
Reviewed-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 846e980a
...@@ -965,10 +965,11 @@ static const struct devlink_ops mlxsw_devlink_ops = { ...@@ -965,10 +965,11 @@ static const struct devlink_ops mlxsw_devlink_ops = {
.sb_occ_tc_port_bind_get = mlxsw_devlink_sb_occ_tc_port_bind_get, .sb_occ_tc_port_bind_get = mlxsw_devlink_sb_occ_tc_port_bind_get,
}; };
int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, static int
const struct mlxsw_bus *mlxsw_bus, __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
void *bus_priv, bool reload, const struct mlxsw_bus *mlxsw_bus,
struct devlink *devlink) void *bus_priv, bool reload,
struct devlink *devlink)
{ {
const char *device_kind = mlxsw_bus_info->device_kind; const char *device_kind = mlxsw_bus_info->device_kind;
struct mlxsw_core *mlxsw_core; struct mlxsw_core *mlxsw_core;
...@@ -1076,6 +1077,29 @@ int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, ...@@ -1076,6 +1077,29 @@ int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
err_devlink_alloc: err_devlink_alloc:
return err; return err;
} }
int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
const struct mlxsw_bus *mlxsw_bus,
void *bus_priv, bool reload,
struct devlink *devlink)
{
bool called_again = false;
int err;
again:
err = __mlxsw_core_bus_device_register(mlxsw_bus_info, mlxsw_bus,
bus_priv, reload, devlink);
/* -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;
}
return err;
}
EXPORT_SYMBOL(mlxsw_core_bus_device_register); EXPORT_SYMBOL(mlxsw_core_bus_device_register);
void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core, void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
......
...@@ -1720,7 +1720,6 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1720,7 +1720,6 @@ 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);
...@@ -1777,18 +1776,10 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1777,18 +1776,10 @@ 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);
/* -EAGAIN is returned in case the FW was updated. FW needs if (err) {
* 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;
} }
......
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