Skip to contentSkip to conversation

dma: ste_dma40: use for_each_set_bit

PATCH In review Akinobu Mita 3 participants 9 messages Oct 27, 2012 – Oct 30, 2012

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma: ste_dma40: use for_each_set_bit

Replace open-coded loop with for_each_set_bit().

Cc Srinidhi Kasagar <[email protected]>
Cc Linus Walleij <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
---
 drivers/dma/ste_dma40.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/dma/ste_dma40.c +3 -10
index ae55091..08f5bfe 100644
@@ -1487,7 +1487,7 @@ static irqreturn_t d40_handle_interrupt(int irq, void *data)
 	u32 regs[ARRAY_SIZE(il)];
 	u32 idx;
 	u32 row;
-	long chan = -1;
+	long chan;
 	struct d40_chan *d40c;
 	unsigned long flags;
 	struct d40_base *base = data;
@@ -1498,15 +1498,8 @@ static irqreturn_t d40_handle_interrupt(int irq, void *data)
 	for (i = 0; i < ARRAY_SIZE(il); i++)
 		regs[i] = readl(base->virtbase + il[i].src);
 
-	for (;;) {
-
-		chan = find_next_bit((unsigned long *)regs,
-				     BITS_PER_LONG * ARRAY_SIZE(il), chan + 1);
-
-		/* No more set bits found? */
-		if (chan == BITS_PER_LONG * ARRAY_SIZE(il))
-			break;
-
+	for_each_set_bit(chan, (unsigned long *)regs,
+			BITS_PER_LONG * ARRAY_SIZE(il)) {
 		row = chan / BITS_PER_LONG;
 		idx = chan & (BITS_PER_LONG - 1);
 
Signature · 1 line
1.7.11.7
#1 lore raw

PATCH 1/1 dma: amba-pl08x: use vchan_dma_desc_free_list

vchan_dma_desc_free_list() iterates through each virt_dma_desc in the specified list_head and calls vchan->desc_free().

We can use it instead of repeated execution of pl08x_desc_free() for each virt_dma_desc in the list_head. Because vchan->desc_free callback is set as pl08x_desc_free() for amba-pl08x driver.

Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
---
 drivers/dma/amba-pl08x.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/dma/amba-pl08x.c +1 -7
index d1cc579..6eb6a5c 100644
@@ -1096,15 +1096,9 @@ static void pl08x_free_txd_list(struct pl08x_driver_data *pl08x,
 				struct pl08x_dma_chan *plchan)
 {
 	LIST_HEAD(head);
-	struct pl08x_txd *txd;
 
 	vchan_get_all_descriptors(&plchan->vc, &head);
-
-	while (!list_empty(&head)) {
-		txd = list_first_entry(&head, struct pl08x_txd, vd.node);
-		list_del(&txd->vd.node);
-		pl08x_desc_free(&txd->vd);
-	}
+	vchan_dma_desc_free_list(&plchan->vc, &head);
 }
 
 /*
Signature · 1 line
1.7.11.7
#3 lore raw

PATCH 1/1 dmatest: adjust invalid module parameters for number of source buffers

In reply to Akinobu Mita

DMA Engine test module has module parameters to set the number of source buffers for xor and pq operations. We can set these values larger than the maximum number of sources that the device can support. These values are not adjusted and the unsupported number of source buffers are passed to the device. But most drivers don't check it, so unexpected results will happen.

This makes an appropriate adjustment for these module parameters before use.

Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
---
 drivers/dma/dmatest.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/dma/dmatest.c +13 -3
index 24225f0..8f130d4e 100644
@@ -228,6 +228,13 @@ static void dmatest_callback(void *arg)
 	wake_up_all(done->wait);
 }
 
+static unsigned int min_odd(unsigned int x, unsigned int y)
+{
+	unsigned int val = min(x, y);
+
+	return val % 2 ? val : val - 1;
+}
+
 /*
  * This function repeatedly tests DMA transfers of various lengths and
  * offsets for a given operation type until it is told to exit by
@@ -248,6 +255,7 @@ static int dmatest_func(void *data)
 	struct dmatest_thread	*thread = data;
 	struct dmatest_done	done = { .wait = &done_wait };
 	struct dma_chan		*chan;
+	struct dma_device	*dev;
 	const char		*thread_name;
 	unsigned int		src_off, dst_off, len;
 	unsigned int		error_count;
@@ -269,13 +277,16 @@ static int dmatest_func(void *data)
 
 	smp_rmb();
 	chan = thread->chan;
+	dev = chan->device;
 	if (thread->type == DMA_MEMCPY)
 		src_cnt = dst_cnt = 1;
 	else if (thread->type == DMA_XOR) {
-		src_cnt = xor_sources | 1; /* force odd to ensure dst = src */
+		/* force odd to ensure dst = src */
+		src_cnt = min_odd(xor_sources | 1, dev->max_xor);
 		dst_cnt = 1;
 	} else if (thread->type == DMA_PQ) {
-		src_cnt = pq_sources | 1; /* force odd to ensure dst = src */
+		/* force odd to ensure dst = src */
+		src_cnt = min_odd(pq_sources | 1, dma_maxpq(dev, 0));
 		dst_cnt = 2;
 		for (i = 0; i < src_cnt; i++)
 			pq_coefs[i] = 1;
@@ -313,7 +324,6 @@ static int dmatest_func(void *data)
 
 	while (!kthread_should_stop()
 	       && !(iterations && total_tests >= iterations)) {
-		struct dma_device *dev = chan->device;
 		struct dma_async_tx_descriptor *tx = NULL;
 		dma_addr_t dma_srcs[src_cnt];
 		dma_addr_t dma_dsts[dst_cnt];
Signature · 1 line
1.7.11.7
#5 lore raw

PATCH 1/1 async_tx: use memchr_inv

In reply to Akinobu Mita

Use memchr_inv() to check the specified page is filled with zero.

Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
---
 crypto/async_tx/async_xor.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
crypto/async_tx/async_xor.c +1 -3
index 154cc84..8ade0a0 100644
@@ -230,9 +230,7 @@ EXPORT_SYMBOL_GPL(async_xor);
 
 static int page_is_zero(struct page *p, unsigned int offset, size_t len)
 {
-	char *a = page_address(p) + offset;
-	return ((*(u32 *) a) == 0 &&
-		memcmp(a, a + 4, len - 4) == 0);
+	return !memchr_inv(page_address(p) + offset, 0, len);
 }
 
 static inline struct dma_chan *
Signature · 1 line
1.7.11.7
#6 lore raw

Re: [PATCH] async_tx: use memchr_inv

In reply to Akinobu Mita
Quoted 6 lines · Akinobu Mita

Use memchr_inv() to check the specified page is filled with zero.

Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>

---

Looks fine to me, need Dan;s ack before applying

Quoted 18 lines
 crypto/async_tx/async_xor.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
crypto/async_tx/async_xor.c +1 -3
index 154cc84..8ade0a0 100644
@@ -230,9 +230,7 @@ EXPORT_SYMBOL_GPL(async_xor);
 
 static int page_is_zero(struct page *p, unsigned int offset, size_t len)
 {
-	char *a = page_address(p) + offset;
-	return ((*(u32 *) a) == 0 &&
-		memcmp(a, a + 4, len - 4) == 0);
+	return !memchr_inv(page_address(p) + offset, 0, len);
 }
 
 static inline struct dma_chan *
Signature · 2 lines
Vinod Koul
Intel Corp.
#2 lore raw

Re: [PATCH] dma: amba-pl08x: use vchan_dma_desc_free_list

In reply to Akinobu Mita
Quoted 8 lines · Akinobu Mita

vchan_dma_desc_free_list() iterates through each virt_dma_desc in the specified list_head and calls vchan->desc_free().

We can use it instead of repeated execution of pl08x_desc_free() for each
virt_dma_desc in the list_head. Because vchan->desc_free callback is set
as pl08x_desc_free() for amba-pl08x driver.

Applied thanks

Signature · 2 lines
Vinod Koul
Intel Corp.
#4 lore raw

Re: [PATCH] dmatest: adjust invalid module parameters for number of source buffers

In reply to Akinobu Mita
Quoted 7 lines · Akinobu Mita

DMA Engine test module has module parameters to set the number of source buffers for xor and pq operations. We can set these values larger than the maximum number of sources that the device can support. These values are not adjusted and the unsupported number of source buffers are passed to the device. But most drivers don't check it, so unexpected results will happen.

This makes an appropriate adjustment for these module parameters before use.

Applied thanks

Signature · 2 lines
Vinod Koul
Intel Corp.
#7 lore raw

Re: [PATCH] async_tx: use memchr_inv

In reply to Akinobu Mita
Quoted 2 lines · Akinobu Mita

Use memchr_inv() to check the specified page is filled with zero.

Applied Thanks

Signature · 2 lines
Vinod Koul
Intel Corp.