From: Shengjiu Wang <hidden> Date: 2020-06-12 07:48:52
Reuse the dma channel if available in Back-End
Shengjiu Wang (4):
ASoC: soc-card: export snd_soc_lookup_component_nolocked
ASoC: dmaengine_pcm: export soc_component_to_pcm
ASoC: fsl_asrc_dma: Reuse the dma channel if available in Back-End
ASoC: fsl_asrc_dma: Fix data copying speed issue with EDMA
changes in v3:
- update according to Nicolin's comments
- split previous 0003 patch to two patches
changes in v2:
- update according to Mark's comments and split the patch
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 | 47 +++++++++++++++++++--------
sound/soc/soc-core.c | 3 +-
sound/soc/soc-generic-dmaengine-pcm.c | 12 -------
6 files changed, 50 insertions(+), 27 deletions(-)
--
2.21.0
From: Shengjiu Wang <hidden> Date: 2020-06-12 07:48:58
snd_soc_lookup_component_nolocked can be used for the DPCM case
that Front-End needs to get the unused platform component but
added by Back-End cpu dai driver.
If the component is gotten, then we can get the dma chan created
by Back-End component and reused it in Front-End.
Signed-off-by: Shengjiu Wang <redacted>
---
include/sound/soc.h | 2 ++
sound/soc/soc-core.c | 3 ++-
2 files changed, 4 insertions(+), 1 deletion(-)
From: Shengjiu Wang <hidden> Date: 2020-06-12 07:48:59
In DPCM case, Front-End needs to get the dma chan which has
been requested by Back-End and reuse it.
Signed-off-by: Shengjiu Wang <redacted>
---
include/sound/dmaengine_pcm.h | 11 +++++++++++
sound/soc/soc-generic-dmaengine-pcm.c | 12 ------------
2 files changed, 11 insertions(+), 12 deletions(-)
From: Shengjiu Wang <hidden> Date: 2020-06-12 07:49:01
With EDMA, there is two dma channels can be used for dev_to_dev,
one is from ASRC, one is from another peripheral (ESAI or SAI).
If we select the dma channel of ASRC, there is an issue for ideal
ratio case, the speed of copy data is faster than sample
frequency, because ASRC output data is very fast in ideal ratio
mode.
So it is reasonable to use the dma channel of Back-End peripheral.
then copying speed of DMA is controlled by data consumption
speed in the peripheral FIFO,
Signed-off-by: Shengjiu Wang <redacted>
---
sound/soc/fsl/fsl_asrc_common.h | 2 ++
sound/soc/fsl/fsl_asrc_dma.c | 26 +++++++++++++++-----------
2 files changed, 17 insertions(+), 11 deletions(-)
@@ -233,11 +233,11 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,pair->dma_chan[dir]=dma_request_channel(mask,filter,&pair->dma_data);+pair->req_dma_chan=true;}else{-if(!be_chan)-dma_release_channel(tmp_chan);-pair->dma_chan[dir]=-asrc->get_dma_channel(pair,dir);+pair->dma_chan[dir]=tmp_chan;+/* Do not flag to release if we are reusing the Back-End one */+pair->req_dma_chan=!be_chan;}if(!pair->dma_chan[dir]){
@@ -276,7 +276,8 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,ret=dmaengine_slave_config(pair->dma_chan[dir],&config_be);if(ret){dev_err(dev,"failed to config DMA channel for Back-End\n");-dma_release_channel(pair->dma_chan[dir]);+if(pair->req_dma_chan)+dma_release_channel(pair->dma_chan[dir]);returnret;}
@@ -288,19 +289,22 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,staticintfsl_asrc_dma_hw_free(structsnd_soc_component*component,structsnd_pcm_substream*substream){+booltx=substream->stream==SNDRV_PCM_STREAM_PLAYBACK;structsnd_pcm_runtime*runtime=substream->runtime;structfsl_asrc_pair*pair=runtime->private_data;+u8dir=tx?OUT:IN;snd_pcm_set_runtime_buffer(substream,NULL);-if(pair->dma_chan[IN])-dma_release_channel(pair->dma_chan[IN]);+if(pair->dma_chan[!dir])+dma_release_channel(pair->dma_chan[!dir]);-if(pair->dma_chan[OUT])-dma_release_channel(pair->dma_chan[OUT]);+/* release dev_to_dev chan if we aren't reusing the Back-End one */+if(pair->dma_chan[dir]&&pair->req_dma_chan)+dma_release_channel(pair->dma_chan[dir]);-pair->dma_chan[IN]=NULL;-pair->dma_chan[OUT]=NULL;+pair->dma_chan[!dir]=NULL;+pair->dma_chan[dir]=NULL;return0;}
From: Shengjiu Wang <hidden> Date: 2020-06-12 07:49:12
The dma channel has been requested by Back-End cpu dai driver already.
If fsl_asrc_dma requests dma chan with same dma:tx symlink, then
there will be below warning with SDMA.
[ 48.174236] fsl-esai-dai 2024000.esai: Cannot create DMA dma:tx symlink
So if we can reuse the dma channel of Back-End, then the issue can be
fixed.
In order to get the dma channel which is already requested in Back-End.
we use the exported 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 <redacted>
---
sound/soc/fsl/fsl_asrc_dma.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
@@ -135,6 +135,8 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,structsnd_dmaengine_dai_dma_data*dma_params_be=NULL;structsnd_pcm_runtime*runtime=substream->runtime;structfsl_asrc_pair*pair=runtime->private_data;+structdma_chan*tmp_chan=NULL,*be_chan=NULL;+structsnd_soc_component*component_be=NULL;structfsl_asrc*asrc=pair->asrc;structdma_slave_configconfig_fe,config_be;enumasrc_pair_indexindex=pair->index;
@@ -142,7 +144,6 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,intstream=substream->stream;structimx_dma_data*tmp_data;structsnd_soc_dpcm*dpcm;-structdma_chan*tmp_chan;structdevice*dev_be;u8dir=tx?OUT:IN;dma_cap_mask_tmask;
@@ -197,18 +198,30 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,dma_cap_set(DMA_SLAVE,mask);dma_cap_set(DMA_CYCLIC,mask);+/*+*TheBack-EnddevicemighthavealreadyrequestedaDMAchannel,+*sotrytoreuseitfirst,andthenrequestanewoneuponNULL.+*/+component_be=snd_soc_lookup_component_nolocked(dev_be,SND_DMAENGINE_PCM_DRV_NAME);+if(component_be){+be_chan=soc_component_to_pcm(component_be)->chan[substream->stream];+tmp_chan=be_chan;+}+if(!tmp_chan)+tmp_chan=dma_request_slave_channel(dev_be,tx?"tx":"rx");+/**AnEDMADEV_TO_DEVchannelisfixedandboundwithDMAeventofeach*peripheral,unlikeSDMAchannelthatisallocateddynamically.Sono-*needtoconfiguredma_requestanddma_request2,butgetdma_chanvia-*dma_request_slave_channeldirectlywithdmanameofFront-Enddevice+*needtoconfiguredma_requestanddma_request2,butgetdma_chanof+*Back-Enddevicedirectlyviadma_request_slave_channel.*/if(!asrc->use_edma){/* Get DMA request of Back-End */-tmp_chan=dma_request_slave_channel(dev_be,tx?"tx":"rx");tmp_data=tmp_chan->private;pair->dma_data.dma_request=tmp_data->dma_request;-dma_release_channel(tmp_chan);+if(!be_chan)+dma_release_channel(tmp_chan);/* Get DMA request of Front-End */tmp_chan=asrc->get_dma_channel(pair,dir);
@@ -221,6 +234,8 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,pair->dma_chan[dir]=dma_request_channel(mask,filter,&pair->dma_data);}else{+if(!be_chan)+dma_release_channel(tmp_chan);pair->dma_chan[dir]=asrc->get_dma_channel(pair,dir);}
On Fri, Jun 12, 2020 at 03:37:48PM +0800, Shengjiu Wang wrote:
snd_soc_lookup_component_nolocked can be used for the DPCM case
that Front-End needs to get the unused platform component but
added by Back-End cpu dai driver.
If the component is gotten, then we can get the dma chan created
by Back-End component and reused it in Front-End.
Signed-off-by: Shengjiu Wang <redacted>
On Fri, Jun 12, 2020 at 03:37:50PM +0800, Shengjiu Wang wrote:
The dma channel has been requested by Back-End cpu dai driver already.
If fsl_asrc_dma requests dma chan with same dma:tx symlink, then
there will be below warning with SDMA.
[ 48.174236] fsl-esai-dai 2024000.esai: Cannot create DMA dma:tx symlink
So if we can reuse the dma channel of Back-End, then the issue can be
fixed.
In order to get the dma channel which is already requested in Back-End.
we use the exported 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 <redacted>
On Fri, Jun 12, 2020 at 03:37:51PM +0800, Shengjiu Wang wrote:
With EDMA, there is two dma channels can be used for dev_to_dev,
one is from ASRC, one is from another peripheral (ESAI or SAI).
If we select the dma channel of ASRC, there is an issue for ideal
ratio case, the speed of copy data is faster than sample
frequency, because ASRC output data is very fast in ideal ratio
mode.
So it is reasonable to use the dma channel of Back-End peripheral.
then copying speed of DMA is controlled by data consumption
speed in the peripheral FIFO,
Signed-off-by: Shengjiu Wang <redacted>
From: Mark Brown <broonie@kernel.org> Date: 2020-06-12 13:59:07
On Fri, 12 Jun 2020 15:37:47 +0800, Shengjiu Wang wrote:
Reuse the dma channel if available in Back-End
Shengjiu Wang (4):
ASoC: soc-card: export snd_soc_lookup_component_nolocked
ASoC: dmaengine_pcm: export soc_component_to_pcm
ASoC: fsl_asrc_dma: Reuse the dma channel if available in Back-End
ASoC: fsl_asrc_dma: Fix data copying speed issue with EDMA
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/4] ASoC: soc-card: export snd_soc_lookup_component_nolocked
commit: 6fbea6b6a838f9aa941fe53a3637fd8d8aab1eba
[2/4] ASoC: dmaengine_pcm: export soc_component_to_pcm
commit: a9a21e1eafc94b79502cab8272b392f7f63ef7bb
[3/4] ASoC: fsl_asrc_dma: Reuse the dma channel if available in Back-End
commit: 706e2c8811585f42612b6cff218ab3adbe63a4ee
[4/4] ASoC: fsl_asrc_dma: Fix data copying speed issue with EDMA
commit: b287a6d9723c601dd947f1c27d4cc0192e384a5a
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark