]> git.baikalelectronics.ru Git - kernel.git/commit
net/mlx5: Delay events till ib registration ends
authorErez Shitrit <erezsh@mellanox.com>
Wed, 7 Jun 2017 09:14:24 +0000 (12:14 +0300)
committerSaeed Mahameed <saeedm@mellanox.com>
Mon, 7 Aug 2017 07:47:07 +0000 (10:47 +0300)
commit97834eba7c194659a72c5bb0f8c19c7055bb69ea
tree2ca3e322e59cb9a9cf43708faa02304679cc0ade
parente80541ecabd57b69726232b89242e28d8123cccc
net/mlx5: Delay events till ib registration ends

When mlx5_ib registers itself to mlx5_core as an interface, it will
call mlx5_add_device which will call mlx5_ib interface add callback,
in case the latter successfully returns, only then mlx5_core will add
it to the interface list and async events will be forwarded to mlx5_ib.
Between mlx5_ib interface add callback and mlx5_core adding the mlx5_ib
interface to its devices list, arriving mlx5_core events can be missed
by the new mlx5_ib registering interface.

In other words:
thread 1: mlx5_ib: mlx5_register_interface(dev)
thread 1: mlx5_core: mlx5_add_device(dev)
thread 1: mlx5_core: ctx = dev->add => (mlx5_ib)->mlx5_ib_add
thread 2: mlx5_core_event: **new event arrives, forward to dev_list
thread 1: mlx5_core: add_ctx_to_dev_list(ctx)
/* previous event was missed by the new interface.*/
It is ok to miss events before dev->add (mlx5_ib)->mlx5_ib_add_device
but not after.

We fix this race by accumulating the events that come between the
ib_register_device (inside mlx5_add_device->(dev->add)) till the adding
to the list completes and fire them to the new registering interface
after that.

Fixes: f1ee87fe55c8 ("net/mlx5: Organize device list API in one place")
Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/dev.c
drivers/net/ethernet/mellanox/mlx5/core/main.c
include/linux/mlx5/driver.h