public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [bug report] {net, IB}/mlx5: Manage port association for multiport RoCE
       [not found] <20210518082855.GB32682@kadam>
@ 2021-05-19 14:18 ` Dan Carpenter
  2021-05-20  8:09   ` Leon Romanovsky
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-05-19 14:18 UTC (permalink / raw)
  To: danielj; +Cc: linux-rdma

Hello Daniel Jurgens,

The patch 32f69e4be269: "{net, IB}/mlx5: Manage port association for
multiport RoCE" from Jan 4, 2018, leads to the following static
checker warning:

	drivers/infiniband/hw/mlx5/main.c:3285 mlx5_ib_init_multiport_master()
	warn: iterator 'mpi->list.next' changed during iteration

drivers/infiniband/hw/mlx5/main.c
  3285                  list_for_each_entry(mpi, &mlx5_ib_unaffiliated_port_list,
                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
We're iterating through the unafiliated list.

  3286                                      list) {
  3287                          if (dev->sys_image_guid == mpi->sys_image_guid &&
  3288                              (mlx5_core_native_port_num(mpi->mdev) - 1) == i) {
  3289                                  bound = mlx5_ib_bind_slave_port(dev, mpi);

The mlx5_ib_bind_slave_port() function returns true on success and
false on failure.  On the failure path it calls:

	mlx5_ib_unbind_slave_port(ibdev, mpi);

Which adds our "mpi" as the last item on the unaffiliated list.  I don't
think anything good can come from adding a list item to a list twice.

  3290                          }
  3291  
  3292                          if (bound) {
  3293                                  dev_dbg(mpi->mdev->device,
  3294                                          "removing port from unaffiliated list.\n");
  3295                                  mlx5_ib_dbg(dev, "port %d bound\n", i + 1);
  3296                                  list_del(&mpi->list);
  3297                                  break;
  3298                          }
  3299                  }
  3300                  if (!bound)
  3301                          mlx5_ib_dbg(dev, "no free port found for port %d\n",
  3302                                      i + 1);

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] {net, IB}/mlx5: Manage port association for multiport RoCE
  2021-05-19 14:18 ` [bug report] {net, IB}/mlx5: Manage port association for multiport RoCE Dan Carpenter
@ 2021-05-20  8:09   ` Leon Romanovsky
  0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2021-05-20  8:09 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: danielj, linux-rdma

On Wed, May 19, 2021 at 05:18:33PM +0300, Dan Carpenter wrote:
> Hello Daniel Jurgens,
> 
> The patch 32f69e4be269: "{net, IB}/mlx5: Manage port association for
> multiport RoCE" from Jan 4, 2018, leads to the following static
> checker warning:
> 
> 	drivers/infiniband/hw/mlx5/main.c:3285 mlx5_ib_init_multiport_master()
> 	warn: iterator 'mpi->list.next' changed during iteration

Thanks Dan for the report, I'll prepare the fix.

> 
> drivers/infiniband/hw/mlx5/main.c
>   3285                  list_for_each_entry(mpi, &mlx5_ib_unaffiliated_port_list,
>                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> We're iterating through the unafiliated list.
> 
>   3286                                      list) {
>   3287                          if (dev->sys_image_guid == mpi->sys_image_guid &&
>   3288                              (mlx5_core_native_port_num(mpi->mdev) - 1) == i) {
>   3289                                  bound = mlx5_ib_bind_slave_port(dev, mpi);
> 
> The mlx5_ib_bind_slave_port() function returns true on success and
> false on failure.  On the failure path it calls:
> 
> 	mlx5_ib_unbind_slave_port(ibdev, mpi);
> 
> Which adds our "mpi" as the last item on the unaffiliated list.  I don't
> think anything good can come from adding a list item to a list twice.
> 
>   3290                          }
>   3291  
>   3292                          if (bound) {
>   3293                                  dev_dbg(mpi->mdev->device,
>   3294                                          "removing port from unaffiliated list.\n");
>   3295                                  mlx5_ib_dbg(dev, "port %d bound\n", i + 1);
>   3296                                  list_del(&mpi->list);
>   3297                                  break;
>   3298                          }
>   3299                  }
>   3300                  if (!bound)
>   3301                          mlx5_ib_dbg(dev, "no free port found for port %d\n",
>   3302                                      i + 1);
> 
> regards,
> dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-20  8:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20210518082855.GB32682@kadam>
2021-05-19 14:18 ` [bug report] {net, IB}/mlx5: Manage port association for multiport RoCE Dan Carpenter
2021-05-20  8:09   ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox