diff mbox series

[v2,2/3] ASoC: SOF: acpi: add module param to disable pm_runtime

Message ID 20190612164726.26768-3-pierre-louis.bossart@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series ASoC: SOF: suspend/resume debug tools | expand

Commit Message

Pierre-Louis Bossart June 12, 2019, 4:47 p.m. UTC
Add debug option to disable pm_runtime. This is not intended for
production devices but is very useful for platform bringup.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/sof/sof-acpi-dev.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Mark Brown June 13, 2019, 6:48 p.m. UTC | #1
On Wed, Jun 12, 2019 at 11:47:25AM -0500, Pierre-Louis Bossart wrote:
> Add debug option to disable pm_runtime. This is not intended for
> production devices but is very useful for platform bringup.

I can't immediately find it right now but isn't there some generic way
of doing this in the runtime PM framework?  If not it seems like it'd be
a good thing to add, these can't be the only devices where it'd be
useful.
Takashi Iwai June 13, 2019, 7:04 p.m. UTC | #2
On Thu, 13 Jun 2019 20:48:01 +0200,
Mark Brown wrote:
> 
> On Wed, Jun 12, 2019 at 11:47:25AM -0500, Pierre-Louis Bossart wrote:
> > Add debug option to disable pm_runtime. This is not intended for
> > production devices but is very useful for platform bringup.
> 
> I can't immediately find it right now but isn't there some generic way
> of doing this in the runtime PM framework?  If not it seems like it'd be
> a good thing to add, these can't be the only devices where it'd be
> useful.

Well, runtime PM can be fully controlled via sysfs, but the problem is
that the driver declares itself being runtime-enabled.
So, either we leave it default and let user-space enabling it (via
udev or other way), or introduce some condition in the driver side.


Takashi
Mark Brown June 13, 2019, 7:13 p.m. UTC | #3
On Thu, Jun 13, 2019 at 09:04:28PM +0200, Takashi Iwai wrote:
> Mark Brown wrote:

> > I can't immediately find it right now but isn't there some generic way
> > of doing this in the runtime PM framework?  If not it seems like it'd be
> > a good thing to add, these can't be the only devices where it'd be
> > useful.

> Well, runtime PM can be fully controlled via sysfs, but the problem is
> that the driver declares itself being runtime-enabled.
> So, either we leave it default and let user-space enabling it (via
> udev or other way), or introduce some condition in the driver side.

I thought someone had added a command line parameter to do it based on
dev_name(), perhaps they were just talking about it or it was in some
BSP somewhere though.
Pierre-Louis Bossart June 14, 2019, 10:24 a.m. UTC | #4
>>> I can't immediately find it right now but isn't there some generic way
>>> of doing this in the runtime PM framework?  If not it seems like it'd be
>>> a good thing to add, these can't be the only devices where it'd be
>>> useful.
> 
>> Well, runtime PM can be fully controlled via sysfs, but the problem is
>> that the driver declares itself being runtime-enabled.
>> So, either we leave it default and let user-space enabling it (via
>> udev or other way), or introduce some condition in the driver side.
> 
> I thought someone had added a command line parameter to do it based on
> dev_name(), perhaps they were just talking about it or it was in some
> BSP somewhere though.

If there is a better way I am all ears. It's indeed not very elegant to 
duplicate the same parameter for two different modules and it's not an 
SOF-specific need.

The only way I am aware of is to play with 
/sys/bus/pci/devices/xyz/power/ files but it's not very useful if you 
want to disable the initial runtime pm transition which is often the 
more problematic one. Completely removing runtime_pm support from all 
drivers at compile time is also not very good either.
diff mbox series

Patch

diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c
index c8dafb1ac54e..93a8e15bbd2c 100644
--- a/sound/soc/sof/sof-acpi-dev.c
+++ b/sound/soc/sof/sof-acpi-dev.c
@@ -29,6 +29,12 @@  static char *tplg_path;
 module_param(tplg_path, charp, 0444);
 MODULE_PARM_DESC(tplg_path, "alternate path for SOF topology.");
 
+static int sof_acpi_debug;
+module_param_named(sof_debug, sof_acpi_debug, int, 0444);
+MODULE_PARM_DESC(sof_debug, "SOF ACPI debug options (0x0 all off)");
+
+#define SOF_ACPI_DISABLE_PM_RUNTIME BIT(0)
+
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HASWELL)
 static const struct sof_dev_desc sof_acpi_haswell_desc = {
 	.machines = snd_soc_acpi_intel_haswell_machines,
@@ -121,6 +127,9 @@  static const struct dev_pm_ops sof_acpi_pm = {
 
 static void sof_acpi_probe_complete(struct device *dev)
 {
+	if (sof_acpi_debug & SOF_ACPI_DISABLE_PM_RUNTIME)
+		return;
+
 	/* allow runtime_pm */
 	pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY_MS);
 	pm_runtime_use_autosuspend(dev);
@@ -221,7 +230,8 @@  static int sof_acpi_probe(struct platform_device *pdev)
 
 static int sof_acpi_remove(struct platform_device *pdev)
 {
-	pm_runtime_disable(&pdev->dev);
+	if (!(sof_acpi_debug & SOF_ACPI_DISABLE_PM_RUNTIME))
+		pm_runtime_disable(&pdev->dev);
 
 	/* call sof helper for DSP hardware remove */
 	snd_sof_device_remove(&pdev->dev);