Skip to contentSkip to conversation

Fix SoundWire randconfig issues

PATCH In review Charles Keepax 2 participants 7 messages Jun 23 – Jun 24

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v2 cover Fix SoundWire randconfig issues

Moving all the waiting for soundwire devices to enumerate into the core code [1] has caused some randconfig issues. This is the second attempt to fix this after there were some short coming in [2].

Sorry for sending during the merge window, but people are keen to see a solution posted.

Thanks,
Charles

[1] https://lore.kernel.org/linux-sound/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/

Changes since v1:
- Add include of jiffies.h

Charles Keepax (5):
soundwire: Move wait for initialisation helper to header
ASoC: es9356: Add back local call to sdw_show_ping_status()
ASoC: max98373: Add back local call to sdw_show_ping_status()
ASoC: ti: Add back local call to sdw_show_ping_status()
ASoC: realtek: Add back local call to sdw_show_ping_status()

 drivers/soundwire/bus.c            | 28 ----------------------
 include/linux/soundwire/sdw.h      | 38 +++++++++++++++++++++++-------
 sound/soc/codecs/es9356.c          |  4 +++-
 sound/soc/codecs/max98373-sdw.c    |  4 +++-
 sound/soc/codecs/rt1017-sdca-sdw.c |  4 +++-
 sound/soc/codecs/rt1308-sdw.c      |  4 +++-
 sound/soc/codecs/rt1316-sdw.c      |  4 +++-
 sound/soc/codecs/rt5682-sdw.c      |  4 +++-
 sound/soc/codecs/rt700-sdw.c       |  4 +++-
 sound/soc/codecs/rt711-sdca-sdw.c  |  4 +++-
 sound/soc/codecs/rt712-sdca-dmic.c |  4 +++-
 sound/soc/codecs/rt712-sdca-sdw.c  |  4 +++-
 sound/soc/codecs/rt715-sdca-sdw.c  |  4 +++-
 sound/soc/codecs/rt715-sdw.c       |  4 +++-
 sound/soc/codecs/rt721-sdca-sdw.c  |  4 +++-
 sound/soc/codecs/rt722-sdca-sdw.c  |  4 +++-
 sound/soc/codecs/tac5xx2-sdw.c     |  4 +++-
 sound/soc/codecs/tas2783-sdw.c     |  4 +++-
 18 files changed, 78 insertions(+), 52 deletions(-)
Signature · 1 line
2.47.3
#1 lore raw

PATCH v2 1/5 soundwire: Move wait for initialisation helper to header

As SoundWire devices tend to enumerate on the bus after probe, drivers frequently need to wait for the device to initialise from common driver code. The common system is to split drivers into a core module and then a module for each communication bus. These two facts tend to cause Kconfig issues, the issue tends to be when SOUNDWIRE=m and DRIVER_I2C=y, this usually selects DRIVER=y. The driver code then wants to call sdw_slave_wait_for_init(), but this results in calling a module function from built in code. A depends on SOUNDWIRE | !SOUNDWIRE could be added to the end driver but this seems slightly off as it adds a lot of counter intuitive depends.

A simpler solution is to make sdw_slave_wait_for_init() a static inline function. As part of doing this add a check for the slave device being NULL acknowledging that this is likely called from code that is shared between control buses. It does require dropping the call to sdw_show_ping_status() but this can be added back in end drivers that used it originally.

Currently this is causing rand config issues on RT5682 and will soon also cause similar problems on cs42l43.

---

Changes since v1:
- Add include of jiffies.h

 drivers/soundwire/bus.c       | 28 --------------------------
 include/linux/soundwire/sdw.h | 38 +++++++++++++++++++++++++++--------
 2 files changed, 30 insertions(+), 36 deletions(-)
drivers/soundwire/bus.c +0 -28
index b7bdf19ebb42e..fe5316d93fefe 100644
@@ -1372,34 +1372,6 @@ int sdw_slave_get_current_bank(struct sdw_slave *slave)
 }
 EXPORT_SYMBOL_GPL(sdw_slave_get_current_bank);
 
-/**
- * sdw_slave_wait_for_init - Wait for device initialisation
- * @slave: Pointer to the SoundWire peripheral.
- * @timeout_ms: Timeout in milliseconds.
- *
- * Wait for a peripheral device to enumerate and be initialised by the
- * SoundWire core.
- *
- * Return: Zero on success, and a negative error code on failure.
- */
-int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout_ms)
-{
-	unsigned long time;
-
-	time = wait_for_completion_timeout(&slave->initialization_complete,
-					   msecs_to_jiffies(timeout_ms));
-	if (!time) {
-		dev_err(&slave->dev, "Initialization not complete\n");
-		sdw_show_ping_status(slave->bus, true);
-		return -ETIMEDOUT;
-	}
-
-	slave->unattach_request = 0;
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(sdw_slave_wait_for_init);
-
 static int sdw_slave_set_frequency(struct sdw_slave *slave)
 {
 	int scale_index;
include/linux/soundwire/sdw.h +30 -8
index a46cbaec59491..b484784e2690d 100644
@@ -11,6 +11,7 @@
 #include <linux/idr.h>
 #include <linux/irq.h>
 #include <linux/irqdomain.h>
+#include <linux/jiffies.h>
 #include <linux/lockdep_types.h>
 #include <linux/mod_devicetable.h>
 #include <linux/mutex.h>
@@ -1093,8 +1094,6 @@ int sdw_slave_get_current_bank(struct sdw_slave *sdev);
 
 int sdw_slave_get_scale_index(struct sdw_slave *slave, u8 *base);
 
-int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout_ms);
-
 /* messaging and data APIs */
 int sdw_read(struct sdw_slave *slave, u32 addr);
 int sdw_write(struct sdw_slave *slave, u32 addr, u8 value);
@@ -1138,12 +1137,6 @@ static inline int sdw_slave_get_current_bank(struct sdw_slave *sdev)
 	return -EINVAL;
 }
 
-static inline int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout_ms)
-{
-	WARN_ONCE(1, "SoundWire API is disabled");
-	return -EINVAL;
-}
-
 /* messaging and data APIs */
 static inline int sdw_read(struct sdw_slave *slave, u32 addr)
 {
@@ -1207,4 +1200,33 @@ static inline int sdw_update_no_pm(struct sdw_slave *slave, u32 addr, u8 mask, u
 
 #endif /* CONFIG_SOUNDWIRE */
 
+/**
+ * sdw_slave_wait_for_init - Wait for device initialisation
+ * @slave: Pointer to the SoundWire peripheral.
+ * @timeout_ms: Timeout in milliseconds.
+ *
+ * Wait for a peripheral device to enumerate and be initialised by the
+ * SoundWire core.
+ *
+ * Return: Zero on success, and a negative error code on failure.
+ */
+static inline int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout_ms)
+{
+	unsigned long time;
+
+	if (!slave)
+		return 0;
+
+	time = wait_for_completion_timeout(&slave->initialization_complete,
+					   msecs_to_jiffies(timeout_ms));
+	if (!time) {
+		dev_err(&slave->dev, "Initialization not complete\n");
+		return -ETIMEDOUT;
+	}
+
+	slave->unattach_request = 0;
+
+	return 0;
+}
+
 #endif /* __SOUNDWIRE_H */
Signature · 1 line
2.47.3
#2 lore raw

PATCH v2 2/5 ASoC: es9356: Add back local call to sdw_show_ping_status()

In reply to Charles Keepax

As the core no longer calls this debug helper add it back to the drivers that originally called it.

---

No changes since v1.

 sound/soc/codecs/es9356.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/codecs/es9356.c +3 -1
index 670e918b56a46..8db81d5746240 100644
@@ -1111,8 +1111,10 @@ static int es9356_sdca_dev_resume(struct device *dev)
 		es9356->disable_irq = false;
 
 	ret = sdw_slave_wait_for_init(slave, es9356_PROBE_TIMEOUT);
-	if (ret)
+	if (ret) {
+		sdw_show_ping_status(slave->bus, true);
 		return ret;
+	}
 
 	regcache_cache_only(es9356->regmap, false);
 	regcache_sync(es9356->regmap);
Signature · 1 line
2.47.3
#3 lore raw

PATCH v2 3/5 ASoC: max98373: Add back local call to sdw_show_ping_status()

In reply to Charles Keepax

As the core no longer calls this debug helper add it back to the drivers that originally called it.

---

No changes since v1.

 sound/soc/codecs/max98373-sdw.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/codecs/max98373-sdw.c +3 -1
index 6829fa07c9ecb..7a42052dc0516 100644
@@ -272,8 +272,10 @@ static int max98373_resume(struct device *dev)
 		return 0;
 
 	ret = sdw_slave_wait_for_init(slave, MAX98373_PROBE_TIMEOUT);
-	if (ret)
+	if (ret) {
+		sdw_show_ping_status(slave->bus, true);
 		return ret;
+	}
 
 	regcache_cache_only(max98373->regmap, false);
 	regcache_sync(max98373->regmap);
Signature · 1 line
2.47.3
#4 lore raw

PATCH v2 4/5 ASoC: ti: Add back local call to sdw_show_ping_status()

In reply to Charles Keepax

As the core no longer calls this debug helper add it back to the drivers that originally called it.

---

No changes since v1.

 sound/soc/codecs/tac5xx2-sdw.c | 4 +++-
 sound/soc/codecs/tas2783-sdw.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
sound/soc/codecs/tac5xx2-sdw.c +3 -1
index bb12cfb6da12b..ace06f5ab58c1 100644
@@ -1445,8 +1445,10 @@ static s32 tac5xx2_sdca_dev_resume(struct device *dev)
 	}
 
 	ret = sdw_slave_wait_for_init(slave, TAC5XX2_PROBE_TIMEOUT_MS);
-	if (ret)
+	if (ret) {
+		sdw_show_ping_status(slave->bus, true);
 		return ret;
+	}
 
 	regcache_cache_only(tac_dev->regmap, false);
 	regcache_mark_dirty(tac_dev->regmap);
sound/soc/codecs/tas2783-sdw.c +3 -1
index 7d70e7e3f24f4..1127ea59b5e4c 100644
@@ -1083,8 +1083,10 @@ static s32 tas2783_sdca_dev_resume(struct device *dev)
 	int ret;
 
 	ret = sdw_slave_wait_for_init(slave, TAS2783_PROBE_TIMEOUT);
-	if (ret)
+	if (ret) {
+		sdw_show_ping_status(slave->bus, true);
 		return ret;
+	}
 
 	regcache_cache_only(tas_dev->regmap, false);
 	regcache_sync(tas_dev->regmap);
Signature · 1 line
2.47.3
#5 lore raw

PATCH v2 5/5 ASoC: realtek: Add back local call to sdw_show_ping_status()

In reply to Charles Keepax

As the core no longer calls this debug helper add it back to the drivers that originally called it.

---

No changes since v1.

 sound/soc/codecs/rt1017-sdca-sdw.c | 4 +++-
 sound/soc/codecs/rt1308-sdw.c      | 4 +++-
 sound/soc/codecs/rt1316-sdw.c      | 4 +++-
 sound/soc/codecs/rt5682-sdw.c      | 4 +++-
 sound/soc/codecs/rt700-sdw.c       | 4 +++-
 sound/soc/codecs/rt711-sdca-sdw.c  | 4 +++-
 sound/soc/codecs/rt712-sdca-dmic.c | 4 +++-
 sound/soc/codecs/rt712-sdca-sdw.c  | 4 +++-
 sound/soc/codecs/rt715-sdca-sdw.c  | 4 +++-
 sound/soc/codecs/rt715-sdw.c       | 4 +++-
 sound/soc/codecs/rt721-sdca-sdw.c  | 4 +++-
 sound/soc/codecs/rt722-sdca-sdw.c  | 4 +++-
 12 files changed, 36 insertions(+), 12 deletions(-)
sound/soc/codecs/rt1017-sdca-sdw.c +3 -1
index d62e8a2536767..91d3d43cd9988 100644
@@ -779,8 +779,10 @@ static int rt1017_sdca_dev_resume(struct device *dev)
 		return 0;
 
 	ret = sdw_slave_wait_for_init(slave, RT1017_PROBE_TIMEOUT);
-	if (ret)
+	if (ret) {
+		sdw_show_ping_status(slave->bus, true);
 		return ret;
+	}
 
 	regcache_cache_only(rt1017->regmap, false);
 	regcache_sync(rt1017->regmap);
sound/soc/codecs/rt1308-sdw.c +3 -1
index 39e06a3a75609..60e5040b6dd9d 100644
@@ -774,8 +774,10 @@ static int rt1308_dev_resume(struct device *dev)
 		return 0;
 
 	ret = sdw_slave_wait_for_init(slave, RT1308_PROBE_TIMEOUT);
-	if (ret)
+	if (ret) {
+		sdw_show_ping_status(slave->bus, true);
 		return ret;
+	}
 
 	regcache_cache_only(rt1308->regmap, false);
 	regcache_sync_region(rt1308->regmap, 0xc000, 0xcfff);
sound/soc/codecs/rt1316-sdw.c +3 -1
index 1828fd9d5af6a..5e8eda6a5f7f8 100644
@@ -751,8 +751,10 @@ static int rt1316_dev_resume(struct device *dev)
 		return 0;
 
 	ret = sdw_slave_wait_for_init(slave, RT1316_PROBE_TIMEOUT);
-	if (ret)
+	if (ret) {
+		sdw_show_ping_status(slave->bus, true);
 		return ret;
+	}
 
 	regcache_cache_only(rt1316->regmap, false);
 	regcache_sync(rt1316->regmap);
sound/soc/codecs/rt5682-sdw.c +3 -1
index ec2a35a0cacde..dec8c2147d684 100644
@@ -769,8 +769,10 @@ static int rt5682_dev_resume(struct device *dev)
 	}
 
 	ret = sdw_slave_wait_for_init(slave, RT5682_PROBE_TIMEOUT);
-	if (ret)
+	if (ret) {
+		sdw_show_ping_status(slave->bus, true);
 		return ret;
+	}
 
 	regcache_cache_only(rt5682->sdw_regmap, false);
 	regcache_cache_only(rt5682->regmap, false);
sound/soc/codecs/rt700-sdw.c +3 -1
index 30fcca210f051..6bc636c86f427 100644
@@ -528,8 +528,10 @@ static int rt700_dev_resume(struct device *dev)
 		return 0;
 
 	ret = sdw_slave_wait_for_init(slave, RT700_PROBE_TIMEOUT);
-	if (ret)
+	if (ret) {
+		sdw_show_ping_status(slave->bus, true);
 		return ret;
+	}
 
 	regcache_cache_only(rt700->regmap, false);
 	regcache_sync_region(rt700->regmap, 0x3000, 0x8fff);
sound/soc/codecs/rt711-sdca-sdw.c +3 -1
index a8164fc3979ab..461315844ba99 100644
@@ -454,8 +454,10 @@ static int rt711_sdca_dev_resume(struct device *dev)
 	}
 
 	ret = sdw_slave_wait_for_init(slave, RT711_PROBE_TIMEOUT);
-	if (ret)
+	if (ret) {
+		sdw_show_ping_status(slave->bus, true);
 		return ret;
+	}
 
 	regcache_cache_only(rt711->regmap, false);
 	regcache_sync(rt711->regmap);
sound/soc/codecs/rt712-sdca-dmic.c +3 -1
index 4c5c2f5ba5edf..8b7d50a80ff98 100644
@@ -911,8 +911,10 @@ static int rt712_sdca_dmic_dev_resume(struct device *dev)
 		return 0;
 
 	ret = sdw_slave_wait_for_init(slave, RT712_PROBE_TIMEOUT);
-	if (ret)
+	if (ret) {
+		sdw_show_ping_status(slave->bus, true);
 		return ret;
+	}
 
 	regcache_cache_only(rt712->regmap, false);
 	regcache_sync(rt712->regmap);
sound/soc/codecs/rt712-sdca-sdw.c +3 -1
index 5817321804736..2787524c796e8 100644
@@ -467,8 +467,10 @@ static int rt712_sdca_dev_resume(struct device *dev)
 	}
 
 	ret = sdw_slave_wait_for_init(slave, RT712_PROBE_TIMEOUT);
-	if (ret)
+	if (ret) {
+		sdw_show_ping_status(slave->bus, true);
 		return ret;
+	}
 
 	regcache_cache_only(rt712->regmap, false);
 	regcache_sync(rt712->regmap);
sound/soc/codecs/rt715-sdca-sdw.c +3 -1
index 4b9815b5628db..fabd21bbbe5b9 100644
@@ -230,8 +230,10 @@ static int rt715_dev_resume(struct device *dev)
 		return 0;
 
 	ret = sdw_slave_wait_for_init(slave, RT715_PROBE_TIMEOUT);
-	if (ret)
+	if (ret) {
+		sdw_show_ping_status(slave->bus, true);
 		return ret;
+	}
 
 	regcache_cache_only(rt715->regmap, false);
 	regcache_sync_region(rt715->regmap,
sound/soc/codecs/rt715-sdw.c +3 -1
index 7f83a8f1a06e9..a4a3945522e81 100644
@@ -507,8 +507,10 @@ static int rt715_dev_resume(struct device *dev)
 		return 0;
 
 	ret = sdw_slave_wait_for_init(slave, RT715_PROBE_TIMEOUT);
-	if (ret)
+	if (ret) {
+		sdw_show_ping_status(slave->bus, true);
 		return ret;
+	}
 
 	regcache_cache_only(rt715->regmap, false);
 	regcache_sync_region(rt715->regmap, 0x3000, 0x8fff);
sound/soc/codecs/rt721-sdca-sdw.c +3 -1
index 58606209316a4..02df04a0ddad4 100644
@@ -505,8 +505,10 @@ static int rt721_sdca_dev_resume(struct device *dev)
 	}
 
 	ret = sdw_slave_wait_for_init(slave, RT721_PROBE_TIMEOUT);
-	if (ret)
+	if (ret) {
+		sdw_show_ping_status(slave->bus, true);
 		return ret;
+	}
 
 	regcache_cache_only(rt721->regmap, false);
 	regcache_sync(rt721->regmap);
sound/soc/codecs/rt722-sdca-sdw.c +3 -1
index 0f76492ff915c..284900933ebf4 100644
@@ -552,8 +552,10 @@ static int rt722_sdca_dev_resume(struct device *dev)
 	}
 
 	ret = sdw_slave_wait_for_init(slave, RT722_PROBE_TIMEOUT);
-	if (ret)
+	if (ret) {
+		sdw_show_ping_status(slave->bus, true);
 		return ret;
+	}
 
 	regcache_cache_only(rt722->regmap, false);
 	regcache_sync(rt722->regmap);
Signature · 1 line
2.47.3
maintainer
#6 lore raw
In reply to Charles Keepax
Quoted 10 lines · Charles Keepax

Fix SoundWire randconfig issues

Moving all the waiting for soundwire devices to enumerate into the core code [1] has caused some randconfig issues. This is the second attempt to fix this after there were some short coming in [2].

Sorry for sending during the merge window, but people are keen to see a solution posted.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.2

Thanks!

[1/5] soundwire: Move wait for initialisation helper to header

      https://git.kernel.org/broonie/sound/c/5714c8359f4f
[2/5] ASoC: es9356: Add back local call to sdw_show_ping_status()
      https://git.kernel.org/broonie/sound/c/ce52450319fb
[3/5] ASoC: max98373: Add back local call to sdw_show_ping_status()
      https://git.kernel.org/broonie/sound/c/1921303a1d2f
[4/5] ASoC: ti: Add back local call to sdw_show_ping_status()
      https://git.kernel.org/broonie/sound/c/ea9ff3b7bcfb
[5/5] ASoC: realtek: Add back local call to sdw_show_ping_status()
      https://git.kernel.org/broonie/sound/c/6540b9d9ccc3

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark