From c4df5316340d4f60bccfe5f618c794a5b8fba25b Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Fri, 23 Oct 2020 11:32:14 +0800 Subject: [PATCH] soundwire: intel: waiting for all Slaves be attached Everything should be ready when resume function returns. Signed-off-by: Bard Liao --- drivers/soundwire/intel.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/soundwire/intel.c b/drivers/soundwire/intel.c index 6a1e862b16c38c..8939c7a8126972 100644 --- a/drivers/soundwire/intel.c +++ b/drivers/soundwire/intel.c @@ -1708,6 +1708,8 @@ static int __maybe_unused intel_resume(struct device *dev) struct sdw_cdns *cdns = dev_get_drvdata(dev); struct sdw_intel *sdw = cdns_to_intel(cdns); struct sdw_bus *bus = &cdns->bus; + struct sdw_slave *slave; + unsigned long time; int link_flags; bool multi_link; int ret; @@ -1781,6 +1783,18 @@ static int __maybe_unused intel_resume(struct device *dev) } } + /* Waiting for all Slaves be attached */ + list_for_each_entry(slave, &bus->slaves, node) { + if (!slave->unattach_request) + continue; + time = wait_for_completion_timeout(&slave->enumeration_complete, + 500); + if (!time) { + dev_err(&slave->dev, "enumeration not complete, timed out\n"); + return -ETIMEDOUT; + } + } + /* * after system resume, the pm_runtime suspend() may kick in * during the enumeration, before any children device force the @@ -1801,6 +1815,8 @@ static int intel_resume_runtime(struct device *dev) struct sdw_cdns *cdns = dev_get_drvdata(dev); struct sdw_intel *sdw = cdns_to_intel(cdns); struct sdw_bus *bus = &cdns->bus; + struct sdw_slave *slave; + unsigned long time; u32 clock_stop_quirks; bool clock_stop0; int link_flags; @@ -1966,6 +1982,18 @@ static int intel_resume_runtime(struct device *dev) ret = -EINVAL; } + /* Waiting for all Slaves be attached */ + list_for_each_entry(slave, &bus->slaves, node) { + if (!slave->unattach_request) + continue; + time = wait_for_completion_timeout(&slave->enumeration_complete, + 500); + if (!time) { + dev_err(&slave->dev, "enumeration not complete, timed out\n"); + return -ETIMEDOUT; + } + } + return ret; }