Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
* [PATCH 00/10] Expand SoundWire enumeration helper coverage
@ 2026-06-03 14:44 Charles Keepax
  2026-06-03 14:44 ` [PATCH 01/10] soundwire: Always wait for initialisation of unattached devices Charles Keepax
                   ` (9 more replies)
  0 siblings, 10 replies; 16+ messages in thread
From: Charles Keepax @ 2026-06-03 14:44 UTC (permalink / raw)
  To: broonie, vkoul, lee
  Cc: lgirdwood, pierre-louis.bossart, yung-chuan.liao, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, srini, linux-sound, linux-arm-msm,
	linux-kernel, patches

The patch series in [1] added a new helper to remove common boiler plate
waiting for a device to enumerate on SoundWire, however, many devices
also wait for enumeration during probe. This series updates things to be
suitable such that we can call the same helper at probe time when the
unattach_request is not valid.

There is one final step outstanding which is to add a core helper
that waits for a device to drop off the bus. This is not include
in this series and should be the last step of this process.

Thanks,
Charles

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

Charles Keepax (10):
  soundwire: Always wait for initialisation of unattached devices
  ASoC: wsa881x: Use new SoundWire enumeration helper
  mfd: cs42l43: Use new SoundWire enumeration helper
  ASoC: rt5682: Use new SoundWire enumeration helper
  ASoC: pm4125: Use new SoundWire enumeration helper
  ASoC: wcd937x: Use new SoundWire enumeration helper
  ASoC: wcd938x: Use new SoundWire enumeration helper
  ASoC: wcd939x: Use new SoundWire enumeration helper
  ASoC: SDCA: Use new SoundWire enumeration helper
  ASoC: cs35l56: Remove unnecessary conditionals waiting for enumeration

 drivers/mfd/cs42l43-sdw.c      |  3 --
 drivers/mfd/cs42l43.c          | 15 ++++------
 drivers/soundwire/bus.c        |  3 --
 include/linux/mfd/cs42l43.h    |  1 -
 sound/soc/codecs/cs35l56-sdw.c | 47 +++++++-----------------------
 sound/soc/codecs/cs35l56.h     |  1 -
 sound/soc/codecs/pm4125.c      | 11 ++-----
 sound/soc/codecs/rt5682.c      | 14 +++------
 sound/soc/codecs/wcd937x.c     | 11 ++-----
 sound/soc/codecs/wcd938x.c     | 11 ++-----
 sound/soc/codecs/wcd939x.c     | 11 ++-----
 sound/soc/codecs/wsa881x.c     | 10 +++----
 sound/soc/sdca/sdca_class.c    | 53 ++++------------------------------
 sound/soc/sdca/sdca_class.h    |  3 --
 14 files changed, 41 insertions(+), 153 deletions(-)

-- 
2.47.3


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 01/10] soundwire: Always wait for initialisation of unattached devices
  2026-06-03 14:44 [PATCH 00/10] Expand SoundWire enumeration helper coverage Charles Keepax
@ 2026-06-03 14:44 ` Charles Keepax
  2026-06-04  6:44   ` Vinod Koul
  2026-06-03 14:44 ` [PATCH 02/10] ASoC: wsa881x: Use new SoundWire enumeration helper Charles Keepax
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: Charles Keepax @ 2026-06-03 14:44 UTC (permalink / raw)
  To: broonie, vkoul, lee
  Cc: lgirdwood, pierre-louis.bossart, yung-chuan.liao, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, srini, linux-sound, linux-arm-msm,
	linux-kernel, patches

Currently in sdw_slave_wait_for_init() the waiting can be skipped
if unattach_request is not set. Doing so was added in [1] likely
because the core used to do a complete() on the completion so
waiting in the case an unattach hadn't actually happened would
block for the full timeout. However patch [2] updated the core to
use complete_all() which means that the wait_for_completion() will
now simply return if the device is already attached skipping the
completion doesn't add much.

Additionally, unatttach_request is only set if the host initiates
a bus reset. However, the host doing a bus reset is not the only
reason a device may be unattached from the bus. Other options
could include the driver probing before the device enumerates, a
sync-loss, or the device itself powering down.

Removing the skip using unattached_request, doesn't cost much in
terms of efficiency and allows the sdw_slave_wiat_for_init() helper
to be used outside of runtime resume.

[1] b2bd75f806c4 ("soundwire: sdw_slave: track unattach_request to handle all init sequences")
[2] c40d6b3249b1 ("soundwire: fix enumeration completion")
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 drivers/soundwire/bus.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
index ea3a24f805c00..b7bdf19ebb42e 100644
--- a/drivers/soundwire/bus.c
+++ b/drivers/soundwire/bus.c
@@ -1386,9 +1386,6 @@ int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout_ms)
 {
 	unsigned long time;
 
-	if (!slave->unattach_request)
-		return 0;
-
 	time = wait_for_completion_timeout(&slave->initialization_complete,
 					   msecs_to_jiffies(timeout_ms));
 	if (!time) {
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 02/10] ASoC: wsa881x: Use new SoundWire enumeration helper
  2026-06-03 14:44 [PATCH 00/10] Expand SoundWire enumeration helper coverage Charles Keepax
  2026-06-03 14:44 ` [PATCH 01/10] soundwire: Always wait for initialisation of unattached devices Charles Keepax
@ 2026-06-03 14:44 ` Charles Keepax
  2026-06-03 14:44 ` [PATCH 03/10] mfd: cs42l43: " Charles Keepax
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Charles Keepax @ 2026-06-03 14:44 UTC (permalink / raw)
  To: broonie, vkoul, lee
  Cc: lgirdwood, pierre-louis.bossart, yung-chuan.liao, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, srini, linux-sound, linux-arm-msm,
	linux-kernel, patches

Now the new wait for SoundWire enumeration helper no longer depends on
unattach_request it can be used for code that also doesn't check this
flag. Update the driver to use the new core helper.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/wsa881x.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/sound/soc/codecs/wsa881x.c b/sound/soc/codecs/wsa881x.c
index d15fda648dada..5174614c3e837 100644
--- a/sound/soc/codecs/wsa881x.c
+++ b/sound/soc/codecs/wsa881x.c
@@ -1167,16 +1167,14 @@ static int wsa881x_runtime_resume(struct device *dev)
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct regmap *regmap = dev_get_regmap(dev, NULL);
 	struct wsa881x_priv *wsa881x = dev_get_drvdata(dev);
-	unsigned long time;
+	int ret;
 
 	gpiod_direction_output(wsa881x->sd_n, 0);
 
-	time = wait_for_completion_timeout(&slave->initialization_complete,
-					   msecs_to_jiffies(WSA881X_PROBE_TIMEOUT));
-	if (!time) {
-		dev_err(dev, "Initialization not complete, timed out\n");
+	ret = sdw_slave_wait_for_init(slave, WSA881X_PROBE_TIMEOUT);
+	if (ret) {
 		gpiod_direction_output(wsa881x->sd_n, 1);
-		return -ETIMEDOUT;
+		return ret;
 	}
 
 	regcache_cache_only(regmap, false);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 03/10] mfd: cs42l43: Use new SoundWire enumeration helper
  2026-06-03 14:44 [PATCH 00/10] Expand SoundWire enumeration helper coverage Charles Keepax
  2026-06-03 14:44 ` [PATCH 01/10] soundwire: Always wait for initialisation of unattached devices Charles Keepax
  2026-06-03 14:44 ` [PATCH 02/10] ASoC: wsa881x: Use new SoundWire enumeration helper Charles Keepax
@ 2026-06-03 14:44 ` Charles Keepax
  2026-06-04 11:04   ` Mark Brown
  2026-06-03 14:44 ` [PATCH 04/10] ASoC: rt5682: " Charles Keepax
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: Charles Keepax @ 2026-06-03 14:44 UTC (permalink / raw)
  To: broonie, vkoul, lee
  Cc: lgirdwood, pierre-louis.bossart, yung-chuan.liao, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, srini, linux-sound, linux-arm-msm,
	linux-kernel, patches

Now the new wait for SoundWire enumeration helper no longer depends on
unattach_request it is safe to use from probe time. Update the driver
to use the new core helper.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 drivers/mfd/cs42l43-sdw.c   |  3 ---
 drivers/mfd/cs42l43.c       | 15 ++++++---------
 include/linux/mfd/cs42l43.h |  1 -
 3 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/mfd/cs42l43-sdw.c b/drivers/mfd/cs42l43-sdw.c
index 794c983781750..2c890a4315438 100644
--- a/drivers/mfd/cs42l43-sdw.c
+++ b/drivers/mfd/cs42l43-sdw.c
@@ -102,15 +102,12 @@ static int cs42l43_sdw_update_status(struct sdw_slave *sdw, enum sdw_slave_statu
 				CS42L43_INT_STAT_GEN1_MASK);
 
 		cs42l43->attached = true;
-
-		complete(&cs42l43->device_attach);
 		break;
 	case SDW_SLAVE_UNATTACHED:
 		dev_dbg(cs42l43->dev, "Device detach\n");
 
 		cs42l43->attached = false;
 
-		reinit_completion(&cs42l43->device_attach);
 		complete(&cs42l43->device_detach);
 		break;
 	default:
diff --git a/drivers/mfd/cs42l43.c b/drivers/mfd/cs42l43.c
index 166881751e698..cb1e175586bd1 100644
--- a/drivers/mfd/cs42l43.c
+++ b/drivers/mfd/cs42l43.c
@@ -586,15 +586,13 @@ static int cs42l43_soft_reset(struct cs42l43 *cs42l43)
  */
 static int cs42l43_wait_for_attach(struct cs42l43 *cs42l43)
 {
-	if (!cs42l43->attached) {
-		unsigned long timeout = msecs_to_jiffies(CS42L43_SDW_ATTACH_TIMEOUT_MS);
-		unsigned long time;
+	int ret;
 
-		time = wait_for_completion_timeout(&cs42l43->device_attach, timeout);
-		if (!time) {
-			dev_err(cs42l43->dev, "Timed out waiting for device re-attach\n");
-			return -ETIMEDOUT;
-		}
+	if (cs42l43->sdw) {
+		ret = sdw_slave_wait_for_init(cs42l43->sdw,
+					      CS42L43_SDW_ATTACH_TIMEOUT_MS);
+		if (ret)
+			return ret;
 	}
 
 	regcache_cache_only(cs42l43->regmap, false);
@@ -1120,7 +1118,6 @@ int cs42l43_dev_probe(struct cs42l43 *cs42l43)
 	dev_set_drvdata(cs42l43->dev, cs42l43);
 
 	mutex_init(&cs42l43->pll_lock);
-	init_completion(&cs42l43->device_attach);
 	init_completion(&cs42l43->device_detach);
 	init_completion(&cs42l43->firmware_download);
 	INIT_WORK(&cs42l43->boot_work, cs42l43_boot_work);
diff --git a/include/linux/mfd/cs42l43.h b/include/linux/mfd/cs42l43.h
index ff0f7e365a19f..5f5c043e7cab9 100644
--- a/include/linux/mfd/cs42l43.h
+++ b/include/linux/mfd/cs42l43.h
@@ -86,7 +86,6 @@ struct cs42l43 {
 	struct regmap_irq_chip_data *irq_data;
 
 	struct work_struct boot_work;
-	struct completion device_attach;
 	struct completion device_detach;
 	struct completion firmware_download;
 	int firmware_error;
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 04/10] ASoC: rt5682: Use new SoundWire enumeration helper
  2026-06-03 14:44 [PATCH 00/10] Expand SoundWire enumeration helper coverage Charles Keepax
                   ` (2 preceding siblings ...)
  2026-06-03 14:44 ` [PATCH 03/10] mfd: cs42l43: " Charles Keepax
@ 2026-06-03 14:44 ` Charles Keepax
  2026-06-04 11:05   ` Mark Brown
  2026-06-03 14:44 ` [PATCH 05/10] ASoC: pm4125: " Charles Keepax
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: Charles Keepax @ 2026-06-03 14:44 UTC (permalink / raw)
  To: broonie, vkoul, lee
  Cc: lgirdwood, pierre-louis.bossart, yung-chuan.liao, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, srini, linux-sound, linux-arm-msm,
	linux-kernel, patches

Now the new wait for SoundWire enumeration helper no longer depends on
unattach_request it is safe to use from probe time. Update the driver
to use the new core helper.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/rt5682.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index d39f8e4f3474c..4b82e07d3b2c7 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -2929,20 +2929,14 @@ static int rt5682_probe(struct snd_soc_component *component)
 {
 	struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
 	struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component);
-	struct sdw_slave *slave;
-	unsigned long time;
+	int ret;
 
 	rt5682->component = component;
 
 	if (rt5682->is_sdw) {
-		slave = rt5682->slave;
-		time = wait_for_completion_timeout(
-			&slave->initialization_complete,
-			msecs_to_jiffies(RT5682_PROBE_TIMEOUT));
-		if (!time) {
-			dev_err(&slave->dev, "Initialization not complete, timed out\n");
-			return -ETIMEDOUT;
-		}
+		ret = sdw_slave_wait_for_init(rt5682->slave, RT5682_PROBE_TIMEOUT);
+		if (ret)
+			return ret;
 	}
 
 	snd_soc_dapm_disable_pin(dapm, "MICBIAS");
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 05/10] ASoC: pm4125: Use new SoundWire enumeration helper
  2026-06-03 14:44 [PATCH 00/10] Expand SoundWire enumeration helper coverage Charles Keepax
                   ` (3 preceding siblings ...)
  2026-06-03 14:44 ` [PATCH 04/10] ASoC: rt5682: " Charles Keepax
@ 2026-06-03 14:44 ` Charles Keepax
  2026-06-03 14:44 ` [PATCH 06/10] ASoC: wcd937x: " Charles Keepax
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Charles Keepax @ 2026-06-03 14:44 UTC (permalink / raw)
  To: broonie, vkoul, lee
  Cc: lgirdwood, pierre-louis.bossart, yung-chuan.liao, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, srini, linux-sound, linux-arm-msm,
	linux-kernel, patches

Now the new wait for SoundWire enumeration helper no longer depends on
unattach_request it is safe to use from probe time. Update the driver
to use the new core helper.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/pm4125.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/pm4125.c b/sound/soc/codecs/pm4125.c
index 1f0a3f5389f1b..29655175ea289 100644
--- a/sound/soc/codecs/pm4125.c
+++ b/sound/soc/codecs/pm4125.c
@@ -1309,17 +1309,12 @@ static int pm4125_irq_init(struct pm4125_priv *pm4125, struct device *dev)
 static int pm4125_soc_codec_probe(struct snd_soc_component *component)
 {
 	struct pm4125_priv *pm4125 = snd_soc_component_get_drvdata(component);
-	struct sdw_slave *tx_sdw_dev = pm4125->tx_sdw_dev;
 	struct device *dev = component->dev;
-	unsigned long time_left;
 	int i, ret;
 
-	time_left = wait_for_completion_timeout(&tx_sdw_dev->initialization_complete,
-						msecs_to_jiffies(5000));
-	if (!time_left) {
-		dev_err(dev, "soundwire device init timeout\n");
-		return -ETIMEDOUT;
-	}
+	ret = sdw_slave_wait_for_init(pm4125->tx_sdw_dev, 5000);
+	if (ret)
+		return ret;
 
 	snd_soc_component_init_regmap(component, pm4125->regmap);
 	ret = pm_runtime_resume_and_get(dev);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 06/10] ASoC: wcd937x: Use new SoundWire enumeration helper
  2026-06-03 14:44 [PATCH 00/10] Expand SoundWire enumeration helper coverage Charles Keepax
                   ` (4 preceding siblings ...)
  2026-06-03 14:44 ` [PATCH 05/10] ASoC: pm4125: " Charles Keepax
@ 2026-06-03 14:44 ` Charles Keepax
  2026-06-03 14:44 ` [PATCH 07/10] ASoC: wcd938x: " Charles Keepax
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Charles Keepax @ 2026-06-03 14:44 UTC (permalink / raw)
  To: broonie, vkoul, lee
  Cc: lgirdwood, pierre-louis.bossart, yung-chuan.liao, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, srini, linux-sound, linux-arm-msm,
	linux-kernel, patches

Now the new wait for SoundWire enumeration helper no longer depends on
unattach_request it is safe to use from probe time. Update the driver
to use the new core helper.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/wcd937x.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/wcd937x.c b/sound/soc/codecs/wcd937x.c
index 72a53f95d6887..e0169e783ee96 100644
--- a/sound/soc/codecs/wcd937x.c
+++ b/sound/soc/codecs/wcd937x.c
@@ -2499,18 +2499,13 @@ static int wcd937x_soc_codec_probe(struct snd_soc_component *component)
 {
 	struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component);
 	struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component);
-	struct sdw_slave *tx_sdw_dev = wcd937x->tx_sdw_dev;
 	struct device *dev = component->dev;
-	unsigned long time_left;
 	int i, ret;
 	u32 chipid;
 
-	time_left = wait_for_completion_timeout(&tx_sdw_dev->initialization_complete,
-						msecs_to_jiffies(5000));
-	if (!time_left) {
-		dev_err(dev, "soundwire device init timeout\n");
-		return -ETIMEDOUT;
-	}
+	ret = sdw_slave_wait_for_init(wcd937x->tx_sdw_dev, 5000);
+	if (ret)
+		return ret;
 
 	snd_soc_component_init_regmap(component, wcd937x->regmap);
 	ret = pm_runtime_resume_and_get(dev);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 07/10] ASoC: wcd938x: Use new SoundWire enumeration helper
  2026-06-03 14:44 [PATCH 00/10] Expand SoundWire enumeration helper coverage Charles Keepax
                   ` (5 preceding siblings ...)
  2026-06-03 14:44 ` [PATCH 06/10] ASoC: wcd937x: " Charles Keepax
@ 2026-06-03 14:44 ` Charles Keepax
  2026-06-03 14:44 ` [PATCH 08/10] ASoC: wcd939x: " Charles Keepax
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Charles Keepax @ 2026-06-03 14:44 UTC (permalink / raw)
  To: broonie, vkoul, lee
  Cc: lgirdwood, pierre-louis.bossart, yung-chuan.liao, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, srini, linux-sound, linux-arm-msm,
	linux-kernel, patches

Now the new wait for SoundWire enumeration helper no longer depends on
unattach_request it is safe to use from probe time. Update the driver
to use the new core helper.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/wcd938x.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c
index cb0a0bfdb6e32..c69e18667a85b 100644
--- a/sound/soc/codecs/wcd938x.c
+++ b/sound/soc/codecs/wcd938x.c
@@ -3016,18 +3016,13 @@ static int wcd938x_irq_init(struct wcd938x_priv *wcd, struct device *dev)
 static int wcd938x_soc_codec_probe(struct snd_soc_component *component)
 {
 	struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
-	struct sdw_slave *tx_sdw_dev = wcd938x->tx_sdw_dev;
 	struct device *dev = component->dev;
-	unsigned long time_left;
 	unsigned int variant;
 	int ret, i;
 
-	time_left = wait_for_completion_timeout(&tx_sdw_dev->initialization_complete,
-						msecs_to_jiffies(2000));
-	if (!time_left) {
-		dev_err(dev, "soundwire device init timeout\n");
-		return -ETIMEDOUT;
-	}
+	ret = sdw_slave_wait_for_init(wcd938x->tx_sdw_dev, 2000);
+	if (ret)
+		return ret;
 
 	snd_soc_component_init_regmap(component, wcd938x->regmap);
 
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 08/10] ASoC: wcd939x: Use new SoundWire enumeration helper
  2026-06-03 14:44 [PATCH 00/10] Expand SoundWire enumeration helper coverage Charles Keepax
                   ` (6 preceding siblings ...)
  2026-06-03 14:44 ` [PATCH 07/10] ASoC: wcd938x: " Charles Keepax
@ 2026-06-03 14:44 ` Charles Keepax
  2026-06-03 14:44 ` [PATCH 09/10] ASoC: SDCA: " Charles Keepax
  2026-06-03 14:44 ` [PATCH 10/10] ASoC: cs35l56: Remove unnecessary conditionals waiting for enumeration Charles Keepax
  9 siblings, 0 replies; 16+ messages in thread
From: Charles Keepax @ 2026-06-03 14:44 UTC (permalink / raw)
  To: broonie, vkoul, lee
  Cc: lgirdwood, pierre-louis.bossart, yung-chuan.liao, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, srini, linux-sound, linux-arm-msm,
	linux-kernel, patches

Now the new wait for SoundWire enumeration helper no longer depends on
unattach_request it is safe to use from probe time. Update the driver
to use the new core helper.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/wcd939x.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/wcd939x.c b/sound/soc/codecs/wcd939x.c
index 01f1a08f48e65..010d124667224 100644
--- a/sound/soc/codecs/wcd939x.c
+++ b/sound/soc/codecs/wcd939x.c
@@ -2968,17 +2968,12 @@ static int wcd939x_irq_init(struct wcd939x_priv *wcd, struct device *dev)
 static int wcd939x_soc_codec_probe(struct snd_soc_component *component)
 {
 	struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component);
-	struct sdw_slave *tx_sdw_dev = wcd939x->tx_sdw_dev;
 	struct device *dev = component->dev;
-	unsigned long time_left;
 	int ret, i;
 
-	time_left = wait_for_completion_timeout(&tx_sdw_dev->initialization_complete,
-						msecs_to_jiffies(2000));
-	if (!time_left) {
-		dev_err(dev, "soundwire device init timeout\n");
-		return -ETIMEDOUT;
-	}
+	ret = sdw_slave_wait_for_init(wcd939x->tx_sdw_dev, 2000);
+	if (ret)
+		return ret;
 
 	snd_soc_component_init_regmap(component, wcd939x->regmap);
 
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 09/10] ASoC: SDCA: Use new SoundWire enumeration helper
  2026-06-03 14:44 [PATCH 00/10] Expand SoundWire enumeration helper coverage Charles Keepax
                   ` (7 preceding siblings ...)
  2026-06-03 14:44 ` [PATCH 08/10] ASoC: wcd939x: " Charles Keepax
@ 2026-06-03 14:44 ` Charles Keepax
  2026-06-03 14:44 ` [PATCH 10/10] ASoC: cs35l56: Remove unnecessary conditionals waiting for enumeration Charles Keepax
  9 siblings, 0 replies; 16+ messages in thread
From: Charles Keepax @ 2026-06-03 14:44 UTC (permalink / raw)
  To: broonie, vkoul, lee
  Cc: lgirdwood, pierre-louis.bossart, yung-chuan.liao, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, srini, linux-sound, linux-arm-msm,
	linux-kernel, patches

Now the new wait for SoundWire enumeration helper no longer depends on
unattach_request it is safe to use from probe time. Update the driver
to use the new core helper.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/sdca/sdca_class.c | 53 ++++---------------------------------
 sound/soc/sdca/sdca_class.h |  3 ---
 2 files changed, 5 insertions(+), 51 deletions(-)

diff --git a/sound/soc/sdca/sdca_class.c b/sound/soc/sdca/sdca_class.c
index a6a3da8de4371..6937a91ddfb9b 100644
--- a/sound/soc/sdca/sdca_class.c
+++ b/sound/soc/sdca/sdca_class.c
@@ -38,35 +38,8 @@ static int class_read_prop(struct sdw_slave *sdw)
 	return 0;
 }
 
-static int class_sdw_update_status(struct sdw_slave *sdw, enum sdw_slave_status status)
-{
-	struct sdca_class_drv *drv = dev_get_drvdata(&sdw->dev);
-
-	switch (status) {
-	case SDW_SLAVE_ATTACHED:
-		dev_dbg(drv->dev, "device attach\n");
-
-		drv->attached = true;
-
-		complete(&drv->device_attach);
-		break;
-	case SDW_SLAVE_UNATTACHED:
-		dev_dbg(drv->dev, "device detach\n");
-
-		drv->attached = false;
-
-		reinit_completion(&drv->device_attach);
-		break;
-	default:
-		break;
-	}
-
-	return 0;
-}
-
 static const struct sdw_slave_ops class_sdw_ops = {
 	.read_prop	= class_read_prop,
-	.update_status	= class_sdw_update_status,
 };
 
 static void class_regmap_lock(void *data)
@@ -83,24 +56,6 @@ static void class_regmap_unlock(void *data)
 	mutex_unlock(lock);
 }
 
-static int class_wait_for_attach(struct sdca_class_drv *drv)
-{
-	if (!drv->attached) {
-		unsigned long timeout = msecs_to_jiffies(CLASS_SDW_ATTACH_TIMEOUT_MS);
-		unsigned long time;
-
-		time = wait_for_completion_timeout(&drv->device_attach, timeout);
-		if (!time) {
-			dev_err(drv->dev, "timed out waiting for device re-attach\n");
-			return -ETIMEDOUT;
-		}
-	}
-
-	regcache_cache_only(drv->dev_regmap, false);
-
-	return 0;
-}
-
 static bool class_dev_regmap_volatile(struct device *dev, unsigned int reg)
 {
 	switch (reg) {
@@ -151,10 +106,12 @@ static void class_boot_work(struct work_struct *work)
 						  boot_work);
 	int ret;
 
-	ret = class_wait_for_attach(drv);
+	ret = sdw_slave_wait_for_init(drv->sdw, CLASS_SDW_ATTACH_TIMEOUT_MS);
 	if (ret)
 		goto err;
 
+	regcache_cache_only(drv->dev_regmap, false);
+
 	drv->irq_info = sdca_irq_allocate(drv->dev, drv->dev_regmap,
 					  drv->sdw->irq);
 	if (IS_ERR(drv->irq_info))
@@ -206,7 +163,6 @@ static int class_sdw_probe(struct sdw_slave *sdw, const struct sdw_device_id *id
 	dev_set_drvdata(drv->dev, drv);
 
 	INIT_WORK(&drv->boot_work, class_boot_work);
-	init_completion(&drv->device_attach);
 
 	dev_config->lock_arg = &drv->regmap_lock;
 
@@ -290,10 +246,11 @@ static int class_runtime_resume(struct device *dev)
 	struct sdca_class_drv *drv = dev_get_drvdata(dev);
 	int ret;
 
-	ret = class_wait_for_attach(drv);
+	ret = sdw_slave_wait_for_init(drv->sdw, CLASS_SDW_ATTACH_TIMEOUT_MS);
 	if (ret)
 		goto err;
 
+	regcache_cache_only(drv->dev_regmap, false);
 	regcache_mark_dirty(drv->dev_regmap);
 
 	ret = regcache_sync(drv->dev_regmap);
diff --git a/sound/soc/sdca/sdca_class.h b/sound/soc/sdca/sdca_class.h
index 8b63e62485e64..57f7f8d08f497 100644
--- a/sound/soc/sdca/sdca_class.h
+++ b/sound/soc/sdca/sdca_class.h
@@ -30,9 +30,6 @@ struct sdca_class_drv {
 	/* Serialise function initialisations */
 	struct mutex init_lock;
 	struct work_struct boot_work;
-	struct completion device_attach;
-
-	bool attached;
 };
 
 #endif /* __SDCA_CLASS_H__ */
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 10/10] ASoC: cs35l56: Remove unnecessary conditionals waiting for enumeration
  2026-06-03 14:44 [PATCH 00/10] Expand SoundWire enumeration helper coverage Charles Keepax
                   ` (8 preceding siblings ...)
  2026-06-03 14:44 ` [PATCH 09/10] ASoC: SDCA: " Charles Keepax
@ 2026-06-03 14:44 ` Charles Keepax
  9 siblings, 0 replies; 16+ messages in thread
From: Charles Keepax @ 2026-06-03 14:44 UTC (permalink / raw)
  To: broonie, vkoul, lee
  Cc: lgirdwood, pierre-louis.bossart, yung-chuan.liao, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, srini, linux-sound, linux-arm-msm,
	linux-kernel, patches

Commit [1] updated the core to use complete_all() which means that
the wait_for_completion() will now simply return if the device
is already attached, so skipping the completion isn't required
anymore.  Update the code to simply call sdw_slave_wait_for_init()
unconditionally.

[1] c40d6b3249b1 ("soundwire: fix enumeration completion")
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/cs35l56-sdw.c | 47 ++++++++--------------------------
 sound/soc/codecs/cs35l56.h     |  1 -
 2 files changed, 10 insertions(+), 38 deletions(-)

diff --git a/sound/soc/codecs/cs35l56-sdw.c b/sound/soc/codecs/cs35l56-sdw.c
index 847e88f3b2044..0a55b93b96f96 100644
--- a/sound/soc/codecs/cs35l56-sdw.c
+++ b/sound/soc/codecs/cs35l56-sdw.c
@@ -330,7 +330,6 @@ static int cs35l56_sdw_update_status(struct sdw_slave *peripheral,
 
 	switch (status) {
 	case SDW_SLAVE_ATTACHED:
-		cs35l56->sdw_in_clock_stop_1 = false;
 		if (cs35l56->sdw_attached)
 			break;
 
@@ -352,31 +351,10 @@ static int cs35l56_sdw_update_status(struct sdw_slave *peripheral,
 	return 0;
 }
 
-static int __maybe_unused cs35l56_sdw_clk_stop(struct sdw_slave *peripheral,
-					       enum sdw_clk_stop_mode mode,
-					       enum sdw_clk_stop_type type)
-{
-	struct cs35l56_private *cs35l56 = dev_get_drvdata(&peripheral->dev);
-
-	dev_dbg(cs35l56->base.dev, "%s: clock_stop_mode%d stage:%d\n", __func__, mode, type);
-
-	switch (type) {
-	case SDW_CLK_POST_PREPARE:
-		if (mode == SDW_CLK_STOP_MODE1)
-			cs35l56->sdw_in_clock_stop_1 = true;
-		else
-			cs35l56->sdw_in_clock_stop_1 = false;
-		return 0;
-	default:
-		return 0;
-	}
-}
-
 static const struct sdw_slave_ops cs35l56_sdw_ops = {
 	.read_prop = cs35l56_sdw_read_prop,
 	.interrupt_callback = cs35l56_sdw_interrupt,
 	.update_status = cs35l56_sdw_update_status,
-	.clk_stop = cs35l56_sdw_clk_stop,
 };
 
 static int __maybe_unused cs35l56_sdw_handle_unattach(struct cs35l56_private *cs35l56)
@@ -384,23 +362,18 @@ static int __maybe_unused cs35l56_sdw_handle_unattach(struct cs35l56_private *cs
 	struct sdw_slave *peripheral = cs35l56->sdw_peripheral;
 	int ret;
 
-	dev_dbg(cs35l56->base.dev, "attached:%u unattach_request:%u in_clock_stop_1:%u\n",
-		cs35l56->sdw_attached, peripheral->unattach_request, cs35l56->sdw_in_clock_stop_1);
+	dev_dbg(cs35l56->base.dev, "attached:%u unattach_request:%u\n",
+		cs35l56->sdw_attached, peripheral->unattach_request);
 
-	if (cs35l56->sdw_in_clock_stop_1 || peripheral->unattach_request) {
-		/* Cannot access registers until bus is re-initialized. */
-		dev_dbg(cs35l56->base.dev, "Wait for initialization_complete\n");
-		ret = sdw_slave_wait_for_init(peripheral, 5000);
-		if (ret)
-			return ret;
-
-		cs35l56->sdw_in_clock_stop_1 = false;
+	/* Cannot access registers until bus is re-initialized. */
+	ret = sdw_slave_wait_for_init(peripheral, 5000);
+	if (ret)
+		return ret;
 
-		/*
-		 * Don't call regcache_mark_dirty(), we can't be sure that the
-		 * Manager really did issue a Bus Reset.
-		 */
-	}
+	/*
+	 * Don't call regcache_mark_dirty(), we can't be sure that the
+	 * Manager really did issue a Bus Reset.
+	 */
 
 	return 0;
 }
diff --git a/sound/soc/codecs/cs35l56.h b/sound/soc/codecs/cs35l56.h
index 6a27ef2b7569a..9acd2e7e17c93 100644
--- a/sound/soc/codecs/cs35l56.h
+++ b/sound/soc/codecs/cs35l56.h
@@ -43,7 +43,6 @@ struct cs35l56_private {
 	bool sdw_irq_no_unmask;
 	bool soft_resetting;
 	bool sdw_attached;
-	bool sdw_in_clock_stop_1;
 	struct completion init_completion;
 
 	int speaker_id;
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 01/10] soundwire: Always wait for initialisation of unattached devices
  2026-06-03 14:44 ` [PATCH 01/10] soundwire: Always wait for initialisation of unattached devices Charles Keepax
@ 2026-06-04  6:44   ` Vinod Koul
  0 siblings, 0 replies; 16+ messages in thread
From: Vinod Koul @ 2026-06-04  6:44 UTC (permalink / raw)
  To: Charles Keepax
  Cc: broonie, lee, lgirdwood, pierre-louis.bossart, yung-chuan.liao,
	peter.ujfalusi, oder_chiou, jack.yu, shumingf, srini, linux-sound,
	linux-arm-msm, linux-kernel, patches

On 03-06-26, 15:44, Charles Keepax wrote:
> Currently in sdw_slave_wait_for_init() the waiting can be skipped
> if unattach_request is not set. Doing so was added in [1] likely
> because the core used to do a complete() on the completion so
> waiting in the case an unattach hadn't actually happened would
> block for the full timeout. However patch [2] updated the core to
> use complete_all() which means that the wait_for_completion() will
> now simply return if the device is already attached skipping the
> completion doesn't add much.
> 
> Additionally, unatttach_request is only set if the host initiates
> a bus reset. However, the host doing a bus reset is not the only
> reason a device may be unattached from the bus. Other options
> could include the driver probing before the device enumerates, a
> sync-loss, or the device itself powering down.
> 
> Removing the skip using unattached_request, doesn't cost much in
> terms of efficiency and allows the sdw_slave_wiat_for_init() helper
> to be used outside of runtime resume.

Acked-by: Vinod Koul <vkoul@kernel.org>

-- 
~Vinod

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 03/10] mfd: cs42l43: Use new SoundWire enumeration helper
  2026-06-03 14:44 ` [PATCH 03/10] mfd: cs42l43: " Charles Keepax
@ 2026-06-04 11:04   ` Mark Brown
  2026-06-04 11:07     ` Mark Brown
  2026-06-04 12:05     ` Charles Keepax
  0 siblings, 2 replies; 16+ messages in thread
From: Mark Brown @ 2026-06-04 11:04 UTC (permalink / raw)
  To: Charles Keepax
  Cc: vkoul, lee, lgirdwood, pierre-louis.bossart, yung-chuan.liao,
	peter.ujfalusi, oder_chiou, jack.yu, shumingf, srini, linux-sound,
	linux-arm-msm, linux-kernel, patches

[-- Attachment #1: Type: text/plain, Size: 856 bytes --]

On Wed, Jun 03, 2026 at 03:44:36PM +0100, Charles Keepax wrote:
> Now the new wait for SoundWire enumeration helper no longer depends on
> unattach_request it is safe to use from probe time. Update the driver
> to use the new core helper.

> --- a/drivers/mfd/cs42l43.c
> +++ b/drivers/mfd/cs42l43.c
> @@ -586,15 +586,13 @@ static int cs42l43_soft_reset(struct cs42l43 *cs42l43)

> -	if (!cs42l43->attached) {
> -		unsigned long timeout = msecs_to_jiffies(CS42L43_SDW_ATTACH_TIMEOUT_MS);
> -		unsigned long time;

Are there any other users of attached left?

> +	if (cs42l43->sdw) {
> +		ret = sdw_slave_wait_for_init(cs42l43->sdw,
> +					      CS42L43_SDW_ATTACH_TIMEOUT_MS);
> +		if (ret)
> +			return ret;

This is in the bus independent code and the SOUNDWIRE dependency is only
on MFD_CS42L43_SDW so this will be a build break for !SOUNDWIRE builds.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 04/10] ASoC: rt5682: Use new SoundWire enumeration helper
  2026-06-03 14:44 ` [PATCH 04/10] ASoC: rt5682: " Charles Keepax
@ 2026-06-04 11:05   ` Mark Brown
  0 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2026-06-04 11:05 UTC (permalink / raw)
  To: Charles Keepax
  Cc: vkoul, lee, lgirdwood, pierre-louis.bossart, yung-chuan.liao,
	peter.ujfalusi, oder_chiou, jack.yu, shumingf, srini, linux-sound,
	linux-arm-msm, linux-kernel, patches

[-- Attachment #1: Type: text/plain, Size: 762 bytes --]

On Wed, Jun 03, 2026 at 03:44:37PM +0100, Charles Keepax wrote:
> Now the new wait for SoundWire enumeration helper no longer depends on
> unattach_request it is safe to use from probe time. Update the driver
> to use the new core helper.
> 
> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>

> index d39f8e4f3474c..4b82e07d3b2c7 100644
> --- a/sound/soc/codecs/rt5682.c
> +++ b/sound/soc/codecs/rt5682.c
> @@ -2929,20 +2929,14 @@ static int rt5682_probe(struct snd_soc_component *component)
>  {

> +		ret = sdw_slave_wait_for_init(rt5682->slave, RT5682_PROBE_TIMEOUT);
> +		if (ret)
> +			return ret;

Similar issue here with !SOUNDWIRE builds.

>  	}
>  
>  	snd_soc_dapm_disable_pin(dapm, "MICBIAS");
> -- 
> 2.47.3
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 03/10] mfd: cs42l43: Use new SoundWire enumeration helper
  2026-06-04 11:04   ` Mark Brown
@ 2026-06-04 11:07     ` Mark Brown
  2026-06-04 12:05     ` Charles Keepax
  1 sibling, 0 replies; 16+ messages in thread
From: Mark Brown @ 2026-06-04 11:07 UTC (permalink / raw)
  To: Charles Keepax
  Cc: vkoul, lee, lgirdwood, pierre-louis.bossart, yung-chuan.liao,
	peter.ujfalusi, oder_chiou, jack.yu, shumingf, srini, linux-sound,
	linux-arm-msm, linux-kernel, patches

[-- Attachment #1: Type: text/plain, Size: 680 bytes --]

On Thu, Jun 04, 2026 at 12:04:22PM +0100, Mark Brown wrote:
> On Wed, Jun 03, 2026 at 03:44:36PM +0100, Charles Keepax wrote:
> > Now the new wait for SoundWire enumeration helper no longer depends on
> > unattach_request it is safe to use from probe time. Update the driver
> > to use the new core helper.
> 
> > +	if (cs42l43->sdw) {
> > +		ret = sdw_slave_wait_for_init(cs42l43->sdw,
> > +					      CS42L43_SDW_ATTACH_TIMEOUT_MS);
> > +		if (ret)
> > +			return ret;

> This is in the bus independent code and the SOUNDWIRE dependency is only
> on MFD_CS42L43_SDW so this will be a build break for !SOUNDWIRE builds.

Sorry, there is actually a stub for this.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 03/10] mfd: cs42l43: Use new SoundWire enumeration helper
  2026-06-04 11:04   ` Mark Brown
  2026-06-04 11:07     ` Mark Brown
@ 2026-06-04 12:05     ` Charles Keepax
  1 sibling, 0 replies; 16+ messages in thread
From: Charles Keepax @ 2026-06-04 12:05 UTC (permalink / raw)
  To: Mark Brown
  Cc: vkoul, lee, lgirdwood, pierre-louis.bossart, yung-chuan.liao,
	peter.ujfalusi, oder_chiou, jack.yu, shumingf, srini, linux-sound,
	linux-arm-msm, linux-kernel, patches

On Thu, Jun 04, 2026 at 12:04:16PM +0100, Mark Brown wrote:
> On Wed, Jun 03, 2026 at 03:44:36PM +0100, Charles Keepax wrote:
> > Now the new wait for SoundWire enumeration helper no longer depends on
> > unattach_request it is safe to use from probe time. Update the driver
> > to use the new core helper.
> 
> > --- a/drivers/mfd/cs42l43.c
> > +++ b/drivers/mfd/cs42l43.c
> > @@ -586,15 +586,13 @@ static int cs42l43_soft_reset(struct cs42l43 *cs42l43)
> 
> > -	if (!cs42l43->attached) {
> > -		unsigned long timeout = msecs_to_jiffies(CS42L43_SDW_ATTACH_TIMEOUT_MS);
> > -		unsigned long time;
> 
> Are there any other users of attached left?

Hmm.. yes that is true this is actually the last user of
attached. I will spin a v2 that removes it completely.

Thanks,
Charles

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-06-04 12:07 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-03 14:44 [PATCH 00/10] Expand SoundWire enumeration helper coverage Charles Keepax
2026-06-03 14:44 ` [PATCH 01/10] soundwire: Always wait for initialisation of unattached devices Charles Keepax
2026-06-04  6:44   ` Vinod Koul
2026-06-03 14:44 ` [PATCH 02/10] ASoC: wsa881x: Use new SoundWire enumeration helper Charles Keepax
2026-06-03 14:44 ` [PATCH 03/10] mfd: cs42l43: " Charles Keepax
2026-06-04 11:04   ` Mark Brown
2026-06-04 11:07     ` Mark Brown
2026-06-04 12:05     ` Charles Keepax
2026-06-03 14:44 ` [PATCH 04/10] ASoC: rt5682: " Charles Keepax
2026-06-04 11:05   ` Mark Brown
2026-06-03 14:44 ` [PATCH 05/10] ASoC: pm4125: " Charles Keepax
2026-06-03 14:44 ` [PATCH 06/10] ASoC: wcd937x: " Charles Keepax
2026-06-03 14:44 ` [PATCH 07/10] ASoC: wcd938x: " Charles Keepax
2026-06-03 14:44 ` [PATCH 08/10] ASoC: wcd939x: " Charles Keepax
2026-06-03 14:44 ` [PATCH 09/10] ASoC: SDCA: " Charles Keepax
2026-06-03 14:44 ` [PATCH 10/10] ASoC: cs35l56: Remove unnecessary conditionals waiting for enumeration Charles Keepax

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox