Re: [PATCH] SoC: rt5682: Disable jack detection interrupt during suspend

From: Stephen Boyd
Date: Tue May 16 2023 - 20:31:36 EST


Quoting Matthias Kaehlcke (2023-05-16 09:46:30)
> The rt5682 driver switches its regmap to cache-only when the
> device suspends and back to regular mode on resume. When the
> jack detect interrupt fires rt5682_irq() schedules the jack
> detect work. This can result in invalid reads from the regmap
> in cache-only mode if the work runs before the device has
> resumed:

I was wondering why we can't resume the device before device irqs are
enabled (and similarly suspend it after irqs are disabled). It looks
like snd_soc_component_driver is not an actual 'struct driver' instance
so it reimplements PM hooks like suspend and resume for the components
and the suspend hooks run from snd_soc_suspend() at the struct
dev_pm_ops::suspend() path. Adding a noirq variant looks like it isn't
worth it.

>
> [ 56.245502] rt5682 9-001a: ASoC: error at soc_component_read_no_lock on rt5682.9-001a for register: [0x000000f0] -16
>
> Disable the jack detection interrupt during suspend and
> re-enable it on resume. The driver already schedules the
> jack detection work on resume, so any state change during
> suspend is still handled.
>
> This is essentially the same as commit f7d00a9be147 ("SoC:
> rt5682s: Disable jack detection interrupt during suspend")
> for the rt5682s.
>
> Cc: stable@xxxxxxxxxx
> Signed-off-by: Matthias Kaehlcke <mka@xxxxxxxxxxxx>
> ---

Reviewed-by: Stephen Boyd <swboyd@xxxxxxxxxxxx>

> diff --git a/sound/soc/codecs/rt5682-i2c.c b/sound/soc/codecs/rt5682-i2c.c
> index 2935c1bb81f3..5bc46b041786 100644
> --- a/sound/soc/codecs/rt5682-i2c.c
> +++ b/sound/soc/codecs/rt5682-i2c.c
> @@ -267,7 +267,9 @@ static int rt5682_i2c_probe(struct i2c_client *i2c)
> ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL,
> rt5682_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING
> | IRQF_ONESHOT, "rt5682", rt5682);
> - if (ret)
> + if (!ret)
> + rt5682->irq = i2c->irq;
> + else
> dev_err(&i2c->dev, "Failed to reguest IRQ: %d\n", ret);

Not in this patch, but

s/reguest/request/