dmaengine: dw: resolve recursion lock when audio playback
Subsystems (2)
PATCH 1/1 dmaengine: dw: resolve recursion lock when audio playback
when audio playback is running, user space will call snd_pcm_lib_write1() function, it will first get pcm stream lock, after that it may call function snd_pcm_update_hw_ptr(), the call stack will be as below:
snd_pcm_lib_write1 <-- got pcm stream lock
--> snd_pcm_update_hw_ptr
--> dwc_tx_status
--> dwc_scan_descriptors
--> callback
--> dmaengine_pcm_dma_complete
--> snd_pcm_period_elapsed <-- get stream lock againrecursion lock occurs in snd_pcm_period_elapsed function. remove dwc_scan_descriptors from dwc_tx_status can fix this issue.
--- drivers/dma/dw/core.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/dma/dw/core.c +1 -5
@@ -1078,11 +1078,7 @@ dwc_tx_status(struct dma_chan *chan, ret =dma_cookie_status (chan, cookie, txstate);if (ret ==DMA_COMPLETE )return ret; - -dwc_scan_descriptors (to_dw_dma (chan->device), dwc); - - ret =dma_cookie_status (chan, cookie, txstate); -if (ret !=DMA_COMPLETE ) +else dma_set_residue (txstate,dwc_get_residue (dwc));if (dwc->paused && ret ==DMA_IN_PROGRESS )
Signature · 6 lines
1.7.12.4 Yitian Best Regards
Quoted 11 lines · yitian
when audio playback is running, user space will call
snd_pcm_lib_write1()function, it will first get pcm stream lock, after that it may call functionsnd_pcm_update_hw_ptr(), the call stack will be as below:
snd_pcm_lib_write1<-- got pcm stream lock
-->snd_pcm_update_hw_ptr--> dwc_tx_status --> dwc_scan_descriptors --> callback --> dmaengine_pcm_dma_complete --> snd_pcm_period_elapsed <-- get stream lock again
Quoted 7 lines
recursion lock occurs in
snd_pcm_period_elapsedfunction. removedwc_scan_descriptorsfromdwc_tx_statuscan fix this issue.Signed-off-by Yitian Bu <[email protected]>--- drivers/dma/dw/core.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
I am not sure if this is a sane way of doing that, and we were scanning the descriptors for some valid reason..
Though, I am on vacation for few days now and will be able to look at the details later.
Quoted 15 lines · Viresh Kumar
Quoted 14 lines · yitian
when audio playback is running, user space will call
snd_pcm_lib_write1()function, it will first get pcm stream lock, after that it may call functionsnd_pcm_update_hw_ptr(), the call stack will be as below:
snd_pcm_lib_write1<-- got pcm stream lock
-->snd_pcm_update_hw_ptr--> dwc_tx_status --> dwc_scan_descriptors --> callback --> dmaengine_pcm_dma_complete --> snd_pcm_period_elapsed <-- get stream lock againrecursion lock occurs in
snd_pcm_period_elapsedfunction. removedwc_scan_descriptorsfromdwc_tx_statuscan fix this issue.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Yitian Bu <[email protected]>--- drivers/dma/dw/core.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)I am not sure if this is a sane way of doing that, and we were scanning the descriptors for some valid reason..
Actually one of the patches in a pile sitting in my private repo is also including similar change. In my case the reason is to support cyclic transfers natively.
Quoted 2 lines
Though, I am on vacation for few days now and will be able to look at the details later.
Have a good rest then!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 10 lines
From: Andy Shevchenko [mailto:[email protected]]
Sent: Monday, September 28, 2015 3:06 PM
To: Viresh Kumar <[email protected]>
Cc: yitian <[email protected]>; Viresh Kumar <[email protected]>; Andy Shevchenko <[email protected]>; Vinod Koul <[email protected]>; Dan Williams <[email protected]>; dmaengine <[email protected]>; Linux Kernel Mailing List <[email protected]>
Subject: Re: [PATCH 1/1] dmaengine: dw: resolve recursion
Quoted 7 lines
Quoted 2 lines
I am not sure if this is a sane way of doing that, and we were scanning the descriptors for some valid reason..
Actually one of the patches in a pile sitting in my private repo is also including similar change. In my case the reason is to support cyclic transfers natively.
Yes, i am using DW DMAC to support cyclic transfer. Currently it is very easy to get recursion lock crash, but after this patch everything is fine on my device. I am waiting for your further guide.
Thanks.
Andy Shevchenko
reviewerQuoted 16 lines · yitian
Quoted 16 lines
From: Andy Shevchenko [mailto:[email protected]]
Sent: Monday, September 28, 2015 3:06 PM
To: Viresh Kumar <[email protected]>
Cc: yitian <[email protected]>; Viresh Kumar <[email protected]>; Andy Shevchenko <[email protected]>; Vinod Koul < [email protected]>;
Dan Williams <[email protected]>; dmaengine <[email protected]>; Linux Kernel Mailing List <[email protected]>
Subject: Re: [PATCH 1/1] dmaengine: dw: resolve recursionQuoted 3 lines
I am not sure if this is a sane way of doing that, and we were scanning
the descriptors for some valid reason..
Quoted 8 lines
Quoted 4 lines
Actually one of the patches in a pile sitting in my private repo is also including similar change. In my case the reason is to support cyclic transfers natively.
Yes, i am using DW DMAC to support cyclic transfer. Currently it is very easy to get recursion lock crash, but after this patch everything is fine on my device.
What is an actual hardware you are running kernel on?
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 33 lines
From: Andy Shevchenko [mailto:[email protected]]
Sent: Monday, September 28, 2015 4:46 PM
To: yitian <[email protected]>; 'Andy Shevchenko' <[email protected]>; 'Viresh Kumar' <[email protected]>
Cc: 'Viresh Kumar' <[email protected]>; 'Vinod Koul' <[email protected]>; 'Dan Williams' <[email protected]>; 'dmaengine' <[email protected]>; 'Linux Kernel Mailing List' <[email protected]>
Subject: Re: [PATCH 1/1] dmaengine: dw: resolve recursion lock when audio playbackQuoted 21 lines · yitian
Quoted 20 lines
From: Andy Shevchenko [mailto:[email protected]]
Sent: Monday, September 28, 2015 3:06 PM
To: Viresh Kumar <[email protected]>
Cc: yitian <[email protected]>; Viresh Kumar <[email protected]>; Andy Shevchenko <[email protected]>; Vinod Koul < [email protected]>;
Dan Williams <[email protected]>; dmaengine <[email protected]>; Linux Kernel Mailing List <[email protected]>
Subject: Re: [PATCH 1/1] dmaengine: dw: resolve recursionQuoted 3 lines
I am not sure if this is a sane way of doing that, and we were scanning
the descriptors for some valid reason..Actually one of the patches in a pile sitting in my private repo is also including similar change. In my case the reason is to support cyclic transfers natively.
Quoted 6 lines
Quoted 3 lines
Yes, i am using DW DMAC to support cyclic transfer. Currently it is very easy to get recursion lock crash, but after this patch everything is fine on my device.
What is an actual hardware you are running kernel on?
Hi Andy:
I am using a FPGA, with Cortex-A5 core, Designware I2S IP, Designware DMAC IP. What I was done is to run tinyplay and tinycap to test the playback and capture function on the FPGA. With my change, both of them are okay now. I didn't push the patch which added cyclic DMA support for dw DMAC because I didn't make it decent enough yet.