net/mlx4_core: Fix sleeping while holding spinlock at rem_slave_counters
authorEran Ben Elisha <eranbe@mellanox.com>
Thu, 12 Nov 2015 17:35:29 +0000 (19:35 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sun, 15 Nov 2015 23:43:41 +0000 (18:43 -0500)
commitf5adbfee72282bb1f456d52b04adacd4fe6ac502
treeef56854525a2b48771ccb32a81387ccb33931cf5
parentd4e28cbd24c8cb004960ddb8b22124953f6c220c
net/mlx4_core: Fix sleeping while holding spinlock at rem_slave_counters

When cleaning slave's counter resources, we hold a spinlock that
protects the slave's counters list. As part of the clean, we call
__mlx4_clear_if_stat which calls mlx4_alloc_cmd_mailbox which is a
sleepable function.

In order to fix this issue, hold the spinlock, and copy all counter
indices into a temporary array, and release the spinlock. Afterwards,
iterate over this array and free every counter. Repeat this scenario
until the original list is empty (a new counter might have been added
while releasing the counters from the temporary array).

Fixes: b72ca7e96acf ("net/mlx4_core: Reset counters data when freed")
Reported-by: Moni Shoua <monis@mellanox.com>
Tested-by: Moni Shoua <monis@mellanox.com>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c