Commit a2d9c161 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Vinod Koul

soundwire: intel: pm_runtime idle scheduling

Add quirk and pm_runtime idle scheduling to let the Master suspend if
no Slaves become attached. This can happen when a link is not marked
as disabled and has devices exposed in the DSDT, if the power is
controlled by sideband means or the link includes a pluggable
connector.
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarRander Wang <rander.wang@linux.intel.com>
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20200817152923.3259-7-yung-chuan.liao@linux.intel.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent a5a0239c
...@@ -31,8 +31,9 @@ ...@@ -31,8 +31,9 @@
* flags reused in each byte, with master0 using the ls-byte, etc. * flags reused in each byte, with master0 using the ls-byte, etc.
*/ */
#define SDW_INTEL_MASTER_DISABLE_PM_RUNTIME BIT(0) #define SDW_INTEL_MASTER_DISABLE_PM_RUNTIME BIT(0)
#define SDW_INTEL_MASTER_DISABLE_CLOCK_STOP BIT(1) #define SDW_INTEL_MASTER_DISABLE_CLOCK_STOP BIT(1)
#define SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE BIT(2)
static int md_flags; static int md_flags;
module_param_named(sdw_md_flags, md_flags, int, 0444); module_param_named(sdw_md_flags, md_flags, int, 0444);
...@@ -1422,6 +1423,22 @@ int intel_master_startup(struct platform_device *pdev) ...@@ -1422,6 +1423,22 @@ int intel_master_startup(struct platform_device *pdev)
pm_runtime_enable(dev); pm_runtime_enable(dev);
} }
/*
* The runtime PM status of Slave devices is "Unsupported"
* until they report as ATTACHED. If they don't, e.g. because
* there are no Slave devices populated or if the power-on is
* delayed or dependent on a power switch, the Master will
* remain active and prevent its parent from suspending.
*
* Conditionally force the pm_runtime core to re-evaluate the
* Master status in the absence of any Slave activity. A quirk
* is provided to e.g. deal with Slaves that may be powered on
* with a delay. A more complete solution would require the
* definition of Master properties.
*/
if (!(link_flags & SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE))
pm_runtime_idle(dev);
return 0; return 0;
err_interrupt: err_interrupt:
...@@ -1561,6 +1578,7 @@ static int intel_resume(struct device *dev) ...@@ -1561,6 +1578,7 @@ static int intel_resume(struct device *dev)
struct sdw_cdns *cdns = dev_get_drvdata(dev); struct sdw_cdns *cdns = dev_get_drvdata(dev);
struct sdw_intel *sdw = cdns_to_intel(cdns); struct sdw_intel *sdw = cdns_to_intel(cdns);
struct sdw_bus *bus = &cdns->bus; struct sdw_bus *bus = &cdns->bus;
int link_flags;
int ret; int ret;
if (bus->prop.hw_disabled) { if (bus->prop.hw_disabled) {
...@@ -1577,6 +1595,10 @@ static int intel_resume(struct device *dev) ...@@ -1577,6 +1595,10 @@ static int intel_resume(struct device *dev)
pm_runtime_set_active(dev); pm_runtime_set_active(dev);
pm_runtime_mark_last_busy(dev); pm_runtime_mark_last_busy(dev);
pm_runtime_enable(dev); pm_runtime_enable(dev);
link_flags = md_flags >> (bus->link_id * 8);
if (!(link_flags & SDW_INTEL_MASTER_DISABLE_PM_RUNTIME_IDLE))
pm_runtime_idle(dev);
} }
ret = intel_init(sdw); ret = intel_init(sdw);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment