All of lore.kernel.org
 help / color / mirror / Atom feed
From: <Claudiu.Beznea@microchip.com>
To: <anssi.hannula@bitwise.fi>, <Nicolas.Ferre@microchip.com>,
	<davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <harini.katakam@xilinx.com>,
	<michal.simek@xilinx.com>
Subject: Re: [PATCH 1/3] net: macb: fix random memory corruption on RX with 64-bit DMA
Date: Wed, 5 Dec 2018 12:37:25 +0000	[thread overview]
Message-ID: <d69effaf-0aa8-b90d-ed31-2b40bd792102@microchip.com> (raw)
In-Reply-To: <20181130182137.27974-2-anssi.hannula@bitwise.fi>

Hi Anssi,

Few comments... Otherwise I tested this series on a SAMA5D2 Xplained and
SAMA5D4 Xplained under heavy traffic and it seems to behave OK.

Thank you,
Claudiu Beznea

On 30.11.2018 20:21, Anssi Hannula wrote:
> 64-bit DMA addresses are split in upper and lower halves that are
> written in separate fields on GEM. For RX, bit 0 of the address is used
> as the ownership bit (RX_USED). When the RX_USED bit is unset the
> controller is allowed to write data to the buffer.
> 
> The driver does not guarantee that the controller already sees the upper
> half when the RX_USED bit is cleared, possibly resulting in the
> controller writing an incoming frame to an address with an incorrect
> upper half and therefore possibly corrupting unrelated system memory.
> 
> Fix that by adding the necessary DMA memory barrier between the writes.>
> This corruption was observed on a ZynqMP based system.
> 
> Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi>
> Fixes: fff8019a08b6 ("net: macb: Add 64 bit addressing support for GEM")
> Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> Cc: Harini Katakam <harini.katakam@xilinx.com>
> Cc: Michal Simek <michal.simek@xilinx.com>
> ---
>  drivers/net/ethernet/cadence/macb_main.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index d8c7ca037ae3..0bc2aab7be40 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -682,6 +682,11 @@ static void macb_set_addr(struct macb *bp, struct macb_dma_desc *desc, dma_addr_
>  	if (bp->hw_dma_cap & HW_DMA_CAP_64B) {
>  		desc_64 = macb_64b_desc(bp, desc);
>  		desc_64->addrh = upper_32_bits(addr);
> +		/* The low bits of RX address contain the RX_USED bit, clearing
> +		 * of which allows packet RX. Make sure the high bits are also
> +		 * visible to HW at that point.
> +		 */
> +		dma_wmb();

I think a wmb() would fit better here so that on ARM to also force the
flushing of caches not affected by dmb() by calling arm_heavy_mb().

Thank you,
Claudiu Beznea

>  	}
>  #endif
>  	desc->addr = lower_32_bits(addr);
> 

  parent reply	other threads:[~2018-12-05 12:37 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-30 18:21 [PATCH 0/3] net: macb: DMA race condition fixes Anssi Hannula
2018-11-30 18:21 ` [PATCH 1/3] net: macb: fix random memory corruption on RX with 64-bit DMA Anssi Hannula
2018-12-03  4:44   ` Harini Katakam
2018-12-05 12:37   ` Claudiu.Beznea [this message]
2018-12-05 13:58     ` Anssi Hannula
2018-12-05 20:32   ` David Miller
2018-12-06 14:16     ` Claudiu.Beznea
2018-11-30 18:21 ` [PATCH 2/3] net: macb: fix dropped RX frames due to a race Anssi Hannula
2018-12-03  4:52   ` Harini Katakam
2018-12-03 10:31     ` Anssi Hannula
2018-12-03 10:36       ` Harini Katakam
2018-12-05 12:38   ` Claudiu.Beznea
2018-11-30 18:21 ` [PATCH 3/3] net: macb: add missing barriers when reading buffers Anssi Hannula
2018-12-05 12:37   ` Claudiu.Beznea
2018-12-05 14:00     ` Anssi Hannula
2018-12-06 14:14       ` Claudiu.Beznea
2018-12-07 12:00         ` Anssi Hannula
2018-12-10 10:34           ` Claudiu.Beznea
2018-12-11 13:21             ` Anssi Hannula
2018-12-12 10:58               ` Claudiu.Beznea
2018-12-12 11:27                 ` Anssi Hannula
2018-12-13 10:48                   ` Claudiu.Beznea
2018-12-12 10:59               ` [PATCH 3/3 v2] net: macb: add missing barriers when reading descriptors Anssi Hannula
2018-12-12 23:19                 ` David Miller
2018-12-03  8:26 ` [PATCH 0/3] net: macb: DMA race condition fixes Nicolas.Ferre
2018-12-03 23:56   ` David Miller
2018-12-05 20:35 ` David Miller
2018-12-07 12:04   ` Anssi Hannula
2018-12-10 10:58     ` Nicolas.Ferre
2018-12-10 11:32       ` Claudiu.Beznea
2018-12-10 11:34         ` Claudiu.Beznea

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=d69effaf-0aa8-b90d-ed31-2b40bd792102@microchip.com \
    --to=claudiu.beznea@microchip.com \
    --cc=Nicolas.Ferre@microchip.com \
    --cc=anssi.hannula@bitwise.fi \
    --cc=davem@davemloft.net \
    --cc=harini.katakam@xilinx.com \
    --cc=michal.simek@xilinx.com \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.