Re: [RFC PATCH] ASoC: fsl_asrc_dma: Fix warning "Cannot create DMA dma:tx symlink"

2020-06-09 Thread Mark Brown
On Mon, Jun 08, 2020 at 03:07:00PM +0800, Shengjiu Wang wrote:
> The issue log is:
> 
> [   48.021506] CPU: 0 PID: 664 Comm: aplay Not tainted 
> 5.7.0-rc1-13120-g12b434cbbea0 #343
> [   48.031063] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
> [   48.037638] [] (unwind_backtrace) from [] 
> (show_stack+0x10/0x14)
> [   48.045413] [] (show_stack) from [] 
> (dump_stack+0xe4/0x118)

Please think hard before including complete backtraces in upstream
reports, they are very large and contain almost no useful information
relative to their size so often obscure the relevant content in your
message. If part of the backtrace is usefully illustrative (it often is
for search engines if nothing else) then it's usually better to pull out
the relevant sections.

> ---
>  include/sound/dmaengine_pcm.h | 11 ++
>  include/sound/soc.h   |  2 ++
>  sound/soc/fsl/fsl_asrc_common.h   |  2 ++
>  sound/soc/fsl/fsl_asrc_dma.c  | 49 +--
>  sound/soc/soc-core.c  |  3 +-
>  sound/soc/soc-generic-dmaengine-pcm.c | 12 ---
>  6 files changed, 55 insertions(+), 24 deletions(-)

Please split the core changes you are adding from the driver changes
that use them.

The change does look reasonable for the issue, it's not ideal but I'm
not sure it's avoidable with DPCM.


signature.asc
Description: PGP signature


[RFC PATCH] ASoC: fsl_asrc_dma: Fix warning "Cannot create DMA dma:tx symlink"

2020-06-08 Thread Shengjiu Wang
The issue log is:

[   48.021506] CPU: 0 PID: 664 Comm: aplay Not tainted 
5.7.0-rc1-13120-g12b434cbbea0 #343
[   48.031063] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[   48.037638] [] (unwind_backtrace) from [] 
(show_stack+0x10/0x14)
[   48.045413] [] (show_stack) from [] 
(dump_stack+0xe4/0x118)
[   48.052757] [] (dump_stack) from [] 
(sysfs_warn_dup+0x50/0x64)
[   48.060357] [] (sysfs_warn_dup) from [] 
(sysfs_do_create_link_sd+0xc8/0xd4)
[   48.069086] [] (sysfs_do_create_link_sd) from [] 
(dma_request_chan+0xb0/0x210)
[   48.078068] [] (dma_request_chan) from [] 
(dma_request_slave_channel+0x8/0x14)
[   48.087060] [] (dma_request_slave_channel) from [] 
(fsl_asrc_dma_hw_params+0x1dc/0x434)
[   48.096831] [] (fsl_asrc_dma_hw_params) from [] 
(soc_pcm_hw_params+0x4b0/0x650)
[   48.105903] [] (soc_pcm_hw_params) from [] 
(dpcm_fe_dai_hw_params+0x70/0xe4)
[   48.114715] [] (dpcm_fe_dai_hw_params) from [] 
(snd_pcm_hw_params+0x158/0x418)
[   48.123701] [] (snd_pcm_hw_params) from [] 
(snd_pcm_ioctl+0x734/0x183c)
[   48.132079] [] (snd_pcm_ioctl) from [] 
(ksys_ioctl+0x2ac/0xb98)
[   48.139765] [] (ksys_ioctl) from [] 
(ret_fast_syscall+0x0/0x28)
[   48.147440] Exception stack(0xed3c5fa8 to 0xed3c5ff0)
[   48.152515] 5fa0:   bec28670 00e92870 0004 c25c4111 
bec28670 0002000f
[   48.160716] 5fc0: bec28670 00e92870 00e92820 0036 bb80  
0002c2f8 0003
[   48.168913] 5fe0: b6f4d3fc bec2853c b6ee7655 b6e22cf8
[   48.174236] fsl-esai-dai 2024000.esai: Cannot create DMA dma:tx symlink

The dma channel is already requested by Back-End cpu dai driver,
if fsl_asrc_dma requests dma chan with same dma:tx symlink, then
this warning comes out.

The warning is added by
commit 71723a96b8b1 ("dmaengine: Create symlinks between DMA channels and 
slaves")
commit bad83565eafe ("dmaengine: Cleanups for the slave <-> channel symlink 
support")

As the dma channel is requested by Back-End, we need to reuse the channel
and avoid to request a new one, then the issue can be fixed.

In order to get the dma channel which is already requested in Back-End.
we export two functions (snd_soc_lookup_component_nolocked and
soc_component_to_pcm), if we can get the dma channel, then reuse it.
if can't, then request a new one.

Signed-off-by: Shengjiu Wang 
---
 include/sound/dmaengine_pcm.h | 11 ++
 include/sound/soc.h   |  2 ++
 sound/soc/fsl/fsl_asrc_common.h   |  2 ++
 sound/soc/fsl/fsl_asrc_dma.c  | 49 +--
 sound/soc/soc-core.c  |  3 +-
 sound/soc/soc-generic-dmaengine-pcm.c | 12 ---
 6 files changed, 55 insertions(+), 24 deletions(-)

diff --git a/include/sound/dmaengine_pcm.h b/include/sound/dmaengine_pcm.h
index b65220685920..8c5e38180fb0 100644
--- a/include/sound/dmaengine_pcm.h
+++ b/include/sound/dmaengine_pcm.h
@@ -161,4 +161,15 @@ int snd_dmaengine_pcm_prepare_slave_config(struct 
snd_pcm_substream *substream,
 
 #define SND_DMAENGINE_PCM_DRV_NAME "snd_dmaengine_pcm"
 
+struct dmaengine_pcm {
+   struct dma_chan *chan[SNDRV_PCM_STREAM_LAST + 1];
+   const struct snd_dmaengine_pcm_config *config;
+   struct snd_soc_component component;
+   unsigned int flags;
+};
+
+static inline struct dmaengine_pcm *soc_component_to_pcm(struct 
snd_soc_component *p)
+{
+   return container_of(p, struct dmaengine_pcm, component);
+}
 #endif
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 74868436ac79..565612a8d690 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -444,6 +444,8 @@ int devm_snd_soc_register_component(struct device *dev,
 const struct snd_soc_component_driver 
*component_driver,
 struct snd_soc_dai_driver *dai_drv, int num_dai);
 void snd_soc_unregister_component(struct device *dev);
+struct snd_soc_component *snd_soc_lookup_component_nolocked(struct device *dev,
+   const char 
*driver_name);
 struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
   const char *driver_name);
 
diff --git a/sound/soc/fsl/fsl_asrc_common.h b/sound/soc/fsl/fsl_asrc_common.h
index 77665b15c8db..09512bc79b80 100644
--- a/sound/soc/fsl/fsl_asrc_common.h
+++ b/sound/soc/fsl/fsl_asrc_common.h
@@ -32,6 +32,7 @@ enum asrc_pair_index {
  * @dma_chan: inputer and output DMA channels
  * @dma_data: private dma data
  * @pos: hardware pointer position
+ * @req_dma_chan_dev_to_dev: flag for release dev_to_dev chan
  * @private: pair private area
  */
 struct fsl_asrc_pair {
@@ -45,6 +46,7 @@ struct fsl_asrc_pair {
struct dma_chan *dma_chan[2];
struct imx_dma_data dma_data;
unsigned int pos;
+   bool req_dma_chan_dev_to_dev;
 
void *private;
 };
diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c
index d6a3fc5f87e5..3ad862225326 100644
---