Skip to contentSkip to conversation

ASoC: Intel: fix broadwell module removing failed issue

PATCH Applied Jie Yang 4 participants 9 messages May 28, 2015 – May 30, 2015

Subsystems (3)
lore
Share & tools
lore

Jie Yang

author
#0 lore raw

PATCH 1/1 ASoC: Intel: fix broadwell module removing failed issue

From: Liam Girdwood <[email protected]>

In haswell-pcm module unloading, we can't free runtime modules directly, for they may be already freed in runtime suspend.

Here add executing suspend call to unload runtime modules, only for status not equal to RPM_SUSPEND, to fix broadwell module removing failed issue.

---
 sound/soc/intel/haswell/sst-haswell-pcm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/intel/haswell/sst-haswell-pcm.c +3 -1
index 23ae040..bd96629 100644
@@ -1118,8 +1118,10 @@ static int hsw_pcm_remove(struct snd_soc_platform *platform)
 		snd_soc_platform_get_drvdata(platform);
 	int i;
 
+	/* execute a suspend call to unload all FW resources */
+	if (!pm_runtime_status_suspended(platform->dev))
+		pm_runtime_put_sync_suspend(platform->dev);
 	pm_runtime_disable(platform->dev);
-	hsw_pcm_free_modules(priv_data);
 
 	for (i = 0; i < ARRAY_SIZE(hsw_dais); i++) {
 		if (hsw_dais[i].playback.channels_min)
Signature · 1 line
1.9.1
maintainer Applied
#1 lore raw
Quoted 4 lines · Jie Yang

From: Liam Girdwood <[email protected]>

In haswell-pcm module unloading, we can't free runtime modules directly, for they may be already freed in runtime suspend.

Applied, thanks.

#2 lore raw
In reply to Jie Yang

At Thu, 28 May 2015 14:14:18 +0800,

Quoted 9 lines · Jie Yang

From: Liam Girdwood <[email protected]>

In haswell-pcm module unloading, we can't free runtime modules directly, for they may be already freed in runtime suspend.

Here add executing suspend call to unload runtime modules, only for status not equal to RPM_SUSPEND, to fix broadwell module removing failed issue.

What if a kernel is built without PM support? (Practically seen, it's never any serious problem, though.)

Takashi

Quoted 26 lines
---
 sound/soc/intel/haswell/sst-haswell-pcm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/intel/haswell/sst-haswell-pcm.c +3 -1
index 23ae040..bd96629 100644
@@ -1118,8 +1118,10 @@ static int hsw_pcm_remove(struct snd_soc_platform *platform)
 		snd_soc_platform_get_drvdata(platform);
 	int i;
 
+	/* execute a suspend call to unload all FW resources */
+	if (!pm_runtime_status_suspended(platform->dev))
+		pm_runtime_put_sync_suspend(platform->dev);
 	pm_runtime_disable(platform->dev);
-	hsw_pcm_free_modules(priv_data);
 
 	for (i = 0; i < ARRAY_SIZE(hsw_dais); i++) {
 		if (hsw_dais[i].playback.channels_min)
Signature · 1 line
1.9.1
#3 lore raw
Quoted 8 lines · Takashi Iwai

At Thu, 28 May 2015 14:14:18 +0800,

Quoted 6 lines · Jie Yang

From: Liam Girdwood <[email protected]>

In haswell-pcm module unloading, we can't free runtime modules directly, for they may be already freed in runtime suspend.

Quoted 7 lines
Quoted 3 lines

Here add executing suspend call to unload runtime modules, only for status not equal to RPM_SUSPEND, to fix broadwell module removing failed issue.

What if a kernel is built without PM support? (Practically seen, it's never any serious problem, though.)

Keyon, it sounds like you will still need hsw_pcm_free_modules() and should call it after the PM put/disable on module remove. You will need to add some code too that will check the memory state prior to doing any unloading though....

Liam

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

author
#4 lore raw
Quoted 7 lines

-----Original Message-----
From: Girdwood, Liam R
Sent: Thursday, May 28, 2015 11:45 PM
To: Takashi Iwai
Cc: Jie, Yang; [email protected]; [email protected]
Subject: Re: [PATCH] ASoC: Intel: fix broadwell module removing failed issue

Quoted 15 lines
Quoted 14 lines · Takashi Iwai

At Thu, 28 May 2015 14:14:18 +0800,

Quoted 9 lines · Jie Yang

From: Liam Girdwood <[email protected]>

In haswell-pcm module unloading, we can't free runtime modules directly, for they may be already freed in runtime suspend.

Here add executing suspend call to unload runtime modules, only for status not equal to RPM_SUSPEND, to fix broadwell module removing failed issue.

What if a kernel is built without PM support? (Practically seen, it's never any serious problem, though.)

I think or kernel built without PM, empty pm_runtime_xxx()s are called and no problems for that.

Quoted 6 lines
Quoted 1 line

Keyon, it sounds like you will still need hsw_pcm_free_modules() and should call it after the PM put/disable on module remove. You will need to add some code too that will check the memory state prior to doing any unloading though....

Yes, I plan to add both check before runtime_module_free() and set pcm_data->runtime to NULL after that. At the same time, make sure hsw_pcm_free_modules() is called before fw_unload() called.

With those implemented, suppose the issue can be fixed neatly.

I will test it and submit then.

~Keyon

Quoted 4 lines

Liam

#5 lore raw

At Fri, 29 May 2015 07:46:37 +0000,

Quoted 21 lines · Yang
Quoted 21 lines

-----Original Message-----
From: Girdwood, Liam R
Sent: Thursday, May 28, 2015 11:45 PM
To: Takashi Iwai
Cc: Jie, Yang; [email protected]; [email protected]
Subject: Re: [PATCH] ASoC: Intel: fix broadwell module removing failed issue

Quoted 12 lines · Takashi Iwai

At Thu, 28 May 2015 14:14:18 +0800,

Quoted 9 lines · Jie Yang

From: Liam Girdwood <[email protected]>

In haswell-pcm module unloading, we can't free runtime modules directly, for they may be already freed in runtime suspend.

Here add executing suspend call to unload runtime modules, only for status not equal to RPM_SUSPEND, to fix broadwell module removing failed issue.

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

What if a kernel is built without PM support? (Practically seen, it's never any serious problem, though.)

I think or kernel built without PM, empty pm_runtime_xxx()s are called and no problems for that.

Well, but what about the modules? Where will they be freed? Your patch description sounds as if they are freed in the runtime suspend path.

Also, I'm not quite certain whether it's allowed to do runtime suspend at driver free. Usually it's even forcibly powered up, as we can't leave the device as suspended state after free (who can wake up rightly if no driver is bound?)

Quoted 5 lines
Quoted 4 lines

Keyon, it sounds like you will still need hsw_pcm_free_modules() and should call it after the PM put/disable on module remove. You will need to add some code too that will check the memory state prior to doing any unloading though....

Quoted 7 lines

Yes, I plan to add both check before runtime_module_free() and set pcm_data->runtime to NULL after that. At the same time, make sure hsw_pcm_free_modules() is called before fw_unload() called.

With those implemented, suppose the issue can be fixed neatly.

I will test it and submit then.

Yes, this looks like the missing piece.

Takashi

author
#6 lore raw
Quoted 30 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Friday, May 29, 2015 6:52 PM
To: Jie, Yang
Cc: Girdwood, Liam R; [email protected]; [email protected]
Subject: Re: [PATCH] ASoC: Intel: fix broadwell module removing failed issue

At Fri, 29 May 2015 07:46:37 +0000,

Quoted 21 lines · Yang
Quoted 21 lines

-----Original Message-----
From: Girdwood, Liam R
Sent: Thursday, May 28, 2015 11:45 PM
To: Takashi Iwai
Cc: Jie, Yang; [email protected]; [email protected]
Subject: Re: [PATCH] ASoC: Intel: fix broadwell module removing failed issue

Quoted 11 lines · Takashi Iwai
Quoted 9 lines · Jie Yang

From: Liam Girdwood <[email protected]>

In haswell-pcm module unloading, we can't free runtime modules directly, for they may be already freed in runtime suspend.

Here add executing suspend call to unload runtime modules, only for status not equal to RPM_SUSPEND, to fix broadwell module removing failed issue.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

What if a kernel is built without PM support? (Practically seen, it's never any serious problem, though.)

I think or kernel built without PM, empty pm_runtime_xxx()s are called and no problems for that.

Well, but what about the modules? Where will they be freed? Your patch description sounds as if they are freed in the runtime suspend path.

The freeing of modules is actually done in fw_unload() stage.

Quoted 5 lines

Also, I'm not quite certain whether it's allowed to do runtime suspend at driver free. Usually it's even forcibly powered up, as we can't leave the device as suspended state after free (who can wake up rightly if no driver is bound?)

You are right. Will change it to that descripted below.

Quoted 11 lines
Quoted 11 lines
Quoted 6 lines

Keyon, it sounds like you will still need hsw_pcm_free_modules() and should call it after the PM put/disable on module remove. You will need to add some code too that will check the memory state prior to doing any unloading though....

Yes, I plan to add both check before runtime_module_free() and set pcm_data->runtime to NULL after that. At the same time, make sure hsw_pcm_free_modules() is called before fw_unload() called.

Quoted 5 lines
Quoted 3 lines

With those implemented, suppose the issue can be fixed neatly.

I will test it and submit then.

Yes, this looks like the missing piece.

OK, then I will follow this.

Hi Mark, can you help revert these 2 commits? Sorry for the inconvenience caused.

ASoC: Intel: fix broadwell module removing failed issue
ASoC: Intel: remove unused function hsw_pcm_free_modules()

~Keyon

Quoted 3 lines

Takashi

maintainer
#7 lore raw
Quoted 7 lines · Yang

OK, then I will follow this.

Hi Mark, can you help revert these 2 commits? Sorry for the inconvenience caused.

ASoC: Intel: fix broadwell module removing failed issue
ASoC: Intel: remove unused function hsw_pcm_free_modules()

No, please send patches for any changes you want to integrate into the kernel.

author
#8 lore raw
Quoted 11 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Friday, May 29, 2015 11:19 PM
To: Jie, Yang
Cc: Takashi Iwai; Girdwood, Liam R; [email protected]
Subject: Re: [PATCH] ASoC: Intel: fix broadwell module removing failed issue

Quoted 1 line · Yang

OK, then I will follow this.

Quoted 8 lines
Quoted 5 lines

Hi Mark, can you help revert these 2 commits? Sorry for the inconvenience caused.

ASoC: Intel: fix broadwell module removing failed issue
ASoC: Intel: remove unused function hsw_pcm_free_modules()

No, please send patches for any changes you want to integrate into the kernel.

Got it, thanks, Mark.

~Keyon