Skip to contentSkip to conversation

ASoC: codecs: propagate sdw_write() errors from bus_config callbacks

PATCH RESEND In review Andrey Karelin 1 participant 4 messages Nov 18 – Dec 2

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

cover ASoC: codecs: propagate sdw_write() errors from bus_config callbacks

wsa881x_bus_config() and wcd_bus_config() (shared by the WCD938x and WCD939x SoundWire drivers) program the clock divider for the next bank with sdw_write() but ignore its result and always return 0, so a failed write is never reported to sdw_notify_config(). The other SoundWire codec drivers that implement bus_config already return the error.

Both patches simply return the result of sdw_write().

Resending the series unchanged, only rebased onto current mainline. The original posting got no response, probably because it went out right before the v7.4 merge window:
https://lore.kernel.org/all/[email protected]/

Andrey Karelin (2):
ASoC: codecs: wsa881x: propagate sdw_write() error from bus_config
ASoC: codecs: wcd-common: propagate sdw_write() error from bus_config

 sound/soc/codecs/wcd-common.c | 4 +---
 sound/soc/codecs/wsa881x.c    | 6 ++----
 2 files changed, 3 insertions(+), 7 deletions(-)

base-commit: 20eef29b7c8465ac98d7dd6d6f2ac07a8d8056ca

Signature · 1 line
2.56.1
#1 lore raw

PATCH RESEND 1/2 ASoC: codecs: wsa881x: propagate sdw_write() error from bus_config

wsa881x_bus_config() programs the clock divider for the next bank via sdw_write() but ignores its result and always returns 0. A failed write is therefore hidden from sdw_notify_config(), which aborts programming of the stream parameters when a bus_config callback fails, and the amplifier may keep running with a wrong clock configuration after the bank switch.

Return the result of sdw_write() instead.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes a0aab9e1404a ("ASoC: codecs: add wsa881x amplifier support")
---
 sound/soc/codecs/wsa881x.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/codecs/wsa881x.c +2 -4
index f6cba55288e0..12b81edfbd87 100644
@@ -1093,10 +1093,8 @@ static int wsa881x_port_prep(struct sdw_slave *slave,
 static int wsa881x_bus_config(struct sdw_slave *slave,
 			      struct sdw_bus_params *params)
 {
-	sdw_write(slave, SWRS_SCP_HOST_CLK_DIV2_CTL_BANK(params->next_bank),
-		  0x01);
-
-	return 0;
+	return sdw_write(slave, SWRS_SCP_HOST_CLK_DIV2_CTL_BANK(params->next_bank),
+			 0x01);
 }
 
 static const struct sdw_slave_ops wsa881x_slave_ops = {
Signature · 1 line
2.56.1
#2 lore raw

PATCH RESEND 2/2 ASoC: codecs: wcd-common: propagate sdw_write() error from bus_config

In reply to Andrey Karelin

wcd_bus_config() programs the clock divider for the next bank via sdw_write() but ignores its result and always returns 0. A failed write is therefore hidden from sdw_notify_config(), which aborts programming of the stream parameters when a bus_config callback fails, and the codec may keep running with a wrong clock configuration after the bank switch.

The callback is shared by the WCD938x and WCD939x SoundWire drivers. It was moved to the common helper as is by commit 59aebbbb0b47 ("ASoC:
codecs: wcd-common: move status_update callback to common"); the original per-driver callbacks had the same problem.

Return the result of sdw_write() instead.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 16572522aece ("ASoC: codecs: wcd938x-sdw: add SoundWire driver")
Fixes be2af391cea0 ("ASoC: codecs: Add WCD939x Soundwire devices driver")
---
 sound/soc/codecs/wcd-common.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
sound/soc/codecs/wcd-common.c +1 -3
index 9016e974582f..74bd718b8a34 100644
@@ -115,9 +115,7 @@ EXPORT_SYMBOL_GPL(wcd_update_status);
 
 int wcd_bus_config(struct sdw_slave *slave, struct sdw_bus_params *params)
 {
-	sdw_write(slave, SWRS_SCP_HOST_CLK_DIV2_CTL_BANK(params->next_bank), 0x01);
-
-	return 0;
+	return sdw_write(slave, SWRS_SCP_HOST_CLK_DIV2_CTL_BANK(params->next_bank), 0x01);
 }
 EXPORT_SYMBOL_GPL(wcd_bus_config);
 
Signature · 1 line
2.56.1
#3 lore raw
In reply to Andrey Karelin

Hi Srinivas,

Gentle ping on this series. It was first posted on 16 Oct and resent unchanged on 18 Nov; there have been no comments so far.

The change is small: wsa881x_bus_config() and wcd_bus_config() return the result of sdw_write() instead of always returning 0, as the other SoundWire codec drivers already do. Both patches still apply to broonie/sound for-7.5, including on top of "ASoC: codecs: wcd-common:
bound interrupt status retries".

Could you take a look and let me know if you have any concerns, or ack the series if it looks fine to you?

Thanks,
Andrey