From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: Justin Forbes <jmforbes@linuxtx.org>,
Zwane Mwaikambo <zwane@arm.linux.org.uk>,
"Theodore Ts'o" <tytso@mit.edu>,
Randy Dunlap <rdunlap@xenotime.net>,
Dave Jones <davej@redhat.com>,
Chuck Wolber <chuckw@quantumlinux.com>,
Chris Wedgwood <reviews@ml.cw.f00f.org>,
Michael Krufky <mkrufky@linuxtv.org>,
Chuck Ebbert <cebbert@redhat.com>,
Domenico Andreoli <cavokz@gmail.com>, Willy Tarreau <w@1wt.eu>,
Rodrigo Rubira Branco <rbranco@la.checkpoint.com>,
Jake Edge <jake@lwn.net>, Eugene Teo <eteo@redhat.com>,
torvalds@linux-foundation.org, akpm@linux-foundation.org,
alan@lxorguk.ukuu.org.uk, Saeed Bishara <saeed@marvell.com>,
Yuri Tikhonov <yur@emcraft.com>,
Dan Williams <dan.j.williams@intel.com>
Subject: [patch 07/21] async_xor: dma_map destination DMA_BIDIRECTIONAL
Date: Mon, 12 Jan 2009 17:27:02 -0800 [thread overview]
Message-ID: <20090113012702.GH4512@kroah.com> (raw)
In-Reply-To: <20090113012633.GA4512@kroah.com>
[-- Attachment #1: async_xor-dma_map-destination-dma_bidirectional.patch --]
[-- Type: text/plain, Size: 3646 bytes --]
2.6.27-stable review patch. If anyone has any objections, please let us know.
------------------
From: Dan Williams <dan.j.williams@intel.com>
commit a06d568f7c5e40e34ea64881842deb8f4382babf upstream.
Mapping the destination multiple times is a misuse of the dma-api.
Since the destination may be reused as a source, ensure that it is only
mapped once and that it is mapped bidirectionally. This appears to add
ugliness on the unmap side in that it always reads back the destination
address from the descriptor, but gcc can determine that dma_unmap is a
nop and not emit the code that calculates its arguments.
Cc: Saeed Bishara <saeed@marvell.com>
Acked-by: Yuri Tikhonov <yur@emcraft.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
crypto/async_tx/async_xor.c | 11 +++++++++--
drivers/dma/iop-adma.c | 16 +++++++++++++---
drivers/dma/mv_xor.c | 15 ++++++++++++---
3 files changed, 34 insertions(+), 8 deletions(-)
--- a/crypto/async_tx/async_xor.c
+++ b/crypto/async_tx/async_xor.c
@@ -53,10 +53,17 @@ do_async_xor(struct dma_chan *chan, stru
int xor_src_cnt;
dma_addr_t dma_dest;
- dma_dest = dma_map_page(dma->dev, dest, offset, len, DMA_FROM_DEVICE);
- for (i = 0; i < src_cnt; i++)
+ /* map the dest bidrectional in case it is re-used as a source */
+ dma_dest = dma_map_page(dma->dev, dest, offset, len, DMA_BIDIRECTIONAL);
+ for (i = 0; i < src_cnt; i++) {
+ /* only map the dest once */
+ if (unlikely(src_list[i] == dest)) {
+ dma_src[i] = dma_dest;
+ continue;
+ }
dma_src[i] = dma_map_page(dma->dev, src_list[i], offset,
len, DMA_TO_DEVICE);
+ }
while (src_cnt) {
async_flags = flags;
--- a/drivers/dma/iop-adma.c
+++ b/drivers/dma/iop-adma.c
@@ -85,18 +85,28 @@ iop_adma_run_tx_complete_actions(struct
enum dma_ctrl_flags flags = desc->async_tx.flags;
u32 src_cnt;
dma_addr_t addr;
+ dma_addr_t dest;
+ src_cnt = unmap->unmap_src_cnt;
+ dest = iop_desc_get_dest_addr(unmap, iop_chan);
if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
- addr = iop_desc_get_dest_addr(unmap, iop_chan);
- dma_unmap_page(dev, addr, len, DMA_FROM_DEVICE);
+ enum dma_data_direction dir;
+
+ if (src_cnt > 1) /* is xor? */
+ dir = DMA_BIDIRECTIONAL;
+ else
+ dir = DMA_FROM_DEVICE;
+
+ dma_unmap_page(dev, dest, len, dir);
}
if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
- src_cnt = unmap->unmap_src_cnt;
while (src_cnt--) {
addr = iop_desc_get_src_addr(unmap,
iop_chan,
src_cnt);
+ if (addr == dest)
+ continue;
dma_unmap_page(dev, addr, len,
DMA_TO_DEVICE);
}
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -311,17 +311,26 @@ mv_xor_run_tx_complete_actions(struct mv
enum dma_ctrl_flags flags = desc->async_tx.flags;
u32 src_cnt;
dma_addr_t addr;
+ dma_addr_t dest;
+ src_cnt = unmap->unmap_src_cnt;
+ dest = mv_desc_get_dest_addr(unmap);
if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
- addr = mv_desc_get_dest_addr(unmap);
- dma_unmap_page(dev, addr, len, DMA_FROM_DEVICE);
+ enum dma_data_direction dir;
+
+ if (src_cnt > 1) /* is xor ? */
+ dir = DMA_BIDIRECTIONAL;
+ else
+ dir = DMA_FROM_DEVICE;
+ dma_unmap_page(dev, dest, len, dir);
}
if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
- src_cnt = unmap->unmap_src_cnt;
while (src_cnt--) {
addr = mv_desc_get_src_addr(unmap,
src_cnt);
+ if (addr == dest)
+ continue;
dma_unmap_page(dev, addr, len,
DMA_TO_DEVICE);
}
next prev parent reply other threads:[~2009-01-13 1:31 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20090113012006.063755472@mini.kroah.org>
2009-01-13 1:26 ` [patch 00/21] 2.6.27-stable review Greg KH
2009-01-13 1:26 ` [patch 01/21] USB: gadget: fix rndis working at high speed Greg KH
2009-01-13 1:26 ` [patch 02/21] usb-storage: update unusual_devs entry for Nokia 5310 Greg KH
2009-01-13 3:15 ` Alan Stern
2009-01-13 1:26 ` [patch 03/21] USB: storage: unusual_devs.h: Nokia 3109c addition Greg KH
2009-01-13 1:26 ` [patch 04/21] USB: Unusual devs patch for Nokia 3500c Greg KH
2009-01-13 1:26 ` [patch 05/21] powerpc: Fix corruption error in rh_alloc_fixed() Greg KH
2009-01-13 1:27 ` [patch 06/21] iwlagn: downgrade BUG_ON in interrupt Greg KH
2009-01-13 1:27 ` Greg KH [this message]
2009-01-13 1:27 ` [patch 08/21] dmaengine: protect id from concurrent registrations Greg KH
2009-01-13 1:27 ` [patch 09/21] ioat: wait for self-test completion Greg KH
2009-01-13 1:27 ` [patch 10/21] md: Dont read past end of bitmap when reading bitmap Greg KH
2009-01-13 1:27 ` [patch 11/21] ALSA: Fix a Oops bug in omap soc driver Greg KH
2009-01-13 1:27 ` [patch 12/21] SCSI: ibmvstgt: move crq_queue_create to the end of initialization Greg KH
2009-01-13 1:27 ` [patch 13/21] SCSI: aacraid: disable Dell Percraid quirk on Adaptec 2200S and 2120S Greg KH
2009-01-13 1:27 ` [patch 14/21] cciss: fix problem that deleting multiple logical drives could cause a panic Greg KH
2009-01-13 1:27 ` [patch 15/21] ALSA: hda - Add missing terminators in patch_sigmatel.c Greg KH
2009-01-13 1:27 ` [patch 16/21] parisc: disable UP-optimized flush_tlb_mm Greg KH
2009-01-13 1:27 ` [patch 17/21] drivers/net: starfire: Fix napi ->poll() weight handling Greg KH
2009-01-13 1:27 ` [patch 18/21] AMD IOMMU: reset command buffer pointers manually Greg KH
2009-01-13 1:27 ` [patch 19/21] AMD IOMMU: allocate rlookup_table with __GFP_ZERO Greg KH
2009-01-13 1:27 ` [patch 20/21] AMD IOMMU: initialize phys_addr correctly in iommu_page_map Greg KH
2009-01-13 1:27 ` [patch 21/21] AMD IOMMU: fix wrong loop counter in free_pagetables Greg KH
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=20090113012702.GH4512@kroah.com \
--to=gregkh@suse.de \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=cavokz@gmail.com \
--cc=cebbert@redhat.com \
--cc=chuckw@quantumlinux.com \
--cc=dan.j.williams@intel.com \
--cc=davej@redhat.com \
--cc=eteo@redhat.com \
--cc=jake@lwn.net \
--cc=jmforbes@linuxtx.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkrufky@linuxtv.org \
--cc=rbranco@la.checkpoint.com \
--cc=rdunlap@xenotime.net \
--cc=reviews@ml.cw.f00f.org \
--cc=saeed@marvell.com \
--cc=stable@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
--cc=w@1wt.eu \
--cc=yur@emcraft.com \
--cc=zwane@arm.linux.org.uk \
/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