2012-10-27 15:50:06

by Akinobu Mita

[permalink] [raw]
Subject: [PATCH] dma: ste_dma40: use for_each_set_bit

Replace open-coded loop with for_each_set_bit().

Signed-off-by: Akinobu Mita <[email protected]>
Cc: Srinidhi Kasagar <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: [email protected]
Cc: Vinod Koul <[email protected]>
Cc: Dan Williams <[email protected]>
---
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


2012-10-27 15:50:08

by Akinobu Mita

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Akinobu Mita <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: Dan Williams <[email protected]>
---
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

2012-10-27 15:50:11

by Akinobu Mita

[permalink] [raw]
Subject: [PATCH] dmatest: adjust invalid module parameters for number of source buffers

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 <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: Dan Williams <[email protected]>
---
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

2012-10-27 15:50:31

by Akinobu Mita

[permalink] [raw]
Subject: [PATCH] async_tx: use memchr_inv

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

Signed-off-by: Akinobu Mita <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: Dan Williams <[email protected]>
---
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

2012-10-28 19:06:21

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH] dma: ste_dma40: use for_each_set_bit

On Sat, Oct 27, 2012 at 5:49 PM, Akinobu Mita <[email protected]> wrote:

> Replace open-coded loop with for_each_set_bit().
>
> Signed-off-by: Akinobu Mita <[email protected]>
> Cc: Srinidhi Kasagar <[email protected]>
> Cc: Linus Walleij <[email protected]>
> Cc: [email protected]
> Cc: Vinod Koul <[email protected]>
> Cc: Dan Williams <[email protected]>

Makes perfect sense to me,
Acked-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

2012-10-29 05:06:54

by Vinod Koul

[permalink] [raw]
Subject: Re: [PATCH] async_tx: use memchr_inv

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 <[email protected]>
> Cc: Vinod Koul <[email protected]>
> Cc: Dan Williams <[email protected]>
> ---
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.

2012-10-29 06:06:54

by Vinod Koul

[permalink] [raw]
Subject: Re: [PATCH] dma: amba-pl08x: use vchan_dma_desc_free_list

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.

2012-10-29 06:07:16

by Vinod Koul

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

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.

2012-10-30 04:03:14

by Vinod Koul

[permalink] [raw]
Subject: Re: [PATCH] async_tx: use memchr_inv

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.