Skip to content

Commit 03bffca

Browse files
Shalom Toledodavem330
authored andcommitted
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: Shalom Toledo <shalomt@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 846e980 commit 03bffca

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

drivers/net/ethernet/mellanox/mlxsw/core.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -965,10 +965,11 @@ static const struct devlink_ops mlxsw_devlink_ops = {
965965
.sb_occ_tc_port_bind_get = mlxsw_devlink_sb_occ_tc_port_bind_get,
966966
};
967967

968-
int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
969-
const struct mlxsw_bus *mlxsw_bus,
970-
void *bus_priv, bool reload,
971-
struct devlink *devlink)
968+
static int
969+
__mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
970+
const struct mlxsw_bus *mlxsw_bus,
971+
void *bus_priv, bool reload,
972+
struct devlink *devlink)
972973
{
973974
const char *device_kind = mlxsw_bus_info->device_kind;
974975
struct mlxsw_core *mlxsw_core;
@@ -1076,6 +1077,29 @@ int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
10761077
err_devlink_alloc:
10771078
return err;
10781079
}
1080+
1081+
int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
1082+
const struct mlxsw_bus *mlxsw_bus,
1083+
void *bus_priv, bool reload,
1084+
struct devlink *devlink)
1085+
{
1086+
bool called_again = false;
1087+
int err;
1088+
1089+
again:
1090+
err = __mlxsw_core_bus_device_register(mlxsw_bus_info, mlxsw_bus,
1091+
bus_priv, reload, devlink);
1092+
/* -EAGAIN is returned in case the FW was updated. FW needs
1093+
* a reset, so lets try to call __mlxsw_core_bus_device_register()
1094+
* again.
1095+
*/
1096+
if (err == -EAGAIN && !called_again) {
1097+
called_again = true;
1098+
goto again;
1099+
}
1100+
1101+
return err;
1102+
}
10791103
EXPORT_SYMBOL(mlxsw_core_bus_device_register);
10801104

10811105
void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,

drivers/net/ethernet/mellanox/mlxsw/pci.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,6 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
17201720
{
17211721
const char *driver_name = pdev->driver->name;
17221722
struct mlxsw_pci *mlxsw_pci;
1723-
bool called_again = false;
17241723
int err;
17251724

17261725
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)
17771776
mlxsw_pci->bus_info.dev = &pdev->dev;
17781777
mlxsw_pci->id = id;
17791778

1780-
again:
17811779
err = mlxsw_core_bus_device_register(&mlxsw_pci->bus_info,
17821780
&mlxsw_pci_bus, mlxsw_pci, false,
17831781
NULL);
1784-
/* -EAGAIN is returned in case the FW was updated. FW needs
1785-
* a reset, so lets try to call mlxsw_core_bus_device_register()
1786-
* again.
1787-
*/
1788-
if (err == -EAGAIN && !called_again) {
1789-
called_again = true;
1790-
goto again;
1791-
} else if (err) {
1782+
if (err) {
17921783
dev_err(&pdev->dev, "cannot register bus device\n");
17931784
goto err_bus_device_register;
17941785
}

0 commit comments

Comments
 (0)