On Sun, Jun 30, 2019 at 10:52:52AM +0300, Leon Romanovsky wrote: > From: Parav Pandit <parav@xxxxxxxxxxxx> > > Currently during dual port IB device registration in below code flow, > > ib_register_device() > ib_device_register_sysfs() > ib_setup_port_attrs() > add_port() > get_counter_table() > get_perf_mad() > process_mad() > mlx5_ib_process_mad() > > mlx5_ib_process_mad() fails on 2nd port when both the ports are not > fully setup at the device level (because 2nd port is unaffiliated). > > As a result, get_perf_mad() registers different PMA counter group for > 1st and 2nd port, namely pma_counter_ext and pma_counter. However both > ports have the same capability and counter offsets. > > Due to this when counters are read by the user via sysfs in below code > flow, counters are queried from wrong location from the device mainly > from PPCNT instead of VPORT counters. > > show_pma_counter() > get_perf_mad() > process_mad() > mlx5_ib_process_mad() > process_pma_cmd() > > This shows all zero counters for 2nd port. > > To overcome this, process_pma_cmd() is invoked, and when unaffiliated port is not > yet setup during device registration phase, make the query on the first port. > while at it, only process_pma_cmd() needs to work on the native port > number and underlying mdev, so shift the get, put calls to where its needed > inside process_pma_cmd(). > > Fixes: 212f2a87b74f ("IB/mlx5: Route MADs for dual port RoCE") > Signed-off-by: Parav Pandit <parav@xxxxxxxxxxxx> > Reviewed-by: Daniel Jurgens <danielj@xxxxxxxxxxxx> > Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> > --- > drivers/infiniband/hw/mlx5/mad.c | 60 +++++++++++++++++++------------- > 1 file changed, 36 insertions(+), 24 deletions(-) Applied to for-next, thanks Jason