netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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>,
	Moshe Shemesh <moshe@nvidia.com>, Shay Drory <shayd@nvidia.com>
Subject: [net-next 01/15] net/mlx5: Ack on sync_reset_request only if PF can do reset_now
Date: Fri, 16 Jun 2023 13:10:59 -0700	[thread overview]
Message-ID: <20230616201113.45510-2-saeed@kernel.org> (raw)
In-Reply-To: <20230616201113.45510-1-saeed@kernel.org>

From: Moshe Shemesh <moshe@nvidia.com>

Verify at reset_request stage that PF is capable to do reset_now. In
case PF is not capable, notify the firmware that the sync reset can not
happen and so firmware will abort the sync reset at early stage and will
not send reset_now event to any PF.

Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Shay Drory <shayd@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../ethernet/mellanox/mlx5/core/fw_reset.c    | 57 ++++++++++++++-----
 1 file changed, 44 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c
index 50022e7565f1..952cc340b510 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c
@@ -276,6 +276,44 @@ static void mlx5_fw_live_patch_event(struct work_struct *work)
 		mlx5_core_err(dev, "Failed to reload FW tracer\n");
 }
 
+static int mlx5_check_dev_ids(struct mlx5_core_dev *dev, u16 dev_id)
+{
+	struct pci_bus *bridge_bus = dev->pdev->bus;
+	struct pci_dev *sdev;
+	u16 sdev_id;
+	int err;
+
+	/* Check that all functions under the pci bridge are PFs of
+	 * this device otherwise fail this function.
+	 */
+	list_for_each_entry(sdev, &bridge_bus->devices, bus_list) {
+		err = pci_read_config_word(sdev, PCI_DEVICE_ID, &sdev_id);
+		if (err)
+			return err;
+		if (sdev_id != dev_id) {
+			mlx5_core_warn(dev, "unrecognized dev_id (0x%x)\n", sdev_id);
+			return -EPERM;
+		}
+	}
+	return 0;
+}
+
+static bool mlx5_is_reset_now_capable(struct mlx5_core_dev *dev)
+{
+	u16 dev_id;
+	int err;
+
+	if (!MLX5_CAP_GEN(dev, fast_teardown)) {
+		mlx5_core_warn(dev, "fast teardown is not supported by firmware\n");
+		return -EOPNOTSUPP;
+	}
+
+	err = pci_read_config_word(dev->pdev, PCI_DEVICE_ID, &dev_id);
+	if (err)
+		return false;
+	return (!mlx5_check_dev_ids(dev, dev_id));
+}
+
 static void mlx5_sync_reset_request_event(struct work_struct *work)
 {
 	struct mlx5_fw_reset *fw_reset = container_of(work, struct mlx5_fw_reset,
@@ -283,7 +321,8 @@ static void mlx5_sync_reset_request_event(struct work_struct *work)
 	struct mlx5_core_dev *dev = fw_reset->dev;
 	int err;
 
-	if (test_bit(MLX5_FW_RESET_FLAGS_NACK_RESET_REQUEST, &fw_reset->reset_flags)) {
+	if (test_bit(MLX5_FW_RESET_FLAGS_NACK_RESET_REQUEST, &fw_reset->reset_flags) ||
+	    !mlx5_is_reset_now_capable(dev)) {
 		err = mlx5_fw_reset_set_reset_sync_nack(dev);
 		mlx5_core_warn(dev, "PCI Sync FW Update Reset Nack %s",
 			       err ? "Failed" : "Sent");
@@ -303,26 +342,18 @@ static int mlx5_pci_link_toggle(struct mlx5_core_dev *dev)
 {
 	struct pci_bus *bridge_bus = dev->pdev->bus;
 	struct pci_dev *bridge = bridge_bus->self;
-	u16 reg16, dev_id, sdev_id;
 	unsigned long timeout;
 	struct pci_dev *sdev;
+	u16 reg16, dev_id;
 	int cap, err;
 	u32 reg32;
 
-	/* Check that all functions under the pci bridge are PFs of
-	 * this device otherwise fail this function.
-	 */
 	err = pci_read_config_word(dev->pdev, PCI_DEVICE_ID, &dev_id);
 	if (err)
 		return err;
-	list_for_each_entry(sdev, &bridge_bus->devices, bus_list) {
-		err = pci_read_config_word(sdev, PCI_DEVICE_ID, &sdev_id);
-		if (err)
-			return err;
-		if (sdev_id != dev_id)
-			return -EPERM;
-	}
-
+	err = mlx5_check_dev_ids(dev, dev_id);
+	if (err)
+		return err;
 	cap = pci_find_capability(bridge, PCI_CAP_ID_EXP);
 	if (!cap)
 		return -EOPNOTSUPP;
-- 
2.40.1


  reply	other threads:[~2023-06-16 20:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-16 20:10 [pull request][net-next 00/15] mlx5 updates 2023-06-16 Saeed Mahameed
2023-06-16 20:10 ` Saeed Mahameed [this message]
2023-06-18 18:00   ` [net-next 01/15] net/mlx5: Ack on sync_reset_request only if PF can do reset_now patchwork-bot+netdevbpf
2023-06-16 20:11 ` [net-next 02/15] net/mlx5: Expose timeout for sync reset unload stage Saeed Mahameed
2023-06-16 20:11 ` [net-next 03/15] net/mlx5: Check DTOR entry value is not zero Saeed Mahameed
2023-06-16 20:11 ` [net-next 04/15] net/mlx5: Handle sync reset unload event Saeed Mahameed
2023-06-16 20:11 ` [net-next 05/15] net/mlx5: Create eswitch debugfs root directory Saeed Mahameed
2023-06-16 20:11 ` [net-next 06/15] net/mlx5: Bridge, pass net device when linking vport to bridge Saeed Mahameed
2023-06-16 20:11 ` [net-next 07/15] net/mlx5: Bridge, expose FDB state via debugfs Saeed Mahameed
2023-06-17  7:48   ` Jakub Kicinski
2023-06-19  8:37     ` Vlad Buslov
2023-06-19 18:28       ` Jakub Kicinski
2023-06-19 18:34         ` Vlad Buslov
2023-06-19 19:05           ` Jakub Kicinski
2023-06-19 19:13             ` Vlad Buslov
2023-06-16 20:11 ` [net-next 08/15] net/mlx5: E-Switch, remove redundant else statements Saeed Mahameed
2023-06-16 20:11 ` [net-next 09/15] net/mlx5e: Remove mlx5e_dbg() and msglvl support Saeed Mahameed
2023-06-16 20:11 ` [net-next 10/15] net/mlx5: Expose bits for local loopback counter Saeed Mahameed
2023-06-16 20:11 ` [net-next 11/15] net/mlx5e: Add local loopback counter to vport stats Saeed Mahameed
2023-06-16 20:11 ` [net-next 12/15] net/mlx5: Fix the macro for accessing EC VF vports Saeed Mahameed
2023-06-16 20:11 ` [net-next 13/15] net/mlx5: DR, update query of HCA caps for EC VFs Saeed Mahameed
2023-06-16 20:11 ` [net-next 14/15] net/mlx5: Add header file for events Saeed Mahameed
2023-06-16 20:11 ` [net-next 15/15] net/mlx5: Remove unused ecpu field from struct mlx5_sf_table 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=20230616201113.45510-2-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=moshe@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=shayd@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).