All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] SoC: rt5682s: Disable jack detection interrupt during suspend
@ 2023-02-09  1:20 Matthias Kaehlcke
  2023-02-14 13:07   ` Mark Brown
  2023-02-14 18:01 ` Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Matthias Kaehlcke @ 2023-02-09  1:20 UTC (permalink / raw)
  To: Oder Chiou, Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai
  Cc: alsa-devel, Douglas Anderson, Judy Hsiao, linux-kernel,
	Matthias Kaehlcke

The rt5682s driver switches its regmap to cache-only when the
device suspends and back to regular mode on resume. When the
jack detect interrupt fires rt5682s_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:

[   19.672162] rt5682s 2-001a: ASoC: error at soc_component_read_no_lock on rt5682s.2-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.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---

 sound/soc/codecs/rt5682s.c | 10 +++++++++-
 sound/soc/codecs/rt5682s.h |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/rt5682s.c b/sound/soc/codecs/rt5682s.c
index f5e5dbc3b0f0..59117ebc5ecd 100644
--- a/sound/soc/codecs/rt5682s.c
+++ b/sound/soc/codecs/rt5682s.c
@@ -2895,6 +2895,9 @@ static int rt5682s_suspend(struct snd_soc_component *component)
 {
 	struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component);
 
+	if (rt5682s->irq)
+		disable_irq(rt5682s->irq);
+
 	cancel_delayed_work_sync(&rt5682s->jack_detect_work);
 	cancel_delayed_work_sync(&rt5682s->jd_check_work);
 
@@ -2919,6 +2922,9 @@ static int rt5682s_resume(struct snd_soc_component *component)
 			&rt5682s->jack_detect_work, msecs_to_jiffies(0));
 	}
 
+	if (rt5682s->irq)
+		enable_irq(rt5682s->irq);
+
 	return 0;
 }
 #else
@@ -3259,7 +3265,9 @@ static int rt5682s_i2c_probe(struct i2c_client *i2c)
 		ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL, rt5682s_irq,
 			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
 			"rt5682s", rt5682s);
-		if (ret)
+		if (!ret)
+			rt5682s->irq = i2c->irq;
+		else
 			dev_err(&i2c->dev, "Failed to reguest IRQ: %d\n", ret);
 	}
 
diff --git a/sound/soc/codecs/rt5682s.h b/sound/soc/codecs/rt5682s.h
index 67f86a38a1cc..caa7733b430f 100644
--- a/sound/soc/codecs/rt5682s.h
+++ b/sound/soc/codecs/rt5682s.h
@@ -1472,6 +1472,7 @@ struct rt5682s_priv {
 	int pll_comb;
 
 	int jack_type;
+	unsigned int irq;
 	int irq_work_delay_time;
 	int wclk_enabled;
 };
-- 
2.39.1.519.gcb327c4b5f-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] SoC: rt5682s: Disable jack detection interrupt during suspend
  2023-02-09  1:20 [PATCH] SoC: rt5682s: Disable jack detection interrupt during suspend Matthias Kaehlcke
@ 2023-02-14 13:07   ` Mark Brown
  2023-02-14 18:01 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2023-02-14 13:07 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: Oder Chiou, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, Douglas Anderson, Judy Hsiao, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 723 bytes --]

On Thu, Feb 09, 2023 at 01:20:23AM +0000, Matthias Kaehlcke wrote:
> The rt5682s driver switches its regmap to cache-only when the
> device suspends and back to regular mode on resume. When the
> jack detect interrupt fires rt5682s_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:

Please submit patches using subject lines reflecting the style for the
subsystem, this makes it easier for people to identify relevant patches.
Look at what existing commits in the area you're changing are doing and
make sure your subject lines visually resemble what they're doing.
There's no need to resubmit to fix this alone.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] SoC: rt5682s: Disable jack detection interrupt during suspend
@ 2023-02-14 13:07   ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2023-02-14 13:07 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: Oder Chiou, Liam Girdwood, Takashi Iwai, alsa-devel,
	Douglas Anderson, Judy Hsiao, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 723 bytes --]

On Thu, Feb 09, 2023 at 01:20:23AM +0000, Matthias Kaehlcke wrote:
> The rt5682s driver switches its regmap to cache-only when the
> device suspends and back to regular mode on resume. When the
> jack detect interrupt fires rt5682s_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:

Please submit patches using subject lines reflecting the style for the
subsystem, this makes it easier for people to identify relevant patches.
Look at what existing commits in the area you're changing are doing and
make sure your subject lines visually resemble what they're doing.
There's no need to resubmit to fix this alone.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] SoC: rt5682s: Disable jack detection interrupt during suspend
  2023-02-09  1:20 [PATCH] SoC: rt5682s: Disable jack detection interrupt during suspend Matthias Kaehlcke
  2023-02-14 13:07   ` Mark Brown
@ 2023-02-14 18:01 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2023-02-14 18:01 UTC (permalink / raw)
  To: Oder Chiou, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	Matthias Kaehlcke
  Cc: alsa-devel, Douglas Anderson, Judy Hsiao, linux-kernel

On Thu, 09 Feb 2023 01:20:23 +0000, Matthias Kaehlcke wrote:
> The rt5682s driver switches its regmap to cache-only when the
> device suspends and back to regular mode on resume. When the
> jack detect interrupt fires rt5682s_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:
> 
> [...]

Applied to

   broonie/sound.git for-next

Thanks!

[1/1] SoC: rt5682s: Disable jack detection interrupt during suspend
      commit: f7d00a9be147d9c6feeb19591b39f8102f70cc45

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-02-14 18:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-09  1:20 [PATCH] SoC: rt5682s: Disable jack detection interrupt during suspend Matthias Kaehlcke
2023-02-14 13:07 ` Mark Brown
2023-02-14 13:07   ` Mark Brown
2023-02-14 18:01 ` Mark Brown

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.