mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 7/7] net: fec_imx: Do not use DMA coherent memory for Rx buffers
Date: Mon, 14 Jan 2019 15:17:17 +0100	[thread overview]
Message-ID: <20190114141717.nbs3h3nxnrrbizob@pengutronix.de> (raw)
In-Reply-To: <20190114122130.dsfqagod6rrpqv2x@pengutronix.de>

On Mon, Jan 14, 2019 at 01:21:30PM +0100, Uwe Kleine-König wrote:
> Hello,
> 
> On Mon, Sep 17, 2018 at 10:21:22PM -0700, Andrey Smirnov wrote:
> > Trying to do unaligned access of coherent memory on AArch64 will lead
> > to an abort and some parts of our IP stack will do exactly that with
> > received packet buffer by using memcpy() to extracts parts of it.
> > 
> > Convert the driver to use regular memory for received data buffers to
> > prevent the issue from happening.
> 
> I didn't spend time yet to debug, but this commit is pointed out to
> break nfs booting on an mx28evk board.
> 
> Maybe someone spots the obvious problem before I come around to fix
> this.

Sascha found it. The problem is that the nfs code uses the memory
location the packet was placed in only after the net_receive function
returned.

With this patch applied it works for me again:

diff --git a/fs/nfs.c b/fs/nfs.c
index d7f156687fc9..20fdf5ff4dfc 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -440,6 +440,7 @@ again:
 	nfs_timer_start = get_time_ns();
 
 	nfs_state = STATE_START;
+	free(nfs_packet);
 	nfs_packet = NULL;
 
 	while (nfs_state != STATE_DONE) {
@@ -924,7 +925,7 @@ static void nfs_handler(void *ctx, char *packet, unsigned len)
 	char *pkt = net_eth_to_udp_payload(packet);
 
 	nfs_state = STATE_DONE;
-	nfs_packet = pkt;
+	nfs_packet = xmemdup(pkt, len);
 	nfs_len = len;
 }
 

(Not completely nice though, as (at least) the last packet isn't freed.)

Will try to come up with a proper patch later.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2019-01-14 14:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-18  5:21 [PATCH 0/7] non-coherent Rx buffers in FEC and some small fixes Andrey Smirnov
2018-09-18  5:21 ` [PATCH 1/7] net: fec_imx: Drop extra indentation level by exiting early Andrey Smirnov
2018-09-18  5:21 ` [PATCH 2/7] net: fec_imx: Don't check bd_status & FEC_RBD_ERR twice Andrey Smirnov
2018-09-18  5:21 ` [PATCH 3/7] net: fec_imx: Read data_length only once Andrey Smirnov
2018-09-18  5:21 ` [PATCH 4/7] net: fec_imx: Drop struct fec_frame Andrey Smirnov
2018-09-18  5:21 ` [PATCH 5/7] net: fec_imx: Drop frame_length Andrey Smirnov
2018-09-18  5:21 ` [PATCH 6/7] net: fec_imx: Make use of readx_poll_timeout() macros Andrey Smirnov
2018-09-18  5:21 ` [PATCH 7/7] net: fec_imx: Do not use DMA coherent memory for Rx buffers Andrey Smirnov
2019-01-14 12:21   ` Uwe Kleine-König
2019-01-14 14:17     ` Uwe Kleine-König [this message]
2018-09-19  7:41 ` [PATCH 0/7] non-coherent Rx buffers in FEC and some small fixes 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=20190114141717.nbs3h3nxnrrbizob@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.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