From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: Tariq Toukan <tariqt@nvidia.com>, Jianbo Liu <jianbol@nvidia.com>
Cc: <netdev@vger.kernel.org>, Saeed Mahameed <saeedm@nvidia.com>,
Gal Pressman <gal@nvidia.com>,
Leon Romanovsky <leonro@nvidia.com>,
Mark Bloch <mbloch@nvidia.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Eric Dumazet <edumazet@google.com>,
Andrew Lunn <andrew+netdev@lunn.ch>
Subject: Re: [PATCH net 4/4] net/mlx5e: Keep netdev when leave switchdev for devlink set legacy only
Date: Fri, 20 Dec 2024 09:48:11 +0100 [thread overview]
Message-ID: <ec95c546-114d-402f-b7b9-b3e54b33dbf0@intel.com> (raw)
In-Reply-To: <20241220081505.1286093-5-tariqt@nvidia.com>
On 12/20/24 09:15, Tariq Toukan wrote:
> From: Jianbo Liu <jianbol@nvidia.com>
>
> In the cited commit, when changing from switchdev to legacy mode,
> uplink representor's netdev is kept, and its profile is replaced with
> nic profile, so netdev is detached from old profile, then attach to
> new profile.
>
> During profile change, the hardware resources allocated by the old
> profile will be cleaned up. However, the cleanup is relying on the
> related kernel modules. And they may need to flush themselves first,
> which is triggered by netdev events, for example, NETDEV_UNREGISTER.
> However, netdev is kept, or netdev_register is called after the
> cleanup, which may cause troubles because the resources are still
> referred by kernel modules.
>
> The same process applies to all the caes when uplink is leaving
case
> switchdev mode, including devlink eswitch mode set legacy, driver
> unload and devlink reload. For the first one, it can be blocked and
> returns failure to users, whenever possible. But it's hard for the
> others. Besides, the attachment to nic profile is unnecessary as the
> netdev will be unregistered anyway for such cases.
>
> So in this patch, the original behavior is kept only for devlink
> eswitch set mode legacy. For the others, moves netdev unregistration
> before the profile change.
>
> Fixes: 7a9fb35e8c3a ("net/mlx5e: Do not reload ethernet ports when changing eswitch mode")
> Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
> ---
> .../net/ethernet/mellanox/mlx5/core/en_main.c | 19 +++++++++++++++++--
> .../net/ethernet/mellanox/mlx5/core/en_rep.c | 15 +++++++++++++++
> .../mellanox/mlx5/core/eswitch_offloads.c | 2 ++
> include/linux/mlx5/driver.h | 1 +
> 4 files changed, 35 insertions(+), 2 deletions(-)
>
sorry for nitpick-only review
I didn't spotted anything bad in the logic through the series OTOH
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> index dd16d73000c3..0ec17c276bdd 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> @@ -6542,8 +6542,23 @@ static void _mlx5e_remove(struct auxiliary_device *adev)
>
> mlx5_core_uplink_netdev_set(mdev, NULL);
> mlx5e_dcbnl_delete_app(priv);
> - unregister_netdev(priv->netdev);
> - _mlx5e_suspend(adev, false);
> + /* When unload driver, the netdev is in registered state
/*
* Netdev dropped the special comment allowance rule,
* now you have to put one line almost blank at the front.
*/
> + * if it's from legacy mode. If from switchdev mode, it
> + * is already unregistered before changing to NIC profile.
> + */
> + if (priv->netdev->reg_state == NETREG_REGISTERED) {
> + unregister_netdev(priv->netdev);
> + _mlx5e_suspend(adev, false);
> + } else {
> + struct mlx5_core_dev *pos;
> + int i;
> +
> + if (test_bit(MLX5E_STATE_DESTROYING, &priv->state))
you have more than one statement/expression inside the if,
so you must wrap with braces
> + mlx5_sd_for_each_dev(i, mdev, pos)
> + mlx5e_destroy_mdev_resources(pos);
> + else
> + _mlx5e_suspend(adev, true);
> + }
> /* Avoid cleanup if profile rollback failed. */
> if (priv->profile)
> priv->profile->cleanup(priv);
next prev parent reply other threads:[~2024-12-20 8:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-20 8:15 [PATCH net 0/4] mlx5 misc fixes 2024-12-20 Tariq Toukan
2024-12-20 8:15 ` [PATCH net 1/4] net/mlx5: DR, select MSIX vector 0 for completion queue creation Tariq Toukan
2024-12-20 8:15 ` [PATCH net 2/4] net/mlx5e: macsec: Maintain TX SA from encoding_sa Tariq Toukan
2024-12-20 8:15 ` [PATCH net 3/4] net/mlx5e: Skip restore TC rules for vport rep without loaded flag Tariq Toukan
2024-12-20 8:15 ` [PATCH net 4/4] net/mlx5e: Keep netdev when leave switchdev for devlink set legacy only Tariq Toukan
2024-12-20 8:48 ` Przemek Kitszel [this message]
2024-12-20 14:46 ` Jakub Kicinski
2024-12-20 15:10 ` Przemek Kitszel
2024-12-23 19:10 ` [PATCH net 0/4] mlx5 misc fixes 2024-12-20 patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ec95c546-114d-402f-b7b9-b3e54b33dbf0@intel.com \
--to=przemyslaw.kitszel@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=jianbol@nvidia.com \
--cc=kuba@kernel.org \
--cc=leonro@nvidia.com \
--cc=mbloch@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).