From: Cezary Rojewski <cezary.rojewski@intel.com>
To: alsa-devel@alsa-project.org, broonie@kernel.org
Cc: Cezary Rojewski <cezary.rojewski@intel.com>,
pierre-louis.bossart@linux.intel.com, tiwai@suse.com,
hdegoede@redhat.com, amadeuszx.slawinski@linux.intel.com
Subject: [PATCH 2/3] ASoC: core: Inline resume work back to resume function
Date: Fri, 4 Nov 2022 14:12:43 +0100 [thread overview]
Message-ID: <20221104131244.3920179-3-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20221104131244.3920179-1-cezary.rojewski@intel.com>
From: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Commit 6ed2597883b1 ("ALSA: ASoC: Don't block system resume") introduced
deferred_resume_work for ASoC subsystem. While this allows for potential
speed up during boot on some slow devices, it doesn't allow to properly
propagate return values in case something failed during system resume.
Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
include/sound/soc.h | 3 ---
sound/soc/soc-core.c | 48 +++++++++++---------------------------------
2 files changed, 12 insertions(+), 39 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 37bbfc8b45cb..3465aa075afe 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1005,9 +1005,6 @@ struct snd_soc_card {
#ifdef CONFIG_DEBUG_FS
struct dentry *debugfs_card_root;
-#endif
-#ifdef CONFIG_PM_SLEEP
- struct work_struct deferred_resume_work;
#endif
u32 pop_time;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index a409fbed8f34..5f7e0735f0c1 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -643,17 +643,21 @@ int snd_soc_suspend(struct device *dev)
}
EXPORT_SYMBOL_GPL(snd_soc_suspend);
-/*
- * deferred resume work, so resume can complete before we finished
- * setting our codec back up, which can be very slow on I2C
- */
-static void soc_resume_deferred(struct work_struct *work)
+/* powers up audio subsystem after a suspend */
+int snd_soc_resume(struct device *dev)
{
- struct snd_soc_card *card =
- container_of(work, struct snd_soc_card,
- deferred_resume_work);
+ struct snd_soc_card *card = dev_get_drvdata(dev);
struct snd_soc_component *component;
+ /* If the card is not initialized yet there is nothing to do */
+ if (!card->instantiated)
+ return 0;
+
+ /* activate pins from sleep state */
+ for_each_card_components(card, component)
+ if (snd_soc_component_active(component))
+ pinctrl_pm_select_default_state(component->dev);
+
/*
* our power state is still SNDRV_CTL_POWER_D3hot from suspend time,
* so userspace apps are blocked from touching us
@@ -686,40 +690,14 @@ static void soc_resume_deferred(struct work_struct *work)
/* userspace can access us now we are back as we were before */
snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D0);
-}
-
-/* powers up audio subsystem after a suspend */
-int snd_soc_resume(struct device *dev)
-{
- struct snd_soc_card *card = dev_get_drvdata(dev);
- struct snd_soc_component *component;
-
- /* If the card is not initialized yet there is nothing to do */
- if (!card->instantiated)
- return 0;
-
- /* activate pins from sleep state */
- for_each_card_components(card, component)
- if (snd_soc_component_active(component))
- pinctrl_pm_select_default_state(component->dev);
-
- dev_dbg(dev, "ASoC: Scheduling resume work\n");
- if (!schedule_work(&card->deferred_resume_work))
- dev_err(dev, "ASoC: resume work item may be lost\n");
return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_resume);
-static void soc_resume_init(struct snd_soc_card *card)
-{
- /* deferred resume work */
- INIT_WORK(&card->deferred_resume_work, soc_resume_deferred);
-}
#else
#define snd_soc_suspend NULL
#define snd_soc_resume NULL
-static inline void soc_resume_init(struct snd_soc_card *card) { }
#endif
static struct device_node
@@ -1968,8 +1946,6 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
soc_init_card_debugfs(card);
- soc_resume_init(card);
-
ret = snd_soc_dapm_new_controls(&card->dapm, card->dapm_widgets,
card->num_dapm_widgets);
if (ret < 0)
--
2.25.1
next prev parent reply other threads:[~2022-11-04 12:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-04 13:12 [PATCH 0/3] ASoC: core: Suspend/resume error propagation Cezary Rojewski
2022-11-04 13:12 ` [PATCH 1/3] ASoC: component: Propagate result of suspend and resume callbacks Cezary Rojewski
2022-11-04 14:00 ` Pierre-Louis Bossart
2022-11-07 8:51 ` Amadeusz Sławiński
2022-11-07 14:11 ` Pierre-Louis Bossart
2022-11-04 13:12 ` Cezary Rojewski [this message]
2022-11-04 13:58 ` [PATCH 2/3] ASoC: core: Inline resume work back to resume function Pierre-Louis Bossart
2022-11-04 23:54 ` Mark Brown
2022-11-07 9:26 ` Cezary Rojewski
2022-11-07 14:28 ` Mark Brown
2022-11-08 19:22 ` Cezary Rojewski
2022-11-04 13:12 ` [PATCH 3/3] ASoC: core: Propagate component suspend/resume errors Cezary Rojewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221104131244.3920179-3-cezary.rojewski@intel.com \
--to=cezary.rojewski@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=amadeuszx.slawinski@linux.intel.com \
--cc=broonie@kernel.org \
--cc=hdegoede@redhat.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox