linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Niklas Cassel <niklas.cassel@axis.com>
To: Giuseppe Cavallaro <peppe.cavallaro@st.com>,
	Alexandre Torgue <alexandre.torgue@st.com>
Cc: Jose.Abreu@synopsys.com, pavel@ucw.cz,
	Niklas Cassel <niklass@axis.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net-next 3/4] net: stmmac: ensure that the device has released ownership before reading data
Date: Mon, 26 Feb 2018 22:47:08 +0100	[thread overview]
Message-ID: <20180226214709.4359-4-niklas.cassel@axis.com> (raw)
In-Reply-To: <20180226214709.4359-1-niklas.cassel@axis.com>

According to Documentation/memory-barriers.txt, we need to use a
dma_rmb() after reading the status/own bit, to ensure that all
descriptor fields are read after reading the own bit.

This way, we ensure that the DMA engine is done with the DMA
descriptor before we read the other descriptor fields, e.g. reading
the tx hardware timestamp (if PTP is enabled).

Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 6dd04f237b2a..a9856a8bf8ad 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1844,6 +1844,11 @@ static void stmmac_tx_clean(struct stmmac_priv *priv, u32 queue)
 		if (unlikely(status & tx_dma_own))
 			break;
 
+		/* Make sure descriptor fields are read after reading
+		 * the own bit.
+		 */
+		dma_rmb();
+
 		/* Just consider the last segment and ...*/
 		if (likely(!(status & tx_not_ls))) {
 			/* ... verify the status error condition */
-- 
2.14.2

  parent reply	other threads:[~2018-02-26 21:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-26 21:47 [PATCH net-next 0/4] stmmac barrier fixes and cleanup Niklas Cassel
2018-02-26 21:47 ` [PATCH net-next 1/4] net: stmmac: ensure that the MSS desc is the last desc to set the own bit Niklas Cassel
2018-02-26 21:47 ` [PATCH net-next 2/4] net: stmmac: use correct barrier between coherent memory and MMIO Niklas Cassel
2018-03-02  9:20   ` Pavel Machek
2018-03-02 14:54     ` David Miller
2018-03-02 23:28       ` Niklas Cassel
2018-03-07 15:32         ` David Miller
2018-03-07 17:21           ` Niklas Cassel
2018-03-07 17:42             ` David Miller
2018-03-07 18:09               ` Niklas Cassel
2018-03-08  9:05               ` Pavel Machek
2018-02-26 21:47 ` Niklas Cassel [this message]
2018-02-26 21:47 ` [PATCH net-next 4/4] net: stmmac: make dwmac4_release_tx_desc() clear all descriptor fields Niklas Cassel
2018-02-27 19:28 ` [PATCH net-next 0/4] stmmac barrier fixes and cleanup David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180226214709.4359-4-niklas.cassel@axis.com \
    --to=niklas.cassel@axis.com \
    --cc=Jose.Abreu@synopsys.com \
    --cc=alexandre.torgue@st.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=niklass@axis.com \
    --cc=pavel@ucw.cz \
    --cc=peppe.cavallaro@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).