Skip to content

Commit 4b67894

Browse files
mosheshemesh2gregkh
authored andcommitted
net/mlx5: Nack sync reset when SFs are present
[ Upstream commit 26e42ec ] If PF (Physical Function) has SFs (Sub-Functions), since the SFs are not taking part in the synchronization flow, sync reset can lead to fatal error on the SFs, as the function will be closed unexpectedly from the SF point of view. Add a check to prevent sync reset when there are SFs on a PF device which is not ECPF, as ECPF is teardowned gracefully before reset. Fixes: 92501fa ("net/mlx5: Ack on sync_reset_request only if PF can do reset_now") Signed-off-by: Moshe Shemesh <moshe@nvidia.com> Reviewed-by: Parav Pandit <parav@nvidia.com> Reviewed-by: Tariq Toukan <tariqt@nvidia.com> Signed-off-by: Mark Bloch <mbloch@nvidia.com> Link: https://patch.msgid.link/20250825143435.598584-8-mbloch@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 06d8971 commit 4b67894

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "fw_reset.h"
77
#include "diag/fw_tracer.h"
88
#include "lib/tout.h"
9+
#include "sf/sf.h"
910

1011
enum {
1112
MLX5_FW_RESET_FLAGS_RESET_REQUESTED,
@@ -428,6 +429,11 @@ static bool mlx5_is_reset_now_capable(struct mlx5_core_dev *dev,
428429
return false;
429430
}
430431

432+
if (!mlx5_core_is_ecpf(dev) && !mlx5_sf_table_empty(dev)) {
433+
mlx5_core_warn(dev, "SFs should be removed before reset\n");
434+
return false;
435+
}
436+
431437
#if IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE)
432438
if (reset_method != MLX5_MFRL_REG_PCI_RESET_METHOD_HOT_RESET) {
433439
err = mlx5_check_hotplug_interrupt(dev, bridge);

drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,3 +518,13 @@ void mlx5_sf_table_cleanup(struct mlx5_core_dev *dev)
518518
WARN_ON(!xa_empty(&table->function_ids));
519519
kfree(table);
520520
}
521+
522+
bool mlx5_sf_table_empty(const struct mlx5_core_dev *dev)
523+
{
524+
struct mlx5_sf_table *table = dev->priv.sf_table;
525+
526+
if (!table)
527+
return true;
528+
529+
return xa_empty(&table->function_ids);
530+
}

drivers/net/ethernet/mellanox/mlx5/core/sf/sf.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ void mlx5_sf_hw_table_destroy(struct mlx5_core_dev *dev);
1717

1818
int mlx5_sf_table_init(struct mlx5_core_dev *dev);
1919
void mlx5_sf_table_cleanup(struct mlx5_core_dev *dev);
20+
bool mlx5_sf_table_empty(const struct mlx5_core_dev *dev);
2021

2122
int mlx5_devlink_sf_port_new(struct devlink *devlink,
2223
const struct devlink_port_new_attrs *add_attr,
@@ -61,6 +62,11 @@ static inline void mlx5_sf_table_cleanup(struct mlx5_core_dev *dev)
6162
{
6263
}
6364

65+
static inline bool mlx5_sf_table_empty(const struct mlx5_core_dev *dev)
66+
{
67+
return true;
68+
}
69+
6470
#endif
6571

6672
#endif

0 commit comments

Comments
 (0)