* [PATCH] ASoC: core: Don't schedule deferred_resume_work twice
@ 2011-05-25 20:06 Stephen Warren
2011-05-26 10:56 ` Liam Girdwood
2011-05-26 14:08 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Stephen Warren @ 2011-05-25 20:06 UTC (permalink / raw)
To: broonie, lrg; +Cc: alsa-devel, Stephen Warren
For cards that have two or more DAIs, snd_soc_resume's loop over all
DAIs ends up calling schedule_work(deferred_resume_work) once per DAI.
Since this is the same work item each time, the 2nd and subsequent
calls return 0 (work item already queued), and trigger the dev_err
message below stating that a work item may have been lost.
Solve this by adjusting the loop to simply calculate whether to run the
resume work immediately or defer it, and then call schedule work (or not)
one time based on that.
Note: This has not been tested in mainline, but only in chromeos-2.6.38;
mainline doesn't support suspend/resume on Tegra, nor does the mainline
Tegra ASoC driver contain multiple DAIs. It has been compile-checked in
mainline.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
sound/soc/soc-core.c | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index a477e21..c261eeb 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1256,7 +1256,7 @@ static void soc_resume_deferred(struct work_struct *work)
int snd_soc_resume(struct device *dev)
{
struct snd_soc_card *card = dev_get_drvdata(dev);
- int i;
+ int i, ac97_control = 0;
/* AC97 devices might have other drivers hanging off them so
* need to resume immediately. Other drivers don't have that
@@ -1265,14 +1265,15 @@ int snd_soc_resume(struct device *dev)
*/
for (i = 0; i < card->num_rtd; i++) {
struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;
- if (cpu_dai->driver->ac97_control) {
- dev_dbg(dev, "Resuming AC97 immediately\n");
- soc_resume_deferred(&card->deferred_resume_work);
- } else {
- dev_dbg(dev, "Scheduling resume work\n");
- if (!schedule_work(&card->deferred_resume_work))
- dev_err(dev, "resume work item may be lost\n");
- }
+ ac97_control |= cpu_dai->driver->ac97_control;
+ }
+ if (ac97_control) {
+ dev_dbg(dev, "Resuming AC97 immediately\n");
+ soc_resume_deferred(&card->deferred_resume_work);
+ } else {
+ dev_dbg(dev, "Scheduling resume work\n");
+ if (!schedule_work(&card->deferred_resume_work))
+ dev_err(dev, "resume work item may be lost\n");
}
return 0;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: core: Don't schedule deferred_resume_work twice
2011-05-25 20:06 [PATCH] ASoC: core: Don't schedule deferred_resume_work twice Stephen Warren
@ 2011-05-26 10:56 ` Liam Girdwood
2011-05-26 14:08 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Liam Girdwood @ 2011-05-26 10:56 UTC (permalink / raw)
To: Stephen Warren
Cc: alsa-devel@alsa-project.org, broonie@opensource.wolfsonmicro.com
On 25/05/11 21:06, Stephen Warren wrote:
> For cards that have two or more DAIs, snd_soc_resume's loop over all
> DAIs ends up calling schedule_work(deferred_resume_work) once per DAI.
> Since this is the same work item each time, the 2nd and subsequent
> calls return 0 (work item already queued), and trigger the dev_err
> message below stating that a work item may have been lost.
>
> Solve this by adjusting the loop to simply calculate whether to run the
> resume work immediately or defer it, and then call schedule work (or not)
> one time based on that.
>
> Note: This has not been tested in mainline, but only in chromeos-2.6.38;
> mainline doesn't support suspend/resume on Tegra, nor does the mainline
> Tegra ASoC driver contain multiple DAIs. It has been compile-checked in
> mainline.
>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
> sound/soc/soc-core.c | 19 ++++++++++---------
> 1 files changed, 10 insertions(+), 9 deletions(-)
This looks fine for 2.6.41.
Acked-by: Liam girdwood <lrg@ti.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: core: Don't schedule deferred_resume_work twice
2011-05-25 20:06 [PATCH] ASoC: core: Don't schedule deferred_resume_work twice Stephen Warren
2011-05-26 10:56 ` Liam Girdwood
@ 2011-05-26 14:08 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2011-05-26 14:08 UTC (permalink / raw)
To: Stephen Warren; +Cc: alsa-devel, lrg
On Wed, May 25, 2011 at 02:06:41PM -0600, Stephen Warren wrote:
> For cards that have two or more DAIs, snd_soc_resume's loop over all
> DAIs ends up calling schedule_work(deferred_resume_work) once per DAI.
> Since this is the same work item each time, the 2nd and subsequent
> calls return 0 (work item already queued), and trigger the dev_err
> message below stating that a work item may have been lost.
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-05-26 14:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-25 20:06 [PATCH] ASoC: core: Don't schedule deferred_resume_work twice Stephen Warren
2011-05-26 10:56 ` Liam Girdwood
2011-05-26 14:08 ` Mark Brown
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).