Skip to content

Commit feb09fa

Browse files
plbossartcujomalainey
authored andcommitted
UPSTREAM: soundwire: sdw_slave: track unattach_request to handle all init sequences
The Slave device initialization can be split in 4 different cases: 1. Master-initiated hardware reset, system suspend-resume and pm_runtime based on clock-stop mode1. To avoid timeouts and a bad audio experience, the Slave device resume operations need to wait for the Slave device to be re-enumerated and its settings restored. 2. Exit from clock-stop mode0. In this case, the Slave device is required to remain enumerated and its context preserved while the clock is stopped, so no re-initialization or wait_for_completion() is necessary. 3. Slave-initiated pm_runtime D3 transition. With the parent child relationship, it is possible that a Slave device becomes 'suspended' while its parent is still 'active' with the bus clock still toggling. In this case, during the pm_runtime resume operation, there is no need to wait for any settings to be restored. 4. Slave reset (sync loss or implementation-defined). In that case the bus remains operational and the Slave device will be re-initialized when it becomes ATTACHED again. In previous patches, we suggested the use of wait_for_completion() to deal with the case #1, but case #2 and #3 do not need any wait. To account for those differences, this patch adds an unattach_request field. The field is explicitly set by the Master for the case #1, and if non-zero the Slave device shall wait on resume. In all other cases, the Slave resume operations can proceed without wait. The only request tracked so far is Master HardReset, but the request is declared as a bit mask for future extensions (if needed). The definition for this value is added in bus.h and does not need to be exposed in sdw.h Signed-off-by: Pierre-Louis Bossart <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]> (cherry picked from commit b2bd75f) Signed-off-by: Chintan Patel <[email protected]> BUG=b:153422295 TEST=No audio regression on TGL/JSL devices Signed-off-by: Curtis Malainey <[email protected]>
1 parent 4bfe4e7 commit feb09fa

File tree

1 file changed

+6
-0
lines changed
  • include/linux/soundwire

1 file changed

+6
-0
lines changed

include/linux/soundwire/sdw.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,11 @@ struct sdw_slave_ops {
556556
* Slave device
557557
* @initialization_complete: completion utility to control potential races
558558
* on startup between device enumeration and settings being restored
559+
* @unattach_request: mask field to keep track why the Slave re-attached and
560+
* was re-initialized. This is useful to deal with potential race conditions
561+
* between the Master suspending and the codec resuming, and make sure that
562+
* when the Master triggered a reset the Slave is properly enumerated and
563+
* initialized
559564
*/
560565
struct sdw_slave {
561566
struct sdw_slave_id id;
@@ -574,6 +579,7 @@ struct sdw_slave {
574579
struct completion probe_complete;
575580
struct completion enumeration_complete;
576581
struct completion initialization_complete;
582+
u32 unattach_request;
577583
};
578584

579585
#define dev_to_sdw_dev(_dev) container_of(_dev, struct sdw_slave, dev)

0 commit comments

Comments
 (0)