* [PATCH v2 0/6] ASoC: fsl_asrc: Fix probe and resource management issues
@ 2026-11-13 5:07 phucduc.bui
2026-11-13 5:07 ` [PATCH v2 1/6] ASoC: fsl_asrc: Improve probe error handling phucduc.bui
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: phucduc.bui @ 2026-11-13 5:07 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.
Link v1:
https://lore.kernel.org/all/20261112105116.32274-1-phucduc.bui@gmail.com/
Change in v2:
- Update the commit based on Sashiko's review.
- Add handling for CONFIG_PM being disabled.
- Add a patch to use devm for M2M cleanup.
Compile-tested only.
Best regards,
Phuc
bui duc phuc (6):
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
ASoC: fsl_asrc: Use devm for m2m cleanup
sound/soc/fsl/fsl_asrc.c | 113 +++++++++++++++++++++------------------
1 file changed, 62 insertions(+), 51 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/6] ASoC: fsl_asrc: Improve probe error handling
2026-11-13 5:07 [PATCH v2 0/6] ASoC: fsl_asrc: Fix probe and resource management issues phucduc.bui
@ 2026-11-13 5:07 ` phucduc.bui
2026-11-13 5:07 ` [PATCH v2 2/6] ASoC: fsl_asrc: Fix handling of deferred spba clock phucduc.bui
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: phucduc.bui @ 2026-11-13 5:07 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] 7+ messages in thread
* [PATCH v2 2/6] ASoC: fsl_asrc: Fix handling of deferred spba clock
2026-11-13 5:07 [PATCH v2 0/6] ASoC: fsl_asrc: Fix probe and resource management issues phucduc.bui
2026-11-13 5:07 ` [PATCH v2 1/6] ASoC: fsl_asrc: Improve probe error handling phucduc.bui
@ 2026-11-13 5:07 ` phucduc.bui
2026-11-13 5:07 ` [PATCH v2 3/6] ASoC: fsl_asrc: Fix runtime PM usage count on init failure phucduc.bui
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: phucduc.bui @ 2026-11-13 5:07 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] 7+ messages in thread
* [PATCH v2 3/6] ASoC: fsl_asrc: Fix runtime PM usage count on init failure
2026-11-13 5:07 [PATCH v2 0/6] ASoC: fsl_asrc: Fix probe and resource management issues phucduc.bui
2026-11-13 5:07 ` [PATCH v2 1/6] ASoC: fsl_asrc: Improve probe error handling phucduc.bui
2026-11-13 5:07 ` [PATCH v2 2/6] ASoC: fsl_asrc: Fix handling of deferred spba clock phucduc.bui
@ 2026-11-13 5:07 ` phucduc.bui
2026-11-13 5:07 ` [PATCH v2 4/6] ASoC: fsl_asrc: Request the IRQ after the device is initialized phucduc.bui
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: phucduc.bui @ 2026-11-13 5:07 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_resume_and_get() succeeds.
Fixes: cab04ab5900f ("ASoC: fsl_asrc: Don't use devm_regmap_init_mmio_clk")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
Change in v2:
- Update the commit based on Sashiko's review.
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] 7+ messages in thread
* [PATCH v2 4/6] ASoC: fsl_asrc: Request the IRQ after the device is initialized
2026-11-13 5:07 [PATCH v2 0/6] ASoC: fsl_asrc: Fix probe and resource management issues phucduc.bui
` (2 preceding siblings ...)
2026-11-13 5:07 ` [PATCH v2 3/6] ASoC: fsl_asrc: Fix runtime PM usage count on init failure phucduc.bui
@ 2026-11-13 5:07 ` phucduc.bui
2026-11-13 5:07 ` [PATCH v2 5/6] ASoC: fsl_asrc: Use devm for runtime PM cleanup phucduc.bui
2026-11-13 5:07 ` [PATCH v2 6/6] ASoC: fsl_asrc: Use devm for m2m cleanup phucduc.bui
5 siblings, 0 replies; 7+ messages in thread
From: phucduc.bui @ 2026-11-13 5:07 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] 7+ messages in thread
* [PATCH v2 5/6] ASoC: fsl_asrc: Use devm for runtime PM cleanup
2026-11-13 5:07 [PATCH v2 0/6] ASoC: fsl_asrc: Fix probe and resource management issues phucduc.bui
` (3 preceding siblings ...)
2026-11-13 5:07 ` [PATCH v2 4/6] ASoC: fsl_asrc: Request the IRQ after the device is initialized phucduc.bui
@ 2026-11-13 5:07 ` phucduc.bui
2026-11-13 5:07 ` [PATCH v2 6/6] ASoC: fsl_asrc: Use devm for m2m cleanup phucduc.bui
5 siblings, 0 replies; 7+ messages in thread
From: phucduc.bui @ 2026-11-13 5:07 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>
---
Change in v2:
- Remove fsl_asrc_runtime_suspend_action when CONFIG_PM is disabled.
sound/soc/fsl/fsl_asrc.c | 54 +++++++++++++++++++++++++---------------
1 file changed, 34 insertions(+), 20 deletions(-)
diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index c97f814d7358..317ce0a5c765 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,38 @@ 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;
+ if (ret) {
+ devm_remove_action(&pdev->dev,
+ fsl_asrc_runtime_suspend_action,
+ &pdev->dev);
+ 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 +1461,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 +1487,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] 7+ messages in thread
* [PATCH v2 6/6] ASoC: fsl_asrc: Use devm for m2m cleanup
2026-11-13 5:07 [PATCH v2 0/6] ASoC: fsl_asrc: Fix probe and resource management issues phucduc.bui
` (4 preceding siblings ...)
2026-11-13 5:07 ` [PATCH v2 5/6] ASoC: fsl_asrc: Use devm for runtime PM cleanup phucduc.bui
@ 2026-11-13 5:07 ` phucduc.bui
5 siblings, 0 replies; 7+ messages in thread
From: phucduc.bui @ 2026-11-13 5:07 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>
Register fsl_asrc_m2m_exit() as a devm action and drop
fsl_asrc_remove(), which has nothing else left to do.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/fsl/fsl_asrc.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index 317ce0a5c765..c8db02f16453 100644
--- a/sound/soc/fsl/fsl_asrc.c
+++ b/sound/soc/fsl/fsl_asrc.c
@@ -1267,6 +1267,11 @@ static void fsl_asrc_runtime_suspend_action(void *data)
fsl_asrc_runtime_suspend(dev);
}
+static void fsl_asrc_m2m_exit_action(void *data)
+{
+ fsl_asrc_m2m_exit(data);
+}
+
static int fsl_asrc_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
@@ -1479,14 +1484,7 @@ static int fsl_asrc_probe(struct platform_device *pdev)
return ret;
}
- return 0;
-}
-
-static void fsl_asrc_remove(struct platform_device *pdev)
-{
- struct fsl_asrc *asrc = dev_get_drvdata(&pdev->dev);
-
- fsl_asrc_m2m_exit(asrc);
+ return devm_add_action_or_reset(&pdev->dev, fsl_asrc_m2m_exit_action, asrc);
}
static int fsl_asrc_runtime_resume(struct device *dev)
@@ -1648,7 +1646,6 @@ MODULE_DEVICE_TABLE(of, fsl_asrc_ids);
static struct platform_driver fsl_asrc_driver = {
.probe = fsl_asrc_probe,
- .remove = fsl_asrc_remove,
.driver = {
.name = "fsl-asrc",
.of_match_table = fsl_asrc_ids,
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-13 5:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-13 5:07 [PATCH v2 0/6] ASoC: fsl_asrc: Fix probe and resource management issues phucduc.bui
2026-11-13 5:07 ` [PATCH v2 1/6] ASoC: fsl_asrc: Improve probe error handling phucduc.bui
2026-11-13 5:07 ` [PATCH v2 2/6] ASoC: fsl_asrc: Fix handling of deferred spba clock phucduc.bui
2026-11-13 5:07 ` [PATCH v2 3/6] ASoC: fsl_asrc: Fix runtime PM usage count on init failure phucduc.bui
2026-11-13 5:07 ` [PATCH v2 4/6] ASoC: fsl_asrc: Request the IRQ after the device is initialized phucduc.bui
2026-11-13 5:07 ` [PATCH v2 5/6] ASoC: fsl_asrc: Use devm for runtime PM cleanup phucduc.bui
2026-11-13 5:07 ` [PATCH v2 6/6] ASoC: fsl_asrc: Use devm for m2m 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®