dma: ste_dma40: use for_each_set_bit
Subsystems (4)
PATCH 1/1 dma: ste_dma40: use for_each_set_bit
Replace open-coded loop with for_each_set_bit().
--- drivers/dma/ste_dma40.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/dma/ste_dma40.c +3 -10
@@ -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
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.
--- drivers/dma/amba-pl08x.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/dma/amba-pl08x.c +1 -7
@@ -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
PATCH 1/1 dmatest: adjust invalid module parameters for number of source buffers
In reply to Akinobu MitaDMA 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.
--- drivers/dma/dmatest.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/dma/dmatest.c +13 -3
@@ -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
PATCH 1/1 async_tx: use memchr_inv
In reply to Akinobu MitaUse memchr_inv() to check the specified page is filled with zero.
--- crypto/async_tx/async_xor.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
crypto/async_tx/async_xor.c +1 -3
@@ -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
Quoted 8 lines · Akinobu Mita
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 linux-arm-kernel at lists.infradead.orgCc Vinod Koul <[email protected]>Cc Dan Williams <[email protected]>
Makes perfect sense to me,
Yours,
Linus Walleij
Re: [PATCH] async_tx: use memchr_inv
In reply to Akinobu MitaQuoted 6 lines · Akinobu Mita
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
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@@ -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.
Re: [PATCH] dma: amba-pl08x: use vchan_dma_desc_free_list
In reply to Akinobu MitaQuoted 8 lines · Akinobu Mita
vchan_dma_desc_free_list()iterates through eachvirt_dma_descin the specifiedlist_headand callsvchan->desc_free().We can use it instead of repeated execution of
pl08x_desc_free()for eachvirt_dma_descin thelist_head. Becausevchan->desc_freecallback is set
aspl08x_desc_free()for amba-pl08x driver.
Applied thanks
Signature · 2 lines
Vinod Koul Intel Corp.
Re: [PATCH] dmatest: adjust invalid module parameters for number of source buffers
In reply to Akinobu MitaQuoted 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.
Re: [PATCH] async_tx: use memchr_inv
In reply to Akinobu MitaQuoted 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.