* [PATCH 0/5] ASoC: fsl_asrc: Fix probe and resource management issues
@ 2026-11-12 10:51 phucduc.bui
2026-11-12 10:51 ` [PATCH 1/5] ASoC: fsl_asrc: Improve probe error handling phucduc.bui
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: phucduc.bui @ 2026-11-12 10:51 UTC (permalink / raw)
To: Shengjiu Wang, Shengjiu Wang, Xiubo Li, Fabio Estevam,
Nicolin Chen, Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linuxppc-dev,
linux-sound, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Hi all,
This series improves error handling and resource management in
the fsl_asrc probe function. It fixes deferred clock handling and
runtime PM usage count, ensures the IRQ is requested after device
initialization, and moves runtime PM cleanup to devm.
Compile-tested only.
Best regards,
Phuc
bui duc phuc (5):
ASoC: fsl_asrc: Improve probe error handling
ASoC: fsl_asrc: Fix handling of deferred spba clock
ASoC: fsl_asrc: Fix runtime PM usage count on init failure
ASoC: fsl_asrc: Request the IRQ after the device is initialized
ASoC: fsl_asrc: Use devm for runtime PM cleanup
sound/soc/fsl/fsl_asrc.c | 92 ++++++++++++++++++++++------------------
1 file changed, 51 insertions(+), 41 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/5] ASoC: fsl_asrc: Improve probe error handling
2026-11-12 10:51 [PATCH 0/5] ASoC: fsl_asrc: Fix probe and resource management issues phucduc.bui
@ 2026-11-12 10:51 ` phucduc.bui
2026-11-12 10:51 ` [PATCH 2/5] ASoC: fsl_asrc: Fix handling of deferred spba clock phucduc.bui
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: phucduc.bui @ 2026-11-12 10:51 UTC (permalink / raw)
To: Shengjiu Wang, Shengjiu Wang, Xiubo Li, Fabio Estevam,
Nicolin Chen, Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linuxppc-dev,
linux-sound, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Use dev_err_probe() when retrieving clocks to avoid logging errors
for deferred probes. Also remove redundant error messages from
the probe function when failures are already reported deeper in
the call chain.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/fsl/fsl_asrc.c | 29 +++++++++++------------------
1 file changed, 11 insertions(+), 18 deletions(-)
diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index faf348dd582d..055593d5d37b 100644
--- a/sound/soc/fsl/fsl_asrc.c
+++ b/sound/soc/fsl/fsl_asrc.c
@@ -1301,22 +1301,18 @@ static int fsl_asrc_probe(struct platform_device *pdev)
ret = devm_request_irq(&pdev->dev, irq, fsl_asrc_isr, 0,
dev_name(&pdev->dev), asrc);
- if (ret) {
- dev_err(&pdev->dev, "failed to claim irq %u: %d\n", irq, ret);
+ if (ret)
return ret;
- }
asrc->mem_clk = devm_clk_get(&pdev->dev, "mem");
- if (IS_ERR(asrc->mem_clk)) {
- dev_err(&pdev->dev, "failed to get mem clock\n");
- return PTR_ERR(asrc->mem_clk);
- }
+ if (IS_ERR(asrc->mem_clk))
+ return dev_err_probe(&pdev->dev, PTR_ERR(asrc->mem_clk),
+ "failed to get mem clock\n");
asrc->ipg_clk = devm_clk_get(&pdev->dev, "ipg");
- if (IS_ERR(asrc->ipg_clk)) {
- dev_err(&pdev->dev, "failed to get ipg clock\n");
- return PTR_ERR(asrc->ipg_clk);
- }
+ if (IS_ERR(asrc->ipg_clk))
+ return dev_err_probe(&pdev->dev, PTR_ERR(asrc->ipg_clk),
+ "failed to get ipg clock\n");
asrc->spba_clk = devm_clk_get(&pdev->dev, "spba");
if (IS_ERR(asrc->spba_clk))
@@ -1325,10 +1321,9 @@ static int fsl_asrc_probe(struct platform_device *pdev)
for (i = 0; i < ASRC_CLK_MAX_NUM; i++) {
sprintf(tmp, "asrck_%x", i);
asrc_priv->asrck_clk[i] = devm_clk_get(&pdev->dev, tmp);
- if (IS_ERR(asrc_priv->asrck_clk[i])) {
- dev_err(&pdev->dev, "failed to get %s clock\n", tmp);
- return PTR_ERR(asrc_priv->asrck_clk[i]);
- }
+ if (IS_ERR(asrc_priv->asrck_clk[i]))
+ return dev_err_probe(&pdev->dev, PTR_ERR(asrc_priv->asrck_clk[i]),
+ "failed to get %s clock\n", tmp);
}
asrc_priv->soc = of_device_get_match_data(&pdev->dev);
@@ -1443,10 +1438,8 @@ static int fsl_asrc_probe(struct platform_device *pdev)
ret = devm_snd_soc_register_component(&pdev->dev, &fsl_asrc_component,
fsl_asrc_dai, ARRAY_SIZE(fsl_asrc_dai));
- if (ret) {
- dev_err(&pdev->dev, "failed to register ASoC DAI\n");
+ if (ret)
goto err_pm_get_sync;
- }
ret = fsl_asrc_m2m_init(asrc);
if (ret) {
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/5] ASoC: fsl_asrc: Fix handling of deferred spba clock
2026-11-12 10:51 [PATCH 0/5] ASoC: fsl_asrc: Fix probe and resource management issues phucduc.bui
2026-11-12 10:51 ` [PATCH 1/5] ASoC: fsl_asrc: Improve probe error handling phucduc.bui
@ 2026-11-12 10:51 ` phucduc.bui
2026-11-12 10:51 ` [PATCH 3/5] ASoC: fsl_asrc: Fix runtime PM usage count on init failure phucduc.bui
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: phucduc.bui @ 2026-11-12 10:51 UTC (permalink / raw)
To: Shengjiu Wang, Shengjiu Wang, Xiubo Li, Fabio Estevam,
Nicolin Chen, Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linuxppc-dev,
linux-sound, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
The current device tree binding does not describe the spba clock
as optional. However, the driver currently continues probing when
devm_clk_get() returns an error.
Return -EPROBE_DEFER when the clock provider is not ready, allowing
the driver to retry probing later. Preserve the existing behavior
for other errors.
Fixes: 13b8a97a760e ("ASoC: fsl_asrc: spba clock is needed by asrc device")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/fsl/fsl_asrc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index 055593d5d37b..c91ffb5e0c5e 100644
--- a/sound/soc/fsl/fsl_asrc.c
+++ b/sound/soc/fsl/fsl_asrc.c
@@ -1315,8 +1315,11 @@ static int fsl_asrc_probe(struct platform_device *pdev)
"failed to get ipg clock\n");
asrc->spba_clk = devm_clk_get(&pdev->dev, "spba");
- if (IS_ERR(asrc->spba_clk))
+ if (IS_ERR(asrc->spba_clk)) {
+ if (PTR_ERR(asrc->spba_clk) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
dev_warn(&pdev->dev, "failed to get spba clock\n");
+ }
for (i = 0; i < ASRC_CLK_MAX_NUM; i++) {
sprintf(tmp, "asrck_%x", i);
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/5] ASoC: fsl_asrc: Fix runtime PM usage count on init failure
2026-11-12 10:51 [PATCH 0/5] ASoC: fsl_asrc: Fix probe and resource management issues phucduc.bui
2026-11-12 10:51 ` [PATCH 1/5] ASoC: fsl_asrc: Improve probe error handling phucduc.bui
2026-11-12 10:51 ` [PATCH 2/5] ASoC: fsl_asrc: Fix handling of deferred spba clock phucduc.bui
@ 2026-11-12 10:51 ` phucduc.bui
2026-11-12 10:51 ` [PATCH 4/5] ASoC: fsl_asrc: Request the IRQ after the device is initialized phucduc.bui
2026-11-12 10:51 ` [PATCH 5/5] ASoC: fsl_asrc: Use devm for runtime PM cleanup phucduc.bui
4 siblings, 0 replies; 6+ messages in thread
From: phucduc.bui @ 2026-11-12 10:51 UTC (permalink / raw)
To: Shengjiu Wang, Shengjiu Wang, Xiubo Li, Fabio Estevam,
Nicolin Chen, Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linuxppc-dev,
linux-sound, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Balance the runtime PM usage count when fsl_asrc_init() fails
after pm_runtime_get_sync() succeeds.
Fixes: 286d658477a4 ("ASoC: fsl_asrc: register m2m platform device")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/fsl/fsl_asrc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index c91ffb5e0c5e..f7ac60724c6c 100644
--- a/sound/soc/fsl/fsl_asrc.c
+++ b/sound/soc/fsl/fsl_asrc.c
@@ -1432,6 +1432,7 @@ static int fsl_asrc_probe(struct platform_device *pdev)
ret = fsl_asrc_init(asrc);
if (ret) {
dev_err(&pdev->dev, "failed to init asrc %d\n", ret);
+ pm_runtime_put_noidle(&pdev->dev);
goto err_pm_get_sync;
}
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 4/5] ASoC: fsl_asrc: Request the IRQ after the device is initialized
2026-11-12 10:51 [PATCH 0/5] ASoC: fsl_asrc: Fix probe and resource management issues phucduc.bui
` (2 preceding siblings ...)
2026-11-12 10:51 ` [PATCH 3/5] ASoC: fsl_asrc: Fix runtime PM usage count on init failure phucduc.bui
@ 2026-11-12 10:51 ` phucduc.bui
2026-11-12 10:51 ` [PATCH 5/5] ASoC: fsl_asrc: Use devm for runtime PM cleanup phucduc.bui
4 siblings, 0 replies; 6+ messages in thread
From: phucduc.bui @ 2026-11-12 10:51 UTC (permalink / raw)
To: Shengjiu Wang, Shengjiu Wang, Xiubo Li, Fabio Estevam,
Nicolin Chen, Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linuxppc-dev,
linux-sound, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Request the IRQ after fsl_asrc_init(), while the device is still
runtime active, so that the interrupt handler cannot run before
the device is initialized.
If requesting the IRQ fails, balance the runtime PM usage count
before proceeding with cleanup.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/fsl/fsl_asrc.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index f7ac60724c6c..c97f814d7358 100644
--- a/sound/soc/fsl/fsl_asrc.c
+++ b/sound/soc/fsl/fsl_asrc.c
@@ -1299,11 +1299,6 @@ static int fsl_asrc_probe(struct platform_device *pdev)
if (irq < 0)
return irq;
- ret = devm_request_irq(&pdev->dev, irq, fsl_asrc_isr, 0,
- dev_name(&pdev->dev), asrc);
- if (ret)
- return ret;
-
asrc->mem_clk = devm_clk_get(&pdev->dev, "mem");
if (IS_ERR(asrc->mem_clk))
return dev_err_probe(&pdev->dev, PTR_ERR(asrc->mem_clk),
@@ -1436,6 +1431,14 @@ static int fsl_asrc_probe(struct platform_device *pdev)
goto err_pm_get_sync;
}
+ /* Request the IRQ only once the device is initialized */
+ ret = devm_request_irq(&pdev->dev, irq, fsl_asrc_isr, 0,
+ dev_name(&pdev->dev), asrc);
+ if (ret) {
+ pm_runtime_put_noidle(&pdev->dev);
+ goto err_pm_get_sync;
+ }
+
ret = pm_runtime_put_sync(&pdev->dev);
if (ret < 0 && ret != -ENOSYS)
goto err_pm_get_sync;
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 5/5] ASoC: fsl_asrc: Use devm for runtime PM cleanup
2026-11-12 10:51 [PATCH 0/5] ASoC: fsl_asrc: Fix probe and resource management issues phucduc.bui
` (3 preceding siblings ...)
2026-11-12 10:51 ` [PATCH 4/5] ASoC: fsl_asrc: Request the IRQ after the device is initialized phucduc.bui
@ 2026-11-12 10:51 ` phucduc.bui
4 siblings, 0 replies; 6+ messages in thread
From: phucduc.bui @ 2026-11-12 10:51 UTC (permalink / raw)
To: Shengjiu Wang, Shengjiu Wang, Xiubo Li, Fabio Estevam,
Nicolin Chen, Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linuxppc-dev,
linux-sound, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
On unbind, fsl_asrc_remove() gates the clocks before devres
unregisters the component and frees the IRQ, while the component
may still be in use.
Move the cleanup to devm. The action that disables the clocks is
registered before devm_pm_runtime_enable(), so it runs last, after
runtime PM is disabled, as in fsl_asrc_remove().
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/fsl/fsl_asrc.c | 48 ++++++++++++++++++++++++----------------
1 file changed, 29 insertions(+), 19 deletions(-)
diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index c97f814d7358..09e09164a106 100644
--- a/sound/soc/fsl/fsl_asrc.c
+++ b/sound/soc/fsl/fsl_asrc.c
@@ -1258,6 +1258,15 @@ static int fsl_asrc_m2m_pair_resume(struct fsl_asrc_pair *pair)
static int fsl_asrc_runtime_resume(struct device *dev);
static int fsl_asrc_runtime_suspend(struct device *dev);
+/* devm action: runtime suspend the device if it is not runtime suspended yet */
+static void fsl_asrc_runtime_suspend_action(void *data)
+{
+ struct device *dev = data;
+
+ if (!pm_runtime_status_suspended(dev))
+ fsl_asrc_runtime_suspend(dev);
+}
+
static int fsl_asrc_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
@@ -1413,22 +1422,34 @@ static int fsl_asrc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, asrc);
spin_lock_init(&asrc->lock);
- pm_runtime_enable(&pdev->dev);
+
+ /*
+ * Ensure the device is suspended after the IRQ and component
+ * have been released.
+ */
+ ret = devm_add_action(&pdev->dev, fsl_asrc_runtime_suspend_action,
+ &pdev->dev);
+ if (ret)
+ return ret;
+
+ ret = devm_pm_runtime_enable(&pdev->dev);
+ if (ret)
+ return ret;
if (!pm_runtime_enabled(&pdev->dev)) {
ret = fsl_asrc_runtime_resume(&pdev->dev);
if (ret)
- goto err_pm_disable;
+ return ret;
}
ret = pm_runtime_resume_and_get(&pdev->dev);
if (ret < 0)
- goto err_pm_get_sync;
+ return ret;
ret = fsl_asrc_init(asrc);
if (ret) {
dev_err(&pdev->dev, "failed to init asrc %d\n", ret);
pm_runtime_put_noidle(&pdev->dev);
- goto err_pm_get_sync;
+ return ret;
}
/* Request the IRQ only once the device is initialized */
@@ -1436,32 +1457,25 @@ static int fsl_asrc_probe(struct platform_device *pdev)
dev_name(&pdev->dev), asrc);
if (ret) {
pm_runtime_put_noidle(&pdev->dev);
- goto err_pm_get_sync;
+ return ret;
}
ret = pm_runtime_put_sync(&pdev->dev);
if (ret < 0 && ret != -ENOSYS)
- goto err_pm_get_sync;
+ return ret;
ret = devm_snd_soc_register_component(&pdev->dev, &fsl_asrc_component,
fsl_asrc_dai, ARRAY_SIZE(fsl_asrc_dai));
if (ret)
- goto err_pm_get_sync;
+ return ret;
ret = fsl_asrc_m2m_init(asrc);
if (ret) {
dev_err(&pdev->dev, "failed to init m2m device %d\n", ret);
- goto err_pm_get_sync;
+ return ret;
}
return 0;
-
-err_pm_get_sync:
- if (!pm_runtime_status_suspended(&pdev->dev))
- fsl_asrc_runtime_suspend(&pdev->dev);
-err_pm_disable:
- pm_runtime_disable(&pdev->dev);
- return ret;
}
static void fsl_asrc_remove(struct platform_device *pdev)
@@ -1469,10 +1483,6 @@ static void fsl_asrc_remove(struct platform_device *pdev)
struct fsl_asrc *asrc = dev_get_drvdata(&pdev->dev);
fsl_asrc_m2m_exit(asrc);
-
- pm_runtime_disable(&pdev->dev);
- if (!pm_runtime_status_suspended(&pdev->dev))
- fsl_asrc_runtime_suspend(&pdev->dev);
}
static int fsl_asrc_runtime_resume(struct device *dev)
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-12 10:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-12 10:51 [PATCH 0/5] ASoC: fsl_asrc: Fix probe and resource management issues phucduc.bui
2026-11-12 10:51 ` [PATCH 1/5] ASoC: fsl_asrc: Improve probe error handling phucduc.bui
2026-11-12 10:51 ` [PATCH 2/5] ASoC: fsl_asrc: Fix handling of deferred spba clock phucduc.bui
2026-11-12 10:51 ` [PATCH 3/5] ASoC: fsl_asrc: Fix runtime PM usage count on init failure phucduc.bui
2026-11-12 10:51 ` [PATCH 4/5] ASoC: fsl_asrc: Request the IRQ after the device is initialized phucduc.bui
2026-11-12 10:51 ` [PATCH 5/5] ASoC: fsl_asrc: Use devm for runtime PM cleanup phucduc.bui
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®