Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Jan 2017 08:32:50 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r312865 - head/sys/dev/mlx5/mlx5_en
Message-ID:  <201701270832.v0R8WoGG085361@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Fri Jan 27 08:32:50 2017
New Revision: 312865
URL: https://svnweb.freebsd.org/changeset/base/312865

Log:
  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

Modified:
  head/sys/dev/mlx5/mlx5_en/en.h

Modified: head/sys/dev/mlx5/mlx5_en/en.h
==============================================================================
--- head/sys/dev/mlx5/mlx5_en/en.h	Fri Jan 27 08:30:43 2017	(r312864)
+++ head/sys/dev/mlx5/mlx5_en/en.h	Fri Jan 27 08:32:50 2017	(r312865)
@@ -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 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701270832.v0R8WoGG085361>