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 v1 4/7] ALSA: hda/cs35l41: Split System Suspend/Resume callbacks
Date: Fri, 20 Nov 2026 16:27:33 +0000	[thread overview]
Message-ID: <sashiko-outbox-225566@kernel.org> (raw)
In-Reply-To: <20261120161136.157593-5-sbinding@opensource.cirrus.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] ALSA: hda/cs35l41: shared reset race in cs35l41_system_resume()
- [Medium] ALSA: hda/cs35l41: disable_irq() ordered after
  pm_runtime_force_suspend()
--

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

ALSA: hda/cs35l41: Split System Suspend/Resume callbacks

This commit splits CS35L41 HDA system suspend and resume into
suspend_late, suspend_noirq, and resume_noirq callbacks to assert the
shared reset GPIO after all instances have suspended and temporarily
disable the shared IRQ line across suspend and resume transitions.

> diff --git a/sound/hda/codecs/side-codecs/cs35l41_hda.c b/sound/hda/codecs/side-codecs/cs35l41_hda.c
> index 2e2bf231d3fc4..1a192749c7b06 100644
> --- a/sound/hda/codecs/side-codecs/cs35l41_hda.c
> +++ b/sound/hda/codecs/side-codecs/cs35l41_hda.c

[ ... ]

> @@ -963,15 +961,75 @@ static int cs35l41_system_suspend(struct device *dev)
>  	if (ret)
>  		dev_err(dev, "System Suspend Failed, not ready for Reset: %d\n", ret);
>  
> +
> +	/*
> +	 * The interrupt line is normally shared, but after we start suspending
> +	 * we can't check if our device is the source of an interrupt, and can't
> +	 * clear it. Prevent this race by temporarily disabling the parent irq
> +	 * until we reach _noirq.
> +	 */
> +	if (cs35l41->irq)
> +		disable_irq(cs35l41->irq);

[Severity: Medium]
Should disable_irq(cs35l41->irq) run before pm_runtime_force_suspend(dev)
rather than after cs35l41_ready_for_reset()?

pm_runtime_force_suspend() disables runtime PM and runs
cs35l41_runtime_suspend(), which puts the chip into hibernate or
safe-reset and sets regcache_cache_only(cs35l41->regmap, true).  If an
interrupt fires on the shared line before disable_irq() is reached,
regmap_irq_thread() runs while runtime PM is disabled and regmap is
cache-only, causing pm_runtime_get_sync() or volatile IRQ status reads to
fail without clearing the interrupt.

[ ... ]

> @@ -981,28 +1039,32 @@ static int cs35l41_system_resume(struct device *dev)
>  
>  	dev_dbg(cs35l41->dev, "System Resume\n");
>  
> -	if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) {
> -		dev_err_once(cs35l41->dev, "System Resume not supported\n");
> +	if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH)
>  		return 0; /* don't block the whole system resume */
> -	}
>  
>  	if (cs35l41->reset_gpio) {
> +		dev_info(cs35l41->dev, "Deasserting Reset\n");
>  		gpiod_set_value_cansleep(cs35l41->reset_gpio, 0);
>  		usleep_range(2000, 2100);
>  		gpiod_set_value_cansleep(cs35l41->reset_gpio, 1);
> +		usleep_range(2000, 2100);
>  	}
>  
> -	usleep_range(2000, 2100);
> -
>  	regcache_cache_only(cs35l41->regmap, false);
>  
>  	ret = cs35l41_reset_and_boot(cs35l41->dev, cs35l41->regmap);

[Severity: High]
Can pulsing and releasing the shared reset_gpio in
cs35l41_system_resume() race with sibling amplifier instances that have
cs35l41->reset_gpio == NULL?

In cs35l41_hda_probe(), only the first amplifier acquires reset_gpio;
sibling instances sharing the physical reset line get -EBUSY and set
reset_gpio = NULL.  With async resume enabled on I2C/SPI devices and the
post-reset sleep moved inside the if (cs35l41->reset_gpio) block, the
amplifiers can interleave during dpm_resume():

CPU0 (amp0, owns reset_gpio)      CPU1 (amp1, reset_gpio == NULL)
cs35l41_system_resume()           cs35l41_system_resume()
  gpiod_set_value_cansleep(..., 0)
  usleep_range(2000, 2100)
                                    regcache_cache_only(..., false)
                                    cs35l41_reset_and_boot()
                                      <-- fails or is wiped by reset
  gpiod_set_value_cansleep(..., 1)

Moving the shared reset pulse and deassertion into a .resume_early
callback paired with cs35l41_system_suspend_late() (as in
cs35l56_hda_system_resume_early()) would ensure reset is released before
any instance starts cs35l41_system_resume().

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

  reply	other threads:[~2026-11-20 16:27 UTC|newest]

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

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-225566@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