linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] dmaengine: pxa_dma: fix cyclic transfers
@ 2016-02-16 21:54 Robert Jarzmik
  2016-02-26 22:22 ` Robert Jarzmik
  2016-03-03 15:37 ` Vinod Koul
  0 siblings, 2 replies; 4+ messages in thread
From: Robert Jarzmik @ 2016-02-16 21:54 UTC (permalink / raw)
  To: linux-arm-kernel

While testing audio with pxa2xx-ac97, underrun were happening while the
user application was correctly feeding the music. Debug proved that the
cyclic transfer is not cyclic, ie. the last descriptor did not loop on
the first.

Another issue is that the descriptor length was always set to 8192,
because of an trivial operator issue.

This was tested on a pxa27x platform.

Fixes: a57e16cf0333 ("dmaengine: pxa: add pxa dmaengine driver")
Reported-by: Vasily Khoruzhick <anarsoul@gmail.com>
Tested-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
Since v1: add the mask fix suggested by Vasily
---
 drivers/dma/pxa_dma.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
index 8ab4a53e5660..77c1c44009d8 100644
--- a/drivers/dma/pxa_dma.c
+++ b/drivers/dma/pxa_dma.c
@@ -586,6 +586,8 @@ static void set_updater_desc(struct pxad_desc_sw *sw_desc,
 		(PXA_DCMD_LENGTH & sizeof(u32));
 	if (flags & DMA_PREP_INTERRUPT)
 		updater->dcmd |= PXA_DCMD_ENDIRQEN;
+	if (sw_desc->cyclic)
+		sw_desc->hw_desc[sw_desc->nb_desc - 2]->ddadr = sw_desc->first;
 }
 
 static bool is_desc_completed(struct virt_dma_desc *vd)
@@ -676,6 +678,10 @@ static irqreturn_t pxad_chan_handler(int irq, void *dev_id)
 		dev_dbg(&chan->vc.chan.dev->device,
 			"%s(): checking txd %p[%x]: completed=%d\n",
 			__func__, vd, vd->tx.cookie, is_desc_completed(vd));
+		if (to_pxad_sw_desc(vd)->cyclic) {
+			vchan_cyclic_callback(vd);
+			break;
+		}
 		if (is_desc_completed(vd)) {
 			list_del(&vd->node);
 			vchan_cookie_complete(vd);
@@ -1084,7 +1090,7 @@ pxad_prep_dma_cyclic(struct dma_chan *dchan,
 		return NULL;
 
 	pxad_get_config(chan, dir, &dcmd, &dsadr, &dtadr);
-	dcmd |= PXA_DCMD_ENDIRQEN | (PXA_DCMD_LENGTH | period_len);
+	dcmd |= PXA_DCMD_ENDIRQEN | (PXA_DCMD_LENGTH & period_len);
 	dev_dbg(&chan->vc.chan.dev->device,
 		"%s(): buf_addr=0x%lx len=%zu period=%zu dir=%d flags=%lx\n",
 		__func__, (unsigned long)buf_addr, len, period_len, dir, flags);
-- 
2.1.4

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

* [PATCH v2] dmaengine: pxa_dma: fix cyclic transfers
  2016-02-16 21:54 [PATCH v2] dmaengine: pxa_dma: fix cyclic transfers Robert Jarzmik
@ 2016-02-26 22:22 ` Robert Jarzmik
  2016-03-03 15:37 ` Vinod Koul
  1 sibling, 0 replies; 4+ messages in thread
From: Robert Jarzmik @ 2016-02-26 22:22 UTC (permalink / raw)
  To: linux-arm-kernel

Robert Jarzmik <robert.jarzmik@free.fr> writes:

> While testing audio with pxa2xx-ac97, underrun were happening while the
> user application was correctly feeding the music. Debug proved that the
> cyclic transfer is not cyclic, ie. the last descriptor did not loop on
> the first.
>
> Another issue is that the descriptor length was always set to 8192,
> because of an trivial operator issue.
>
> This was tested on a pxa27x platform.
>
> Fixes: a57e16cf0333 ("dmaengine: pxa: add pxa dmaengine driver")
> Reported-by: Vasily Khoruzhick <anarsoul@gmail.com>
> Tested-by: Vasily Khoruzhick <anarsoul@gmail.com>
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
> ---
> Since v1: add the mask fix suggested by Vasily
Hi Vinod,

Could you consider this patch, it's a fix and I'd like to have it reviewed.

Cheers.

--
Robert

[1] The patch on cyclic transfers
> ---
>  drivers/dma/pxa_dma.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
> index 8ab4a53e5660..77c1c44009d8 100644
> --- a/drivers/dma/pxa_dma.c
> +++ b/drivers/dma/pxa_dma.c
> @@ -586,6 +586,8 @@ static void set_updater_desc(struct pxad_desc_sw *sw_desc,
>  		(PXA_DCMD_LENGTH & sizeof(u32));
>  	if (flags & DMA_PREP_INTERRUPT)
>  		updater->dcmd |= PXA_DCMD_ENDIRQEN;
> +	if (sw_desc->cyclic)
> +		sw_desc->hw_desc[sw_desc->nb_desc - 2]->ddadr = sw_desc->first;
>  }
>  
>  static bool is_desc_completed(struct virt_dma_desc *vd)
> @@ -676,6 +678,10 @@ static irqreturn_t pxad_chan_handler(int irq, void *dev_id)
>  		dev_dbg(&chan->vc.chan.dev->device,
>  			"%s(): checking txd %p[%x]: completed=%d\n",
>  			__func__, vd, vd->tx.cookie, is_desc_completed(vd));
> +		if (to_pxad_sw_desc(vd)->cyclic) {
> +			vchan_cyclic_callback(vd);
> +			break;
> +		}
>  		if (is_desc_completed(vd)) {
>  			list_del(&vd->node);
>  			vchan_cookie_complete(vd);
> @@ -1084,7 +1090,7 @@ pxad_prep_dma_cyclic(struct dma_chan *dchan,
>  		return NULL;
>  
>  	pxad_get_config(chan, dir, &dcmd, &dsadr, &dtadr);
> -	dcmd |= PXA_DCMD_ENDIRQEN | (PXA_DCMD_LENGTH | period_len);
> +	dcmd |= PXA_DCMD_ENDIRQEN | (PXA_DCMD_LENGTH & period_len);
>  	dev_dbg(&chan->vc.chan.dev->device,
>  		"%s(): buf_addr=0x%lx len=%zu period=%zu dir=%d flags=%lx\n",
>  		__func__, (unsigned long)buf_addr, len, period_len, dir, flags);

-- 
Robert

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

* [PATCH v2] dmaengine: pxa_dma: fix cyclic transfers
  2016-02-16 21:54 [PATCH v2] dmaengine: pxa_dma: fix cyclic transfers Robert Jarzmik
  2016-02-26 22:22 ` Robert Jarzmik
@ 2016-03-03 15:37 ` Vinod Koul
  2016-03-03 17:19   ` Robert Jarzmik
  1 sibling, 1 reply; 4+ messages in thread
From: Vinod Koul @ 2016-03-03 15:37 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Feb 16, 2016 at 10:54:02PM +0100, Robert Jarzmik wrote:
> While testing audio with pxa2xx-ac97, underrun were happening while the
> user application was correctly feeding the music. Debug proved that the
> cyclic transfer is not cyclic, ie. the last descriptor did not loop on
> the first.
> 
> Another issue is that the descriptor length was always set to 8192,
> because of an trivial operator issue.
> 
> This was tested on a pxa27x platform.

Applied, thanks

-- 
~Vinod

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

* [PATCH v2] dmaengine: pxa_dma: fix cyclic transfers
  2016-03-03 15:37 ` Vinod Koul
@ 2016-03-03 17:19   ` Robert Jarzmik
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Jarzmik @ 2016-03-03 17:19 UTC (permalink / raw)
  To: linux-arm-kernel

Vinod Koul <vinod.koul@intel.com> writes:

> On Tue, Feb 16, 2016 at 10:54:02PM +0100, Robert Jarzmik wrote:
>> While testing audio with pxa2xx-ac97, underrun were happening while the
>> user application was correctly feeding the music. Debug proved that the
>> cyclic transfer is not cyclic, ie. the last descriptor did not loop on
>> the first.
>> 
>> Another issue is that the descriptor length was always set to 8192,
>> because of an trivial operator issue.
>> 
>> This was tested on a pxa27x platform.
>
> Applied, thanks
Thanks Vinod !

Cheers.

-- 
Robert

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

end of thread, other threads:[~2016-03-03 17:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-16 21:54 [PATCH v2] dmaengine: pxa_dma: fix cyclic transfers Robert Jarzmik
2016-02-26 22:22 ` Robert Jarzmik
2016-03-03 15:37 ` Vinod Koul
2016-03-03 17:19   ` Robert Jarzmik

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