From: Lucas Stach <l.stach@pengutronix.de>
To: Ladislav Michl <ladis@linux-mips.org>, barebox@lists.infradead.org
Subject: Re: [PATCH] net: macb: dma_sync_* receive buffers
Date: Fri, 16 Nov 2018 16:07:25 +0100 [thread overview]
Message-ID: <1542380845.23489.24.camel@pengutronix.de> (raw)
In-Reply-To: <20181115003637.GA16443@lenoch>
Am Donnerstag, den 15.11.2018, 01:36 +0100 schrieb Ladislav Michl:
> Receive buffers are properly synchronized only if Cadence is
> GEM. Fix it for MACB as well.
>
> Fixes: 86dc5259e25d (net: macb: no need for coherent memory for receive buffer)
> > Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
> ---
> Hi Sascha,
>
> I'm unsure this is proper fix, but works for me (as well as
> reverting 86dc5259e25d)
>
> drivers/net/macb.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/macb.c b/drivers/net/macb.c
> index 1c5752d10..2bd5b62a4 100644
> --- a/drivers/net/macb.c
> +++ b/drivers/net/macb.c
> @@ -216,9 +216,11 @@ static int macb_recv(struct eth_device *edev)
> > dev_dbg(macb->dev, "%s\n", __func__);
>
> > for (;;) {
> > + barrier();
> > if (!(macb->rx_ring[rx_tail].addr & MACB_BIT(RX_USED)))
> > return -1;
>
> > + barrier();
> > status = macb->rx_ring[rx_tail].ctrl;
> > if (status & MACB_BIT(RX_SOF)) {
> > if (rx_tail != macb->rx_tail)
> @@ -229,6 +231,8 @@ static int macb_recv(struct eth_device *edev)
> > if (status & MACB_BIT(RX_EOF)) {
> > buffer = macb->rx_buffer + macb->rx_buffer_size * macb->rx_tail;
> > length = MACB_BFEXT(RX_FRMLEN, status);
> > + dma_sync_single_for_cpu((unsigned long)buffer, length,
> > + DMA_FROM_DEVICE);
> > if (wrapped) {
> > unsigned int headlen, taillen;
>
> @@ -237,12 +241,17 @@ static int macb_recv(struct eth_device *edev)
> > taillen = length - headlen;
> > memcpy((void *)NetRxPackets[0],
> > buffer, headlen);
> > + dma_sync_single_for_cpu((unsigned long)macb->rx_buffer,
> > + taillen, DMA_FROM_DEVICE);
> > memcpy((void *)NetRxPackets[0] + headlen,
> macb->rx_buffer, taillen);
This is missing a dma_sync_single_for_device() here, matching the
...for_cpu added above. Otherwise patch looks good.
Regards,
Lucas
> buffer = (void *)NetRxPackets[0];
> > }
>
> > net_receive(edev, buffer, length);
> > + dma_sync_single_for_device((unsigned long)buffer, length,
> > + DMA_FROM_DEVICE);
> > + barrier();
> > if (++rx_tail >= macb->rx_ring_size)
> > rx_tail = 0;
> > reclaim_rx_buffers(macb, rx_tail);
> @@ -252,7 +261,6 @@ static int macb_recv(struct eth_device *edev)
> > rx_tail = 0;
> > }
> > }
> > - barrier();
> > }
>
> > return 0;
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-11-16 15:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-15 0:36 Ladislav Michl
2018-11-16 15:07 ` Lucas Stach [this message]
2018-12-04 7:58 ` Sascha Hauer
2019-05-30 12:28 ` Ladislav Michl
2019-06-04 6:49 ` Sascha Hauer
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=1542380845.23489.24.camel@pengutronix.de \
--to=l.stach@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=ladis@linux-mips.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox