soundwire: cadence: re-check Peripheral status with delayed_work
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Mon, 5 Aug 2024 11:49:21 +0000 (19:49 +0800)
committerVinod Koul <vkoul@kernel.org>
Sun, 18 Aug 2024 06:44:24 +0000 (12:14 +0530)
commitf8c35d61ba01afa76846905c67862cdace7f66b0
tree5e9b99b439c5852f5a957bdddceb8b3f34756952
parent663229e24255883f010ae4d94f9f8e9c34e57d6c
soundwire: cadence: re-check Peripheral status with delayed_work

The SoundWire peripheral enumeration is entirely based on interrupts,
more specifically sticky bits tracking state changes.

This patch adds a defensive programming check on the actual status
reported in PING frames. If for some reason an interrupt was lost or
delayed, the delayed work would detect a peripheral change of status
after the bus starts.

The 100ms defined for the delay is not completely arbitrary, if a
Peripheral didn't join the bus within that delay then probably the
hardware link is broken, and conversely if the detection didn't happen
because of software issues the 100ms is still acceptable in terms of
user experience.

The overhead of the one-shot workqueue is minimal, and the mutual
exclusion ensures that the interrupt and delayed work cannot update
the status concurrently.

Reviewed-by: Liam Girdwood <liam.r.girdwood@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20240805114921.88007-1-yung-chuan.liao@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/soundwire/cadence_master.c
drivers/soundwire/cadence_master.h
drivers/soundwire/intel.h
drivers/soundwire/intel_auxdevice.c
drivers/soundwire/intel_bus_common.c