Linux Sound subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Stefan Binding" <sbinding@opensource.cirrus.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH v3 2/8] ASoC: cs35l41: Prevent software reset when using SPI
Date: Thu, 03 Dec 2026 14:55:31 +0000	[thread overview]
Message-ID: <sashiko-outbox-248031@kernel.org> (raw)
In-Reply-To: <20261203141359.150688-3-sbinding@opensource.cirrus.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] ASoC: cs35l41: cs35l41_reset_and_boot() skips SPI reset on
  unload/rebind
- [Low] ASoC: cs35l41: dev_err() called with NULL dev in
  cs35l41_is_spi_regmap()
- [Low] ASoC: cs35l41: Fixes tag cites refactor instead of introducing
  commits
--

commit 1cc179574843ec0efb1395f06726b215379a855a
Author: Stefan Binding <sbinding@opensource.cirrus.com>

> ASoC: cs35l41: Prevent software reset when using SPI
>
> If there is any SPI Bus activity during a software reset, even if the
> chip select is not set for that Amp, the amp may not boot.
>
> This affects both CS35L41 ASoC and HDA drivers. For HDA this also
> affects system resume.
>
> Whilst the driver needs the amp to be reset when coming out of system
> suspend, the driver will try to toggle the reset GPIO off and on to
> ensure this occurs. If a reset GPIO is not defined for the amplifier,
> the amplifier will not probe - unless the amp is using a shared reset.
> In the case of a shared reset, the GPIO will control resets for both
> amps anyway.
>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=221161
> Fixes: 9bfbc1af0713 ("ALSA: hda: cs35l41: Add common wait_for_boot api and reset_and_boot api")
>
> Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>

[Severity: Low]
Should the Fixes tag cite the commits that originally introduced the
software reset on SPI rather than the refactor 9bfbc1af0713 ("ALSA:
hda: cs35l41: Add common wait_for_boot api and reset_and_boot api")?

Commit 2ee06ff5d7cf ("ALSA: hda: cs35l41: Force a software reset after
hardware reset") added the HDA software reset and commit a04a1a820f37
("ASoC: cs35l41: Use common wait_for_boot and reset_and_boot apis")
brought it to ASoC.  Citing only the refactor hides older stable trees:

  Fixes: 2ee06ff5d7cf ("ALSA: hda: cs35l41: Force a software reset after hardware reset")
  Fixes: a04a1a820f37 ("ASoC: cs35l41: Use common wait_for_boot and reset_and_boot apis")

> diff --git a/sound/soc/codecs/cs35l41-lib.c b/sound/soc/codecs/cs35l41-lib.c
> index 9e6bed22fbdb5..e11810795ee86 100644
> --- a/sound/soc/codecs/cs35l41-lib.c
> +++ b/sound/soc/codecs/cs35l41-lib.c

[ ... ]

> @@ -1588,6 +1589,18 @@ int cs35l41_exit_hibernate(struct device *dev, struct regmap *regmap)
>  }
>  EXPORT_SYMBOL_GPL(cs35l41_exit_hibernate);
>  
> +static bool cs35l41_is_spi_regmap(struct regmap *regmap)
> +{
> +	struct device *dev = regmap_get_device(regmap);
> +
> +	if (!dev) {
> +		dev_err(dev, "Failed to get device from regmap\n");
> +		return false;
> +	}
> +
> +	return (IS_ENABLED(CONFIG_SPI) && dev->bus == &spi_bus_type);
> +}

[Severity: Low]
Is passing dev to dev_err() inside the if (!dev) branch intentional?

__dev_printk() guards against NULL and logs "(NULL device *)", so this
won't crash, but it drops device context.  Since cs35l41_reset_and_boot()
already receives struct device *dev, this helper could check that dev
directly and drop the regmap_get_device() lookup and error path.

[ ... ]

> @@ -1627,27 +1640,36 @@ int cs35l41_reset_and_boot(struct device *dev, struct regmap *regmap)
>  {
>  	int ret;
>  
> -	ret = regmap_write(regmap, CS35L41_SFT_RESET, CS35L41_SOFTWARE_RESET);
> -	if (ret) {
> -		dev_warn(dev, "Failed to write software reset: %d\n", ret);
> -
> +	if (cs35l41_is_spi_regmap(regmap)) {
>  		/*
> -		 * If the write failed, it is likely because the chip is still booting after a
> -		 * reset. Wait for boot, then retry the software reset. If the initial write failed
> -		 * for another reason, then either waiting for boot, or the second write will fail,
> -		 * So we can return the error then.
> +		 * If there is any SPI Bus activity during a software reset, even if the
> +		 * chip select is not set for that Amp, the amp may not boot.
>  		 */
> -		ret = cs35l41_wait_boot_done(dev, regmap);
> -		if (ret)
> -			return ret;
> +		dev_dbg(dev, "Preventing Software Reset on SPI\n");
>  
> +	} else {

[Severity: Medium]
As reported by Mark Brown on v2 [1], what happens on driver unload/reload
or unbind/rebind for an SPI amplifier without an owned reset GPIO?

cs35l41_probe() gets reset_gpio with devm_gpiod_get_optional() (clearing
it on -EBUSY for shared resets), and HDA secondary shared-reset amps also
probe with reset_gpio set to NULL.  Neither remove path issues an SPI
software reset, so re-probing now skips CS35L41_SFT_RESET altogether.

That leaves hardware in its prior state while devm_regmap_init_spi()
seeds a fresh REGCACHE_MAPLE cache with defaults, causing cache
divergence on regmap_update_bits() and -ETIMEDOUT in HDA
cs35l41_wait_boot_done() if CS35L41_OTP_BOOT_DONE was already cleared.

Commit "ALSA: hda/cs35l41: Ensure SPI devices are always reset during
system suspend" only handles HDA suspend aborts in
cs35l41_system_suspend(), leaving unload/reload and unbind/rebind
unaddressed.

[1] https://lore.kernel.org/r/179574575897.838304.8691157769089102804.b4-review@b4

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203141359.150688-1-sbinding@opensource.cirrus.com?part=2

  reply	other threads:[~2026-12-03 14:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 14:13 [PATCH v3 0/8] Fixes and improvements in CS35L41 HDA driver for System Suspend/Resume Stefan Binding
2026-12-03 14:13 ` [PATCH v3 1/8] ALSA: hda: cs35l41: Remove redundant lock_system_sleep() calls Stefan Binding
2026-12-03 14:13 ` [PATCH v3 2/8] ASoC: cs35l41: Prevent software reset when using SPI Stefan Binding
2026-12-03 14:55   ` sashiko-bot [this message]
2026-12-03 14:13 ` [PATCH v3 3/8] ALSA: hda: cs35l41: Unset irq if not used or configured Stefan Binding
2026-12-03 14:13 ` [PATCH v3 4/8] ALSA: hda/cs35l41: Split System Suspend/Resume callbacks Stefan Binding
2026-12-03 14:13 ` [PATCH v3 5/8] ALSA: hda/cs35l41: Remove support for alternative firmware types Stefan Binding
2026-12-03 14:13 ` [PATCH v3 6/8] ALSA: hda/cs35l41: Store filenames of successfully loaded firmware and tunings Stefan Binding
2026-12-03 14:13 ` [PATCH v3 7/8] ALSA: hda/cs35l41: rework how firmware requests are queued and flushed to prevent races Stefan Binding
2026-12-03 14:13 ` [PATCH v3 8/8] ALSA: hda/cs35l41: Ensure SPI devices are always reset during system suspend Stefan Binding

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-248031@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sbinding@opensource.cirrus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox