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 <[email protected]>
---
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


Reply via email to