All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: fsl_easrc: Set firmware_loaded only after a successful resume
@ 2026-12-01 14:33 HyeongJun An
  2026-12-01 14:48 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: HyeongJun An @ 2026-12-01 14:33 UTC (permalink / raw)
  To: shengjiu.wang, broonie
  Cc: Xiubo.Lee, festevam, nicoleotsuka, lgirdwood, perex, tiwai,
	linux-sound, linuxppc-dev, linux-kernel, HyeongJun An

The fsl_easrc_runtime_resume() sets firmware_loaded before it requests
the firmware, and leaves it set when the request fails. The next resume
then returns early without the firmware, and a down-sampling hw_params
reads the NULL firmware_hdr.

A failed resume is retried since commit eef1d74bf88f ("PM: runtime:
Only set runtime_error on suspend callback failures"), so this now
happens on an i.MX8MP board without the firmware file. The KernelCI
kselftest-alsa runs on imx8mp-evk hit it in pcm-test:

  Internal error: Oops: 0000000096000004 [#1]  SMP
  pc : fsl_easrc_config_context+0x6ac/0xa70 [snd_soc_fsl_easrc]
  Call trace:
   fsl_easrc_config_context+0x6ac/0xa70 [snd_soc_fsl_easrc] (P)
   fsl_easrc_hw_params+0xdc/0x1e0 [snd_soc_fsl_easrc]

Set the flag only once the firmware is loaded and the coefficients are
written, so a failed resume is tried again in full.

Fixes: 955ac624058f ("ASoC: fsl_easrc: Add EASRC ASoC CPU DAI drivers")
Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
---
The crash shows in four kselftest-alsa runs on imx8mp-evk in the LAVA
lab, for example https://lava.sirena.org.uk/scheduler/job/300907
Each time one open of the EASRC PCM fails with -ENOENT and the next
one crashes in hw_params. With this patch every open fails instead.

Built for arm64. Not tested on hardware.

Prepared with Claude Code (Claude Opus 5.5).

 sound/soc/fsl/fsl_easrc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/fsl/fsl_easrc.c b/sound/soc/fsl/fsl_easrc.c
index b7a429170794f..1765e46ba5a47 100644
--- a/sound/soc/fsl/fsl_easrc.c
+++ b/sound/soc/fsl/fsl_easrc.c
@@ -2386,7 +2386,6 @@ static int fsl_easrc_runtime_resume(struct device *dev)
 	scoped_guard(spinlock_irqsave, &easrc->lock) {
 		if (easrc_priv->firmware_loaded)
 			return 0;
-		easrc_priv->firmware_loaded = 1;
 	}
 
 	ret = fsl_easrc_get_firmware(easrc);
@@ -2435,6 +2434,9 @@ static int fsl_easrc_runtime_resume(struct device *dev)
 			goto disable_mem_clk;
 	}
 
+	scoped_guard(spinlock_irqsave, &easrc->lock)
+		easrc_priv->firmware_loaded = 1;
+
 	return 0;
 disable_mem_clk:
 	clk_disable_unprepare(easrc->mem_clk);
-- 
2.43.0


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

* Re: [PATCH] ASoC: fsl_easrc: Set firmware_loaded only after a successful resume
  2026-12-01 14:33 [PATCH] ASoC: fsl_easrc: Set firmware_loaded only after a successful resume HyeongJun An
@ 2026-12-01 14:48 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-01 14:48 UTC (permalink / raw)
  To: HyeongJun An; +Cc: linux-sound

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] ASoC: fsl_easrc: firmware memory leak in
  fsl_easrc_get_firmware() [1]
--

commit 87f601aeb8732163a051c010051d750b2c2a81db
Author: HyeongJun An <sammiee5311@gmail.com>

ASoC: fsl_easrc: Set firmware_loaded only after a successful resume

This commit defers setting easrc_priv->firmware_loaded in
fsl_easrc_runtime_resume() until after the firmware has been fetched and
the coefficients have been configured.

> diff --git a/sound/soc/fsl/fsl_easrc.c b/sound/soc/fsl/fsl_easrc.c
> index b7a429170794f..1765e46ba5a47 100644
> --- a/sound/soc/fsl/fsl_easrc.c
> +++ b/sound/soc/fsl/fsl_easrc.c
> @@ -2386,7 +2386,6 @@ static int fsl_easrc_runtime_resume(struct device *dev)
>  	scoped_guard(spinlock_irqsave, &easrc->lock) {
>  		if (easrc_priv->firmware_loaded)
>  			return 0;
> -		easrc_priv->firmware_loaded = 1;
>  	}
>  
>  	ret = fsl_easrc_get_firmware(easrc);

[Severity: High]
This problem wasn't introduced by this patch, but does
fsl_easrc_get_firmware() leak easrc_priv->fw [1]?

fsl_easrc_get_firmware() calls request_firmware(&easrc_priv->fw, ...),
and the driver never calls release_firmware().  Because
fsl_easrc_runtime_suspend() clears easrc_priv->firmware_loaded, every
subsequent runtime resume calls fsl_easrc_get_firmware() again and
overwrites easrc_priv->fw, leaking the previous firmware allocation on
each suspend/resume cycle as well as on driver removal.

[1] https://sashiko.dev/#/bug/linux-55cff098-2f82-47eb-bc04-f484dfe8d953

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

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

end of thread, other threads:[~2026-12-01 14:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 14:33 [PATCH] ASoC: fsl_easrc: Set firmware_loaded only after a successful resume HyeongJun An
2026-12-01 14:48 ` sashiko-bot

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.