All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Laurentiu Mihalcea" <laurentiumihalcea111@gmail.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH 3/3] ASoC: wm8962: fix interrupt mis-firing during runtime_resume()
Date: Fri, 27 Nov 2026 17:30:12 +0000	[thread overview]
Message-ID: <sashiko-outbox-237992@kernel.org> (raw)
In-Reply-To: <20261127170039.663-4-laurentiumihalcea111@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] ASoC: wm8962: deadlock between wm8962_runtime_suspend() and
  wm8962_irq()
- [High] ASoC: wm8962: disabling IRQ in wm8962_runtime_suspend() breaks
  idle IRQs
- [Medium] ASoC: wm8962: irq_set_status_flags() called on IRQ 0 in
  wm8962_i2c_probe()
--

commit 917ccfcd5e1f9cc84d87be9fd3e359058c229f93
Author: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>

ASoC: wm8962: fix interrupt mis-firing during runtime_resume()

This commit requests wm8962->irq with IRQF_NO_AUTOEN and IRQ_DISABLE_UNLAZY,
and enables or disables the IRQ across runtime resume and runtime suspend to
avoid spurious interrupt assertions during power transitions.

> diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
> index 3bbaacb08aafa..8c9523d60219b 100644
> --- a/sound/soc/codecs/wm8962.c
> +++ b/sound/soc/codecs/wm8962.c
> @@ -4021,7 +4021,7 @@ static int wm8962_i2c_probe(struct i2c_client *i2c)
>  
>  		ret = devm_request_threaded_irq(&i2c->dev, wm8962->irq, NULL,
>  						wm8962_irq,
> -						trigger | IRQF_ONESHOT,
> +						trigger | IRQF_ONESHOT | IRQF_NO_AUTOEN,
>  						"wm8962", &i2c->dev);
>  		if (ret != 0) {
>  			dev_err(&i2c->dev, "Failed to request IRQ %d: %d\n",
> @@ -4039,6 +4039,15 @@ static int wm8962_i2c_probe(struct i2c_client *i2c)
>  			/* enable GPIO IRQs if need be */
>  			wm8962_init_gpio_irq(wm8962);
>  		}
> +
> +		/*
> +		 * we are forced to keep interrupts disabled while doing runtime_resume().
> +		 * Otherwise, we may end up with some unwanted transitions on the interrupt
> +		 * line. Some interrupt controllers may not implement the .irq_disable()
> +		 * callback. In such cases, the interrupts will only be masked if
> +		 * IRQ_DISABLE_UNLAZY is set.
> +		 */
> +		irq_set_status_flags(wm8962->irq, IRQ_DISABLE_UNLAZY);
>  	}

[Severity: Medium]
Should irq_set_status_flags() be inside the else branch above?  When
devm_request_threaded_irq() fails, the error path sets wm8962->irq = 0
and treats the failure as non-fatal, so execution falls through and
calls irq_set_status_flags(0, IRQ_DISABLE_UNLAZY) on IRQ 0.

> @@ -4131,6 +4140,10 @@ static int wm8962_runtime_resume(struct device *dev)
>  				   WM8962_MSTR, WM8962_MSTR);
>  	msleep(5);
>  
> +	/* keep this last - keeps the interrupt line from mis-firing */
> +	if (wm8962->irq)
> +		enable_irq(wm8962->irq);
> +
>  	return 0;
>  
>  cache_sync_err:
> @@ -4147,6 +4160,9 @@ static int wm8962_runtime_suspend(struct device *dev)
>  {
>  	struct wm8962_priv *wm8962 = dev_get_drvdata(dev);
>  
> +	if (wm8962->irq)
> +		disable_irq(wm8962->irq);

[Severity: High]
Can disable_irq() in wm8962_runtime_suspend() deadlock with wm8962_irq()?

sound/soc/codecs/wm8962.c:wm8962_irq() {
	...
	ret = pm_runtime_resume_and_get(dev);
	if (ret < 0) {
	...
}

If an interrupt fires just before disable_irq() masks the line, the two
contexts wait on each other:

CPU0                              CPU1
rpm_suspend()
  runtime_status = RPM_SUSPENDING
  wm8962_runtime_suspend()
                                  wm8962_irq()
                                    pm_runtime_resume_and_get()
                                      rpm_resume()
                                        /* waits for RPM_SUSPENDING */
    disable_irq()
      synchronize_irq()
        /* waits for wm8962_irq() */

 *** DEADLOCK ***

[Severity: High]
Does keeping wm8962->irq disabled while runtime suspended prevent GPIO
interrupts from firing when the codec is idle?

soc_component_dev_wm8962 does not set idle_bias_on, and neither
wm8962_init_gpio() nor wm8962_irq_chip holds a runtime PM reference
while child GPIO IRQs are active.  Whenever no audio stream is active
(and after wm8962_gpio_get() drops its temporary runtime PM reference),
the codec stays in RPM_SUSPENDED with wm8962->irq masked at the parent
interrupt controller, so asynchronous GPIO5/GPIO6 events such as jack
detection cannot wake the device via wm8962_irq().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261127170039.663-1-laurentiumihalcea111@gmail.com?part=3

      reply	other threads:[~2026-11-27 17:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 17:00 [PATCH 0/3] ASoC: wm8962: make GPIO-based HP detection work Laurentiu Mihalcea
2026-11-27 17:00 ` [PATCH 1/3] ASoC: wm8962: implement GPIO .get callback Laurentiu Mihalcea
2026-11-27 17:22   ` sashiko-bot
2026-11-30 11:18   ` Charles Keepax
2026-12-01 21:36     ` Laurentiu Mihalcea
2026-11-27 17:00 ` [PATCH 2/3] ASoC: wm8962: add GPIO interrupt controller support Laurentiu Mihalcea
2026-11-27 17:36   ` sashiko-bot
2026-11-30 11:25   ` Charles Keepax
2026-12-01 22:35     ` Laurentiu Mihalcea
2026-11-27 17:00 ` [PATCH 3/3] ASoC: wm8962: fix interrupt mis-firing during runtime_resume() Laurentiu Mihalcea
2026-11-27 17:30   ` sashiko-bot [this message]

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-237992@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=laurentiumihalcea111@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.