ASoC: codecs: soundwire: call pm_runtime_resume() in component probe
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Thu, 16 Jun 2022 21:08:25 +0000 (16:08 -0500)
committerMark Brown <broonie@kernel.org>
Fri, 17 Jun 2022 17:37:59 +0000 (18:37 +0100)
Make sure that the bus and codecs are pm_runtime active when the card
is registered/created. This avoid timeouts when accessing registers.

BugLink: https://github.com/thesofproject/linux/issues/3651
BugLink: https://github.com/thesofproject/linux/issues/3650
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20220616210825.132093-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/max98373.c
sound/soc/codecs/rt1308-sdw.c
sound/soc/codecs/rt1316-sdw.c
sound/soc/codecs/rt700.c
sound/soc/codecs/rt711-sdca.c
sound/soc/codecs/rt711.c
sound/soc/codecs/rt715-sdca.c
sound/soc/codecs/rt715.c

index e14fe98349a5eaf6102f12659b7ec55bc4649fe7..1517c47afbf14bd0d5f8f9b580e6158524e0093e 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/delay.h>
 #include <linux/i2c.h>
 #include <linux/module.h>
+#include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
 #include <linux/cdev.h>
@@ -440,8 +441,19 @@ const struct snd_soc_component_driver soc_codec_dev_max98373 = {
 };
 EXPORT_SYMBOL_GPL(soc_codec_dev_max98373);
 
+static int max98373_sdw_probe(struct snd_soc_component *component)
+{
+       int ret;
+
+       ret = pm_runtime_resume(component->dev);
+       if (ret < 0 && ret != -EACCES)
+               return ret;
+
+       return 0;
+}
+
 const struct snd_soc_component_driver soc_codec_dev_max98373_sdw = {
-       .probe                  = NULL,
+       .probe                  = max98373_sdw_probe,
        .controls               = max98373_snd_controls,
        .num_controls           = ARRAY_SIZE(max98373_snd_controls),
        .dapm_widgets           = max98373_dapm_widgets,
index 72f673f278eeccdc47c9554185d47f096281e817..0be6e72ff5a9a97880e2c2adab2aa286298406fb 100644 (file)
@@ -608,7 +608,19 @@ static const struct sdw_slave_ops rt1308_slave_ops = {
        .bus_config = rt1308_bus_config,
 };
 
+static int rt1308_sdw_component_probe(struct snd_soc_component *component)
+{
+       int ret;
+
+       ret = pm_runtime_resume(component->dev);
+       if (ret < 0 && ret != -EACCES)
+               return ret;
+
+       return 0;
+}
+
 static const struct snd_soc_component_driver soc_component_sdw_rt1308 = {
+       .probe = rt1308_sdw_component_probe,
        .controls = rt1308_snd_controls,
        .num_controls = ARRAY_SIZE(rt1308_snd_controls),
        .dapm_widgets = rt1308_dapm_widgets,
index 2d6b5f9d4d77041b2623e63f3c1ec2cac20b1775..e53396606a1c6f8af317dbf2904427137027f9ff 100644 (file)
@@ -590,7 +590,19 @@ static struct sdw_slave_ops rt1316_slave_ops = {
        .update_status = rt1316_update_status,
 };
 
+static int rt1316_sdw_component_probe(struct snd_soc_component *component)
+{
+       int ret;
+
+       ret = pm_runtime_resume(component->dev);
+       if (ret < 0 && ret != -EACCES)
+               return ret;
+
+       return 0;
+}
+
 static const struct snd_soc_component_driver soc_component_sdw_rt1316 = {
+       .probe = rt1316_sdw_component_probe,
        .controls = rt1316_snd_controls,
        .num_controls = ARRAY_SIZE(rt1316_snd_controls),
        .dapm_widgets = rt1316_dapm_widgets,
index 9bceeeb830b15a5cb8c66e0b7bdc70b412baf022..055c3ae974d804f603575029b2adf92498783b0a 100644 (file)
@@ -818,9 +818,14 @@ static const struct snd_soc_dapm_route rt700_audio_map[] = {
 static int rt700_probe(struct snd_soc_component *component)
 {
        struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
+       int ret;
 
        rt700->component = component;
 
+       ret = pm_runtime_resume(component->dev);
+       if (ret < 0 && ret != -EACCES)
+               return ret;
+
        return 0;
 }
 
index dfe3c9299ebde4aedcf0d1841d8bc1acad08efc4..9d226b1cb7e9278a766047fce0b38ae13c8c6cc3 100644 (file)
@@ -1194,10 +1194,15 @@ static int rt711_sdca_parse_dt(struct rt711_sdca_priv *rt711, struct device *dev
 static int rt711_sdca_probe(struct snd_soc_component *component)
 {
        struct rt711_sdca_priv *rt711 = snd_soc_component_get_drvdata(component);
+       int ret;
 
        rt711_sdca_parse_dt(rt711, &rt711->slave->dev);
        rt711->component = component;
 
+       ret = pm_runtime_resume(component->dev);
+       if (ret < 0 && ret != -EACCES)
+               return ret;
+
        return 0;
 }
 
index 9df800abfc2d8ca729e6561850e6e339fe95f083..1bf61808919424fc72a548ebd1d93ebb40aa5241 100644 (file)
@@ -935,10 +935,15 @@ static int rt711_parse_dt(struct rt711_priv *rt711, struct device *dev)
 static int rt711_probe(struct snd_soc_component *component)
 {
        struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component);
+       int ret;
 
        rt711_parse_dt(rt711, &rt711->slave->dev);
        rt711->component = component;
 
+       ret = pm_runtime_resume(component->dev);
+       if (ret < 0 && ret != -EACCES)
+               return ret;
+
        return 0;
 }
 
index 5857d08663073573e8c8e87931f6729fc31f0aca..ce8bbc76199a888e505da6d922da1bb659ed4a6a 100644 (file)
@@ -758,7 +758,19 @@ static const struct snd_soc_dapm_route rt715_sdca_audio_map[] = {
        {"ADC 25 Mux", "DMIC4", "DMIC4"},
 };
 
+static int rt715_sdca_probe(struct snd_soc_component *component)
+{
+       int ret;
+
+       ret = pm_runtime_resume(component->dev);
+       if (ret < 0 && ret != -EACCES)
+               return ret;
+
+       return 0;
+}
+
 static const struct snd_soc_component_driver soc_codec_dev_rt715_sdca = {
+       .probe = rt715_sdca_probe,
        .controls = rt715_sdca_snd_controls,
        .num_controls = ARRAY_SIZE(rt715_sdca_snd_controls),
        .dapm_widgets = rt715_sdca_dapm_widgets,
index 418e006b19ef5426cfcb8a2dcc1b270827ea7b88..e93240521c74e217b83fdd6275311571f6ce65dd 100644 (file)
@@ -737,7 +737,19 @@ static int rt715_set_bias_level(struct snd_soc_component *component,
        return 0;
 }
 
+static int rt715_probe(struct snd_soc_component *component)
+{
+       int ret;
+
+       ret = pm_runtime_resume(component->dev);
+       if (ret < 0 && ret != -EACCES)
+               return ret;
+
+       return 0;
+}
+
 static const struct snd_soc_component_driver soc_codec_dev_rt715 = {
+       .probe = rt715_probe,
        .set_bias_level = rt715_set_bias_level,
        .controls = rt715_snd_controls,
        .num_controls = ARRAY_SIZE(rt715_snd_controls),