public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Giuseppe CAVALLARO <peppe.cavallaro@st.com>
To: Pavel Machek <pavel@ucw.cz>, <LinoSanfilippo@gmx.de>,
	<alexandre.torgue@st.com>, <davem@davemloft.net>,
	<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
	<niklas.cassel@axis.com>, <Joao.Pinto@synopsys.com>
Subject: Re: [PATCH] stmmac: fix memory barriers
Date: Mon, 19 Dec 2016 16:36:54 +0100	[thread overview]
Message-ID: <2f88bee3-779e-68d6-d117-74fdc640f2e5@st.com> (raw)
In-Reply-To: <20161218203812.GA1012@amd>

On 12/18/2016 9:38 PM, Pavel Machek wrote:
>
> Fix up memory barriers in stmmac driver. They are meant to protect
> against DMA engine, so smp_ variants are certainly wrong, and dma_
> variants are preferable.
>
> Signed-off-by: Pavel Machek <pavel@denx.de>

Acked-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>

>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> index a340fc8..8816515 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> @@ -334,7 +334,7 @@ static void dwmac4_rd_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
>  		 * descriptors for the same frame has to be set before, to
>  		 * avoid race condition.
>  		 */
> -		wmb();
> +		dma_wmb();
>
>  	p->des3 = cpu_to_le32(tdes3);
>  }
> @@ -377,7 +377,7 @@ static void dwmac4_rd_prepare_tso_tx_desc(struct dma_desc *p, int is_fs,
>  		 * descriptors for the same frame has to be set before, to
>  		 * avoid race condition.
>  		 */
> -		wmb();
> +		dma_wmb();
>
>  	p->des3 = cpu_to_le32(tdes3);
>  }
> diff --git a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
> index ce97e52..f0d8632 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
> @@ -350,7 +350,7 @@ static void enh_desc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
>  		 * descriptors for the same frame has to be set before, to
>  		 * avoid race condition.
>  		 */
> -		wmb();
> +		dma_wmb();
>
>  	p->des0 = cpu_to_le32(tdes0);
>  }
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 3e40578..bb40382 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -2125,7 +2125,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
>  	 * descriptor and then barrier is needed to make sure that
>  	 * all is coherent before granting the DMA engine.
>  	 */
> -	smp_wmb();
> +	dma_wmb();
>
>  	if (netif_msg_pktdata(priv)) {
>  		pr_info("%s: curr=%d dirty=%d f=%d, e=%d, f_p=%p, nfrags %d\n",
> @@ -2338,7 +2338,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
>  		 * descriptor and then barrier is needed to make sure that
>  		 * all is coherent before granting the DMA engine.
>  		 */
> -		smp_wmb();
> +		dma_wmb();
>  	}
>
>  	netdev_sent_queue(dev, skb->len);
> @@ -2443,14 +2443,14 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv)
>  			netif_dbg(priv, rx_status, priv->dev,
>  				  "refill entry #%d\n", entry);
>  		}
> -		wmb();
> +		dma_wmb();
>
>  		if (unlikely(priv->synopsys_id >= DWMAC_CORE_4_00))
>  			priv->hw->desc->init_rx_desc(p, priv->use_riwt, 0, 0);
>  		else
>  			priv->hw->desc->set_rx_owner(p);
>
> -		wmb();
> +		dma_wmb();
>
>  		entry = STMMAC_GET_ENTRY(entry, DMA_RX_SIZE);
>  	}
>

  parent reply	other threads:[~2016-12-19 15:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-18 20:38 [PATCH] stmmac: fix memory barriers Pavel Machek
2016-12-19 15:08 ` Niklas Cassel
2016-12-19 15:36 ` Giuseppe CAVALLARO [this message]
2016-12-19 16:06 ` David Miller
2016-12-19 17:10   ` Joao Pinto
2016-12-19 17:19     ` Niklas Cassel
2016-12-19 17:25       ` Joao Pinto

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=2f88bee3-779e-68d6-d117-74fdc640f2e5@st.com \
    --to=peppe.cavallaro@st.com \
    --cc=Joao.Pinto@synopsys.com \
    --cc=LinoSanfilippo@gmx.de \
    --cc=alexandre.torgue@st.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=niklas.cassel@axis.com \
    --cc=pavel@ucw.cz \
    /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