mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: es9356: defer IRQ readiness until cache replay
@ 2026-10-14  3:23 Pengpeng Hou
  0 siblings, 0 replies; only message in thread
From: Pengpeng Hou @ 2026-10-14  3:23 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: Pengpeng Hou, Jaroslav Kysela, Takashi Iwai, linux-sound,
	linux-kernel, Michael Zhang

For a SoundWire peripheral that remained attached, resume clears
disable_irq before waiting for initialization and replaying the cache.
That can permit deferred interrupt work before register restoration has
succeeded.

Move this attached-device IRQ readiness update after successful cache
replay and protect it with disable_irq_lock. Preserve the entry-time
unattach_request condition because sdw_slave_wait_for_init() clears it.
The reattachment initialization path keeps its separate behavior.

Return cache replay errors with cache-only mode restored and the cache
marked dirty. Use explicit braces around the scoped guard so its internal
control flow cannot bind an else from the surrounding condition.

The issue was found by our static-analysis tool and manually reviewed.

Assisted-by: gpt 5
Signed-off-by: Pengpeng Hou <hppiscas@163.com>
---
Changes since the earlier 20-patch series member:
- regenerate the complete fix against current sound/for-next; the earlier
  applied commit is no longer retained in the target tree
- fix the scoped-guard/dangling-else issue reported by Mark and the 0-day CI
- preserve the pre-wait attached/reattaching distinction explicitly
- restore cache-only mode after replay failure

Previous version:
https://lore.kernel.org/all/20260828113416.47061-6-pengpeng@iscas.ac.cn/

 sound/soc/codecs/es9356.c |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/es9356.c b/sound/soc/codecs/es9356.c
index 80db0f2f4aef624ecdc145d89272e04bebc2de62..fc423ec829f468e663f65039913286086b31e66d 100644
--- a/sound/soc/codecs/es9356.c
+++ b/sound/soc/codecs/es9356.c
@@ -1105,11 +1105,9 @@ static int es9356_sdca_dev_resume(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct es9356_sdw_priv *es9356 = dev_get_drvdata(dev);
+	bool restore_irq = !slave->unattach_request;
 	int ret;
 
-	if (!slave->unattach_request)
-		es9356->disable_irq = false;
-
 	ret = sdw_slave_wait_for_init(slave, es9356_PROBE_TIMEOUT);
 	if (ret) {
 		sdw_show_ping_status(slave->bus, true);
@@ -1117,7 +1115,19 @@ static int es9356_sdca_dev_resume(struct device *dev)
 	}
 
 	regcache_cache_only(es9356->regmap, false);
-	regcache_sync(es9356->regmap);
+	ret = regcache_sync(es9356->regmap);
+	if (ret) {
+		regcache_cache_only(es9356->regmap, true);
+		regcache_mark_dirty(es9356->regmap);
+		return ret;
+	}
+
+	if (restore_irq) {
+		scoped_guard(mutex, &es9356->disable_irq_lock) {
+			es9356->disable_irq = false;
+		}
+	}
+
 	return 0;
 }
 

base-commit: 8ef28aef33f2d5da6959ad6b579ec3cfccc009f6


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-14  3:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-14  3:23 [PATCH v2] ASoC: es9356: defer IRQ readiness until cache replay Pengpeng Hou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®