[PATCH v2 0/2] Add SoundWire detach helper

Charles Keepax posted 2 patches 3 weeks, 4 days ago
There is a newer version of this series
drivers/mfd/cs42l43-sdw.c     |  2 --
drivers/mfd/cs42l43.c         | 15 +--------------
drivers/soundwire/bus.h       |  6 ------
include/linux/mfd/cs42l43.h   |  1 -
include/linux/soundwire/sdw.h | 26 ++++++++++++++++++++++++++
5 files changed, 27 insertions(+), 23 deletions(-)
[PATCH v2 0/2] Add SoundWire detach helper
Posted by Charles Keepax 3 weeks, 4 days ago
Currently, if a SoundWire driver takes an action that causes the device
to detach from the bus it needs to be careful. There will be a period of
time until the detach is recognised by the core, if the driver
immediately
calls sdw_slave_wait_for_init() it is possible for that to complete
before the detach has been recognised. Leaving the driver with a device
that is potentially not ready for what follows.

To avoid this race add a new helper that drivers can use to inform the
core the device will detach. This clears the enumeration completions
ensuring that sdw_slave_wait_for_init() can't complete until the device
re-attaches.

This is the third part of a longer series of moving these slave
attach/deatach operations into the core:

https://lore.kernel.org/linux-sound/20260512103022.1154645-1-ckeepax@opensource.cirrus.com/
https://lore.kernel.org/linux-sound/20260608102714.2503120-1-ckeepax@opensource.cirrus.com/

I have based this series off Vinod's soundwire tree as that probably
makes sense for which tree to take it through.

Thanks,
Charles

Changes since v1:
 - Correct kerneldoc

Charles Keepax (2):
  soundwire: Add a helper function to indicate a device will detach
  mfd: cs42l43: Move to core detach helper

 drivers/mfd/cs42l43-sdw.c     |  2 --
 drivers/mfd/cs42l43.c         | 15 +--------------
 drivers/soundwire/bus.h       |  6 ------
 include/linux/mfd/cs42l43.h   |  1 -
 include/linux/soundwire/sdw.h | 26 ++++++++++++++++++++++++++
 5 files changed, 27 insertions(+), 23 deletions(-)

-- 
2.47.3
Re: [PATCH v2 0/2] Add SoundWire detach helper
Posted by Lee Jones 1 week, 2 days ago
On Mon, 31 Aug 2026, Charles Keepax wrote:

> Currently, if a SoundWire driver takes an action that causes the device
> to detach from the bus it needs to be careful. There will be a period of
> time until the detach is recognised by the core, if the driver
> immediately
> calls sdw_slave_wait_for_init() it is possible for that to complete
> before the detach has been recognised. Leaving the driver with a device
> that is potentially not ready for what follows.
> 
> To avoid this race add a new helper that drivers can use to inform the
> core the device will detach. This clears the enumeration completions
> ensuring that sdw_slave_wait_for_init() can't complete until the device
> re-attaches.
> 
> This is the third part of a longer series of moving these slave
> attach/deatach operations into the core:
> 
> https://lore.kernel.org/linux-sound/20260512103022.1154645-1-ckeepax@opensource.cirrus.com/
> https://lore.kernel.org/linux-sound/20260608102714.2503120-1-ckeepax@opensource.cirrus.com/
> 
> I have based this series off Vinod's soundwire tree as that probably
> makes sense for which tree to take it through.
> 
> Thanks,
> Charles
> 
> Changes since v1:
>  - Correct kerneldoc
> 
> Charles Keepax (2):
>   soundwire: Add a helper function to indicate a device will detach
>   mfd: cs42l43: Move to core detach helper
> 
>  drivers/mfd/cs42l43-sdw.c     |  2 --
>  drivers/mfd/cs42l43.c         | 15 +--------------
>  drivers/soundwire/bus.h       |  6 ------
>  include/linux/mfd/cs42l43.h   |  1 -
>  include/linux/soundwire/sdw.h | 26 ++++++++++++++++++++++++++
>  5 files changed, 27 insertions(+), 23 deletions(-)

I can take the set with a Soundwire Ack.

-- 
Lee Jones
Re: [PATCH v2 0/2] Add SoundWire detach helper
Posted by Pierre-Louis Bossart 3 weeks, 1 day ago
On 8/31/26 16:01, Charles Keepax wrote:
> Currently, if a SoundWire driver takes an action that causes the device
> to detach from the bus it needs to be careful. There will be a period of
> time until the detach is recognised by the core, if the driver
> immediately
> calls sdw_slave_wait_for_init() it is possible for that to complete
> before the detach has been recognised. Leaving the driver with a device
> that is potentially not ready for what follows.
> 
> To avoid this race add a new helper that drivers can use to inform the
> core the device will detach. This clears the enumeration completions
> ensuring that sdw_slave_wait_for_init() can't complete until the device
> re-attaches.
> 
> This is the third part of a longer series of moving these slave
> attach/deatach operations into the core:
> 
> https://lore.kernel.org/linux-sound/20260512103022.1154645-1-ckeepax@opensource.cirrus.com/
> https://lore.kernel.org/linux-sound/20260608102714.2503120-1-ckeepax@opensource.cirrus.com/
> 
> I have based this series off Vinod's soundwire tree as that probably
> makes sense for which tree to take it through.
> 
> Thanks,
> Charles
> 
> Changes since v1:
>  - Correct kerneldoc
> 
> Charles Keepax (2):
>   soundwire: Add a helper function to indicate a device will detach
>   mfd: cs42l43: Move to core detach helper
> 
>  drivers/mfd/cs42l43-sdw.c     |  2 --
>  drivers/mfd/cs42l43.c         | 15 +--------------
>  drivers/soundwire/bus.h       |  6 ------
>  include/linux/mfd/cs42l43.h   |  1 -
>  include/linux/soundwire/sdw.h | 26 ++++++++++++++++++++++++++
>  5 files changed, 27 insertions(+), 23 deletions(-)

LGTM, for the series

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>