-
Notifications
You must be signed in to change notification settings - Fork 140
[RFC]ASoC: SOF: acpi: enable PM for ACPI platforms #1295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -266,7 +266,10 @@ static int sof_resume(struct device *dev, bool runtime_resume) | |
| int ret; | ||
|
|
||
| /* do nothing if dsp resume callbacks are not set */ | ||
| if (!sof_ops(sdev)->resume || !sof_ops(sdev)->runtime_resume) | ||
| if (runtime_resume && !sof_ops(sdev)->runtime_resume) | ||
| return 0; | ||
|
|
||
| if (!runtime_resume && !sof_ops(sdev)->resume) | ||
| return 0; | ||
|
|
||
| /* | ||
|
|
@@ -337,8 +340,11 @@ static int sof_suspend(struct device *dev, bool runtime_suspend) | |
| struct snd_sof_dev *sdev = dev_get_drvdata(dev); | ||
| int ret; | ||
|
|
||
| /* do nothing if dsp suspend callback is not set */ | ||
| if (!sof_ops(sdev)->suspend) | ||
| /* do nothing if dsp suspend callbacks are not set */ | ||
| if (!runtime_suspend && !sof_ops(sdev)->suspend) | ||
| return 0; | ||
|
|
||
| if (runtime_suspend && !sof_ops(sdev)->runtime_suspend) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be a separate patch, no? |
||
| return 0; | ||
|
|
||
| /* release trace */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| #include <linux/firmware.h> | ||
| #include <linux/module.h> | ||
| #include <linux/pm_runtime.h> | ||
| #include <linux/dmi.h> | ||
| #include <sound/soc-acpi.h> | ||
| #include <sound/soc-acpi-intel-match.h> | ||
| #include <sound/sof.h> | ||
|
|
@@ -117,6 +118,39 @@ static const struct sof_dev_desc sof_acpi_cherrytrail_desc = { | |
| .arch_ops = &sof_xtensa_arch_ops | ||
| }; | ||
|
|
||
| static int minnowboard_quirk_cb(const struct dmi_system_id *id) | ||
| { | ||
| struct device *dev = id->driver_data; | ||
|
|
||
| /* | ||
| * Increment the usage count so as to prevent the device | ||
| * from entering runtime suspend. | ||
| */ | ||
| pm_runtime_get_noresume(dev); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. btw what happens if instead of taking a fake reference you just don't enable pm_runtime?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @plbossart this is what I want to do ideally. But the one test that fails with this change is the ipc_flood_test(). When this test runs, we call pm_runtime_get_sync() to resume the DSP if it is suspended and this throws an error is runtime_pm is not enabled. |
||
|
|
||
| return 1; | ||
| } | ||
|
|
||
| static struct dmi_system_id minnowbard_quirk_table[] = { | ||
| { | ||
| /* Minnowboard Max B3 */ | ||
| .callback = minnowboard_quirk_cb, | ||
| .matches = { | ||
| DMI_MATCH(DMI_SYS_VENDOR, "Circuitco"), | ||
| DMI_MATCH(DMI_PRODUCT_NAME, | ||
| "Minnowboard Max B3 PLATFORM"), | ||
| }, | ||
| }, | ||
| { | ||
| /* Minnowboard Turbot */ | ||
| .callback = minnowboard_quirk_cb, | ||
| .matches = { | ||
| DMI_MATCH(DMI_SYS_VENDOR, "ADI"), | ||
| DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Turbot"), | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| #endif | ||
|
|
||
| static const struct dev_pm_ops sof_acpi_pm = { | ||
|
|
@@ -127,13 +161,26 @@ static const struct dev_pm_ops sof_acpi_pm = { | |
|
|
||
| static void sof_acpi_probe_complete(struct device *dev) | ||
| { | ||
| int i; | ||
|
|
||
| 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); | ||
| pm_runtime_set_active(dev); | ||
| pm_runtime_enable(dev); | ||
| pm_runtime_mark_last_busy(dev); | ||
|
|
||
| #if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL) | ||
| /* set driver data in the quirk table */ | ||
| for (i = 0; i < ARRAY_SIZE(minnowbard_quirk_table); i++) | ||
| minnowbard_quirk_table[i].driver_data = dev; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a bit ugly, no? You could just check the quirk, which sets a variable and then you test said variable.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and you can also use the sof-acpi-debug kernel parameter to override the DMI and also disable PM! |
||
|
|
||
| /* check for Minnowboards */ | ||
| dmi_check_system(minnowbard_quirk_table); | ||
| #endif | ||
| } | ||
|
|
||
| static int sof_acpi_probe(struct platform_device *pdev) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this the same routine for basic PM and runtime PM?