]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net/mlx5: fw reset, check bridge accessibility at earlier stage
authorAmir Tzin <amirtz@nvidia.com>
Wed, 19 Mar 2025 14:03:00 +0000 (16:03 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 25 Mar 2025 14:29:47 +0000 (07:29 -0700)
Currently, mlx5_is_reset_now_capable() checks whether the pci bridge is
accessible only on bridge hot plug capability check.  If the pci bridge
is not accessible, reset now will fail regardless of bridge hotplug
capability. Move this check to function mlx5_is_reset_now_capable()
which, in such case, aborts the reset and does so in the request phase
instead of the reset now phase.

Signed-off-by: Aya Levin <ayal@nvidia.com>
Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Signed-off-by: Amir Tzin <amirtz@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/1742392983-153050-3-git-send-email-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c

index 566710d34a7b2e7aba40fc4d2eabd63d5ec89dc4..6830a49fe682e9e8838cb15129e9c510a79394d5 100644 (file)
@@ -345,15 +345,12 @@ static void mlx5_fw_live_patch_event(struct work_struct *work)
 }
 
 #if IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE)
-static int mlx5_check_hotplug_interrupt(struct mlx5_core_dev *dev)
+static int mlx5_check_hotplug_interrupt(struct mlx5_core_dev *dev,
+                                       struct pci_dev *bridge)
 {
-       struct pci_dev *bridge = dev->pdev->bus->self;
        u16 reg16;
        int err;
 
-       if (!bridge)
-               return -EOPNOTSUPP;
-
        err = pcie_capability_read_word(bridge, PCI_EXP_SLTCTL, &reg16);
        if (err)
                return err;
@@ -416,9 +413,15 @@ static int mlx5_check_dev_ids(struct mlx5_core_dev *dev, u16 dev_id)
 static bool mlx5_is_reset_now_capable(struct mlx5_core_dev *dev,
                                      u8 reset_method)
 {
+       struct pci_dev *bridge = dev->pdev->bus->self;
        u16 dev_id;
        int err;
 
+       if (!bridge) {
+               mlx5_core_warn(dev, "PCI bus bridge is not accessible\n");
+               return false;
+       }
+
        if (!MLX5_CAP_GEN(dev, fast_teardown)) {
                mlx5_core_warn(dev, "fast teardown is not supported by firmware\n");
                return false;
@@ -426,7 +429,7 @@ static bool mlx5_is_reset_now_capable(struct mlx5_core_dev *dev,
 
 #if IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE)
        if (reset_method != MLX5_MFRL_REG_PCI_RESET_METHOD_HOT_RESET) {
-               err = mlx5_check_hotplug_interrupt(dev);
+               err = mlx5_check_hotplug_interrupt(dev, bridge);
                if (err)
                        return false;
        }