]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net/mlx5: Allow async trigger completion execution on single CPU systems
authorRoy Novich <royno@nvidia.com>
Thu, 3 Nov 2022 06:55:38 +0000 (23:55 -0700)
committerSaeed Mahameed <saeedm@nvidia.com>
Wed, 9 Nov 2022 18:30:42 +0000 (10:30 -0800)
For a single CPU system, the kernel thread executing mlx5_cmd_flush()
never releases the CPU but calls down_trylock(&cmd→sem) in a busy loop.
On a single processor system, this leads to a deadlock as the kernel
thread which executes mlx5_cmd_invoke() never gets scheduled. Fix this,
by adding the cond_resched() call to the loop, allow the command
completion kernel thread to execute.

Fixes: 8e715cd613a1 ("net/mlx5: Set command entry semaphore up once got index free")
Signed-off-by: Alexander Schmidt <alexschm@de.ibm.com>
Signed-off-by: Roy Novich <royno@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/cmd.c

index 46ba4c2faad21aafc82381467e62c85aa8a06478..2e0d59ca62b5012e23db7adbc9711b08dd788ef6 100644 (file)
@@ -1770,12 +1770,17 @@ void mlx5_cmd_flush(struct mlx5_core_dev *dev)
        struct mlx5_cmd *cmd = &dev->cmd;
        int i;
 
-       for (i = 0; i < cmd->max_reg_cmds; i++)
-               while (down_trylock(&cmd->sem))
+       for (i = 0; i < cmd->max_reg_cmds; i++) {
+               while (down_trylock(&cmd->sem)) {
                        mlx5_cmd_trigger_completions(dev);
+                       cond_resched();
+               }
+       }
 
-       while (down_trylock(&cmd->pages_sem))
+       while (down_trylock(&cmd->pages_sem)) {
                mlx5_cmd_trigger_completions(dev);
+               cond_resched();
+       }
 
        /* Unlock cmdif */
        up(&cmd->pages_sem);