linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH resend 0/7] DMA: DMA unmap fixes for v3.8
@ 2012-12-05 11:10 Bartlomiej Zolnierkiewicz
  2012-12-05 11:10 ` [PATCH resend 1/7] async_tx: add missing DMA unmap to async_memcpy() Bartlomiej Zolnierkiewicz
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2012-12-05 11:10 UTC (permalink / raw)
  To: vinod.koul
  Cc: linux-kernel, djbw, dwmw2, hskinnemoen, iws, vipin.kumar, t.figa,
	kyungmin.park, Bartlomiej Zolnierkiewicz

Hi,

This is a minimal set of patches from a larger DMA unmap
rework (http://lkml.org/lkml/2012/11/5/111).  There are no
changes from the previous posting (except added Acked-by
and Reviewed-by tags).

Vinod, could you please apply them to v3.8?  Thanks!


patches #1-3 add missing DMA unmap on failure to async_tx core
code (async_memcpy()), ioat and fsmc_nand drivers

patch #4 fixes DMA flags used by carma-fpga driver

patch #5 adds missing DMA unmap on failure to ioat3 driver

patch #6 fixes build for async_memset.c

patch #7 adds missing DMA unmap on failure to async tx core
code (async_memset())


Bartlomiej Zolnierkiewicz (7):
  async_tx: add missing DMA unmap to async_memcpy()
  ioat: add missing DMA unmap to ioat_dma_self_test()
  mtd: fsmc_nand: add missing DMA unmap to dma_xfer()
  carma-fpga: pass correct flags to ->device_prep_dma_memcpy()
  ioat3: add missing DMA unmap to ioat_xor_val_self_test()
  async_tx: fix build for async_memset
  async_tx: add missing DMA unmap to async_memset()

 crypto/async_tx/async_memcpy.c  |  6 ++++
 crypto/async_tx/async_memset.c  |  4 +++
 drivers/dma/ioat/dma.c          | 11 +++---
 drivers/dma/ioat/dma_v3.c       | 76 ++++++++++++++++++++++++++++++++---------
 drivers/misc/carma/carma-fpga.c |  4 ++-
 drivers/mtd/nand/fsmc_nand.c    | 22 +++++++-----
 6 files changed, 93 insertions(+), 30 deletions(-)

-- 
1.8.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH resend 1/7] async_tx: add missing DMA unmap to async_memcpy()
  2012-12-05 11:10 [PATCH resend 0/7] DMA: DMA unmap fixes for v3.8 Bartlomiej Zolnierkiewicz
@ 2012-12-05 11:10 ` Bartlomiej Zolnierkiewicz
  2012-12-05 11:10 ` [PATCH resend 2/7] ioat: add missing DMA unmap to ioat_dma_self_test() Bartlomiej Zolnierkiewicz
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2012-12-05 11:10 UTC (permalink / raw)
  To: vinod.koul
  Cc: linux-kernel, djbw, dwmw2, hskinnemoen, iws, vipin.kumar, t.figa,
	kyungmin.park, Bartlomiej Zolnierkiewicz

Do DMA unmap on ->device_prep_dma_memcpy failure.

Acked-by: Dan Williams <djbw@fb.com>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 crypto/async_tx/async_memcpy.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/crypto/async_tx/async_memcpy.c b/crypto/async_tx/async_memcpy.c
index 361b5e8..9e62fef 100644
--- a/crypto/async_tx/async_memcpy.c
+++ b/crypto/async_tx/async_memcpy.c
@@ -67,6 +67,12 @@ async_memcpy(struct page *dest, struct page *src, unsigned int dest_offset,
 
 		tx = device->device_prep_dma_memcpy(chan, dma_dest, dma_src,
 						    len, dma_prep_flags);
+		if (!tx) {
+			dma_unmap_page(device->dev, dma_dest, len,
+				       DMA_FROM_DEVICE);
+			dma_unmap_page(device->dev, dma_src, len,
+				       DMA_TO_DEVICE);
+		}
 	}
 
 	if (tx) {
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH resend 2/7] ioat: add missing DMA unmap to ioat_dma_self_test()
  2012-12-05 11:10 [PATCH resend 0/7] DMA: DMA unmap fixes for v3.8 Bartlomiej Zolnierkiewicz
  2012-12-05 11:10 ` [PATCH resend 1/7] async_tx: add missing DMA unmap to async_memcpy() Bartlomiej Zolnierkiewicz
@ 2012-12-05 11:10 ` Bartlomiej Zolnierkiewicz
  2012-12-05 11:10 ` [PATCH resend 3/7] mtd: fsmc_nand: add missing DMA unmap to dma_xfer() Bartlomiej Zolnierkiewicz
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2012-12-05 11:10 UTC (permalink / raw)
  To: vinod.koul
  Cc: linux-kernel, djbw, dwmw2, hskinnemoen, iws, vipin.kumar, t.figa,
	kyungmin.park, Bartlomiej Zolnierkiewicz

Make ioat_dma_self_test() do DMA unmapping itself and fix handling
of failure cases.

Acked-by: Dan Williams <djbw@fb.com>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/dma/ioat/dma.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c
index 73b2b65..464138a 100644
--- a/drivers/dma/ioat/dma.c
+++ b/drivers/dma/ioat/dma.c
@@ -833,14 +833,14 @@ int __devinit ioat_dma_self_test(struct ioatdma_device *device)
 
 	dma_src = dma_map_single(dev, src, IOAT_TEST_SIZE, DMA_TO_DEVICE);
 	dma_dest = dma_map_single(dev, dest, IOAT_TEST_SIZE, DMA_FROM_DEVICE);
-	flags = DMA_COMPL_SRC_UNMAP_SINGLE | DMA_COMPL_DEST_UNMAP_SINGLE |
+	flags = DMA_COMPL_SKIP_SRC_UNMAP | DMA_COMPL_SKIP_DEST_UNMAP |
 		DMA_PREP_INTERRUPT;
 	tx = device->common.device_prep_dma_memcpy(dma_chan, dma_dest, dma_src,
 						   IOAT_TEST_SIZE, flags);
 	if (!tx) {
 		dev_err(dev, "Self-test prep failed, disabling\n");
 		err = -ENODEV;
-		goto free_resources;
+		goto unmap_dma;
 	}
 
 	async_tx_ack(tx);
@@ -851,7 +851,7 @@ int __devinit ioat_dma_self_test(struct ioatdma_device *device)
 	if (cookie < 0) {
 		dev_err(dev, "Self-test setup failed, disabling\n");
 		err = -ENODEV;
-		goto free_resources;
+		goto unmap_dma;
 	}
 	dma->device_issue_pending(dma_chan);
 
@@ -862,7 +862,7 @@ int __devinit ioat_dma_self_test(struct ioatdma_device *device)
 					!= DMA_SUCCESS) {
 		dev_err(dev, "Self-test copy timed out, disabling\n");
 		err = -ENODEV;
-		goto free_resources;
+		goto unmap_dma;
 	}
 	if (memcmp(src, dest, IOAT_TEST_SIZE)) {
 		dev_err(dev, "Self-test copy failed compare, disabling\n");
@@ -870,6 +870,9 @@ int __devinit ioat_dma_self_test(struct ioatdma_device *device)
 		goto free_resources;
 	}
 
+unmap_dma:
+	dma_unmap_single(dev, dma_src, IOAT_TEST_SIZE, DMA_TO_DEVICE);
+	dma_unmap_single(dev, dma_dest, IOAT_TEST_SIZE, DMA_FROM_DEVICE);
 free_resources:
 	dma->device_free_chan_resources(dma_chan);
 out:
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH resend 3/7] mtd: fsmc_nand: add missing DMA unmap to dma_xfer()
  2012-12-05 11:10 [PATCH resend 0/7] DMA: DMA unmap fixes for v3.8 Bartlomiej Zolnierkiewicz
  2012-12-05 11:10 ` [PATCH resend 1/7] async_tx: add missing DMA unmap to async_memcpy() Bartlomiej Zolnierkiewicz
  2012-12-05 11:10 ` [PATCH resend 2/7] ioat: add missing DMA unmap to ioat_dma_self_test() Bartlomiej Zolnierkiewicz
@ 2012-12-05 11:10 ` Bartlomiej Zolnierkiewicz
  2012-12-05 11:10 ` [PATCH resend 4/7] carma-fpga: pass correct flags to ->device_prep_dma_memcpy() Bartlomiej Zolnierkiewicz
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2012-12-05 11:10 UTC (permalink / raw)
  To: vinod.koul
  Cc: linux-kernel, djbw, dwmw2, hskinnemoen, iws, vipin.kumar, t.figa,
	kyungmin.park, Bartlomiej Zolnierkiewicz

Make dma_xfer() do DMA unmapping itself and fix handling
of failure cases.

Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Vipin Kumar <vipin.kumar@st.com>
Acked-by: Dan Williams <djbw@fb.com>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/mtd/nand/fsmc_nand.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c
index 1d74464..a665768 100644
--- a/drivers/mtd/nand/fsmc_nand.c
+++ b/drivers/mtd/nand/fsmc_nand.c
@@ -573,23 +573,22 @@ static int dma_xfer(struct fsmc_nand_data *host, void *buffer, int len,
 	dma_dev = chan->device;
 	dma_addr = dma_map_single(dma_dev->dev, buffer, len, direction);
 
+	flags |= DMA_COMPL_SKIP_SRC_UNMAP | DMA_COMPL_SKIP_DEST_UNMAP;
+
 	if (direction == DMA_TO_DEVICE) {
 		dma_src = dma_addr;
 		dma_dst = host->data_pa;
-		flags |= DMA_COMPL_SRC_UNMAP_SINGLE | DMA_COMPL_SKIP_DEST_UNMAP;
 	} else {
 		dma_src = host->data_pa;
 		dma_dst = dma_addr;
-		flags |= DMA_COMPL_DEST_UNMAP_SINGLE | DMA_COMPL_SKIP_SRC_UNMAP;
 	}
 
 	tx = dma_dev->device_prep_dma_memcpy(chan, dma_dst, dma_src,
 			len, flags);
-
 	if (!tx) {
 		dev_err(host->dev, "device_prep_dma_memcpy error\n");
-		dma_unmap_single(dma_dev->dev, dma_addr, len, direction);
-		return -EIO;
+		ret = -EIO;
+		goto unmap_dma;
 	}
 
 	tx->callback = dma_complete;
@@ -599,7 +598,7 @@ static int dma_xfer(struct fsmc_nand_data *host, void *buffer, int len,
 	ret = dma_submit_error(cookie);
 	if (ret) {
 		dev_err(host->dev, "dma_submit_error %d\n", cookie);
-		return ret;
+		goto unmap_dma;
 	}
 
 	dma_async_issue_pending(chan);
@@ -610,10 +609,17 @@ static int dma_xfer(struct fsmc_nand_data *host, void *buffer, int len,
 	if (ret <= 0) {
 		chan->device->device_control(chan, DMA_TERMINATE_ALL, 0);
 		dev_err(host->dev, "wait_for_completion_timeout\n");
-		return ret ? ret : -ETIMEDOUT;
+		if (!ret)
+			ret = -ETIMEDOUT;
+		goto unmap_dma;
 	}
 
-	return 0;
+	ret = 0;
+
+unmap_dma:
+	dma_unmap_single(dma_dev->dev, dma_addr, len, direction);
+
+	return ret;
 }
 
 /*
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH resend 4/7] carma-fpga: pass correct flags to ->device_prep_dma_memcpy()
  2012-12-05 11:10 [PATCH resend 0/7] DMA: DMA unmap fixes for v3.8 Bartlomiej Zolnierkiewicz
                   ` (2 preceding siblings ...)
  2012-12-05 11:10 ` [PATCH resend 3/7] mtd: fsmc_nand: add missing DMA unmap to dma_xfer() Bartlomiej Zolnierkiewicz
@ 2012-12-05 11:10 ` Bartlomiej Zolnierkiewicz
  2012-12-05 11:10 ` [PATCH resend 5/7] ioat3: add missing DMA unmap to ioat_xor_val_self_test() Bartlomiej Zolnierkiewicz
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2012-12-05 11:10 UTC (permalink / raw)
  To: vinod.koul
  Cc: linux-kernel, djbw, dwmw2, hskinnemoen, iws, vipin.kumar, t.figa,
	kyungmin.park, Bartlomiej Zolnierkiewicz

DMA unmapping is handled by a driver so tell fsldma.c driver
(which is the DMA engine driver used by carma-fpga) to skip
unmapping destination and source buffers.

Acked-by: Ira W. Snyder <iws@ovro.caltech.edu>
Acked-by: Dan Williams <djbw@fb.com>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/misc/carma/carma-fpga.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/carma/carma-fpga.c b/drivers/misc/carma/carma-fpga.c
index 8835eab..6b43f8c 100644
--- a/drivers/misc/carma/carma-fpga.c
+++ b/drivers/misc/carma/carma-fpga.c
@@ -631,6 +631,8 @@ static int data_submit_dma(struct fpga_device *priv, struct data_buf *buf)
 	struct dma_async_tx_descriptor *tx;
 	dma_cookie_t cookie;
 	dma_addr_t dst, src;
+	unsigned long dma_flags = DMA_COMPL_SKIP_DEST_UNMAP |
+				  DMA_COMPL_SKIP_SRC_UNMAP;
 
 	dst_sg = buf->vb.sglist;
 	dst_nents = buf->vb.sglen;
@@ -666,7 +668,7 @@ static int data_submit_dma(struct fpga_device *priv, struct data_buf *buf)
 	src = SYS_FPGA_BLOCK;
 	tx = chan->device->device_prep_dma_memcpy(chan, dst, src,
 						  REG_BLOCK_SIZE,
-						  0);
+						  dma_flags);
 	if (!tx) {
 		dev_err(priv->dev, "unable to prep SYS-FPGA DMA\n");
 		return -ENOMEM;
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH resend 5/7] ioat3: add missing DMA unmap to ioat_xor_val_self_test()
  2012-12-05 11:10 [PATCH resend 0/7] DMA: DMA unmap fixes for v3.8 Bartlomiej Zolnierkiewicz
                   ` (3 preceding siblings ...)
  2012-12-05 11:10 ` [PATCH resend 4/7] carma-fpga: pass correct flags to ->device_prep_dma_memcpy() Bartlomiej Zolnierkiewicz
@ 2012-12-05 11:10 ` Bartlomiej Zolnierkiewicz
  2012-12-05 11:10 ` [PATCH resend 6/7] async_tx: fix build for async_memset Bartlomiej Zolnierkiewicz
  2012-12-05 11:10 ` [PATCH resend 7/7] async_tx: add missing DMA unmap to async_memset() Bartlomiej Zolnierkiewicz
  6 siblings, 0 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2012-12-05 11:10 UTC (permalink / raw)
  To: vinod.koul
  Cc: linux-kernel, djbw, dwmw2, hskinnemoen, iws, vipin.kumar, t.figa,
	kyungmin.park, Bartlomiej Zolnierkiewicz

Make ioat_xor_val_self_test() do DMA unmapping itself and fix handling
of failure cases.

Acked-by: Dan Williams <djbw@fb.com>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/dma/ioat/dma_v3.c | 76 ++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 59 insertions(+), 17 deletions(-)

diff --git a/drivers/dma/ioat/dma_v3.c b/drivers/dma/ioat/dma_v3.c
index f7f1dc6..6456f7d 100644
--- a/drivers/dma/ioat/dma_v3.c
+++ b/drivers/dma/ioat/dma_v3.c
@@ -863,6 +863,7 @@ static int __devinit ioat_xor_val_self_test(struct ioatdma_device *device)
 	unsigned long tmo;
 	struct device *dev = &device->pdev->dev;
 	struct dma_device *dma = &device->common;
+	u8 op = 0;
 
 	dev_dbg(dev, "%s\n", __func__);
 
@@ -908,18 +909,22 @@ static int __devinit ioat_xor_val_self_test(struct ioatdma_device *device)
 	}
 
 	/* test xor */
+	op = IOAT_OP_XOR;
+
 	dest_dma = dma_map_page(dev, dest, 0, PAGE_SIZE, DMA_FROM_DEVICE);
 	for (i = 0; i < IOAT_NUM_SRC_TEST; i++)
 		dma_srcs[i] = dma_map_page(dev, xor_srcs[i], 0, PAGE_SIZE,
 					   DMA_TO_DEVICE);
 	tx = dma->device_prep_dma_xor(dma_chan, dest_dma, dma_srcs,
 				      IOAT_NUM_SRC_TEST, PAGE_SIZE,
-				      DMA_PREP_INTERRUPT);
+				      DMA_PREP_INTERRUPT |
+				      DMA_COMPL_SKIP_SRC_UNMAP |
+				      DMA_COMPL_SKIP_DEST_UNMAP);
 
 	if (!tx) {
 		dev_err(dev, "Self-test xor prep failed\n");
 		err = -ENODEV;
-		goto free_resources;
+		goto dma_unmap;
 	}
 
 	async_tx_ack(tx);
@@ -930,7 +935,7 @@ static int __devinit ioat_xor_val_self_test(struct ioatdma_device *device)
 	if (cookie < 0) {
 		dev_err(dev, "Self-test xor setup failed\n");
 		err = -ENODEV;
-		goto free_resources;
+		goto dma_unmap;
 	}
 	dma->device_issue_pending(dma_chan);
 
@@ -939,9 +944,13 @@ static int __devinit ioat_xor_val_self_test(struct ioatdma_device *device)
 	if (dma->device_tx_status(dma_chan, cookie, NULL) != DMA_SUCCESS) {
 		dev_err(dev, "Self-test xor timed out\n");
 		err = -ENODEV;
-		goto free_resources;
+		goto dma_unmap;
 	}
 
+	dma_unmap_page(dev, dest_dma, PAGE_SIZE, DMA_FROM_DEVICE);
+	for (i = 0; i < IOAT_NUM_SRC_TEST; i++)
+		dma_unmap_page(dev, dma_srcs[i], PAGE_SIZE, DMA_TO_DEVICE);
+
 	dma_sync_single_for_cpu(dev, dest_dma, PAGE_SIZE, DMA_FROM_DEVICE);
 	for (i = 0; i < (PAGE_SIZE / sizeof(u32)); i++) {
 		u32 *ptr = page_address(dest);
@@ -957,6 +966,8 @@ static int __devinit ioat_xor_val_self_test(struct ioatdma_device *device)
 	if (!dma_has_cap(DMA_XOR_VAL, dma_chan->device->cap_mask))
 		goto free_resources;
 
+	op = IOAT_OP_XOR_VAL;
+
 	/* validate the sources with the destintation page */
 	for (i = 0; i < IOAT_NUM_SRC_TEST; i++)
 		xor_val_srcs[i] = xor_srcs[i];
@@ -969,11 +980,13 @@ static int __devinit ioat_xor_val_self_test(struct ioatdma_device *device)
 					   DMA_TO_DEVICE);
 	tx = dma->device_prep_dma_xor_val(dma_chan, dma_srcs,
 					  IOAT_NUM_SRC_TEST + 1, PAGE_SIZE,
-					  &xor_val_result, DMA_PREP_INTERRUPT);
+					  &xor_val_result, DMA_PREP_INTERRUPT |
+					  DMA_COMPL_SKIP_SRC_UNMAP |
+					  DMA_COMPL_SKIP_DEST_UNMAP);
 	if (!tx) {
 		dev_err(dev, "Self-test zero prep failed\n");
 		err = -ENODEV;
-		goto free_resources;
+		goto dma_unmap;
 	}
 
 	async_tx_ack(tx);
@@ -984,7 +997,7 @@ static int __devinit ioat_xor_val_self_test(struct ioatdma_device *device)
 	if (cookie < 0) {
 		dev_err(dev, "Self-test zero setup failed\n");
 		err = -ENODEV;
-		goto free_resources;
+		goto dma_unmap;
 	}
 	dma->device_issue_pending(dma_chan);
 
@@ -993,9 +1006,12 @@ static int __devinit ioat_xor_val_self_test(struct ioatdma_device *device)
 	if (dma->device_tx_status(dma_chan, cookie, NULL) != DMA_SUCCESS) {
 		dev_err(dev, "Self-test validate timed out\n");
 		err = -ENODEV;
-		goto free_resources;
+		goto dma_unmap;
 	}
 
+	for (i = 0; i < IOAT_NUM_SRC_TEST + 1; i++)
+		dma_unmap_page(dev, dma_srcs[i], PAGE_SIZE, DMA_TO_DEVICE);
+
 	if (xor_val_result != 0) {
 		dev_err(dev, "Self-test validate failed compare\n");
 		err = -ENODEV;
@@ -1007,14 +1023,18 @@ static int __devinit ioat_xor_val_self_test(struct ioatdma_device *device)
 		goto free_resources;
 
 	/* test memset */
+	op = IOAT_OP_FILL;
+
 	dma_addr = dma_map_page(dev, dest, 0,
 			PAGE_SIZE, DMA_FROM_DEVICE);
 	tx = dma->device_prep_dma_memset(dma_chan, dma_addr, 0, PAGE_SIZE,
-					 DMA_PREP_INTERRUPT);
+					 DMA_PREP_INTERRUPT |
+					 DMA_COMPL_SKIP_SRC_UNMAP |
+					 DMA_COMPL_SKIP_DEST_UNMAP);
 	if (!tx) {
 		dev_err(dev, "Self-test memset prep failed\n");
 		err = -ENODEV;
-		goto free_resources;
+		goto dma_unmap;
 	}
 
 	async_tx_ack(tx);
@@ -1025,7 +1045,7 @@ static int __devinit ioat_xor_val_self_test(struct ioatdma_device *device)
 	if (cookie < 0) {
 		dev_err(dev, "Self-test memset setup failed\n");
 		err = -ENODEV;
-		goto free_resources;
+		goto dma_unmap;
 	}
 	dma->device_issue_pending(dma_chan);
 
@@ -1034,9 +1054,11 @@ static int __devinit ioat_xor_val_self_test(struct ioatdma_device *device)
 	if (dma->device_tx_status(dma_chan, cookie, NULL) != DMA_SUCCESS) {
 		dev_err(dev, "Self-test memset timed out\n");
 		err = -ENODEV;
-		goto free_resources;
+		goto dma_unmap;
 	}
 
+	dma_unmap_page(dev, dma_addr, PAGE_SIZE, DMA_FROM_DEVICE);
+
 	for (i = 0; i < PAGE_SIZE/sizeof(u32); i++) {
 		u32 *ptr = page_address(dest);
 		if (ptr[i]) {
@@ -1047,17 +1069,21 @@ static int __devinit ioat_xor_val_self_test(struct ioatdma_device *device)
 	}
 
 	/* test for non-zero parity sum */
+	op = IOAT_OP_XOR_VAL;
+
 	xor_val_result = 0;
 	for (i = 0; i < IOAT_NUM_SRC_TEST + 1; i++)
 		dma_srcs[i] = dma_map_page(dev, xor_val_srcs[i], 0, PAGE_SIZE,
 					   DMA_TO_DEVICE);
 	tx = dma->device_prep_dma_xor_val(dma_chan, dma_srcs,
 					  IOAT_NUM_SRC_TEST + 1, PAGE_SIZE,
-					  &xor_val_result, DMA_PREP_INTERRUPT);
+					  &xor_val_result, DMA_PREP_INTERRUPT |
+					  DMA_COMPL_SKIP_SRC_UNMAP |
+					  DMA_COMPL_SKIP_DEST_UNMAP);
 	if (!tx) {
 		dev_err(dev, "Self-test 2nd zero prep failed\n");
 		err = -ENODEV;
-		goto free_resources;
+		goto dma_unmap;
 	}
 
 	async_tx_ack(tx);
@@ -1068,7 +1094,7 @@ static int __devinit ioat_xor_val_self_test(struct ioatdma_device *device)
 	if (cookie < 0) {
 		dev_err(dev, "Self-test  2nd zero setup failed\n");
 		err = -ENODEV;
-		goto free_resources;
+		goto dma_unmap;
 	}
 	dma->device_issue_pending(dma_chan);
 
@@ -1077,15 +1103,31 @@ static int __devinit ioat_xor_val_self_test(struct ioatdma_device *device)
 	if (dma->device_tx_status(dma_chan, cookie, NULL) != DMA_SUCCESS) {
 		dev_err(dev, "Self-test 2nd validate timed out\n");
 		err = -ENODEV;
-		goto free_resources;
+		goto dma_unmap;
 	}
 
 	if (xor_val_result != SUM_CHECK_P_RESULT) {
 		dev_err(dev, "Self-test validate failed compare\n");
 		err = -ENODEV;
-		goto free_resources;
+		goto dma_unmap;
 	}
 
+	for (i = 0; i < IOAT_NUM_SRC_TEST + 1; i++)
+		dma_unmap_page(dev, dma_srcs[i], PAGE_SIZE, DMA_TO_DEVICE);
+
+	goto free_resources;
+dma_unmap:
+	if (op == IOAT_OP_XOR) {
+		dma_unmap_page(dev, dest_dma, PAGE_SIZE, DMA_FROM_DEVICE);
+		for (i = 0; i < IOAT_NUM_SRC_TEST; i++)
+			dma_unmap_page(dev, dma_srcs[i], PAGE_SIZE,
+				       DMA_TO_DEVICE);
+	} else if (op == IOAT_OP_XOR_VAL) {
+		for (i = 0; i < IOAT_NUM_SRC_TEST + 1; i++)
+			dma_unmap_page(dev, dma_srcs[i], PAGE_SIZE,
+				       DMA_TO_DEVICE);
+	} else if (op == IOAT_OP_FILL)
+		dma_unmap_page(dev, dma_addr, PAGE_SIZE, DMA_FROM_DEVICE);
 free_resources:
 	dma->device_free_chan_resources(dma_chan);
 out:
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH resend 6/7] async_tx: fix build for async_memset
  2012-12-05 11:10 [PATCH resend 0/7] DMA: DMA unmap fixes for v3.8 Bartlomiej Zolnierkiewicz
                   ` (4 preceding siblings ...)
  2012-12-05 11:10 ` [PATCH resend 5/7] ioat3: add missing DMA unmap to ioat_xor_val_self_test() Bartlomiej Zolnierkiewicz
@ 2012-12-05 11:10 ` Bartlomiej Zolnierkiewicz
  2012-12-05 11:10 ` [PATCH resend 7/7] async_tx: add missing DMA unmap to async_memset() Bartlomiej Zolnierkiewicz
  6 siblings, 0 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2012-12-05 11:10 UTC (permalink / raw)
  To: vinod.koul
  Cc: linux-kernel, djbw, dwmw2, hskinnemoen, iws, vipin.kumar, t.figa,
	kyungmin.park, Bartlomiej Zolnierkiewicz

Add missing <linux/module.h> include.

Acked-by: Dan Williams <djbw@fb.com>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 crypto/async_tx/async_memset.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/crypto/async_tx/async_memset.c b/crypto/async_tx/async_memset.c
index 58e4a87..05a4d1e 100644
--- a/crypto/async_tx/async_memset.c
+++ b/crypto/async_tx/async_memset.c
@@ -25,6 +25,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/interrupt.h>
+#include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/dma-mapping.h>
 #include <linux/async_tx.h>
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH resend 7/7] async_tx: add missing DMA unmap to async_memset()
  2012-12-05 11:10 [PATCH resend 0/7] DMA: DMA unmap fixes for v3.8 Bartlomiej Zolnierkiewicz
                   ` (5 preceding siblings ...)
  2012-12-05 11:10 ` [PATCH resend 6/7] async_tx: fix build for async_memset Bartlomiej Zolnierkiewicz
@ 2012-12-05 11:10 ` Bartlomiej Zolnierkiewicz
  6 siblings, 0 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2012-12-05 11:10 UTC (permalink / raw)
  To: vinod.koul
  Cc: linux-kernel, djbw, dwmw2, hskinnemoen, iws, vipin.kumar, t.figa,
	kyungmin.park, Bartlomiej Zolnierkiewicz

Do DMA unmap on ->device_prep_dma_memset failure.

Acked-by: Dan Williams <djbw@fb.com>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 crypto/async_tx/async_memset.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/crypto/async_tx/async_memset.c b/crypto/async_tx/async_memset.c
index 05a4d1e..a6a667b 100644
--- a/crypto/async_tx/async_memset.c
+++ b/crypto/async_tx/async_memset.c
@@ -61,6 +61,9 @@ async_memset(struct page *dest, int val, unsigned int offset, size_t len,
 
 		tx = device->device_prep_dma_memset(chan, dma_dest, val, len,
 						    dma_prep_flags);
+		if (!tx)
+			dma_unmap_page(device->dev, dma_dest, len,
+				       DMA_FROM_DEVICE);
 	}
 
 	if (tx) {
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-12-05 11:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-05 11:10 [PATCH resend 0/7] DMA: DMA unmap fixes for v3.8 Bartlomiej Zolnierkiewicz
2012-12-05 11:10 ` [PATCH resend 1/7] async_tx: add missing DMA unmap to async_memcpy() Bartlomiej Zolnierkiewicz
2012-12-05 11:10 ` [PATCH resend 2/7] ioat: add missing DMA unmap to ioat_dma_self_test() Bartlomiej Zolnierkiewicz
2012-12-05 11:10 ` [PATCH resend 3/7] mtd: fsmc_nand: add missing DMA unmap to dma_xfer() Bartlomiej Zolnierkiewicz
2012-12-05 11:10 ` [PATCH resend 4/7] carma-fpga: pass correct flags to ->device_prep_dma_memcpy() Bartlomiej Zolnierkiewicz
2012-12-05 11:10 ` [PATCH resend 5/7] ioat3: add missing DMA unmap to ioat_xor_val_self_test() Bartlomiej Zolnierkiewicz
2012-12-05 11:10 ` [PATCH resend 6/7] async_tx: fix build for async_memset Bartlomiej Zolnierkiewicz
2012-12-05 11:10 ` [PATCH resend 7/7] async_tx: add missing DMA unmap to async_memset() Bartlomiej Zolnierkiewicz

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).