lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <1352109631-3385-17-git-send-email-b.zolnierkie@samsung.com>
Date:	Mon, 05 Nov 2012 11:00:27 +0100
From:	Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>
To:	linux-kernel@...r.kernel.org
Cc:	djbw@...com, dwmw2@...radead.org, hskinnemoen@...il.com,
	iws@...o.caltech.edu, vinod.koul@...el.com, vipin.kumar@...com,
	t.figa@...sung.com, kyungmin.park@...sung.com,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>
Subject: [PATCH 16/20] async_tx: do DMA unmap in async_raid6_recov.c for PQ
 operations

Convert core async_tx code (async_sum_product() and async_mult())
to do DMA unmapping itself using the ->callback functionality.

Cc: Dan Williams <djbw@...com>
Cc: Tomasz Figa <t.figa@...sung.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@...sung.com>
---
 crypto/async_tx/async_raid6_recov.c | 50 ++++++++++++++++++++++++++++++++++---
 1 file changed, 46 insertions(+), 4 deletions(-)

diff --git a/crypto/async_tx/async_raid6_recov.c b/crypto/async_tx/async_raid6_recov.c
index a9f08a6..3db97aa 100644
--- a/crypto/async_tx/async_raid6_recov.c
+++ b/crypto/async_tx/async_raid6_recov.c
@@ -27,6 +27,20 @@
 #include <linux/raid/pq.h>
 #include <linux/async_tx.h>
 
+static void async_sum_product_cb(void *dma_async_param)
+{
+	struct dma_async_tx_descriptor *tx = dma_async_param;
+	struct dma_device *dev = tx->chan->device;
+
+	dma_unmap_page(dev->dev, tx->dma_dst[1], tx->dma_len,
+		       DMA_BIDIRECTIONAL);
+	dma_unmap_page(dev->dev, tx->dma_src[0], tx->dma_len, DMA_TO_DEVICE);
+	dma_unmap_page(dev->dev, tx->dma_src[1], tx->dma_len, DMA_TO_DEVICE);
+
+	if (tx->orig_callback)
+		tx->orig_callback(tx->orig_callback_param);
+}
+
 static struct dma_async_tx_descriptor *
 async_sum_product(struct page *dest, struct page **srcs, unsigned char *coef,
 		  size_t len, struct async_submit_ctl *submit)
@@ -43,7 +57,9 @@ async_sum_product(struct page *dest, struct page **srcs, unsigned char *coef,
 		dma_addr_t dma_src[2];
 		struct device *dev = dma->dev;
 		struct dma_async_tx_descriptor *tx;
-		enum dma_ctrl_flags dma_flags = DMA_PREP_PQ_DISABLE_P;
+		enum dma_ctrl_flags dma_flags = DMA_COMPL_SKIP_SRC_UNMAP |
+						DMA_COMPL_SKIP_DEST_UNMAP |
+						DMA_PREP_PQ_DISABLE_P;
 
 		if (submit->flags & ASYNC_TX_FENCE)
 			dma_flags |= DMA_PREP_FENCE;
@@ -53,7 +69,13 @@ async_sum_product(struct page *dest, struct page **srcs, unsigned char *coef,
 		tx = dma->device_prep_dma_pq(chan, dma_dest, dma_src, 2, coef,
 					     len, dma_flags);
 		if (tx) {
-			async_tx_submit(chan, tx, submit);
+			tx->dma_dst[1] = dma_dest[1];
+			tx->dma_src[0] = dma_src[0];
+			tx->dma_src[1] = dma_src[1];
+			tx->dma_len = len;
+
+			__async_tx_submit(chan, tx, async_sum_product_cb, tx,
+					  submit);
 			return tx;
 		}
 
@@ -82,6 +104,20 @@ async_sum_product(struct page *dest, struct page **srcs, unsigned char *coef,
 	return NULL;
 }
 
+static void async_mult_cb(void *dma_async_param)
+{
+	struct dma_async_tx_descriptor *tx = dma_async_param;
+	struct dma_device *dev = tx->chan->device;
+
+	dma_unmap_page(dev->dev, tx->dma_dst[1], tx->dma_len,
+		       DMA_BIDIRECTIONAL);
+	dma_unmap_page(dev->dev, tx->dma_src[0], tx->dma_len,
+		       DMA_TO_DEVICE);
+
+	if (tx->orig_callback)
+		tx->orig_callback(tx->orig_callback_param);
+}
+
 static struct dma_async_tx_descriptor *
 async_mult(struct page *dest, struct page *src, u8 coef, size_t len,
 	   struct async_submit_ctl *submit)
@@ -97,7 +133,9 @@ async_mult(struct page *dest, struct page *src, u8 coef, size_t len,
 		dma_addr_t dma_src[1];
 		struct device *dev = dma->dev;
 		struct dma_async_tx_descriptor *tx;
-		enum dma_ctrl_flags dma_flags = DMA_PREP_PQ_DISABLE_P;
+		enum dma_ctrl_flags dma_flags = DMA_COMPL_SKIP_SRC_UNMAP |
+						DMA_COMPL_SKIP_DEST_UNMAP |
+						DMA_PREP_PQ_DISABLE_P;
 
 		if (submit->flags & ASYNC_TX_FENCE)
 			dma_flags |= DMA_PREP_FENCE;
@@ -106,7 +144,11 @@ async_mult(struct page *dest, struct page *src, u8 coef, size_t len,
 		tx = dma->device_prep_dma_pq(chan, dma_dest, dma_src, 1, &coef,
 					     len, dma_flags);
 		if (tx) {
-			async_tx_submit(chan, tx, submit);
+			tx->dma_dst[1] = dma_dest[1];
+			tx->dma_src[0] = dma_src[0];
+			tx->dma_len = len;
+
+			__async_tx_submit(chan, tx, async_mult_cb, tx, submit);
 			return tx;
 		}
 
-- 
1.8.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ