From 5e6a76be8acf4d08c2c96598f5d0700b35d2a2a1 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 27 Jan 2017 08:32:50 +0000 Subject: [PATCH] Enforce reading the consumer and producer counters once to ensure consistent return values from the mlx5e_sq_has_room_for() function. The two counters are incremented by different threads under different locks. MFC after: 1 week Sponsored by: Mellanox Technologies --- sys/dev/mlx5/mlx5_en/en.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/dev/mlx5/mlx5_en/en.h b/sys/dev/mlx5/mlx5_en/en.h index b05d13baff7c..2415f3b6a97f 100644 --- a/sys/dev/mlx5/mlx5_en/en.h +++ b/sys/dev/mlx5/mlx5_en/en.h @@ -546,8 +546,10 @@ struct mlx5e_sq { static inline bool mlx5e_sq_has_room_for(struct mlx5e_sq *sq, u16 n) { - return ((sq->wq.sz_m1 & (sq->cc - sq->pc)) >= n || - sq->cc == sq->pc); + u16 cc = sq->cc; + u16 pc = sq->pc; + + return ((sq->wq.sz_m1 & (cc - pc)) >= n || cc == pc); } struct mlx5e_channel {