Skip to contentSkip to conversation

Expand SoundWire enumeration helper coverage

PATCH Superseded Charles Keepax 3 participants 16 messages Jun 3 – Jun 4

Subsystems (9)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
author maintainer
#11 lore raw

PATCH 6/10 ASoC: wcd937x: Use new SoundWire enumeration helper

In reply to Charles Keepax

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.

---
 sound/soc/codecs/wcd937x.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
sound/soc/codecs/wcd937x.c +3 -8
index 72a53f95d6887..e0169e783ee96 100644
@@ -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);
Signature · 1 line
2.47.3
author maintainer
#10 lore raw

PATCH 5/10 ASoC: pm4125: Use new SoundWire enumeration helper

In reply to Charles Keepax

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.

---
 sound/soc/codecs/pm4125.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
sound/soc/codecs/pm4125.c +3 -8
index 1f0a3f5389f1b..29655175ea289 100644
@@ -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);
Signature · 1 line
2.47.3
author maintainer
#4 lore raw

PATCH 3/10 mfd: cs42l43: Use new SoundWire enumeration helper

In reply to Charles Keepax

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.

---
 drivers/mfd/cs42l43-sdw.c   |  3 ---
 drivers/mfd/cs42l43.c       | 15 ++++++---------
 include/linux/mfd/cs42l43.h |  1 -
 3 files changed, 6 insertions(+), 13 deletions(-)
drivers/mfd/cs42l43-sdw.c +0 -3
index 794c983781750..2c890a4315438 100644
@@ -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:
drivers/mfd/cs42l43.c +6 -9
index 166881751e698..cb1e175586bd1 100644
@@ -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);
include/linux/mfd/cs42l43.h +0 -1
index ff0f7e365a19f..5f5c043e7cab9 100644
@@ -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;
Signature · 1 line
2.47.3
author maintainer
#14 lore raw

PATCH 9/10 ASoC: SDCA: Use new SoundWire enumeration helper

In reply to Charles Keepax

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.

---
 sound/soc/sdca/sdca_class.c | 53 ++++---------------------------------
 sound/soc/sdca/sdca_class.h |  3 ---
 2 files changed, 5 insertions(+), 51 deletions(-)
sound/soc/sdca/sdca_class.c +5 -48
index a6a3da8de4371..6937a91ddfb9b 100644
@@ -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);
sound/soc/sdca/sdca_class.h +0 -3
index 8b63e62485e64..57f7f8d08f497 100644
@@ -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__ */
Signature · 1 line
2.47.3
author maintainer
#1 lore raw

PATCH 1/10 soundwire: Always wait for initialisation of unattached devices

In reply to Charles Keepax

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")

---
 drivers/soundwire/bus.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/soundwire/bus.c +0 -3
index ea3a24f805c00..b7bdf19ebb42e 100644
@@ -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) {
Signature · 1 line
2.47.3
author maintainer
#3 lore raw

PATCH 2/10 ASoC: wsa881x: Use new SoundWire enumeration helper

In reply to Charles Keepax

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.

---
 sound/soc/codecs/wsa881x.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
sound/soc/codecs/wsa881x.c +4 -6
index d15fda648dada..5174614c3e837 100644
@@ -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);
Signature · 1 line
2.47.3
author maintainer
#12 lore raw

PATCH 7/10 ASoC: wcd938x: Use new SoundWire enumeration helper

In reply to Charles Keepax

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.

---
 sound/soc/codecs/wcd938x.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
sound/soc/codecs/wcd938x.c +3 -8
index cb0a0bfdb6e32..c69e18667a85b 100644
@@ -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);
 
Signature · 1 line
2.47.3

Charles Keepax

author maintainer
#0 lore raw

cover Expand SoundWire enumeration helper coverage

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/[email protected]/

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(-)
Signature · 1 line
2.47.3
author maintainer
#8 lore raw

PATCH 4/10 ASoC: rt5682: Use new SoundWire enumeration helper

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.

---
 sound/soc/codecs/rt5682.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
sound/soc/codecs/rt5682.c +4 -10
index d39f8e4f3474c..4b82e07d3b2c7 100644
@@ -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");
Signature · 1 line
2.47.3
author maintainer
#13 lore raw

PATCH 8/10 ASoC: wcd939x: Use new SoundWire enumeration helper

In reply to Charles Keepax

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.

---
 sound/soc/codecs/wcd939x.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
sound/soc/codecs/wcd939x.c +3 -8
index 01f1a08f48e65..010d124667224 100644
@@ -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);
 
Signature · 1 line
2.47.3
author maintainer
#15 lore raw

PATCH 10/10 ASoC: cs35l56: Remove unnecessary conditionals waiting for enumeration

In reply to Charles Keepax

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")

---
 sound/soc/codecs/cs35l56-sdw.c | 47 ++++++++--------------------------
 sound/soc/codecs/cs35l56.h     |  1 -
 2 files changed, 10 insertions(+), 38 deletions(-)
sound/soc/codecs/cs35l56-sdw.c +10 -37
index 847e88f3b2044..0a55b93b96f96 100644
@@ -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;
 }
sound/soc/codecs/cs35l56.h +0 -1
index 6a27ef2b7569a..9acd2e7e17c93 100644
@@ -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;
Signature · 1 line
2.47.3
maintainer Acked-by on v1 1/10
#2 lore raw

Re: [PATCH 01/10] soundwire: Always wait for initialisation of unattached devices

In reply to Charles Keepax
Quoted 15 lines · Charles Keepax

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.

Quoted 3 lines

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.

Signature · 1 line
~Vinod
maintainer
#5 lore raw

Re: [PATCH 03/10] mfd: cs42l43: Use new SoundWire enumeration helper

In reply to Charles Keepax

drivers/mfd/cs42l43.c static int cs42l43_soft_reset(struct cs42l43 *cs42l43) · line 589

Quoted 11 lines · Charles Keepax

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.

drivers/mfd/cs42l43.c +0 -3
@@ -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?

drivers/mfd/cs42l43.c static int cs42l43_soft_reset(struct cs42l43 *cs42l43) · line 595

Quoted 5 lines
drivers/mfd/cs42l43.c +5 -0
+	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.

maintainer
#9 lore raw

Re: [PATCH 04/10] ASoC: rt5682: Use new SoundWire enumeration helper

In reply to Charles Keepax
Quoted 10 lines · Charles Keepax

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.

index d39f8e4f3474c..4b82e07d3b2c7 100644

sound/soc/codecs/rt5682.c static int rt5682_probe(struct snd_soc_component *component) · line 2933

Quoted 5 lines
sound/soc/codecs/rt5682.c +3 -0
@@ -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.

Quoted 6 lines
sound/soc/codecs/rt5682.c +0 -0
 	}
 
 	snd_soc_dapm_disable_pin(dapm, "MICBIAS");
Signature · 1 line
2.47.3
maintainer
#6 lore raw

Re: [PATCH 03/10] mfd: cs42l43: Use new SoundWire enumeration helper

In reply to Mark Brown
Quoted 5 lines · Mark Brown
Quoted 3 lines · Charles Keepax

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.

Quoted 8 lines

drivers/mfd/cs42l43.c static int cs42l43_soft_reset(struct cs42l43 *cs42l43) · line 595

Quoted 5 lines
drivers/mfd/cs42l43.c +5 -0
+	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.

author maintainer
#7 lore raw

Re: [PATCH 03/10] mfd: cs42l43: Use new SoundWire enumeration helper

In reply to Mark Brown
Quoted 9 lines · Mark Brown
Quoted 7 lines · Charles Keepax

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.

drivers/mfd/cs42l43.c +0 -0
@@ -586,15 +586,13 @@ static int cs42l43_soft_reset(struct cs42l43 *cs42l43)
Quoted 5 lines

drivers/mfd/cs42l43.c static int cs42l43_soft_reset(struct cs42l43 *cs42l43) · line 591

Quoted 3 lines
drivers/mfd/cs42l43.c +0 -3
-	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