From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ido Schimmel Subject: [PATCH net-next 2/3] mlxsw: core: Reset firmware after flash during driver initialization Date: Tue, 6 Nov 2018 20:05:02 +0000 Message-ID: <20181106200314.29918-3-idosch@mellanox.com> References: <20181106200314.29918-1-idosch@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: "davem@davemloft.net" , Jiri Pirko , Shalom Toledo , Moshe Shemesh , "dsahern@gmail.com" , "jakub.kicinski@netronome.com" , "andrew@lunn.ch" , "f.fainelli@gmail.com" , mlxsw , Ido Schimmel To: "netdev@vger.kernel.org" Return-path: Received: from mail-eopbgr30068.outbound.protection.outlook.com ([40.107.3.68]:10370 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726157AbeKGFcB (ORCPT ); Wed, 7 Nov 2018 00:32:01 -0500 In-Reply-To: <20181106200314.29918-1-idosch@mellanox.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: From: Shalom Toledo 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 Reviewed-by: Jiri Pirko Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/core.c | 32 +++++++++++++++++++--- drivers/net/ethernet/mellanox/mlxsw/pci.c | 11 +------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ether= net/mellanox/mlxsw/core.c index 30f751e69698..b2e1b83525db 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core.c @@ -965,10 +965,11 @@ static const struct devlink_ops mlxsw_devlink_ops =3D= { .sb_occ_tc_port_bind_get =3D mlxsw_devlink_sb_occ_tc_port_bind_get, }; =20 -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) +static int +__mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_in= fo, + const struct mlxsw_bus *mlxsw_bus, + void *bus_priv, bool reload, + struct devlink *devlink) { const char *device_kind =3D mlxsw_bus_info->device_kind; struct mlxsw_core *mlxsw_core; @@ -1076,6 +1077,29 @@ int mlxsw_core_bus_device_register(const struct mlxs= w_bus_info *mlxsw_bus_info, err_devlink_alloc: 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 =3D false; + int err; + +again: + err =3D __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 =3D=3D -EAGAIN && !called_again) { + called_again =3D true; + goto again; + } + + return err; +} EXPORT_SYMBOL(mlxsw_core_bus_device_register); =20 void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core, diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethern= et/mellanox/mlxsw/pci.c index 5890fdfd62c3..66b8098c6fd2 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/pci.c +++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c @@ -1720,7 +1720,6 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, cons= t struct pci_device_id *id) { const char *driver_name =3D pdev->driver->name; struct mlxsw_pci *mlxsw_pci; - bool called_again =3D false; int err; =20 mlxsw_pci =3D kzalloc(sizeof(*mlxsw_pci), GFP_KERNEL); @@ -1777,18 +1776,10 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, co= nst struct pci_device_id *id) mlxsw_pci->bus_info.dev =3D &pdev->dev; mlxsw_pci->id =3D id; =20 -again: err =3D mlxsw_core_bus_device_register(&mlxsw_pci->bus_info, &mlxsw_pci_bus, mlxsw_pci, false, NULL); - /* -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 =3D=3D -EAGAIN && !called_again) { - called_again =3D true; - goto again; - } else if (err) { + if (err) { dev_err(&pdev->dev, "cannot register bus device\n"); goto err_bus_device_register; } --=20 2.19.1