ASoC: fsl_asrc_dma: Reuse the dma channel if available in Back-End
Subsystems (4)
v2 cover ASoC: fsl_asrc_dma: Reuse the dma channel if available in Back-End
Reuse the dma channel if available in Back-End
Shengjiu Wang (3):
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
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 | 52 ++++++++++++++++++++------- sound/soc/soc-core.c | 3 +- sound/soc/soc-generic-dmaengine-pcm.c | 12 ------- 6 files changed, 57 insertions(+), 25 deletions(-)
Signature · 1 line
2.21.0
RFC PATCH v2 1/3 ASoC: soc-card: export snd_soc_lookup_component_nolocked
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.
--- include/sound/soc.h | 2 ++ sound/soc/soc-core.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-)
include/sound/soc.h +2 -0
@@ -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);
sound/soc/soc-core.c +2 -1
@@ -310,7 +310,7 @@ struct snd_soc_component *snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd, }EXPORT_SYMBOL_GPL (snd_soc_rtdcom_lookup); -static struct snd_soc_component +struct snd_soc_component *snd_soc_lookup_component_nolocked (struct device *dev,const char *driver_name) {struct snd_soc_component *component;
@@ -329,6 +329,7 @@ static struct snd_soc_componentreturn found_component; } +EXPORT_SYMBOL_GPL (snd_soc_lookup_component_nolocked);struct snd_soc_component *snd_soc_lookup_component (struct device *dev,const char *driver_name)
Signature · 1 line
2.21.0
RFC PATCH v2 2/3 ASoC: dmaengine_pcm: export soc_component_to_pcm
In reply to Shengjiu WangIn DPCM case, Front-End needs to get the dma chan which has been requested by Back-End and reuse it.
--- include/sound/dmaengine_pcm.h | 11 +++++++++++ sound/soc/soc-generic-dmaengine-pcm.c | 12 ------------ 2 files changed, 11 insertions(+), 12 deletions(-)
include/sound/dmaengine_pcm.h +11 -0
@@ -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
sound/soc/soc-generic-dmaengine-pcm.c +0 -12
@@ -21,18 +21,6 @@*/ #define SND_DMAENGINE_PCM_FLAG_NO_RESIDUE BIT(31) -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 struct dmaengine_pcm *soc_component_to_pcm (struct snd_soc_component *p) -{ - return container_of(p, struct dmaengine_pcm, component); -} -static struct device *dmaengine_dma_dev (struct dmaengine_pcm *pcm,struct snd_pcm_substream *substream) {
Signature · 1 line
2.21.0
RFC PATCH v2 3/3 ASoC: fsl_asrc_dma: Reuse the dma channel if available in Back-End
In reply to Shengjiu WangThe 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
or with EDMA the request operation will fail for EDMA channel can only be requested once.
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.
--- sound/soc/fsl/fsl_asrc_common.h | 2 ++ sound/soc/fsl/fsl_asrc_dma.c | 52 +++++++++++++++++++++++++-------- 2 files changed, 42 insertions(+), 12 deletions(-)
sound/soc/fsl/fsl_asrc_common.h +2 -0
@@ -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; };
sound/soc/fsl/fsl_asrc_dma.c +40 -12
110 lines not on this page · raw message
Signature · 1 line
2.21.0
Nicolin Chen
reviewerQuoted 28 lines · Shengjiu Wang
The dma channel has been requested by Back-End cpu dai driver already. If
fsl_asrc_dmarequests 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 symlinkor with EDMA the request operation will fail for EDMA channel can only be requested once.
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_nolockedandsoc_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 <[email protected]>--- sound/soc/fsl/fsl_asrc_common.h | 2 ++ sound/soc/fsl/fsl_asrc_dma.c | 52 +++++++++++++++++++++++++-------- 2 files changed, 42 insertions(+), 12 deletions(-)sound/soc/fsl/fsl_asrc_common.h +0
-0
sound/soc/fsl/fsl_asrc_common.h enum asrc_pair_index { · line 35
Quoted 4 lines
sound/soc/fsl/fsl_asrc_common.h +1
-0@@ -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
Since we only have dma_request call for back-end only:
+ * @req_dma_chan: flag to release back-end dma chan
sound/soc/fsl/fsl_asrc_dma.c static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, · line 166
Quoted 11 lines
sound/soc/fsl/fsl_asrc_dma.c +3
-0@@ -160,6 +161,9 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, substream_be =snd_soc_dpcm_get_substream (be, stream); dma_params_be =snd_soc_dai_get_dma_data (dai, substream_be); dev_be = dai->dev; + component_be =snd_soc_lookup_component_nolocked (dev_be,SND_DMAENGINE_PCM_DRV_NAME ); +if (component_be) + tmp_chan =soc_component_to_pcm (component_be)->chan[substream->stream];
Should we use substream_be->stream or just substream->stream?
And would be better to add these lines right before we really use tmp_chan because there's still some distance till it reaches that point. And would be better to have a line of comments too.
sound/soc/fsl/fsl_asrc_dma.c static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, · line 214
Quoted 8 lines
sound/soc/fsl/fsl_asrc_dma.c +3
-1@@ -205,10 +209,14 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,*/ if (!asrc->use_edma) {/* Get DMA request of Back-End */ - tmp_chan =dma_request_slave_channel (dev_be, tx ?"tx" :"rx" ); +if (!tmp_chan) { + tmp_chan_new =dma_request_slave_channel (dev_be, tx ?"tx" :"rx" ); + tmp_chan = tmp_chan_new;
This is a bit confusing...though I finally got it :) So probably better to have a line of comments.
Quoted 10 lines
sound/soc/fsl/fsl_asrc_dma.c +3
-2@@ -220,9 +228,26 @@ 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_dev_to_dev = true; }else { - pair->dma_chan[dir] = - asrc->get_dma_channel (pair, dir); +/* +* With EDMA, there is two dma channels can be used for p2p,
sound/soc/fsl/fsl_asrc_dma.c static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, · line 244
Quoted 10 lines
sound/soc/fsl/fsl_asrc_dma.c +10
-0+* one is from ASRC, one is from another peripheral +* (ESAI or SAI). Previously we select the dma channel of ASRC, +* but find an issue for ideal ratio case, there is no control +* for data copy speed, the speed is faster than sample +* frequency. +* +* So we switch to use dma channel of peripheral (ESAI or SAI), +* that copy speed of DMA is controlled by data consumption +* speed in the peripheral FIFO. +*/
This sounds like a different issue and should be fixed separately? If you prefer not to, better to move this one to commit log, other than having a changelog here, in my opinion.
Since it no longer uses get_dma_channel() for EDMA case, we should update the comments at the top as well.
sound/soc/fsl/fsl_asrc_dma.c static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, · line 251
Quoted 7 lines
sound/soc/fsl/fsl_asrc_dma.c +6
-0+ pair->req_dma_chan_dev_to_dev = false; + pair->dma_chan[dir] = tmp_chan; +if (!pair->dma_chan[dir]) { + pair->dma_chan[dir] =dma_request_slave_channel (dev_be, tx ?"tx" :"rx" ); + pair->req_dma_chan_dev_to_dev = true; + } }
Now there are some duplicated lines between these if-else routines, so combining my previous comments, we can do (sample change, not tested):
@@ -197,18 +199,29 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
dma_cap_set(DMA_SLAVE, mask);
dma_cap_set(DMA_CYCLIC, mask);
+ /*
+ * The Back-End device might have already requested a DMA channel,
+ * so try to reuse it first, and then request a new one upon NULL.
+ */
+ component_be = snd_soc_lookup_component_nolocked(dev_be, SND_DMAENGINE_PCM_DRV_NAME);
+ if (component_be) // should probably error out if !component_be?
+ tmp_chan = be_chan = soc_component_to_pcm(component_be)->chan[substream->stream];
+ if (!tmp_chan)
+ tmp_chan = dma_request_slave_channel(dev_be, tx ? "tx" : "rx");
+
/*
* An EDMA DEV_TO_DEV channel is fixed and bound with DMA event of each
* peripheral, unlike SDMA channel that is allocated dynamically. So no
- * need to configure dma_request and dma_request2, but get dma_chan via
- * dma_request_slave_channel directly with dma name of Front-End device
+ * need to configure dma_request and dma_request2, but get dma_chan of
+ * Back-End device directly via dma_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);
+ /* Do not release tmp_chan if we are reusing the Back-End one */
+ if (!be_chan)
+ dma_release_channel(tmp_chan);
/* Get DMA request of Front-End */
tmp_chan = asrc->get_dma_channel(pair, dir);
@@ -220,9 +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 {
- 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]) {
Quoted 10 lines
sound/soc/fsl/fsl_asrc_dma.c +2
-0@@ -273,19 +299,21 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,static int fsl_asrc_dma_hw_free (struct snd_soc_component *component,struct snd_pcm_substream *substream) { +bool tx = substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ;struct snd_pcm_runtime *runtime = substream->runtime;struct fsl_asrc_pair *pair = runtime->private_data; +u8 dir = tx ?OUT :IN ;snd_pcm_set_runtime_buffer (substream,NULL );
sound/soc/fsl/fsl_asrc_dma.c static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, · line 313
Quoted 10 lines
sound/soc/fsl/fsl_asrc_dma.c +4
-4-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 ]); +if (pair->dma_chan[dir] && pair->req_dma_chan_dev_to_dev) +dma_release_channel (pair->dma_chan[dir]);
Why we only apply this to one direction?
Shengjiu Wang
maintainerQuoted 25 lines · Nicolin Chen
Quoted 22 lines · Shengjiu Wang
The dma channel has been requested by Back-End cpu dai driver already. If
fsl_asrc_dmarequests 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 symlinkor with EDMA the request operation will fail for EDMA channel can only be requested once.
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_nolockedandsoc_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 <[email protected]>--- sound/soc/fsl/fsl_asrc_common.h | 2 ++ sound/soc/fsl/fsl_asrc_dma.c | 52 +++++++++++++++++++++++++-------- 2 files changed, 42 insertions(+), 12 deletions(-)
Quoted 12 lines
sound/soc/fsl/fsl_asrc_common.h enum asrc_pair_index { · line 35
Quoted 9 lines
sound/soc/fsl/fsl_asrc_common.h +1
-0@@ -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 Since we only have
dma_requestcall for back-end only:
+ * @req_dma_chan: flag to release back-end dma chan
I prefer to use the description "flag to release dev_to_dev chan" because we won't release the dma chan of the back-end. if the chan is from the back-end, it is owned by the back-end component.
Quoted 14 lines
sound/soc/fsl/fsl_asrc_dma.c static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, · line 166
Quoted 12 lines
sound/soc/fsl/fsl_asrc_dma.c +3
-0@@ -160,6 +161,9 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, substream_be =snd_soc_dpcm_get_substream (be, stream); dma_params_be =snd_soc_dai_get_dma_data (dai, substream_be); dev_be = dai->dev; + component_be =snd_soc_lookup_component_nolocked (dev_be,SND_DMAENGINE_PCM_DRV_NAME ); +if (component_be) + tmp_chan =soc_component_to_pcm (component_be)->chan[substream->stream];Should we use
substream_be->streamor justsubstream->stream?
substream_be->stream should be better.
Quoted 4 lines
And would be better to add these lines right before we really use
tmp_chanbecause there's still some distance till it reaches that point. And would be better to have a line of comments too.
ok.
Quoted 12 lines
sound/soc/fsl/fsl_asrc_dma.c static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, · line 214
Quoted 9 lines
sound/soc/fsl/fsl_asrc_dma.c +3
-1@@ -205,10 +209,14 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,*/ if (!asrc->use_edma) {/* Get DMA request of Back-End */ - tmp_chan =dma_request_slave_channel (dev_be, tx ?"tx" :"rx" ); +if (!tmp_chan) { + tmp_chan_new =dma_request_slave_channel (dev_be, tx ?"tx" :"rx" ); + tmp_chan = tmp_chan_new;This is a bit confusing...though I finally got it :) So probably better to have a line of comments.
ok.
Quoted 17 lines
Quoted 17 lines
sound/soc/fsl/fsl_asrc_dma.c +9
-2@@ -220,9 +228,26 @@ 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_dev_to_dev = true; }else { - pair->dma_chan[dir] = - asrc->get_dma_channel (pair, dir); +/* +* With EDMA, there is two dma channels can be used for p2p, +* one is from ASRC, one is from another peripheral +* (ESAI or SAI). Previously we select the dma channel of ASRC, +* but find an issue for ideal ratio case, there is no control +* for data copy speed, the speed is faster than sample +* frequency. +*
Quoted 8 lines
sound/soc/fsl/fsl_asrc_dma.c static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, · line 244
Quoted 4 lines
sound/soc/fsl/fsl_asrc_dma.c +4
-0+* So we switch to use dma channel of peripheral (ESAI or SAI), +* that copy speed of DMA is controlled by data consumption +* speed in the peripheral FIFO. +*/ This sounds like a different issue and should be fixed separately? If you prefer not to, better to move this one to commit log, other than having a changelog here, in my opinion.
ok, will move it in commit log.
Quoted 12 lines
Since it no longer uses
get_dma_channel()for EDMA case, we should update the comments at the top as well.sound/soc/fsl/fsl_asrc_dma.c static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, · line 251
Quoted 7 lines
sound/soc/fsl/fsl_asrc_dma.c +6
-0+ pair->req_dma_chan_dev_to_dev = false; + pair->dma_chan[dir] = tmp_chan; +if (!pair->dma_chan[dir]) { + pair->dma_chan[dir] =dma_request_slave_channel (dev_be, tx ?"tx" :"rx" ); + pair->req_dma_chan_dev_to_dev = true; + } }
Quoted 2 lines
Now there are some duplicated lines between these if-else routines, so combining my previous comments, we can do (sample change, not tested):
ok, will try yours.
Quoted 66 lines
sound/soc/fsl/fsl_asrc_dma.c +19
-6@@ -197,18 +199,29 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,dma_cap_set (DMA_SLAVE , mask);dma_cap_set (DMA_CYCLIC , mask); +/* +* The Back-End device might have already requested a DMA channel, +* so try to reuse it first, and then request a new one upon NULL. +*/ + component_be =snd_soc_lookup_component_nolocked (dev_be,SND_DMAENGINE_PCM_DRV_NAME ); +if (component_be)// should probably error out if !component_be? + tmp_chan = be_chan =soc_component_to_pcm (component_be)->chan[substream->stream]; +if (!tmp_chan) + tmp_chan =dma_request_slave_channel (dev_be, tx ?"tx" :"rx" ); +/* * An EDMA DEV_TO_DEV channel is fixed and bound with DMA event of each * peripheral, unlike SDMA channel that is allocated dynamically. So no -* need to configure dma_request and dma_request2, but get dma_chan via -* dma_request_slave_channel directly with dma name of Front-End device +* need to configure dma_request and dma_request2, but get dma_chan of +* Back-End device directly via dma_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); +/* Do not release tmp_chan if we are reusing the Back-End one */ +if (!be_chan) +dma_release_channel (tmp_chan);/* Get DMA request of Front-End */ tmp_chan = asrc->get_dma_channel (pair, dir);@@ -220,9 +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 { - 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]) {Quoted 17 lines
sound/soc/fsl/fsl_asrc_dma.c +4
-2@@ -273,19 +299,21 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,static int fsl_asrc_dma_hw_free (struct snd_soc_component *component,struct snd_pcm_substream *substream) { +bool tx = substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ;struct snd_pcm_runtime *runtime = substream->runtime;struct fsl_asrc_pair *pair = runtime->private_data; +u8 dir = 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]);
Quoted 6 lines
sound/soc/fsl/fsl_asrc_dma.c static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, · line 313
Quoted 4 lines
sound/soc/fsl/fsl_asrc_dma.c +2
-2-if (pair->dma_chan[OUT ]) -dma_release_channel (pair->dma_chan[OUT ]); +if (pair->dma_chan[dir] && pair->req_dma_chan_dev_to_dev) +dma_release_channel (pair->dma_chan[dir]);Why we only apply this to one direction?
if the chan is from the back-end, it is owned by the back-end component, so it should be released by the back-end component, not here. That's why I added the flag "req_dma_chan".
Nicolin Chen
reviewerQuoted 10 lines · Shengjiu Wang
Quoted 6 lines
sound/soc/fsl/fsl_asrc_common.h
Quoted 3 lines
sound/soc/fsl/fsl_asrc_common.h +1
-0+* @req_dma_chan_dev_to_dev: flag for release dev_to_dev chan Since we only have
dma_requestcall for back-end only:
+ * @req_dma_chan: flag to release back-end dma chanI prefer to use the description "flag to release
dev_to_devchan" because we won't release the dma chan of the back-end. if the chan is from the back-end, it is owned by the back-end component.
TBH, it just looks too long. But I wouldn't have problem if you insist so.
Quoted 23 lines
Quoted 16 lines
Quoted 16 lines
sound/soc/fsl/fsl_asrc_common.h +4
-2@@ -273,19 +299,21 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,static int fsl_asrc_dma_hw_free (struct snd_soc_component *component,struct snd_pcm_substream *substream) { +bool tx = substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ;struct snd_pcm_runtime *runtime = substream->runtime;struct fsl_asrc_pair *pair = runtime->private_data; +u8 dir = 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]);Quoted 6 lines
sound/soc/fsl/fsl_asrc_common.h static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, · line 313
Quoted 4 lines
sound/soc/fsl/fsl_asrc_common.h +2
-2-if (pair->dma_chan[OUT ]) -dma_release_channel (pair->dma_chan[OUT ]); +if (pair->dma_chan[dir] && pair->req_dma_chan_dev_to_dev) +dma_release_channel (pair->dma_chan[dir]);Why we only apply this to one direction?
Quoted 3 lines
if the chan is from the back-end, it is owned by the back-end component, so it should be released by the back-end component, not here. That's why I added the flag "
req_dma_chan".
Ah...I forgot the IN and OUT is for front-end and back-end. The naming isn't very good indeed. Probably we should add a line of comments somewhere as a reminder.
Thanks