linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dma: ste_dma40: use for_each_set_bit
@ 2012-10-27 15:49 Akinobu Mita
  2012-10-27 15:49 ` [PATCH] dma: amba-pl08x: use vchan_dma_desc_free_list Akinobu Mita
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Akinobu Mita @ 2012-10-27 15:49 UTC (permalink / raw)
  To: linux-kernel, akpm
  Cc: Akinobu Mita, Srinidhi Kasagar, Linus Walleij, linux-arm-kernel,
	Vinod Koul, Dan Williams

Replace open-coded loop with for_each_set_bit().

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Dan Williams <djbw@fb.com>
---
 drivers/dma/ste_dma40.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index ae55091..08f5bfe 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -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);
 
-- 
1.7.11.7


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

* [PATCH] dma: amba-pl08x: use vchan_dma_desc_free_list
  2012-10-27 15:49 [PATCH] dma: ste_dma40: use for_each_set_bit Akinobu Mita
@ 2012-10-27 15:49 ` Akinobu Mita
  2012-10-29  5:53   ` Vinod Koul
  2012-10-27 15:49 ` [PATCH] dmatest: adjust invalid module parameters for number of source buffers Akinobu Mita
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Akinobu Mita @ 2012-10-27 15:49 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: Akinobu Mita, Vinod Koul, Dan Williams

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.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Dan Williams <djbw@fb.com>
---
 drivers/dma/amba-pl08x.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c
index d1cc579..6eb6a5c 100644
--- a/drivers/dma/amba-pl08x.c
+++ b/drivers/dma/amba-pl08x.c
@@ -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);
 }
 
 /*
-- 
1.7.11.7


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

* [PATCH] dmatest: adjust invalid module parameters for number of source buffers
  2012-10-27 15:49 [PATCH] dma: ste_dma40: use for_each_set_bit Akinobu Mita
  2012-10-27 15:49 ` [PATCH] dma: amba-pl08x: use vchan_dma_desc_free_list Akinobu Mita
@ 2012-10-27 15:49 ` Akinobu Mita
  2012-10-29  5:54   ` Vinod Koul
  2012-10-27 15:49 ` [PATCH] async_tx: use memchr_inv Akinobu Mita
  2012-10-28 19:06 ` [PATCH] dma: ste_dma40: use for_each_set_bit Linus Walleij
  3 siblings, 1 reply; 9+ messages in thread
From: Akinobu Mita @ 2012-10-27 15:49 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: Akinobu Mita, Vinod Koul, Dan Williams

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.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Dan Williams <djbw@fb.com>
---
 drivers/dma/dmatest.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index 24225f0..8f130d4e 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -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];
-- 
1.7.11.7


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

* [PATCH] async_tx: use memchr_inv
  2012-10-27 15:49 [PATCH] dma: ste_dma40: use for_each_set_bit Akinobu Mita
  2012-10-27 15:49 ` [PATCH] dma: amba-pl08x: use vchan_dma_desc_free_list Akinobu Mita
  2012-10-27 15:49 ` [PATCH] dmatest: adjust invalid module parameters for number of source buffers Akinobu Mita
@ 2012-10-27 15:49 ` Akinobu Mita
  2012-10-29  4:53   ` Vinod Koul
  2012-10-30  3:49   ` Vinod Koul
  2012-10-28 19:06 ` [PATCH] dma: ste_dma40: use for_each_set_bit Linus Walleij
  3 siblings, 2 replies; 9+ messages in thread
From: Akinobu Mita @ 2012-10-27 15:49 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: Akinobu Mita, Vinod Koul, Dan Williams

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

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Dan Williams <djbw@fb.com>
---
 crypto/async_tx/async_xor.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/crypto/async_tx/async_xor.c b/crypto/async_tx/async_xor.c
index 154cc84..8ade0a0 100644
--- a/crypto/async_tx/async_xor.c
+++ b/crypto/async_tx/async_xor.c
@@ -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 *
-- 
1.7.11.7


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

* Re: [PATCH] dma: ste_dma40: use for_each_set_bit
  2012-10-27 15:49 [PATCH] dma: ste_dma40: use for_each_set_bit Akinobu Mita
                   ` (2 preceding siblings ...)
  2012-10-27 15:49 ` [PATCH] async_tx: use memchr_inv Akinobu Mita
@ 2012-10-28 19:06 ` Linus Walleij
  3 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2012-10-28 19:06 UTC (permalink / raw)
  To: Akinobu Mita, Rabin VINCENT, Per Forlin
  Cc: linux-kernel, akpm, Srinidhi Kasagar, linux-arm-kernel,
	Vinod Koul, Dan Williams

On Sat, Oct 27, 2012 at 5:49 PM, Akinobu Mita <akinobu.mita@gmail.com> wrote:

> Replace open-coded loop with for_each_set_bit().
>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: Vinod Koul <vinod.koul@intel.com>
> Cc: Dan Williams <djbw@fb.com>

Makes perfect sense to me,
Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH] async_tx: use memchr_inv
  2012-10-27 15:49 ` [PATCH] async_tx: use memchr_inv Akinobu Mita
@ 2012-10-29  4:53   ` Vinod Koul
  2012-10-30  3:49   ` Vinod Koul
  1 sibling, 0 replies; 9+ messages in thread
From: Vinod Koul @ 2012-10-29  4:53 UTC (permalink / raw)
  To: Akinobu Mita; +Cc: vinod.koul, linux-kernel, akpm, Dan Williams

On Sun, 2012-10-28 at 00:49 +0900, Akinobu Mita wrote:
> Use memchr_inv() to check the specified page is filled with zero.
> 
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: Vinod Koul <vinod.koul@intel.com>
> Cc: Dan Williams <djbw@fb.com>
> ---
Looks fine to me, need Dan;s ack before applying

>  crypto/async_tx/async_xor.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/crypto/async_tx/async_xor.c b/crypto/async_tx/async_xor.c
> index 154cc84..8ade0a0 100644
> --- a/crypto/async_tx/async_xor.c
> +++ b/crypto/async_tx/async_xor.c
> @@ -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 *


-- 
Vinod Koul
Intel Corp.


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

* Re: [PATCH] dma: amba-pl08x: use vchan_dma_desc_free_list
  2012-10-27 15:49 ` [PATCH] dma: amba-pl08x: use vchan_dma_desc_free_list Akinobu Mita
@ 2012-10-29  5:53   ` Vinod Koul
  0 siblings, 0 replies; 9+ messages in thread
From: Vinod Koul @ 2012-10-29  5:53 UTC (permalink / raw)
  To: Akinobu Mita; +Cc: vinod.koul, linux-kernel, akpm, Dan Williams

On Sun, 2012-10-28 at 00:49 +0900, Akinobu Mita wrote:
> 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
-- 
Vinod Koul
Intel Corp.


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

* Re: [PATCH] dmatest: adjust invalid module parameters for number of source buffers
  2012-10-27 15:49 ` [PATCH] dmatest: adjust invalid module parameters for number of source buffers Akinobu Mita
@ 2012-10-29  5:54   ` Vinod Koul
  0 siblings, 0 replies; 9+ messages in thread
From: Vinod Koul @ 2012-10-29  5:54 UTC (permalink / raw)
  To: Akinobu Mita; +Cc: vinod.koul, linux-kernel, akpm, Dan Williams

On Sun, 2012-10-28 at 00:49 +0900, Akinobu Mita wrote:
> 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

-- 
Vinod Koul
Intel Corp.


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

* Re: [PATCH] async_tx: use memchr_inv
  2012-10-27 15:49 ` [PATCH] async_tx: use memchr_inv Akinobu Mita
  2012-10-29  4:53   ` Vinod Koul
@ 2012-10-30  3:49   ` Vinod Koul
  1 sibling, 0 replies; 9+ messages in thread
From: Vinod Koul @ 2012-10-30  3:49 UTC (permalink / raw)
  To: Akinobu Mita; +Cc: vinod.koul, linux-kernel, akpm, Dan Williams

On Sun, 2012-10-28 at 00:49 +0900, Akinobu Mita wrote:
> Use memchr_inv() to check the specified page is filled with zero.
> 
Applied Thanks

-- 
Vinod Koul
Intel Corp.


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

end of thread, other threads:[~2012-10-30  4:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-27 15:49 [PATCH] dma: ste_dma40: use for_each_set_bit Akinobu Mita
2012-10-27 15:49 ` [PATCH] dma: amba-pl08x: use vchan_dma_desc_free_list Akinobu Mita
2012-10-29  5:53   ` Vinod Koul
2012-10-27 15:49 ` [PATCH] dmatest: adjust invalid module parameters for number of source buffers Akinobu Mita
2012-10-29  5:54   ` Vinod Koul
2012-10-27 15:49 ` [PATCH] async_tx: use memchr_inv Akinobu Mita
2012-10-29  4:53   ` Vinod Koul
2012-10-30  3:49   ` Vinod Koul
2012-10-28 19:06 ` [PATCH] dma: ste_dma40: use for_each_set_bit Linus Walleij

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