Skip to content

Commit 0c5ddb5

Browse files
edumazetdavem330
authored andcommitted
net/mlx4_en: initialize cmd.context_lock spinlock earlier
Maciej Żenczykowski reported lockdep warning a spinlock was not registered before being held in mlx4_cmd_wake_completions() cmd.context_lock initialization is not at the right place. 1) mlx4_cmd_use_events() can be called multiple times. Calling spin_lock_init() on a live spinlock can lead to hangs. 2) mlx4_cmd_wake_completions() can be called while lock has not been initialized. Lockdep complains, and current logic is not race prone. It seems better to move the initialization earlier in mlx4_load_one() Signed-off-by: Eric Dumazet <[email protected]> Reported-by: Maciej Żenczykowski <[email protected]> Cc: Eugenia Emantayev <[email protected]> Cc: Tariq Toukan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 61e0979 commit 0c5ddb5

File tree

2 files changed

+1
-1
lines changed

2 files changed

+1
-1
lines changed

drivers/net/ethernet/mellanox/mlx4/cmd.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2597,7 +2597,6 @@ int mlx4_cmd_use_events(struct mlx4_dev *dev)
25972597
priv->cmd.free_head = 0;
25982598

25992599
sema_init(&priv->cmd.event_sem, priv->cmd.max_cmds);
2600-
spin_lock_init(&priv->cmd.context_lock);
26012600

26022601
for (priv->cmd.token_mask = 1;
26032602
priv->cmd.token_mask < priv->cmd.max_cmds;

drivers/net/ethernet/mellanox/mlx4/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3222,6 +3222,7 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data,
32223222

32233223
INIT_LIST_HEAD(&priv->pgdir_list);
32243224
mutex_init(&priv->pgdir_mutex);
3225+
spin_lock_init(&priv->cmd.context_lock);
32253226

32263227
INIT_LIST_HEAD(&priv->bf_list);
32273228
mutex_init(&priv->bf_mutex);

0 commit comments

Comments
 (0)