From mboxrd@z Thu Jan 1 00:00:00 1970 From: Laurent Pinchart Subject: Re: [PATCH/RFC 0/5] R-Car Gen2 DMAC hardware descriptor list support Date: Wed, 23 Jul 2014 12:28:47 +0200 Message-ID: <3361994.F0HgAeJkR9@avalon> References: <1406032431-3807-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> <87d2cwvmxa.wl%kuninori.morimoto.gx@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Return-path: In-Reply-To: <87d2cwvmxa.wl%kuninori.morimoto.gx@gmail.com> Sender: linux-sh-owner@vger.kernel.org To: Kuninori Morimoto Cc: dmaengine@vger.kernel.org, linux-sh@vger.kernel.org, Magnus Damm , Linux-ALSA List-Id: alsa-devel@alsa-project.org Hi Morimoto-san, On Tuesday 22 July 2014 19:17:23 Kuninori Morimoto wrote: > Hi Laurent > > > The code has been tested by artificially lowering the maximum chunk size > > to 4096 bytes and running dmatest, which completed sucessfully. Morimoto- > > san, is there an easy way to test cyclic transfers with your audio driver > > ? > > Thank you for your offer. > I tested this patchset with audio DMAC (= cyclic transfer) > but, it doesn't work for me. > > First of all, this sound driver which is using cyclic transfer > was worked well in shdma-base driver. > I had sent audio DMA support plafrom side patches before. > But, of course I'm happy to update sound driver side. > > I will re-send my audio DMAC support patches after this email. > > My troubles are... [snip] > 2. cyclic transfer doesn't work > > I got attached error. [snip] I can reproduce that, but I have this error coming up before. [ 16.207027] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:103 [ 16.215795] in_atomic(): 1, irqs_disabled(): 128, pid: 1319, name: aplay [ 16.222636] CPU: 0 PID: 1319 Comm: aplay Not tainted 3.16.0-rc5-02821-g12a72a3 #2501 [ 16.230536] Backtrace: [ 16.233056] [] (dump_backtrace) from [] (show_stack+0x18/0x1c) [ 16.240778] r6:ffffffff r5:c04aa7c0 r4:00000000 r3:00000000 [ 16.246593] [] (show_stack) from [] (dump_stack+0x8c/0xc0) [ 16.253967] [] (dump_stack) from [] (__might_sleep+0xcc/0x108) [ 16.261689] r4:e8dd2000 r3:00000093 [ 16.265357] [] (__might_sleep) from [] (mutex_lock+0x20/0x70) [ 16.272990] r5:00000000 r4:e900fe00 [ 16.276657] [] (mutex_lock) from [] (regmap_lock_mutex+0x10/0x14) [ 16.284644] r4:e900fe00 r3:00000000 [ 16.288309] [] (regmap_lock_mutex) from [] (regmap_update_bits+0x2c/0x64) [ 16.297009] [] (regmap_update_bits) from [] (regmap_fields_write+0x38/0x44) [ 16.305883] r7:e8d9d990 r6:00000004 r5:00000040 r4:f0368200 [ 16.311701] [] (regmap_fields_write) from [] (rsnd_write+0x30/0x4c [snd_soc_rcar]) [ 16.321195] r5:e93a4c00 r4:e8d1f898 [ 16.324866] [] (rsnd_write [snd_soc_rcar]) from [] (rsnd_src_set_convert_rate.isra.6+0xf8/0x144 [snd_soc_rcar]) [ 16.336940] [] (rsnd_src_set_convert_rate.isra.6 [snd_soc_rcar]) from [] (rsnd_src_init_gen2+0x2c/0xc4 [snd_soc_rcar]) [ 16.349624] r6:00000004 r5:e8d9d810 r4:e8d1f898 r3:bf0ec8d0 [ 16.355438] [] (rsnd_src_init_gen2 [snd_soc_rcar]) from [] (rsnd_soc_dai_trigger+0x1cc/0x22c [snd_soc_rcar]) [ 16.367236] r5:e8d9d810 r4:e8d9d824 [ 16.370916] [] (rsnd_soc_dai_trigger [snd_soc_rcar]) from [] (soc_pcm_trigger+0xa8/0xf8 [snd_soc_core]) [ 16.382271] r10:00002000 r9:00002000 r8:e9290d00 r7:e8d9d700 r6:00000001 r5:e99fb500 [ 16.390301] r4:e8ef3810 [ 16.392910] [] (soc_pcm_trigger [snd_soc_core]) from [] (snd_pcm_do_start+0x34/0x38 [snd_pcm]) [ 16.403467] r8:bf09e050 r7:00000000 r6:00000003 r5:e99fb500 r4:bf09e050 r3:bf0c5144 [ 16.411421] [] (snd_pcm_do_start [snd_pcm]) from [] (snd_pcm_action_single+0x40/0x80 [snd_pcm]) [ 16.422079] [] (snd_pcm_action_single [snd_pcm]) from [] (snd_pcm_action+0xcc/0xd0 [snd_pcm]) [ 16.432547] r7:00000003 r6:e99fb5c8 r5:bf09e4c0 r4:e99fb500 [ 16.438366] [] (snd_pcm_action [snd_pcm]) from [] (snd_pcm_start+0x1c/0x24 [snd_pcm]) [ 16.448125] r8:00000000 r7:e8dd2000 r6:e93a4c00 r5:bf09e4c0 r4:e99fb500 r3:00002000 [ 16.456083] [] (snd_pcm_start [snd_pcm]) from [] (snd_pcm_lib_write1+0x40c/0x4f0 [snd_pcm]) [ 16.466391] [] (snd_pcm_lib_write1 [snd_pcm]) from [] (snd_pcm_lib_write+0x64/0x78 [snd_pcm]) [ 16.476860] r10:be91ea4c r9:e8dd2000 r8:e8d66488 r7:00000000 r6:0002c780 r5:00000800 [ 16.484889] r4:e99fb500 [ 16.487494] [] (snd_pcm_lib_write [snd_pcm]) from [] (snd_pcm_playback_ioctl1+0x134/0x4c8 [snd_pcm]) [ 16.498583] r6:00000000 r5:be91ea4c r4:e99fb500 [ 16.503330] [] (snd_pcm_playback_ioctl1 [snd_pcm]) from [] (snd_pcm_playback_ioctl+0x30/0x3c [snd_pcm]) [ 16.514685] r8:e8d66488 r7:be91ea4c r6:00000004 r5:e93d3880 r4:e93d3880 [ 16.521575] [] (snd_pcm_playback_ioctl [snd_pcm]) from [] (do_vfs_ioctl+0x80/0x5c8) [ 16.531163] [] (do_vfs_ioctl) from [] (SyS_ioctl+0x3c/0x60) [ 16.538618] r10:00000000 r9:e8dd2000 r8:00000004 r7:be91ea4c r6:400c4150 r5:e93d3880 [ 16.546648] r4:e93d3880 [ 16.549243] [] (SyS_ioctl) from [] (ret_fast_syscall+0x0/0x30) [ 16.556964] r8:c000fa24 r7:00000036 r6:00000000 r5:0002c498 r4:0002c448 r3:be91ea4c The rsnd_soc_dai_trigger() function takes a spinlock, making the context atomic, which regmap doesn't like as it locks a mutex. It might be possible to fix this by setting the fast_io field in both the regmap_config and regmap_bus structures in sound/soc/sh/rcar/gen.c. regmap will then use a spinlock instead of a mutex. However, even if I believe that change makes sense and should be done, another atomic context issue will come from the rcar-dmac driver which allocates memory in the prep_dma_cyclic function, called by rsnd_dma_start() from rsnd_soc_dai_trigger() with the spinlock help. What context is the rsnd_soc_dai_trigger() function called in by the alsa core ? If it's guaranteed to be a sleepable context, would it make sense to replace the rsnd_priv spinlock with a mutex ? -- Regards, Laurent Pinchart From mboxrd@z Thu Jan 1 00:00:00 1970 From: Laurent Pinchart Date: Wed, 23 Jul 2014 10:28:47 +0000 Subject: Re: [PATCH/RFC 0/5] R-Car Gen2 DMAC hardware descriptor list support Message-Id: <3361994.F0HgAeJkR9@avalon> List-Id: References: <1406032431-3807-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> <87d2cwvmxa.wl%kuninori.morimoto.gx@gmail.com> In-Reply-To: <87d2cwvmxa.wl%kuninori.morimoto.gx@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Kuninori Morimoto Cc: dmaengine@vger.kernel.org, linux-sh@vger.kernel.org, Magnus Damm , Linux-ALSA Hi Morimoto-san, On Tuesday 22 July 2014 19:17:23 Kuninori Morimoto wrote: > Hi Laurent > > > The code has been tested by artificially lowering the maximum chunk size > > to 4096 bytes and running dmatest, which completed sucessfully. Morimoto- > > san, is there an easy way to test cyclic transfers with your audio driver > > ? > > Thank you for your offer. > I tested this patchset with audio DMAC (= cyclic transfer) > but, it doesn't work for me. > > First of all, this sound driver which is using cyclic transfer > was worked well in shdma-base driver. > I had sent audio DMA support plafrom side patches before. > But, of course I'm happy to update sound driver side. > > I will re-send my audio DMAC support patches after this email. > > My troubles are... [snip] > 2. cyclic transfer doesn't work > > I got attached error. [snip] I can reproduce that, but I have this error coming up before. [ 16.207027] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:103 [ 16.215795] in_atomic(): 1, irqs_disabled(): 128, pid: 1319, name: aplay [ 16.222636] CPU: 0 PID: 1319 Comm: aplay Not tainted 3.16.0-rc5-02821-g12a72a3 #2501 [ 16.230536] Backtrace: [ 16.233056] [] (dump_backtrace) from [] (show_stack+0x18/0x1c) [ 16.240778] r6:ffffffff r5:c04aa7c0 r4:00000000 r3:00000000 [ 16.246593] [] (show_stack) from [] (dump_stack+0x8c/0xc0) [ 16.253967] [] (dump_stack) from [] (__might_sleep+0xcc/0x108) [ 16.261689] r4:e8dd2000 r3:00000093 [ 16.265357] [] (__might_sleep) from [] (mutex_lock+0x20/0x70) [ 16.272990] r5:00000000 r4:e900fe00 [ 16.276657] [] (mutex_lock) from [] (regmap_lock_mutex+0x10/0x14) [ 16.284644] r4:e900fe00 r3:00000000 [ 16.288309] [] (regmap_lock_mutex) from [] (regmap_update_bits+0x2c/0x64) [ 16.297009] [] (regmap_update_bits) from [] (regmap_fields_write+0x38/0x44) [ 16.305883] r7:e8d9d990 r6:00000004 r5:00000040 r4:f0368200 [ 16.311701] [] (regmap_fields_write) from [] (rsnd_write+0x30/0x4c [snd_soc_rcar]) [ 16.321195] r5:e93a4c00 r4:e8d1f898 [ 16.324866] [] (rsnd_write [snd_soc_rcar]) from [] (rsnd_src_set_convert_rate.isra.6+0xf8/0x144 [snd_soc_rcar]) [ 16.336940] [] (rsnd_src_set_convert_rate.isra.6 [snd_soc_rcar]) from [] (rsnd_src_init_gen2+0x2c/0xc4 [snd_soc_rcar]) [ 16.349624] r6:00000004 r5:e8d9d810 r4:e8d1f898 r3:bf0ec8d0 [ 16.355438] [] (rsnd_src_init_gen2 [snd_soc_rcar]) from [] (rsnd_soc_dai_trigger+0x1cc/0x22c [snd_soc_rcar]) [ 16.367236] r5:e8d9d810 r4:e8d9d824 [ 16.370916] [] (rsnd_soc_dai_trigger [snd_soc_rcar]) from [] (soc_pcm_trigger+0xa8/0xf8 [snd_soc_core]) [ 16.382271] r10:00002000 r9:00002000 r8:e9290d00 r7:e8d9d700 r6:00000001 r5:e99fb500 [ 16.390301] r4:e8ef3810 [ 16.392910] [] (soc_pcm_trigger [snd_soc_core]) from [] (snd_pcm_do_start+0x34/0x38 [snd_pcm]) [ 16.403467] r8:bf09e050 r7:00000000 r6:00000003 r5:e99fb500 r4:bf09e050 r3:bf0c5144 [ 16.411421] [] (snd_pcm_do_start [snd_pcm]) from [] (snd_pcm_action_single+0x40/0x80 [snd_pcm]) [ 16.422079] [] (snd_pcm_action_single [snd_pcm]) from [] (snd_pcm_action+0xcc/0xd0 [snd_pcm]) [ 16.432547] r7:00000003 r6:e99fb5c8 r5:bf09e4c0 r4:e99fb500 [ 16.438366] [] (snd_pcm_action [snd_pcm]) from [] (snd_pcm_start+0x1c/0x24 [snd_pcm]) [ 16.448125] r8:00000000 r7:e8dd2000 r6:e93a4c00 r5:bf09e4c0 r4:e99fb500 r3:00002000 [ 16.456083] [] (snd_pcm_start [snd_pcm]) from [] (snd_pcm_lib_write1+0x40c/0x4f0 [snd_pcm]) [ 16.466391] [] (snd_pcm_lib_write1 [snd_pcm]) from [] (snd_pcm_lib_write+0x64/0x78 [snd_pcm]) [ 16.476860] r10:be91ea4c r9:e8dd2000 r8:e8d66488 r7:00000000 r6:0002c780 r5:00000800 [ 16.484889] r4:e99fb500 [ 16.487494] [] (snd_pcm_lib_write [snd_pcm]) from [] (snd_pcm_playback_ioctl1+0x134/0x4c8 [snd_pcm]) [ 16.498583] r6:00000000 r5:be91ea4c r4:e99fb500 [ 16.503330] [] (snd_pcm_playback_ioctl1 [snd_pcm]) from [] (snd_pcm_playback_ioctl+0x30/0x3c [snd_pcm]) [ 16.514685] r8:e8d66488 r7:be91ea4c r6:00000004 r5:e93d3880 r4:e93d3880 [ 16.521575] [] (snd_pcm_playback_ioctl [snd_pcm]) from [] (do_vfs_ioctl+0x80/0x5c8) [ 16.531163] [] (do_vfs_ioctl) from [] (SyS_ioctl+0x3c/0x60) [ 16.538618] r10:00000000 r9:e8dd2000 r8:00000004 r7:be91ea4c r6:400c4150 r5:e93d3880 [ 16.546648] r4:e93d3880 [ 16.549243] [] (SyS_ioctl) from [] (ret_fast_syscall+0x0/0x30) [ 16.556964] r8:c000fa24 r7:00000036 r6:00000000 r5:0002c498 r4:0002c448 r3:be91ea4c The rsnd_soc_dai_trigger() function takes a spinlock, making the context atomic, which regmap doesn't like as it locks a mutex. It might be possible to fix this by setting the fast_io field in both the regmap_config and regmap_bus structures in sound/soc/sh/rcar/gen.c. regmap will then use a spinlock instead of a mutex. However, even if I believe that change makes sense and should be done, another atomic context issue will come from the rcar-dmac driver which allocates memory in the prep_dma_cyclic function, called by rsnd_dma_start() from rsnd_soc_dai_trigger() with the spinlock help. What context is the rsnd_soc_dai_trigger() function called in by the alsa core ? If it's guaranteed to be a sleepable context, would it make sense to replace the rsnd_priv spinlock with a mutex ? -- Regards, Laurent Pinchart