Skip to content

Commit 378c674

Browse files
jinpuwangjgunthorpe
authored andcommitted
RDMA/mlx4: Do not fail the registration on port stats
If the FW doesn't support MLX4_DEV_CAP_FLAG2_DIAG_PER_PORT, mlx4 driver will fail the ib_setup_port_attrs, which is called from ib_register_device()/enable_device_and_get(), in the end leads to device not detected[1][2] To fix it, add a new mlx4_ib_hw_stats_ops1, w/o alloc_hw_port_stats if FW does not support MLX4_DEV_CAP_FLAG2_DIAG_PER_PORT. [1] https://bugzilla.redhat.com/show_bug.cgi?id=2014094 [2] https://lore.kernel.org/linux-rdma/CAMGffEn2wvEnmzc0xe=xYiCLqpphiHDBxCxqAELrBofbUAMQxw@mail.gmail.com Fixes: 4b5f4d3 ("RDMA: Split the alloc_hw_stats() ops to port and device variants") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jack Wang <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent da86dc1 commit 378c674

File tree

1 file changed

+15
-3
lines changed
  • drivers/infiniband/hw/mlx4

1 file changed

+15
-3
lines changed

drivers/infiniband/hw/mlx4/main.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,6 +2215,11 @@ static const struct ib_device_ops mlx4_ib_hw_stats_ops = {
22152215
.get_hw_stats = mlx4_ib_get_hw_stats,
22162216
};
22172217

2218+
static const struct ib_device_ops mlx4_ib_hw_stats_ops1 = {
2219+
.alloc_hw_device_stats = mlx4_ib_alloc_hw_device_stats,
2220+
.get_hw_stats = mlx4_ib_get_hw_stats,
2221+
};
2222+
22182223
static int mlx4_ib_alloc_diag_counters(struct mlx4_ib_dev *ibdev)
22192224
{
22202225
struct mlx4_ib_diag_counters *diag = ibdev->diag_counters;
@@ -2227,9 +2232,16 @@ static int mlx4_ib_alloc_diag_counters(struct mlx4_ib_dev *ibdev)
22272232
return 0;
22282233

22292234
for (i = 0; i < MLX4_DIAG_COUNTERS_TYPES; i++) {
2230-
/* i == 1 means we are building port counters */
2231-
if (i && !per_port)
2232-
continue;
2235+
/*
2236+
* i == 1 means we are building port counters, set a different
2237+
* stats ops without port stats callback.
2238+
*/
2239+
if (i && !per_port) {
2240+
ib_set_device_ops(&ibdev->ib_dev,
2241+
&mlx4_ib_hw_stats_ops1);
2242+
2243+
return 0;
2244+
}
22332245

22342246
ret = __mlx4_ib_alloc_diag_counters(ibdev, &diag[i].descs,
22352247
&diag[i].offset,

0 commit comments

Comments
 (0)