All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC force running of delayed PM work at suspend() and remove()
@ 2007-01-31 12:26 Liam Girdwood
  2007-01-31 13:23 ` Takashi Iwai
  0 siblings, 1 reply; 5+ messages in thread
From: Liam Girdwood @ 2007-01-31 12:26 UTC (permalink / raw)
  To: alsa-devel

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

This patch fixes a bug whereby the power management delayed work would
never be run at driver suspend() or module remove(). Delayed work would
be created (after audio had finished) with a long delay (~5 secs) and
was sometimes never queued before flush_scheduled_work() was being
called at suspend or module remove. This caused the delayed work to
queued after the module had been removed or after resume.

This patch forces any delayed work to complete by cancelling it (timer
cannot fire and add it to queue later), scheduling it for now and
waiting on it's completion.

This is something I probably would like to add to workqueue.c in the
next merge window, however it's here atm because it can oops.

Signed-off-by: Liam Girdwood <lg@opensource.wolfsonmicro.com>  



[-- Attachment #2: asoc-delayed-work.patch --]
[-- Type: text/x-patch, Size: 1421 bytes --]

diff -r b4265ee02e26 soc/soc-core.c
--- a/soc/soc-core.c	Wed Jan 31 10:35:19 2007 +0100
+++ b/soc/soc-core.c	Wed Jan 31 12:06:05 2007 +0000
@@ -76,6 +76,25 @@ static int pmdown_time = 5000;
 static int pmdown_time = 5000;
 module_param(pmdown_time, int, 0);
 MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)");
+
+/*
+ * This function forces any delayed work to be queued and run.
+ */
+static int run_delayed_work(struct delayed_work *dwork)
+{
+	int ret;
+
+	/* cancel any work waiting to be queued. */
+	ret = cancel_delayed_work(dwork);
+
+	/* if there was any work waiting then we run it now and
+	 * wait for it's completion */
+	if (ret) {
+		schedule_delayed_work(dwork, 0);
+		flush_scheduled_work();
+	}
+	return ret;
+}
 
 #ifdef CONFIG_SND_SOC_AC97_BUS
 /* unregister ac97 codec */
@@ -1101,7 +1120,7 @@ static int soc_suspend(struct platform_d
 	}
 
 	/* close any waiting streams and save state */
-	flush_scheduled_work();
+	run_delayed_work(&socdev->delayed_work);
 	codec->suspend_dapm_state = codec->dapm_state;
 
 	for(i = 0; i < codec->num_dai; i++) {
@@ -1254,6 +1273,8 @@ static int soc_remove(struct platform_de
 	struct snd_soc_machine *machine = socdev->machine;
 	struct snd_soc_platform *platform = socdev->platform;
 	struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
+
+	run_delayed_work(&socdev->delayed_work);
 
 	if (platform->remove)
 		platform->remove(pdev);

[-- Attachment #3: Type: text/plain, Size: 347 bytes --]

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

[-- Attachment #4: Type: text/plain, Size: 161 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-devel

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

* Re: [PATCH] ASoC force running of delayed PM work at suspend() and remove()
  2007-01-31 12:26 [PATCH] ASoC force running of delayed PM work at suspend() and remove() Liam Girdwood
@ 2007-01-31 13:23 ` Takashi Iwai
  2007-01-31 17:22   ` Liam Girdwood
  0 siblings, 1 reply; 5+ messages in thread
From: Takashi Iwai @ 2007-01-31 13:23 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: alsa-devel

At Wed, 31 Jan 2007 12:26:25 +0000,
Liam Girdwood wrote:
> 
> This patch fixes a bug whereby the power management delayed work would
> never be run at driver suspend() or module remove(). Delayed work would
> be created (after audio had finished) with a long delay (~5 secs) and
> was sometimes never queued before flush_scheduled_work() was being
> called at suspend or module remove. This caused the delayed work to
> queued after the module had been removed or after resume.
> 
> This patch forces any delayed work to complete by cancelling it (timer
> cannot fire and add it to queue later), scheduling it for now and
> waiting on it's completion.
> 
> This is something I probably would like to add to workqueue.c in the
> next merge window, however it's here atm because it can oops.
> 
> Signed-off-by: Liam Girdwood <lg@opensource.wolfsonmicro.com>  

Applied.  I guess we need to fix a similar (flush_delayed_work) in
ac97 codec code, too.

thanks,

Takashi


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

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

* Re: [PATCH] ASoC force running of delayed PM work at suspend() and remove()
  2007-01-31 13:23 ` Takashi Iwai
@ 2007-01-31 17:22   ` Liam Girdwood
  2007-01-31 17:39     ` Liam Girdwood
  0 siblings, 1 reply; 5+ messages in thread
From: Liam Girdwood @ 2007-01-31 17:22 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

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

On Wed, 2007-01-31 at 14:23 +0100, Takashi Iwai wrote:
> At Wed, 31 Jan 2007 12:26:25 +0000,
> Liam Girdwood wrote:
> > 
> > This patch fixes a bug whereby the power management delayed work would
> > never be run at driver suspend() or module remove(). Delayed work would
> > be created (after audio had finished) with a long delay (~5 secs) and
> > was sometimes never queued before flush_scheduled_work() was being
> > called at suspend or module remove. This caused the delayed work to
> > queued after the module had been removed or after resume.
> > 
> > This patch forces any delayed work to complete by cancelling it (timer
> > cannot fire and add it to queue later), scheduling it for now and
> > waiting on it's completion.
> > 
> > This is something I probably would like to add to workqueue.c in the
> > next merge window, however it's here atm because it can oops.
> > 
> > Signed-off-by: Liam Girdwood <lg@opensource.wolfsonmicro.com>  
> 
> Applied.  I guess we need to fix a similar (flush_delayed_work) in
> ac97 codec code, too.

Patch attached for AC97 codec.

Signed-off-by Liam Girdwood <lg@opensource.wolfsonmicro.com>

Liam

[-- Attachment #2: ac97-delayed-work.patch --]
[-- Type: text/x-patch, Size: 1300 bytes --]

diff -r 2a5adb550155 pci/ac97/ac97_codec.c
--- a/pci/ac97/ac97_codec.c	Wed Jan 31 14:34:38 2007 +0100
+++ b/pci/ac97/ac97_codec.c	Wed Jan 31 17:19:22 2007 +0000
@@ -965,6 +965,22 @@ AD18XX_PCM_BITS("LFE Playback Volume", 2
  *
  */
 
+static int run_ac97_delayed_work(struct delayed_work *dwork)
+{
+	int ret;
+
+	/* cancel any work waiting to be queued. */
+	ret = cancel_delayed_work(dwork);
+
+	/* if there was any work waiting then we run it now and
+	 * wait for it's completion */
+	if (ret) {
+		schedule_delayed_work(dwork, 0);
+		flush_scheduled_work();
+	}
+	return ret;
+}
+
 static void snd_ac97_powerdown(struct snd_ac97 *ac97);
 
 static int snd_ac97_bus_free(struct snd_ac97_bus *bus)
@@ -989,8 +1005,7 @@ static int snd_ac97_free(struct snd_ac97
 {
 	if (ac97) {
 #ifdef CONFIG_SND_AC97_POWER_SAVE
-		cancel_delayed_work(&ac97->power_work);
-		flush_scheduled_work();
+		run_ac97_delayed_work(&ac97->power_work);
 #endif
 		snd_ac97_proc_done(ac97);
 		if (ac97->bus)
@@ -2417,8 +2432,7 @@ void snd_ac97_suspend(struct snd_ac97 *a
 	if (ac97->build_ops->suspend)
 		ac97->build_ops->suspend(ac97);
 #ifdef CONFIG_SND_AC97_POWER_SAVE
-	cancel_delayed_work(&ac97->power_work);
-	flush_scheduled_work();
+	run_ac97_delayed_work(&ac97->power_work);
 #endif
 	snd_ac97_powerdown(ac97);
 }

[-- Attachment #3: Type: text/plain, Size: 347 bytes --]

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

[-- Attachment #4: Type: text/plain, Size: 161 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-devel

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

* Re: [PATCH] ASoC force running of delayed PM work at suspend() and remove()
  2007-01-31 17:22   ` Liam Girdwood
@ 2007-01-31 17:39     ` Liam Girdwood
  2007-02-01 11:13       ` Takashi Iwai
  0 siblings, 1 reply; 5+ messages in thread
From: Liam Girdwood @ 2007-01-31 17:39 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

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

On Wed, 2007-01-31 at 17:22 +0000, Liam Girdwood wrote:

> Patch attached for AC97 codec.

Best use this one. I've now put the #ifdef CONFIG_SND_AC97_POWER_SAVE
around the function.

Signed-off-by: Liam Girdwood <lg@opensource.wolfsonmicro.com>

Liam

[-- Attachment #2: ac97-delayed-work.patch --]
[-- Type: text/x-patch, Size: 1289 bytes --]

diff -r 2a5adb550155 pci/ac97/ac97_codec.c
--- a/pci/ac97/ac97_codec.c	Wed Jan 31 14:34:38 2007 +0100
+++ b/pci/ac97/ac97_codec.c	Wed Jan 31 17:36:31 2007 +0000
@@ -964,6 +964,23 @@ AD18XX_PCM_BITS("LFE Playback Volume", 2
 /*
  *
  */
+#ifdef CONFIG_SND_AC97_POWER_SAVE
+static int run_ac97_delayed_work(struct delayed_work *dwork)
+{
+	int ret;
+
+	/* cancel any work waiting to be queued. */
+	ret = cancel_delayed_work(dwork);
+
+	/* if there was any work waiting then we run it now and
+	 * wait for it's completion */
+	if (ret) {
+		schedule_delayed_work(dwork, 0);
+		flush_scheduled_work();
+	}
+	return ret;
+}
+#endif
 
 static void snd_ac97_powerdown(struct snd_ac97 *ac97);
 
@@ -989,8 +1006,7 @@ static int snd_ac97_free(struct snd_ac97
 {
 	if (ac97) {
 #ifdef CONFIG_SND_AC97_POWER_SAVE
-		cancel_delayed_work(&ac97->power_work);
-		flush_scheduled_work();
+		run_ac97_delayed_work(&ac97->power_work);
 #endif
 		snd_ac97_proc_done(ac97);
 		if (ac97->bus)
@@ -2417,8 +2433,7 @@ void snd_ac97_suspend(struct snd_ac97 *a
 	if (ac97->build_ops->suspend)
 		ac97->build_ops->suspend(ac97);
 #ifdef CONFIG_SND_AC97_POWER_SAVE
-	cancel_delayed_work(&ac97->power_work);
-	flush_scheduled_work();
+	run_ac97_delayed_work(&ac97->power_work);
 #endif
 	snd_ac97_powerdown(ac97);
 }

[-- Attachment #3: Type: text/plain, Size: 347 bytes --]

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

[-- Attachment #4: Type: text/plain, Size: 161 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-devel

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

* Re: [PATCH] ASoC force running of delayed PM work at suspend() and remove()
  2007-01-31 17:39     ` Liam Girdwood
@ 2007-02-01 11:13       ` Takashi Iwai
  0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2007-02-01 11:13 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: alsa-devel

At Wed, 31 Jan 2007 17:39:06 +0000,
Liam Girdwood wrote:
> 
> On Wed, 2007-01-31 at 17:22 +0000, Liam Girdwood wrote:
> 
> > Patch attached for AC97 codec.
> 
> Best use this one. I've now put the #ifdef CONFIG_SND_AC97_POWER_SAVE
> around the function.

Well, in the case of ac97_codec.c, we don't have to put
schedule_delayed_work() there.  The work is only for power-off, and
suspend/powerdown is the very place to force to turn off the power
immediately afterward.


Takashi

> 
> Signed-off-by: Liam Girdwood <lg@opensource.wolfsonmicro.com>
> 
> Liam
> [2 ac97-delayed-work.patch <text/x-patch; utf-8 (7bit)>]
> diff -r 2a5adb550155 pci/ac97/ac97_codec.c
> --- a/pci/ac97/ac97_codec.c	Wed Jan 31 14:34:38 2007 +0100
> +++ b/pci/ac97/ac97_codec.c	Wed Jan 31 17:36:31 2007 +0000
> @@ -964,6 +964,23 @@ AD18XX_PCM_BITS("LFE Playback Volume", 2
>  /*
>   *
>   */
> +#ifdef CONFIG_SND_AC97_POWER_SAVE
> +static int run_ac97_delayed_work(struct delayed_work *dwork)
> +{
> +	int ret;
> +
> +	/* cancel any work waiting to be queued. */
> +	ret = cancel_delayed_work(dwork);
> +
> +	/* if there was any work waiting then we run it now and
> +	 * wait for it's completion */
> +	if (ret) {
> +		schedule_delayed_work(dwork, 0);
> +		flush_scheduled_work();
> +	}
> +	return ret;
> +}
> +#endif
>  
>  static void snd_ac97_powerdown(struct snd_ac97 *ac97);
>  
> @@ -989,8 +1006,7 @@ static int snd_ac97_free(struct snd_ac97
>  {
>  	if (ac97) {
>  #ifdef CONFIG_SND_AC97_POWER_SAVE
> -		cancel_delayed_work(&ac97->power_work);
> -		flush_scheduled_work();
> +		run_ac97_delayed_work(&ac97->power_work);
>  #endif
>  		snd_ac97_proc_done(ac97);
>  		if (ac97->bus)
> @@ -2417,8 +2433,7 @@ void snd_ac97_suspend(struct snd_ac97 *a
>  	if (ac97->build_ops->suspend)
>  		ac97->build_ops->suspend(ac97);
>  #ifdef CONFIG_SND_AC97_POWER_SAVE
> -	cancel_delayed_work(&ac97->power_work);
> -	flush_scheduled_work();
> +	run_ac97_delayed_work(&ac97->power_work);
>  #endif
>  	snd_ac97_powerdown(ac97);
>  }

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

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

end of thread, other threads:[~2007-02-01 11:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-31 12:26 [PATCH] ASoC force running of delayed PM work at suspend() and remove() Liam Girdwood
2007-01-31 13:23 ` Takashi Iwai
2007-01-31 17:22   ` Liam Girdwood
2007-01-31 17:39     ` Liam Girdwood
2007-02-01 11:13       ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.