Skip to contentSkip to conversation

ASoC: cs35l56: Prepare for SDCA Companion Amp

PATCH RESEND In review Richard Fitzgerald 3 participants 11 messages Nov 25

Subsystems (3)
lore
Share & tools
lore

Richard Fitzgerald

author maintainer
#0 lore raw

cover ASoC: cs35l56: Prepare for SDCA Companion Amp

This series removes some unused legacy implementation of the SoundWire DP3 port. This old code conflicts with the actual purpose of DP3 as the SDCA Companion Amp output.

0001 and 0002 are the two changes to switch the code over to being suitable for Companion Amp.

0003 cleans up a regmap table that has been made redundant by #1 and #2

0004 is KUnit testing for the changes in #1.
---
Resending because the dependencies have been applied to for-next so these patches all apply now.

Richard Fitzgerald (4):
ASoC: cs35l56: Remove SDW1 TX source controls and widgets
ASoC: cs35l56: Rename the DP3 DAI to cs35l56-ot127
ASoC: cs35l56: Eliminate trivial regmap patch
ASoC: cs35l56: Add test that probe() doesn't write SDW mux registers

 sound/soc/codecs/cs35l56-shared.c | 44 +++-------------
 sound/soc/codecs/cs35l56-test.c   | 84 +++++++++++++++++++++++++++++++
 sound/soc/codecs/cs35l56.c        | 55 ++------------------
 3 files changed, 95 insertions(+), 88 deletions(-)
Signature · 1 line
2.47.3
author maintainer
#1 lore raw

PATCH RESEND 1/4 ASoC: cs35l56: Remove SDW1 TX source controls and widgets

Remove the ALSA controls and mux widgets for the SDW1 capture DAI. Connect this DAI to a dummy siggen source like the OT25 DAI. This is to allow DP3 to be used for its intended purpose as the SDCA companion amp output.

The implementation of this DAI was incorrect. It provided a capture DAI for the SoundWire DP3 port. But DP4 (OT25 DAI) is the port for feedback to the host.

The DP3 port is used for SDCA companion amp (OT127) and the mixer source registers are owned by the firmware. The driver should not be writing to them.

Nothing has ever used these ALSA controls so they can safely be removed. The incorrect use of DP3 as the feedback to the host has already been fixed in these commits:

commit 86c8360c97f6 ("ASoC: cs35l56: Add DAI for SDCA OT25 stream") commit 4b7f393a01f8 ("ASoC: sdw_utils: Switch CS35L56/57/62/63 to use OT25 DAI")

---
 sound/soc/codecs/cs35l56-shared.c | 16 ----------
 sound/soc/codecs/cs35l56.c        | 51 ++-----------------------------
 2 files changed, 2 insertions(+), 65 deletions(-)
sound/soc/codecs/cs35l56-shared.c +0 -16
index 4d76f1777927..073f7bdd3b0d 100644
@@ -49,14 +49,6 @@ int cs35l56_set_asp_defaults(struct cs35l56_base *cs35l56_base)
 EXPORT_SYMBOL_NS_GPL(cs35l56_set_asp_defaults, "SND_SOC_CS35L56_SHARED");
 
 static const struct reg_sequence cs35l56_patch[] = {
-	/*
-	 * Firmware can change these to non-defaults to satisfy SDCA.
-	 * Ensure that they are at known defaults.
-	 */
-	{ CS35L56_SWIRE_DP3_CH1_INPUT,		0x00000018 },
-	{ CS35L56_SWIRE_DP3_CH2_INPUT,		0x00000019 },
-	{ CS35L56_SWIRE_DP3_CH3_INPUT,		0x00000029 },
-	{ CS35L56_SWIRE_DP3_CH4_INPUT,		0x00000028 },
 	{ CS35L56_IRQ1_MASK_18,			0x1f7df0ff },
 };
 
@@ -105,10 +97,6 @@ int cs35l56_set_patch(struct cs35l56_base *cs35l56_base)
 EXPORT_SYMBOL_NS_GPL(cs35l56_set_patch, "SND_SOC_CS35L56_SHARED");
 
 static const struct reg_default cs35l56_reg_defaults[] = {
-	{ CS35L56_SWIRE_DP3_CH1_INPUT,		0x00000018 },
-	{ CS35L56_SWIRE_DP3_CH2_INPUT,		0x00000019 },
-	{ CS35L56_SWIRE_DP3_CH3_INPUT,		0x00000029 },
-	{ CS35L56_SWIRE_DP3_CH4_INPUT,		0x00000028 },
 	{ CS35L56_IRQ1_MASK_1,			0x83ffffff },
 	{ CS35L56_IRQ1_MASK_2,			0xffff7fff },
 	{ CS35L56_IRQ1_MASK_4,			0xe0ffffff },
@@ -121,10 +109,6 @@ static const struct reg_default cs35l56_reg_defaults[] = {
 };
 
 static const struct reg_default cs35l63_reg_defaults[] = {
-	{ CS35L56_SWIRE_DP3_CH1_INPUT,		0x00000018 },
-	{ CS35L56_SWIRE_DP3_CH2_INPUT,		0x00000019 },
-	{ CS35L56_SWIRE_DP3_CH3_INPUT,		0x00000029 },
-	{ CS35L56_SWIRE_DP3_CH4_INPUT,		0x00000028 },
 	{ CS35L56_IRQ1_MASK_1,			0x8003ffff },
 	{ CS35L56_IRQ1_MASK_2,			0xffff7fff },
 	{ CS35L56_IRQ1_MASK_4,			0xe0ffffff },
sound/soc/codecs/cs35l56.c +2 -49

75 lines not on this page · raw message

Signature · 1 line
2.47.3
#2 lore raw

Re: [PATCH RESEND 1/4] ASoC: cs35l56: Remove SDW1 TX source controls and widgets

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] ASoC: cs35l56: missing volatile marking for DP3 input regs --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] ASoC: cs35l56: missing volatile marking for DP3 input regs --

commit b3ae50f49f263d1a4523d5cee3a2aa7287b0ace9
Author: Richard Fitzgerald <[email protected]>

ASoC: cs35l56: Remove SDW1 TX source controls and widgets

This commit removes the ALSA controls, mux widgets, and regmap default/patch entries for the SoundWire DP3 mixer source registers, and connects the SDW1 Capture DAI to a dummy siggen source.

Quoted 31 lines
sound/soc/codecs/cs35l56-shared.c +0 -12
index 4d76f17779272..073f7bdd3b0d4 100644
@@ -49,14 +49,6 @@ int cs35l56_set_asp_defaults(struct cs35l56_base *cs35l56_base)
 EXPORT_SYMBOL_NS_GPL(cs35l56_set_asp_defaults, "SND_SOC_CS35L56_SHARED");
 
 static const struct reg_sequence cs35l56_patch[] = {
-	/*
-	 * Firmware can change these to non-defaults to satisfy SDCA.
-	 * Ensure that they are at known defaults.
-	 */
-	{ CS35L56_SWIRE_DP3_CH1_INPUT,		0x00000018 },
-	{ CS35L56_SWIRE_DP3_CH2_INPUT,		0x00000019 },
-	{ CS35L56_SWIRE_DP3_CH3_INPUT,		0x00000029 },
-	{ CS35L56_SWIRE_DP3_CH4_INPUT,		0x00000028 },
 	{ CS35L56_IRQ1_MASK_18,			0x1f7df0ff },
 };
 
@@ -105,10 +97,6 @@ int cs35l56_set_patch(struct cs35l56_base *cs35l56_base)
 EXPORT_SYMBOL_NS_GPL(cs35l56_set_patch, "SND_SOC_CS35L56_SHARED");
 
 static const struct reg_default cs35l56_reg_defaults[] = {
-	{ CS35L56_SWIRE_DP3_CH1_INPUT,		0x00000018 },
-	{ CS35L56_SWIRE_DP3_CH2_INPUT,		0x00000019 },
-	{ CS35L56_SWIRE_DP3_CH3_INPUT,		0x00000029 },
-	{ CS35L56_SWIRE_DP3_CH4_INPUT,		0x00000028 },
 	{ CS35L56_IRQ1_MASK_1,			0x83ffffff },
 	{ CS35L56_IRQ1_MASK_2,			0xffff7fff },
 	{ CS35L56_IRQ1_MASK_4,			0xe0ffffff },

sound/soc/codecs/cs35l56-shared.c static const struct reg_default cs35l56_reg_defaults[] = { · line 114

Quoted 10 lines
sound/soc/codecs/cs35l56-shared.c +0 -4
@@ -121,10 +109,6 @@ static const struct reg_default cs35l56_reg_defaults[] = {
 };
 
 static const struct reg_default cs35l63_reg_defaults[] = {
-	{ CS35L56_SWIRE_DP3_CH1_INPUT,		0x00000018 },
-	{ CS35L56_SWIRE_DP3_CH2_INPUT,		0x00000019 },
-	{ CS35L56_SWIRE_DP3_CH3_INPUT,		0x00000029 },
-	{ CS35L56_SWIRE_DP3_CH4_INPUT,		0x00000028 },
 	{ CS35L56_IRQ1_MASK_1,			0x8003ffff },
 	{ CS35L56_IRQ1_MASK_2,			0xffff7fff },
 	{ CS35L56_IRQ1_MASK_4,			0xe0ffffff },

[Severity: Medium]
Should CS35L56_SWIRE_DP3_CH1_INPUT through CS35L56_SWIRE_DP3_CH4_INPUT also be added to cs35l56_common_volatile_reg() alongside the other firmware-owned mixer input registers (CS35L56_DACPCM1_INPUT, CS35L56_DSP1RX1_INPUT, etc.)?

These four registers remain listed in cs35l56_readable_reg(). If they are read through regmap (for example via regmap debugfs), _regmap_read() caches the values in the REGCACHE_MAPLE tree. Because they are no longer in cs35l56_reg_defaults[] or cs35l63_reg_defaults[], regcache_reg_needs_sync() treats any cached entry without a reg_default as needing sync, so regcache_sync() in cs35l56_runtime_resume_common() or cs35l56_init() will write the stale cached values back to the firmware-owned registers.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author maintainer
#3 lore raw

PATCH RESEND 2/4 ASoC: cs35l56: Rename the DP3 DAI to cs35l56-ot127

In reply to Richard Fitzgerald

Rename the DAI for DP3 to cs35l56-ot127 to match its actual function as the SDCA OT127 Companion Amp output (a type of codec-codec link).

The previous designation as "SDW1 Capture" was incorrect. It is not for host capture and never has been (this function is on DP4).

The use of the old DAI name was already removed in previous commit 4b7f393a01f8 ("ASoC: sdw_utils: Switch CS35L56/57/62/63 to use OT25 DAI"), so there are no users of the old DAI name in the kernel.

---
 sound/soc/codecs/cs35l56.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/codecs/cs35l56.c +3 -3
index acb202559dff..439063084d4b 100644
@@ -436,7 +436,7 @@ static const struct snd_soc_dapm_route cs35l56_audio_map[] = {
 	{ "ASP1 Capture", NULL, "ASP1TX3" },
 	{ "ASP1 Capture", NULL, "ASP1TX4" },
 
-	{ "SDW1 Capture", NULL, "OT127 Source" },
+	{ "OT127", NULL, "OT127 Source" },
 
 	{ "OT25", NULL, "OT25 Reference" },
 };
@@ -855,10 +855,10 @@ static struct snd_soc_dai_driver cs35l56_dai[] = {
 		.ops = &cs35l56_sdw_dai_ops,
 	},
 	{
-		.name = "cs35l56-sdw1c",
+		.name = "cs35l56-ot127",
 		.id = 2,
 		.capture = {
-			.stream_name = "SDW1 Capture",
+			.stream_name = "OT127",
 			.channels_min = 1,
 			.channels_max = 4,
 			.rates = CS35L56_RATES,
Signature · 1 line
2.47.3
author maintainer
#4 lore raw

PATCH RESEND 3/4 ASoC: cs35l56: Eliminate trivial regmap patch

In reply to Richard Fitzgerald

Previous commits removed most of the registers from the common cs35l56_patch, leaving only one register in this patch. Move that single register patch into the separate cs35l56 and cs35l63 patches and remove the trivial common patch.

---
 sound/soc/codecs/cs35l56-shared.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)
sound/soc/codecs/cs35l56-shared.c +7 -21
index 073f7bdd3b0d..34aebf81f4a4 100644
@@ -50,16 +50,14 @@ EXPORT_SYMBOL_NS_GPL(cs35l56_set_asp_defaults, "SND_SOC_CS35L56_SHARED");
 
 static const struct reg_sequence cs35l56_patch[] = {
 	{ CS35L56_IRQ1_MASK_18,			0x1f7df0ff },
-};
-
-static const struct reg_sequence cs35l56_patch_fw[] = {
 	/* These are not reset by a soft-reset, so patch to defaults. */
 	{ CS35L56_MAIN_RENDER_USER_MUTE,	0x00000000 },
 	{ CS35L56_MAIN_RENDER_USER_VOLUME,	0x00000000 },
 	{ CS35L56_MAIN_POSTURE_NUMBER,		0x00000000 },
 };
 
-static const struct reg_sequence cs35l63_patch_fw[] = {
+static const struct reg_sequence cs35l63_patch[] = {
+	{ CS35L56_IRQ1_MASK_18,			0x1f7df0ff },
 	/* These are not reset by a soft-reset, so patch to defaults. */
 	{ CS35L63_MAIN_RENDER_USER_MUTE,	0x00000000 },
 	{ CS35L63_MAIN_RENDER_USER_VOLUME,	0x00000000 },
@@ -68,31 +66,19 @@ static const struct reg_sequence cs35l63_patch_fw[] = {
 
 int cs35l56_set_patch(struct cs35l56_base *cs35l56_base)
 {
-	int ret;
-
-	ret = regmap_register_patch(cs35l56_base->regmap, cs35l56_patch,
-				     ARRAY_SIZE(cs35l56_patch));
-	if (ret)
-		return ret;
-
-
 	switch (cs35l56_base->type) {
 	case 0x54:
 	case 0x56:
 	case 0x57:
-		ret = regmap_register_patch(cs35l56_base->regmap, cs35l56_patch_fw,
-					    ARRAY_SIZE(cs35l56_patch_fw));
-		break;
+		return regmap_register_patch(cs35l56_base->regmap, cs35l56_patch,
+					     ARRAY_SIZE(cs35l56_patch));
 	case 0x63:
 	case 0x62:
-		ret = regmap_register_patch(cs35l56_base->regmap, cs35l63_patch_fw,
-					    ARRAY_SIZE(cs35l63_patch_fw));
-		break;
+		return regmap_register_patch(cs35l56_base->regmap, cs35l63_patch,
+					     ARRAY_SIZE(cs35l63_patch));
 	default:
-		break;
+		return 0;
 	}
-
-	return ret;
 }
 EXPORT_SYMBOL_NS_GPL(cs35l56_set_patch, "SND_SOC_CS35L56_SHARED");
 
Signature · 1 line
2.47.3
author maintainer
#5 lore raw

PATCH RESEND 4/4 ASoC: cs35l56: Add test that probe() doesn't write SDW mux registers

In reply to Richard Fitzgerald

The driver cannot assume that it owns control of the CS35L56_SWIRE_DP3_CH?_INPUT registers so it must not do anything during probe() or component_probe() that could result in a write to these registers. Add a test case for this.

---
 sound/soc/codecs/cs35l56-test.c | 84 +++++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)
sound/soc/codecs/cs35l56-test.c +84 -0
index b422d19ba0b2..362da30b949e 100644
@@ -63,6 +63,7 @@ struct cs35l56_test_priv {
 
 	bool asp_config_regs_written;
 	bool asp_mixer_regs_written;
+	bool sdw_mux_regs_written;
 };
 
 struct cs35l56_test_param {
@@ -124,6 +125,11 @@ static const struct range cs35l56_test_asp_mixer_registers_range = {
 	.end = CS35L56_ASP1TX4_INPUT,
 };
 
+static const struct range cs35l56_test_sdw_mux_registers_range = {
+	.start = CS35L56_SWIRE_DP3_CH1_INPUT,
+	.end = CS35L56_SWIRE_DP3_CH4_INPUT,
+};
+
 static int cs35l56_test_mock_registers_read(void *context,
 					    const void *reg_buf, size_t reg_size,
 					    void *val_buf, size_t val_size)
@@ -200,6 +206,9 @@ static int cs35l56_test_mock_registers_write(void *context, const void *data, si
 	if (range_overlaps(&addr_range, &cs35l56_test_asp_mixer_registers_range))
 		priv->asp_mixer_regs_written = true;
 
+	if (range_overlaps(&addr_range, &cs35l56_test_sdw_mux_registers_range))
+		priv->sdw_mux_regs_written = true;
+
 	for (i = 0; i < count; i += sizeof(u32)) {
 		val = get_unaligned_be32(buf + i);
 		ret = regmap_write(priv->registers, reg + i, val);
@@ -929,6 +938,79 @@ static void cs35l56_test_component_probe_omits_asp(struct kunit *test)
 	KUNIT_EXPECT_FALSE(test, priv->asp_mixer_regs_written);
 }
 
+/*
+ * Probing the component must not write the SoundWire TX mux registers,
+ * either directly or through a subsequent regcache_sync().
+ */
+static void cs35l56_test_component_probe_omits_sdw_mux(struct kunit *test)
+{
+	struct cs35l56_test_priv *priv = test->priv;
+	struct cs35l56_private *cs35l56 = priv->cs35l56_priv;
+	struct snd_soc_card *card = cs35l56->component->card;
+	struct snd_soc_aux_dev *aux;
+	struct faux_device *card_dev;
+
+	cs35l56_test_create_mock_supplies(test);
+	cs35l56_test_create_mock_device_registers(test);
+
+	KUNIT_ASSERT_NOT_NULL(test, priv->regmap_config);
+	cs35l56->base.regmap = devm_regmap_init(cs35l56->base.dev,
+						&cs35l56_test_mock_registers_client_regmap_bus,
+						test, priv->regmap_config);
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, cs35l56->base.regmap);
+
+	KUNIT_ASSERT_EQ(test, 0, cs35l56_common_probe(cs35l56, 0));
+	KUNIT_ASSERT_EQ(test, 0,
+			kunit_add_action_or_reset(test, cs35l56_remove_wrapper, cs35l56));
+
+	/* Prevent real dsp_work */
+	INIT_WORK(&cs35l56->dsp_work, cs35l56_test_dummy_dsp_work);
+
+	/* Simulate first attachment and re-attachment after the soft reset. */
+	regcache_cache_only(cs35l56->base.regmap, false);
+	KUNIT_ASSERT_EQ(test, 0, cs35l56_init(cs35l56));
+	KUNIT_ASSERT_EQ(test, 0, cs35l56_init(cs35l56));
+	KUNIT_ASSERT_TRUE(test, cs35l56->base.init_done);
+	flush_work(&cs35l56->component_register_work);
+	KUNIT_ASSERT_TRUE(test, cs35l56->component_registered);
+
+	card_dev = faux_device_create("cs35l56_test_card", NULL, NULL);
+	KUNIT_ASSERT_NOT_NULL(test, card_dev);
+	KUNIT_ASSERT_EQ(test, 0,
+			kunit_add_action_or_reset(test, faux_device_destroy_wrapper, card_dev));
+
+	/* Bind as an auxiliary component so the ASP DAI is never probed. */
+	aux = kunit_kzalloc(test, sizeof(*aux), GFP_KERNEL);
+	KUNIT_ASSERT_NOT_NULL(test, aux);
+	aux->dlc.name = dev_name(cs35l56->base.dev);
+	card->name = "cs35l56-test";
+	card->dev = &card_dev->dev;
+	card->owner = THIS_MODULE;
+	card->aux_dev = aux;
+	card->num_aux_devs = 1;
+	KUNIT_ASSERT_EQ(test, 0, snd_soc_register_card(card));
+	KUNIT_ASSERT_EQ(test, 0,
+			kunit_add_action_or_reset(test, snd_soc_unregister_card_wrapper, card));
+	KUNIT_ASSERT_TRUE(test, card->instantiated);
+	KUNIT_EXPECT_FALSE(test, priv->sdw_mux_regs_written);
+
+	/*
+	 * Flush cache to ensure there aren't cached values for the SoundWire muxes.
+	 * The first case without regcache_mark_dirty() tests flushing when
+	 * hardware registers have not reset, and requires a dummy write to
+	 * the cache to make it dirty.
+	 */
+	regcache_cache_only(cs35l56->base.regmap, true);
+	KUNIT_ASSERT_EQ(test, 0, regmap_write(cs35l56->base.regmap,
+					      CS35L56_DSP_VIRTUAL1_MBOX_1, 0));
+	regcache_cache_only(cs35l56->base.regmap, false);
+	KUNIT_ASSERT_EQ(test, 0, regcache_sync(cs35l56->base.regmap));
+	regcache_mark_dirty(cs35l56->base.regmap);
+	KUNIT_ASSERT_EQ(test, 0, regcache_sync(cs35l56->base.regmap));
+
+	KUNIT_EXPECT_FALSE(test, priv->sdw_mux_regs_written);
+}
+
 static int cs35l56_test_case_init_common(struct kunit *test)
 {
 	struct cs35l56_test_priv *priv;
@@ -1233,6 +1315,8 @@ static struct kunit_case cs35l56_test_cases_soundwire[] = {
 	KUNIT_CASE(cs35l56_test_set_fw_name_preserves_spkid_without_onchip_gpios),
 	KUNIT_CASE_PARAM(cs35l56_test_component_probe_omits_asp,
 			 cs35l56_test_type_rev_all_gen_params),
+	KUNIT_CASE_PARAM(cs35l56_test_component_probe_omits_sdw_mux,
+			 cs35l56_test_type_rev_all_gen_params),
 
 	{ } /* terminator */
 };
Signature · 1 line
2.47.3
#6 lore raw

Re: [PATCH RESEND 4/4] ASoC: cs35l56: Add test that probe() doesn't write SDW mux registers

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] ASoC: cs35l56: missing SDW mux call to cs35l56_test_fill_register_range() --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] ASoC: cs35l56: missing SDW mux call to cs35l56_test_fill_register_range()
--

commit 6abf5b53b66d893e6ef45aa41f1e494247ead199
Author: Richard Fitzgerald <[email protected]>

ASoC: cs35l56: Add test that probe() doesn't write SDW mux registers

This commit adds a KUnit test verifying that probing the cs35l56 component does not write to the SoundWire TX mux registers directly or via a subsequent regcache_sync().

Quoted 4 lines
sound/soc/codecs/cs35l56-test.c +0 -0
index b422d19ba0b21..362da30b949e6 100644

[ ... ]

Quoted 18 lines
sound/soc/codecs/cs35l56-test.c +14 -0
@@ -929,6 +938,79 @@ static void cs35l56_test_component_probe_omits_asp(struct kunit *test)
 	KUNIT_EXPECT_FALSE(test, priv->asp_mixer_regs_written);
 }
 
+/*
+ * Probing the component must not write the SoundWire TX mux registers,
+ * either directly or through a subsequent regcache_sync().
+ */
+static void cs35l56_test_component_probe_omits_sdw_mux(struct kunit *test)
+{
+	struct cs35l56_test_priv *priv = test->priv;
+	struct cs35l56_private *cs35l56 = priv->cs35l56_priv;
+	struct snd_soc_card *card = cs35l56->component->card;
+	struct snd_soc_aux_dev *aux;
+	struct faux_device *card_dev;
+
+	cs35l56_test_create_mock_supplies(test);
+	cs35l56_test_create_mock_device_registers(test);

[ ... ]

Quoted 6 lines
sound/soc/codecs/cs35l56-test.c +6 -0
+	/*
+	 * Flush cache to ensure there aren't cached values for the SoundWire muxes.
+	 * The first case without regcache_mark_dirty() tests flushing when
+	 * hardware registers have not reset, and requires a dummy write to
+	 * the cache to make it dirty.
+	 */

sound/soc/codecs/cs35l56-test.c static void cs35l56_test_component_probe_omits_asp(struct kunit *test) · line 1012

Quoted 10 lines
sound/soc/codecs/cs35l56-test.c +10 -0
+	regcache_cache_only(cs35l56->base.regmap, true);
+	KUNIT_ASSERT_EQ(test, 0, regmap_write(cs35l56->base.regmap,
+					      CS35L56_DSP_VIRTUAL1_MBOX_1, 0));
+	regcache_cache_only(cs35l56->base.regmap, false);
+	KUNIT_ASSERT_EQ(test, 0, regcache_sync(cs35l56->base.regmap));
+	regcache_mark_dirty(cs35l56->base.regmap);
+	KUNIT_ASSERT_EQ(test, 0, regcache_sync(cs35l56->base.regmap));
+
+	KUNIT_EXPECT_FALSE(test, priv->sdw_mux_regs_written);
+}

[Severity: Medium]
Should cs35l56_test_create_mock_device_registers() also pre-populate cs35l56_test_sdw_mux_registers_range with cs35l56_test_fill_register_range()?

priv->registers is in cache-only mode, and the CS35L56_SWIRE_DP3_CH?_INPUT registers are only filled for ASP ranges:

sound/soc/codecs/cs35l56-test.c:cs35l56_test_create_mock_device_registers() {
	...
	cs35l56_test_fill_register_range(test, &cs35l56_test_asp_config_registers_range, 0);
	cs35l56_test_fill_register_range(test, &cs35l56_test_asp_mixer_registers_range, 0);
}

Without pre-populating cs35l56_test_sdw_mux_registers_range, any read of the SoundWire mux registers during probe (for example, via dapm_read() when initializing mux widgets) fails with -EBUSY in cs35l56_test_mock_registers_read(). _regmap_read() then skips caching the value in cs35l56->base.regmap, so the subsequent regcache_sync() test will silently pass instead of catching a read that populated the cache.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
author maintainer
#7 lore raw

Re: [PATCH RESEND 4/4] ASoC: cs35l56: Add test that probe() doesn't write SDW mux registers

In reply to Richard Fitzgerald
Quoted 4 lines · Richard Fitzgerald

The driver cannot assume that it owns control of the CS35L56_SWIRE_DP3_CH?_INPUT registers so it must not do anything during probe() or component_probe() that could result in a write to these registers. Add a test case for this.

Sashiko found a bug in this test. Will send a V2 series.

maintainer
#8 lore raw

Re: [PATCH RESEND 4/4] ASoC: cs35l56: Add test that probe() doesn't write SDW mux registers

Quoted 7 lines · Richard Fitzgerald
Quoted 4 lines · Richard Fitzgerald

The driver cannot assume that it owns control of the CS35L56_SWIRE_DP3_CH?_INPUT registers so it must not do anything during probe() or component_probe() that could result in a write to these registers. Add a test case for this.

Sashiko found a bug in this test. Will send a V2 series.

Send something incremental, this was already applied even before your resend.

author maintainer
#9 lore raw

Re: [PATCH RESEND 4/4] ASoC: cs35l56: Add test that probe() doesn't write SDW mux registers

Quoted 11 lines · Mark Brown
Quoted 7 lines · Richard Fitzgerald
Quoted 4 lines · Richard Fitzgerald

The driver cannot assume that it owns control of the CS35L56_SWIRE_DP3_CH?_INPUT registers so it must not do anything during probe() or component_probe() that could result in a write to these registers. Add a test case for this.

Sashiko found a bug in this test. Will send a V2 series.

Send something incremental, this was already applied even before your resend.

I don't see them in your for-7.4/for-7.5/for-next branches. Are you thinking of the previous series that did something similar for the ASP registers?

maintainer
#10 lore raw

Re: [PATCH RESEND 4/4] ASoC: cs35l56: Add test that probe() doesn't write SDW mux registers

Quoted 8 lines · Richard Fitzgerald
Quoted 2 lines · Mark Brown

Send something incremental, this was already applied even before your resend.

I don't see them in your for-7.4/for-7.5/for-next branches. Are you thinking of the previous series that did something similar for the ASP registers?

It should be in CI, though it's possible if you have two similar enough inapplicable serieses one of them got dropped on the floor. There is a lag between me applying things and them actually appearing where I test them.