From: "Vlad Zolotarov" <vladz@broadcom.com>
To: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
Eilon Greenstein <eilong@broadcom.com>,
Gary Zambrano <zambrano@broadcom.com>,
Stephen Hemminger <shemminger@linux-foundation.org>,
Stefano Brivio <stefano.brivio@polimi.it>,
"e1000-devel@lists.sourceforge.net"
<e1000-devel@lists.sourceforge.net>,
Matthew Carlson <mcarlson@broadcom.com>,
Jesse Brandeburg <jesse.brandeburg@intel.com>,
Francois Romieu <romieu@fr.zoreil.com>,
Realtek linux nic maintainers <nic_swsd@realtek.com>,
"John W. Linville" <linville@tuxdriver.com>,
Ron Mercer <ron.mercer@qlogic.com>,
Michael Chan <mchan@broadcom.com>,
Jitendra Kalsaria <jitendra.kalsaria@qlogic.com>,
Divy Le Ray <divy@chelsio.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Bruce Allan <bruce.w.allan@intel.com>,
Hartley Sweeten <hsweeten@visionengravers.com>,
John Ronciak <john.ronciak@intel.com>,
Jon Mas
Subject: Re: [PATCH v2 03/46] net drivers: remove unnecessary dma_sync_to_device(DMA_FROM_DEVICE)
Date: Mon, 11 Jul 2011 12:46:57 +0300 [thread overview]
Message-ID: <201107111246.57780.vladz@broadcom.com> (raw)
In-Reply-To: <20110711092909.GB6380@rere.qmqm.pl>
On Monday 11 July 2011 12:29:09 Michał Mirosław wrote:
> On Mon, Jul 11, 2011 at 11:30:39AM +0300, Vlad Zolotarov wrote:
> > > prod_rx_buf->skb = skb;
> > >
> > > diff --git a/drivers/net/bnx2x/bnx2x_cmn.h
> > > b/drivers/net/bnx2x/bnx2x_cmn.h index c016e20..c9e49a0 100644
> > > --- a/drivers/net/bnx2x/bnx2x_cmn.h
> > > +++ b/drivers/net/bnx2x/bnx2x_cmn.h
> > > @@ -923,16 +923,11 @@ static inline int bnx2x_alloc_rx_skb(struct bnx2x
> > > *bp, static inline void bnx2x_reuse_rx_skb(struct bnx2x_fastpath *fp,
> > >
> > > u16 cons, u16 prod)
> > >
> > > {
> > >
> > > - struct bnx2x *bp = fp->bp;
> > >
> > > struct sw_rx_bd *cons_rx_buf = &fp->rx_buf_ring[cons];
> > > struct sw_rx_bd *prod_rx_buf = &fp->rx_buf_ring[prod];
> > > struct eth_rx_bd *cons_bd = &fp->rx_desc_ring[cons];
> > > struct eth_rx_bd *prod_bd = &fp->rx_desc_ring[prod];
> > >
> > > - dma_sync_single_for_device(&bp->pdev->dev,
> > > - dma_unmap_addr(cons_rx_buf,
> > > mapping), - RX_COPY_THRESH,
> > > DMA_FROM_DEVICE); -
> > >
> > > dma_unmap_addr_set(prod_rx_buf, mapping,
> > >
> > > dma_unmap_addr(cons_rx_buf, mapping));
> > >
> > > prod_rx_buf->skb = cons_rx_buf->skb;
> >
> > Michal, pls., note that this function is only called for buffers which
> > were previously dma_synced towards CPU (your "[PATCH v2 05/46] net:
> > bnx2x: fix DMA sync direction" properly fixes the direction of the first
> > call which was incorrect). Then, according to the 3d edition of the
> > "Linux device drivers" book, chapter 15, "Setting up streaming DMA
> > mappings" article, end of the page 449, when we call for
> > dma_syc_single_for_cpu() the buffer ownership gets to the CPU and CPU
> > may safely access the buffer (in particular, we read it). Then the
> > author says: "Before the device accesses the buffer, however, ownership
> > should be transfered back to it with: dma_sync_single_for_device().
> >
> > The DMA-API.txt document u've referenced doesn't refer the above
> > function, so, it's unclear how your fix may be based on it. On the other
> > hand it clearly contradicts the "Linux device driver" book.
>
> DMA-API.txt describes what synchronization points are necessary for what
> DMA mapping types (direction). dma_sync_single_for_cpu/device() are
> functions realising those points. Note that example DMA-API-HOWTO.txt is
> misleading as it has dma_sync_single_for_device() where its not required
> by DMA-API.txt.
>
> In this case, you don't need to sync to device for mappings that haven't
> been written to by CPU. CPU caches will be invalidated anyway by next
> dma_sync_single_for_cpu() or dma_unmap_single() and the CPU should not
> ever write to cachelines that belong to FROM_DEVICE mappings.
Okay, I see the section in the doc u r talking about... I agree. We may drop
these sync_single() in the bnx2x_reuse_rx_skb().
>
> The best source is the code.
Hmmm... The code is bug prone, so I'd stick to the Doc...;)
Thanks, Michal.
vlad
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
next prev parent reply other threads:[~2011-07-11 9:46 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-11 0:52 [PATCH v2 00/46] Clean up RX copybreak and DMA handling Michał Mirosław
2011-07-11 0:52 ` [PATCH v2 04/46] net/wireless: p54: remove useless dma_sync_single_for_device(DMA_FROM_DEVICE) Michał Mirosław
[not found] ` <86c8bde08b005ca7eb4806ea77aec1f3212d63fc.1310339688.git.mirq-linux-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org>
2011-07-11 15:15 ` Pavel Roskin
2011-07-12 4:50 ` Felix Fietkau
2011-07-11 0:52 ` [PATCH v2 01/46] net: introduce __netdev_alloc_skb_aligned() Michał Mirosław
2011-07-11 5:46 ` [PATCH net-next-2.6] net: introduce build_skb() Eric Dumazet
2011-07-11 10:53 ` Michał Mirosław
2011-07-12 15:40 ` Eric Dumazet
2011-07-12 15:54 ` Michał Mirosław
2011-07-11 0:52 ` [PATCH v2 05/46] net: bnx2x: fix DMA sync direction Michał Mirosław
2011-07-11 0:52 ` [PATCH v2 03/46] net drivers: remove unnecessary dma_sync_to_device(DMA_FROM_DEVICE) Michał Mirosław
2011-07-11 8:30 ` Vlad Zolotarov
2011-07-11 9:29 ` Michał Mirosław
2011-07-11 9:46 ` Vlad Zolotarov [this message]
2011-07-11 0:52 ` [PATCH v2 02/46] net: wrap common patterns of rx handler code Michał Mirosław
2011-07-11 0:52 ` [PATCH v2 06/46] net/tokenring: 3c359: fix DMA API usage Michał Mirosław
[not found] ` <cover.1310339688.git.mirq-linux-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org>
2011-07-11 0:52 ` [PATCH v2 07/46] net/wireless: ath9k: " Michał Mirosław
2011-07-12 4:36 ` Felix Fietkau
[not found] ` <4E1BCF36.2010506-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
2011-07-12 5:30 ` [ath9k-devel] " Ben Greear
2011-07-12 9:55 ` Michał Mirosław
2011-07-12 12:54 ` Felix Fietkau
[not found] ` <B4765EFC-B5C9-4E2D-BE00-ED5519D13A4E-Vt+b4OUoWG0@public.gmane.org>
2011-07-12 13:03 ` [ath9k-devel] " Michał Mirosław
[not found] ` <20110712130316.GA8621-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org>
2011-07-12 14:21 ` Felix Fietkau
2011-07-12 15:58 ` Michał Mirosław
[not found] ` <20110712155849.GB10651-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org>
2011-07-12 16:04 ` Felix Fietkau
2011-07-12 19:13 ` Michał Mirosław
2011-07-12 19:32 ` Ralf Baechle
[not found] ` <20110712193204.GB13413-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org>
2011-07-12 20:53 ` Michał Mirosław
[not found] ` <20110712205316.GA13503-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org>
2011-07-12 20:59 ` Michał Mirosław
2011-07-11 0:52 ` [PATCH v2 08/46] net/wireless: b43: fix DMA direction for RX buffers Michał Mirosław
2011-07-11 0:52 ` [PATCH v2 13/46] net: sunbmac: cleanup RX skb allocation Michał Mirosław
2011-07-11 0:52 ` [PATCH v2 12/46] net: sunhme: " Michał Mirosław
2011-07-11 0:52 ` [PATCH v2 11/46] net: sungem: " Michał Mirosław
2011-07-11 0:52 ` [PATCH v2 10/46] net: jme: convert to generic DMA API Michał Mirosław
2011-07-11 0:52 ` [PATCH v2 09/46] net: octeon_mgmt: fix DMA unmap size Michał Mirosław
2011-07-11 0:52 ` [PATCH v2 14/46] net: sunbmac: cleanup magic '34' Michał Mirosław
2011-07-11 0:52 ` [PATCH v2 15/46] net/wireless: b43: use kfree_skb() for untouched skbs Michał Mirosław
2011-07-11 0:52 ` [PATCH v2 16/46] net: cxgb3: don't drop packets on memory pressure in driver Michał Mirosław
2011-07-11 0:52 ` [PATCH v2 46/46] net: mark drivers that drop packets from rx queue head under memory pressure Michał Mirosław
2011-07-11 5:40 ` Francois Romieu
2011-07-11 6:47 ` Eilon Greenstein
2011-07-11 10:04 ` Michał Mirosław
2011-07-11 10:16 ` Eilon Greenstein
2011-07-11 15:24 ` Stephen Hemminger
2011-07-11 6:54 ` [PATCH v2 00/46] Clean up RX copybreak and DMA handling David Miller
2011-07-11 9:16 ` Michał Mirosław
2011-07-11 9:24 ` David Miller
2011-07-11 9:47 ` Michał Mirosław
2011-07-11 10:11 ` David Miller
2011-07-11 11:17 ` Michał Mirosław
2011-07-11 12:36 ` Ben Hutchings
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=201107111246.57780.vladz@broadcom.com \
--to=vladz@broadcom.com \
--cc=bruce.w.allan@intel.com \
--cc=divy@chelsio.com \
--cc=e1000-devel@lists.sourceforge.net \
--cc=eilong@broadcom.com \
--cc=hsweeten@visionengravers.com \
--cc=jesse.brandeburg@intel.com \
--cc=jitendra.kalsaria@qlogic.com \
--cc=john.ronciak@intel.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=mcarlson@broadcom.com \
--cc=mchan@broadcom.com \
--cc=mirq-linux@rere.qmqm.pl \
--cc=netdev@vger.kernel.org \
--cc=nic_swsd@realtek.com \
--cc=romieu@fr.zoreil.com \
--cc=ron.mercer@qlogic.com \
--cc=shemminger@linux-foundation.org \
--cc=stefano.brivio@polimi.it \
--cc=zambrano@broadcom.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).