linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: amd: Fix for Subsequent Playback issue.
@ 2020-01-21 10:43 Ravulapati Vishnu vardhan rao
  2020-01-21 16:59 ` Mark Brown
       [not found] ` <87d0bcmjob.wl-kuninori.morimoto.gx@renesas.com>
  0 siblings, 2 replies; 6+ messages in thread
From: Ravulapati Vishnu vardhan rao @ 2020-01-21 10:43 UTC (permalink / raw)
  Cc: Alexander.Deucher, broonie, Ravulapati Vishnu vardhan rao,
	Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Vijendar Mukunda,
	Colin Ian King, YueHaibing, Kuninori Morimoto,
	moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
	open list

If we play audio back to back, which kills one playback
and immediately start another, we can hear clicks.
This patch fixes the issue.

Signed-off-by: Ravulapati Vishnu vardhan rao <Vishnuvardhanrao.Ravulapati@amd.com>
---
 sound/soc/amd/raven/acp3x-pcm-dma.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c
index 5c3ec3c..916649a 100644
--- a/sound/soc/amd/raven/acp3x-pcm-dma.c
+++ b/sound/soc/amd/raven/acp3x-pcm-dma.c
@@ -344,25 +344,28 @@ static int acp3x_dma_close(struct snd_soc_component *component,
 {
 	struct snd_soc_pcm_runtime *prtd;
 	struct i2s_dev_data *adata;
+	struct i2s_stream_instance *rtd;
 
 	prtd = substream->private_data;
 	component = snd_soc_rtdcom_lookup(prtd, DRV_NAME);
 	adata = dev_get_drvdata(component->dev);
+	rtd = substream->runtime->private_data;
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		adata->play_stream = NULL;
-		adata->i2ssp_play_stream = NULL;
-	} else {
-		adata->capture_stream = NULL;
-		adata->i2ssp_capture_stream = NULL;
-	}
 
 	/* Disable ACP irq, when the current stream is being closed and
 	 * another stream is also not active.
 	 */
+	kfree(rtd);
 	if (!adata->play_stream && !adata->capture_stream &&
 		!adata->i2ssp_play_stream && !adata->i2ssp_capture_stream)
 		rv_writel(0, adata->acp3x_base + mmACP_EXTERNAL_INTR_ENB);
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		adata->play_stream = NULL;
+		adata->i2ssp_play_stream = NULL;
+	} else {
+		adata->capture_stream = NULL;
+		adata->i2ssp_capture_stream = NULL;
+	}
 	return 0;
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: amd: Fix for Subsequent Playback issue.
  2020-01-21 10:43 [PATCH] ASoC: amd: Fix for Subsequent Playback issue Ravulapati Vishnu vardhan rao
@ 2020-01-21 16:59 ` Mark Brown
       [not found]   ` <DM6PR12MB3868B9744A40D41450155534E70D0@DM6PR12MB3868.namprd12.prod.outlook.com>
       [not found] ` <87d0bcmjob.wl-kuninori.morimoto.gx@renesas.com>
  1 sibling, 1 reply; 6+ messages in thread
From: Mark Brown @ 2020-01-21 16:59 UTC (permalink / raw)
  To: Ravulapati Vishnu vardhan rao
  Cc: Alexander.Deucher, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	Vijendar Mukunda, Colin Ian King, YueHaibing, Kuninori Morimoto,
	moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
	open list

[-- Attachment #1: Type: text/plain, Size: 459 bytes --]

On Tue, Jan 21, 2020 at 04:13:35PM +0530, Ravulapati Vishnu vardhan rao wrote:

> If we play audio back to back, which kills one playback
> and immediately start another, we can hear clicks.
> This patch fixes the issue.

>  	/* Disable ACP irq, when the current stream is being closed and
>  	 * another stream is also not active.
>  	 */
> +	kfree(rtd);

This free looks like a separate change which seems good and useful but
should be in a separate patch?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: amd: Fix for Subsequent Playback issue.
       [not found]   ` <DM6PR12MB3868B9744A40D41450155534E70D0@DM6PR12MB3868.namprd12.prod.outlook.com>
@ 2020-01-21 17:08     ` Mark Brown
       [not found]       ` <DM6PR12MB386893EE3876B51B35A1787BE70D0@DM6PR12MB3868.namprd12.prod.outlook.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2020-01-21 17:08 UTC (permalink / raw)
  To: RAVULAPATI, VISHNU VARDHAN RAO
  Cc: Deucher, Alexander, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	Mukunda, Vijendar, Colin Ian King, YueHaibing, Kuninori Morimoto,
	moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
	open list

[-- Attachment #1: Type: text/plain, Size: 426 bytes --]

On Tue, Jan 21, 2020 at 05:03:43PM +0000, RAVULAPATI, VISHNU VARDHAN RAO wrote:

> > +     kfree(rtd);

> This free looks like a separate change which seems good and useful but
> should be in a separate patch?

> No Mark,

> That is part of the fix. please let this be included in this patch.

In what way is it part of the fix?  This at least needs some sort of
explanation somewhere, the changelog at least if not the code.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: amd: Fix for Subsequent Playback issue.
       [not found]       ` <DM6PR12MB386893EE3876B51B35A1787BE70D0@DM6PR12MB3868.namprd12.prod.outlook.com>
@ 2020-01-21 17:26         ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2020-01-21 17:26 UTC (permalink / raw)
  To: RAVULAPATI, VISHNU VARDHAN RAO
  Cc: Deucher, Alexander, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	Mukunda, Vijendar, Colin Ian King, YueHaibing, Kuninori Morimoto,
	moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
	open list

[-- Attachment #1: Type: text/plain, Size: 722 bytes --]

On Tue, Jan 21, 2020 at 05:12:42PM +0000, RAVULAPATI, VISHNU VARDHAN RAO wrote:

Please fix your mailer to quote replies normally, it's hard to read your
mails.

> In what way is it part of the fix?  This at least needs some sort of
> explanation somewhere, the changelog at least if not the code.

> When we play subsequently we hear last played sound for moment.kfree clears the structure.

If the rtd is still being referenced after the kfree() you have a use
after free bug so there's a serious problem there and this change is
introducing a bug, you can only free things if they are not in use.  At
a bare minimum I need the changelog to clearly explain what the cause of
the clicks is and how the change fixes that.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: amd: Fix for Subsequent Playback issue.
       [not found] ` <87d0bcmjob.wl-kuninori.morimoto.gx@renesas.com>
@ 2020-01-22  8:48   ` vishnu
  0 siblings, 0 replies; 6+ messages in thread
From: vishnu @ 2020-01-22  8:48 UTC (permalink / raw)
  To: Kuninori Morimoto, Ravulapati Vishnu vardhan rao
  Cc: Alexander.Deucher, broonie, Liam Girdwood, Jaroslav Kysela,
	Takashi Iwai, Vijendar Mukunda, Colin Ian King, YueHaibing,
	moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
	open list



On 22/01/20 5:44 AM, Kuninori Morimoto wrote:
> 
> Hi Ravulapati
> 
>> If we play audio back to back, which kills one playback
>> and immediately start another, we can hear clicks.
>> This patch fixes the issue.
>>
>> Signed-off-by: Ravulapati Vishnu vardhan rao <Vishnuvardhanrao.Ravulapati@amd.com>
>> ---
> (snip)
>> +	kfree(rtd);
> 
> Please double check soc_new_pcm_runtime() and
> soc_free_pcm_runtime() at soc-core.c.
> Because rtd is created via devm_kzalloc(),
> and has many related resources which need to be cared when rtd was freed.
> Just kfree() is not good/enough, I think.
> 
> I think you want to use is snd_soc_remove_pcm_runtime()
> instead of kfree()
> 
> Thank you for your help !!
> Best regards
> ---
> Kuninori Morimoto
> 
I will create a separate patch for kfree and separate one for subsequent 
play back issue.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] ASoC: amd: Fix for Subsequent Playback issue.
@ 2020-01-27 11:26 Ravulapati Vishnu vardhan rao
  0 siblings, 0 replies; 6+ messages in thread
From: Ravulapati Vishnu vardhan rao @ 2020-01-27 11:26 UTC (permalink / raw)
  Cc: Alexander.Deucher, broonie, Ravulapati Vishnu vardhan rao,
	Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Vijendar Mukunda,
	YueHaibing, Kuninori Morimoto,
	moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
	open list

If we play audio back to back, which kills one playback
and immediately start another, we can hear clicks.
This patch fixes the issue.

Signed-off-by: Ravulapati Vishnu vardhan rao <Vishnuvardhanrao.Ravulapati@amd.com>
---
 sound/soc/amd/raven/acp3x-pcm-dma.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c
index 5c3ec3c..aecc3c0 100644
--- a/sound/soc/amd/raven/acp3x-pcm-dma.c
+++ b/sound/soc/amd/raven/acp3x-pcm-dma.c
@@ -349,13 +349,6 @@ static int acp3x_dma_close(struct snd_soc_component *component,
 	component = snd_soc_rtdcom_lookup(prtd, DRV_NAME);
 	adata = dev_get_drvdata(component->dev);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		adata->play_stream = NULL;
-		adata->i2ssp_play_stream = NULL;
-	} else {
-		adata->capture_stream = NULL;
-		adata->i2ssp_capture_stream = NULL;
-	}
 
 	/* Disable ACP irq, when the current stream is being closed and
 	 * another stream is also not active.
@@ -363,6 +356,13 @@ static int acp3x_dma_close(struct snd_soc_component *component,
 	if (!adata->play_stream && !adata->capture_stream &&
 		!adata->i2ssp_play_stream && !adata->i2ssp_capture_stream)
 		rv_writel(0, adata->acp3x_base + mmACP_EXTERNAL_INTR_ENB);
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		adata->play_stream = NULL;
+		adata->i2ssp_play_stream = NULL;
+	} else {
+		adata->capture_stream = NULL;
+		adata->i2ssp_capture_stream = NULL;
+	}
 	return 0;
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-01-27 11:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-21 10:43 [PATCH] ASoC: amd: Fix for Subsequent Playback issue Ravulapati Vishnu vardhan rao
2020-01-21 16:59 ` Mark Brown
     [not found]   ` <DM6PR12MB3868B9744A40D41450155534E70D0@DM6PR12MB3868.namprd12.prod.outlook.com>
2020-01-21 17:08     ` Mark Brown
     [not found]       ` <DM6PR12MB386893EE3876B51B35A1787BE70D0@DM6PR12MB3868.namprd12.prod.outlook.com>
2020-01-21 17:26         ` Mark Brown
     [not found] ` <87d0bcmjob.wl-kuninori.morimoto.gx@renesas.com>
2020-01-22  8:48   ` vishnu
2020-01-27 11:26 Ravulapati Vishnu vardhan rao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).