diff options
author | Eugenia Emantayev <eugenia@mellanox.co.il> | 2012-03-18 00:32:08 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-03-19 18:02:05 -0400 |
commit | 58a3de0592454c216c68427fa3c31a34823f5115 (patch) | |
tree | 0db88951509d01bb815e3357aafd41ba9ef2ee0e /drivers | |
parent | 1c3ac4289a0e4d60cbd4787b4a91de4a0c785df1 (diff) |
mlx4_core: fix race on comm channel
Prevent race condition between commands on comm channel.
Happened while unloading the driver when switching from
event to polling mode. VF got completion on the last command
before switching to polling mode, but toggle was not changed.
After the fix - VF will not write the next command before
toggle is updated.
Signed-off-by: Eugenia Emantayev <eugenia@mellanox.co.il>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/cmd.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c index 48d5c48d7ce8..773c70ea3f62 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c | |||
@@ -239,6 +239,7 @@ static int mlx4_comm_cmd_wait(struct mlx4_dev *dev, u8 op, | |||
239 | { | 239 | { |
240 | struct mlx4_cmd *cmd = &mlx4_priv(dev)->cmd; | 240 | struct mlx4_cmd *cmd = &mlx4_priv(dev)->cmd; |
241 | struct mlx4_cmd_context *context; | 241 | struct mlx4_cmd_context *context; |
242 | unsigned long end; | ||
242 | int err = 0; | 243 | int err = 0; |
243 | 244 | ||
244 | down(&cmd->event_sem); | 245 | down(&cmd->event_sem); |
@@ -268,6 +269,14 @@ static int mlx4_comm_cmd_wait(struct mlx4_dev *dev, u8 op, | |||
268 | } | 269 | } |
269 | 270 | ||
270 | out: | 271 | out: |
272 | /* wait for comm channel ready | ||
273 | * this is necessary for prevention the race | ||
274 | * when switching between event to polling mode | ||
275 | */ | ||
276 | end = msecs_to_jiffies(timeout) + jiffies; | ||
277 | while (comm_pending(dev) && time_before(jiffies, end)) | ||
278 | cond_resched(); | ||
279 | |||
271 | spin_lock(&cmd->context_lock); | 280 | spin_lock(&cmd->context_lock); |
272 | context->next = cmd->free_head; | 281 | context->next = cmd->free_head; |
273 | cmd->free_head = context - cmd->context; | 282 | cmd->free_head = context - cmd->context; |