From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Eric Dumazet <edumazet@google.com>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
netdev@vger.kernel.org, Tariq Toukan <tariqt@nvidia.com>,
Dmytro Linkin <dlinkin@nvidia.com>
Subject: [net 10/17] net/mlx5e: Don't attach netdev profile while handling internal error
Date: Wed, 24 May 2023 20:48:40 -0700 [thread overview]
Message-ID: <20230525034847.99268-11-saeed@kernel.org> (raw)
In-Reply-To: <20230525034847.99268-1-saeed@kernel.org>
From: Dmytro Linkin <dlinkin@nvidia.com>
As part of switchdev mode disablement, driver changes port netdevice
profile from uplink to nic. If this process is triggered by health
recovery flow (PCI reset, for ex.) profile attach would fail because all
fw commands aborted when internal error flag is set. As a result, nic
netdevice profile is not attached and driver fails to rollback to uplink
profile, which leave driver in broken state and cause crash later.
To handle broken state do netdevice profile initialization only instead
of full attachment and release mdev resources on driver suspend as
expected. Actual netdevice attachment is done during driver load.
Fixes: c4d7eb57687f ("net/mxl5e: Add change profile method")
Signed-off-by: Dmytro Linkin <dlinkin@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/en_main.c | 35 ++++++++++++++++---
1 file changed, 31 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 0235adcbc609..a07bbe9a61be 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -5833,8 +5833,8 @@ void mlx5e_detach_netdev(struct mlx5e_priv *priv)
}
static int
-mlx5e_netdev_attach_profile(struct net_device *netdev, struct mlx5_core_dev *mdev,
- const struct mlx5e_profile *new_profile, void *new_ppriv)
+mlx5e_netdev_init_profile(struct net_device *netdev, struct mlx5_core_dev *mdev,
+ const struct mlx5e_profile *new_profile, void *new_ppriv)
{
struct mlx5e_priv *priv = netdev_priv(netdev);
int err;
@@ -5850,6 +5850,25 @@ mlx5e_netdev_attach_profile(struct net_device *netdev, struct mlx5_core_dev *mde
err = new_profile->init(priv->mdev, priv->netdev);
if (err)
goto priv_cleanup;
+
+ return 0;
+
+priv_cleanup:
+ mlx5e_priv_cleanup(priv);
+ return err;
+}
+
+static int
+mlx5e_netdev_attach_profile(struct net_device *netdev, struct mlx5_core_dev *mdev,
+ const struct mlx5e_profile *new_profile, void *new_ppriv)
+{
+ struct mlx5e_priv *priv = netdev_priv(netdev);
+ int err;
+
+ err = mlx5e_netdev_init_profile(netdev, mdev, new_profile, new_ppriv);
+ if (err)
+ return err;
+
err = mlx5e_attach_netdev(priv);
if (err)
goto profile_cleanup;
@@ -5857,7 +5876,6 @@ mlx5e_netdev_attach_profile(struct net_device *netdev, struct mlx5_core_dev *mde
profile_cleanup:
new_profile->cleanup(priv);
-priv_cleanup:
mlx5e_priv_cleanup(priv);
return err;
}
@@ -5876,6 +5894,12 @@ int mlx5e_netdev_change_profile(struct mlx5e_priv *priv,
priv->profile->cleanup(priv);
mlx5e_priv_cleanup(priv);
+ if (mdev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {
+ mlx5e_netdev_init_profile(netdev, mdev, new_profile, new_ppriv);
+ set_bit(MLX5E_STATE_DESTROYING, &priv->state);
+ return -EIO;
+ }
+
err = mlx5e_netdev_attach_profile(netdev, mdev, new_profile, new_ppriv);
if (err) { /* roll back to original profile */
netdev_warn(netdev, "%s: new profile init failed, %d\n", __func__, err);
@@ -5937,8 +5961,11 @@ static int mlx5e_suspend(struct auxiliary_device *adev, pm_message_t state)
struct net_device *netdev = priv->netdev;
struct mlx5_core_dev *mdev = priv->mdev;
- if (!netif_device_present(netdev))
+ if (!netif_device_present(netdev)) {
+ if (test_bit(MLX5E_STATE_DESTROYING, &priv->state))
+ mlx5e_destroy_mdev_resources(mdev);
return -ENODEV;
+ }
mlx5e_detach_netdev(priv);
mlx5e_destroy_mdev_resources(mdev);
--
2.40.1
next prev parent reply other threads:[~2023-05-25 3:49 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-25 3:48 [pull request][net 00/17] mlx5 fixes 2023-05-24 Saeed Mahameed
2023-05-25 3:48 ` [net 01/17] net/mlx5e: Extract remaining tunnel encap code to dedicated file Saeed Mahameed
2023-05-26 4:30 ` patchwork-bot+netdevbpf
2023-05-25 3:48 ` [net 02/17] net/mlx5e: Prevent encap offload when neigh update is running Saeed Mahameed
2023-05-25 3:48 ` [net 03/17] net/mlx5e: Consider internal buffers size in port buffer calculations Saeed Mahameed
2023-05-25 3:48 ` [net 04/17] net/mlx5e: Do not update SBCM when prio2buffer command is invalid Saeed Mahameed
2023-05-25 3:48 ` [net 05/17] net/mlx5: Drain health before unregistering devlink Saeed Mahameed
2023-05-25 3:48 ` [net 06/17] net/mlx5: SF, Drain health before removing device Saeed Mahameed
2023-05-25 3:48 ` [net 07/17] net/mlx5: fw_tracer, Fix event handling Saeed Mahameed
2023-05-25 3:48 ` [net 08/17] net/mlx5e: Use query_special_contexts cmd only once per mdev Saeed Mahameed
2023-05-25 3:48 ` [net 09/17] net/mlx5: Fix post parse infra to only parse every action once Saeed Mahameed
2023-05-25 3:48 ` Saeed Mahameed [this message]
2023-05-25 3:48 ` [net 11/17] net/mlx5e: Move Ethernet driver debugfs to profile init callback Saeed Mahameed
2023-05-25 3:48 ` [net 12/17] net/mlx5: DR, Add missing mutex init/destroy in pattern manager Saeed Mahameed
2023-05-25 3:48 ` [net 13/17] net/mlx5: Fix check for allocation failure in comp_irqs_request_pci() Saeed Mahameed
2023-05-25 3:48 ` [net 14/17] Documentation: net/mlx5: Wrap vnic reporter devlink commands in code blocks Saeed Mahameed
2023-05-25 3:48 ` [net 15/17] Documentation: net/mlx5: Use bullet and definition lists for vnic counters description Saeed Mahameed
2023-05-25 3:48 ` [net 16/17] Documentation: net/mlx5: Add blank line separator before numbered lists Saeed Mahameed
2023-05-25 3:48 ` [net 17/17] Documentation: net/mlx5: Wrap notes in admonition blocks Saeed Mahameed
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=20230525034847.99268-11-saeed@kernel.org \
--to=saeed@kernel.org \
--cc=davem@davemloft.net \
--cc=dlinkin@nvidia.com \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--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).