From: Arnd Bergmann <arnd@arndb.de>
To: linux-arm-kernel@lists.infradead.org
Cc: "David Laight" <David.Laight@aculab.com>,
"David S. Miller" <davem@davemloft.net>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"françois romieu" <romieu@fr.zoreil.com>
Subject: Re: [PATCH 4/9] net: moxart: use correct accessors for DMA memory
Date: Thu, 28 Jan 2016 17:53:43 +0100 [thread overview]
Message-ID: <3468358.kXWNPLZEG9@wuerfel> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D1CCCEDCE@AcuExch.aculab.com>
On Thursday 28 January 2016 12:36:19 David Laight wrote:
> From: Arnd Bergmann
> > Sent: 27 January 2016 14:05
> > The moxart ethernet driver confuses coherent DMA buffers with
> > MMIO registers.
> >
> > moxart_ether.c: In function 'moxart_mac_setup_desc_ring':
> > moxart_ether.c:146:428: error: passing argument 1 of '__fswab32' makes integer from pointer without a
> > cast [-Werror=int-conversion]
> > moxart_ether.c:74:39: warning: incorrect type in argument 3 (different address spaces)
> > moxart_ether.c:74:39: expected void *cpu_addr
> > moxart_ether.c:74:39: got void [noderef] <asn:2>*tx_desc_base
> >
> > This leaves the basic logic alone and uses normal pointers for
> > the virtual address of the descriptor. As we cannot use readl/writel
> > to access them, we also introduce our own moxart_desc_read
> > moxart_desc_write helpers that perform the same endianess swap
> > as the original code, but without the extra barriers and address
> > space conversion.
>
> I'm pretty sure you need to add some explicit barriers:
>
> > @@ -354,8 +364,8 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
> > txdes1 = TX_DESC1_LTS | TX_DESC1_FTS | (len & TX_DESC1_BUF_SIZE_MASK);
> > if (tx_head == TX_DESC_NUM_MASK)
> > txdes1 |= TX_DESC1_END;
> > - writel(txdes1, desc + TX_REG_OFFSET_DESC1);
> > - writel(TX_DESC0_DMA_OWN, desc + TX_REG_OFFSET_DESC0);
> > + moxart_desc_write(txdes1, desc + TX_REG_OFFSET_DESC1);
> > + moxart_desc_write(TX_DESC0_DMA_OWN, desc + TX_REG_OFFSET_DESC0);
>
> Those last two writes must happen in that order.
> There may be others.
Makes sense. I looked at the ftmac100 driver, which is another driver
for the same hardware, and it's also missing barriers. We should
probably add them for both then.
I think for the SoC that uses this, a barrier() would be sufficient
because of the page flags that dma_alloc_coherent() uses on ARM for
non-coherent platforms, but to be on the safe side we need a full
rmb()/wmb(). Sending a version 2 now.
Arnd
next prev parent reply other threads:[~2016-01-28 16:53 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-27 14:04 [PATCH 0/9] network driver fixes Arnd Bergmann
2016-01-27 14:04 ` [PATCH 1/9] net: davinci_cpdma: use dma_addr_t for DMA address Arnd Bergmann
2016-01-27 14:04 ` [PATCH 2/9] net: hp100: remove unnecessary #ifdefs Arnd Bergmann
2016-01-27 14:04 ` [PATCH 3/9] net: bgmac: clarify CONFIG_BCMA dependency Arnd Bergmann
2016-01-27 16:11 ` Paul Gortmaker
2016-01-28 8:49 ` Arnd Bergmann
2016-01-27 14:04 ` [PATCH 4/9] net: moxart: use correct accessors for DMA memory Arnd Bergmann
2016-01-28 12:36 ` David Laight
2016-01-28 16:53 ` Arnd Bergmann [this message]
2016-01-28 16:58 ` Arnd Bergmann
2016-01-27 14:04 ` [PATCH 5/9] net: fddi/defxx: avoid warning about uninitialized variable use Arnd Bergmann
2016-01-27 15:15 ` Maciej W. Rozycki
2016-01-27 14:04 ` [PATCH 6/9] net: vxge: avoid unused function warnings Arnd Bergmann
2016-01-27 14:04 ` [PATCH 7/9] net: macb: avoid uninitialized variables Arnd Bergmann
2016-01-27 15:51 ` Nicolas Ferre
2016-01-27 16:04 ` Nicolas Ferre
2016-01-28 16:32 ` Arnd Bergmann
2016-01-28 13:27 ` Sergei Shtylyov
2016-01-27 14:04 ` [PATCH 8/9] net: nb8800: avoid uninitialized variable warning Arnd Bergmann
2016-01-27 14:13 ` Måns Rullgård
2016-01-27 15:21 ` Arnd Bergmann
2016-01-27 14:04 ` [PATCH 9/9] net: tg3: " Arnd Bergmann
2016-01-29 0:14 ` [PATCH 0/9] network driver fixes David Miller
2016-01-29 12:56 ` Arnd Bergmann
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=3468358.kXWNPLZEG9@wuerfel \
--to=arnd@arndb.de \
--cc=David.Laight@aculab.com \
--cc=davem@davemloft.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=romieu@fr.zoreil.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).