summaryrefslogtreecommitdiffstats
path: root/drivers/soundwire/bus_type.c
diff options
context:
space:
mode:
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>2020-01-14 18:08:35 -0600
committerVinod Koul <vkoul@kernel.org>2020-02-25 15:57:01 +0530
commit2140b66b5d3ecf6c7c0fa9dc5eebb41855765ace (patch)
tree81685de05051ea3febde16436dfbace43dfec4de /drivers/soundwire/bus_type.c
parenteff346f24ba97c3a7c16261d3157adf61ac8960c (diff)
downloadlinux-2140b66b5d3ecf6c7c0fa9dc5eebb41855765ace.tar.bz2
soundwire: bus: fix race condition with probe_complete signaling
The driver probe takes care of basic initialization and is invoked when a Slave becomes attached, after a match between the Slave DevID registers and ACPI/DT entries. The update_status callback is invoked when a Slave state changes, e.g. when it is assigned a non-zero Device Number and it reports with an ATTACHED/ALERT state. The state change detection is usually hardware-based and based on the SoundWire frame rate (e.g. double-digit microseconds) while the probe is a pure software operation, which may involve a kernel module load. In corner cases, it's possible that the state changes before the probe completes. This patch suggests the use of wait_for_completion to avoid races on startup, so that the update_status callback does not rely on invalid pointers/data structures. Signed-off-by: Rander Wang <rander.wang@intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20200115000844.14695-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/soundwire/bus_type.c')
-rw-r--r--drivers/soundwire/bus_type.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c
index 4a465f55039f..17f096dd6806 100644
--- a/drivers/soundwire/bus_type.c
+++ b/drivers/soundwire/bus_type.c
@@ -110,6 +110,11 @@ static int sdw_drv_probe(struct device *dev)
slave->bus->clk_stop_timeout = max_t(u32, slave->bus->clk_stop_timeout,
slave->prop.clk_stop_timeout);
+ slave->probed = true;
+ complete(&slave->probe_complete);
+
+ dev_dbg(dev, "probe complete\n");
+
return 0;
}