* [PATCH 1/7] ASoC: mediatek: mt8188: mt8188-afe-clk: Propagate clock initialization errors
2026-09-07 12:03 [PATCH 0/7] ASoC: mediatek: mt8188: Improve error handling phucduc.bui
@ 2026-09-07 12:03 ` phucduc.bui
2026-09-07 12:03 ` [PATCH 2/7] ASoC: mediatek: mt8188: mt8188-afe-clk: Handle tuner clock enable errors phucduc.bui
` (7 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: phucduc.bui @ 2026-09-07 12:03 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Jaroslav Kysela,
Takashi Iwai, Cezary Rojewski, Kees Cook, Kuninori Morimoto,
Trevor Wu, Douglas Anderson, linux-sound, linux-arm-kernel,
linux-mediatek, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Use dev_err_probe() to handle clock lookup errors without printing
redundant messages for deferred probe.
Propagate the original error from tuner initialization instead of
returning -EINVAL.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/mediatek/mt8188/mt8188-afe-clk.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/sound/soc/mediatek/mt8188/mt8188-afe-clk.c b/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
index fc6cb3f0469e..42878c8a6529 100644
--- a/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
+++ b/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
@@ -416,12 +416,9 @@ int mt8188_afe_init_clock(struct mtk_base_afe *afe)
for (i = 0; i < MT8188_CLK_NUM; i++) {
afe_priv->clk[i] = devm_clk_get(afe->dev, aud_clks[i]);
- if (IS_ERR(afe_priv->clk[i])) {
- dev_err(afe->dev, "%s(), devm_clk_get %s fail, ret %ld\n",
- __func__, aud_clks[i],
- PTR_ERR(afe_priv->clk[i]));
- return PTR_ERR(afe_priv->clk[i]);
- }
+ if (IS_ERR(afe_priv->clk[i]))
+ return dev_err_probe(afe->dev, PTR_ERR(afe_priv->clk[i]),
+ "failed to get clock %s\n", aud_clks[i]);
}
/* initial tuner */
@@ -430,7 +427,7 @@ int mt8188_afe_init_clock(struct mtk_base_afe *afe)
if (ret) {
dev_info(afe->dev, "%s(), init apll_tuner%d failed",
__func__, (i + 1));
- return -EINVAL;
+ return ret;
}
}
--
2.43.0
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 2/7] ASoC: mediatek: mt8188: mt8188-afe-clk: Handle tuner clock enable errors
2026-09-07 12:03 [PATCH 0/7] ASoC: mediatek: mt8188: Improve error handling phucduc.bui
2026-09-07 12:03 ` [PATCH 1/7] ASoC: mediatek: mt8188: mt8188-afe-clk: Propagate clock initialization errors phucduc.bui
@ 2026-09-07 12:03 ` phucduc.bui
2026-09-07 12:03 ` [PATCH 3/7] ASoC: mediatek: mt8188: mt8188-afe-clk: Propagate regmap update errors phucduc.bui
` (6 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: phucduc.bui @ 2026-09-07 12:03 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Jaroslav Kysela,
Takashi Iwai, Cezary Rojewski, Kees Cook, Kuninori Morimoto,
Trevor Wu, Douglas Anderson, linux-sound, linux-arm-kernel,
linux-mediatek, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Clock enable errors are currently ignored when enabling the APLL
and tuner clocks.
Check the return values and roll back the APLL clock if the tuner
clock fails to enable.
Fixes: f6b026479b13 ("ASoC: mediatek: mt8188: support audio clock control")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/mediatek/mt8188/mt8188-afe-clk.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/sound/soc/mediatek/mt8188/mt8188-afe-clk.c b/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
index 42878c8a6529..ecba13eda440 100644
--- a/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
+++ b/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
@@ -260,15 +260,28 @@ static int mt8188_afe_enable_tuner_clk(struct mtk_base_afe *afe,
unsigned int id)
{
struct mt8188_afe_private *afe_priv = afe->platform_priv;
+ int ret;
switch (id) {
case MT8188_AUD_PLL1:
- mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_APLL]);
- mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_APLL1_TUNER]);
+ ret = mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_APLL]);
+ if (ret)
+ return ret;
+ ret = mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_APLL1_TUNER]);
+ if (ret) {
+ mt8188_afe_disable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_APLL]);
+ return ret;
+ }
break;
case MT8188_AUD_PLL2:
- mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_APLL2]);
- mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_APLL2_TUNER]);
+ ret = mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_APLL2]);
+ if (ret)
+ return ret;
+ ret = mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_APLL2_TUNER]);
+ if (ret) {
+ mt8188_afe_disable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_APLL2]);
+ return ret;
+ }
break;
default:
return -EINVAL;
--
2.43.0
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 3/7] ASoC: mediatek: mt8188: mt8188-afe-clk: Propagate regmap update errors
2026-09-07 12:03 [PATCH 0/7] ASoC: mediatek: mt8188: Improve error handling phucduc.bui
2026-09-07 12:03 ` [PATCH 1/7] ASoC: mediatek: mt8188: mt8188-afe-clk: Propagate clock initialization errors phucduc.bui
2026-09-07 12:03 ` [PATCH 2/7] ASoC: mediatek: mt8188: mt8188-afe-clk: Handle tuner clock enable errors phucduc.bui
@ 2026-09-07 12:03 ` phucduc.bui
2026-09-08 17:49 ` Cezary Rojewski
2026-09-07 12:03 ` [PATCH 4/7] ASoC: mediatek: mt8188: mt8188-afe-clk: Handle clock enable errors phucduc.bui
` (5 subsequent siblings)
8 siblings, 1 reply; 14+ messages in thread
From: phucduc.bui @ 2026-09-07 12:03 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Jaroslav Kysela,
Takashi Iwai, Cezary Rojewski, Kees Cook, Kuninori Morimoto,
Trevor Wu, Douglas Anderson, linux-sound, linux-arm-kernel,
linux-mediatek, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
The return values from regmap_update_bits() are currently ignored
by the clock and AFE control functions.
Propagate the errors to allow callers to handle regmap update
failures.
Fixes: f6b026479b13 ("ASoC: mediatek: mt8188: support audio clock control")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/mediatek/mt8188/mt8188-afe-clk.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/sound/soc/mediatek/mt8188/mt8188-afe-clk.c b/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
index ecba13eda440..77511f6fba41 100644
--- a/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
+++ b/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
@@ -564,9 +564,7 @@ static int mt8188_afe_enable_top_cg(struct mtk_base_afe *afe, unsigned int cg_ty
unsigned int mask = get_top_cg_mask(cg_type);
unsigned int val = get_top_cg_on_val(cg_type);
- regmap_update_bits(afe->regmap, reg, mask, val);
-
- return 0;
+ return regmap_update_bits(afe->regmap, reg, mask, val);
}
static int mt8188_afe_disable_top_cg(struct mtk_base_afe *afe, unsigned int cg_type)
@@ -575,9 +573,7 @@ static int mt8188_afe_disable_top_cg(struct mtk_base_afe *afe, unsigned int cg_t
unsigned int mask = get_top_cg_mask(cg_type);
unsigned int val = get_top_cg_off_val(cg_type);
- regmap_update_bits(afe->regmap, reg, mask, val);
-
- return 0;
+ return regmap_update_bits(afe->regmap, reg, mask, val);
}
int mt8188_afe_enable_reg_rw_clk(struct mtk_base_afe *afe)
@@ -617,14 +613,12 @@ int mt8188_afe_disable_reg_rw_clk(struct mtk_base_afe *afe)
static int mt8188_afe_enable_afe_on(struct mtk_base_afe *afe)
{
- regmap_update_bits(afe->regmap, AFE_DAC_CON0, 0x1, 0x1);
- return 0;
+ return regmap_update_bits(afe->regmap, AFE_DAC_CON0, 0x1, 0x1);
}
static int mt8188_afe_disable_afe_on(struct mtk_base_afe *afe)
{
- regmap_update_bits(afe->regmap, AFE_DAC_CON0, 0x1, 0x0);
- return 0;
+ return regmap_update_bits(afe->regmap, AFE_DAC_CON0, 0x1, 0x0);
}
static int mt8188_afe_enable_a1sys(struct mtk_base_afe *afe)
--
2.43.0
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 3/7] ASoC: mediatek: mt8188: mt8188-afe-clk: Propagate regmap update errors
2026-09-07 12:03 ` [PATCH 3/7] ASoC: mediatek: mt8188: mt8188-afe-clk: Propagate regmap update errors phucduc.bui
@ 2026-09-08 17:49 ` Cezary Rojewski
2026-09-08 18:52 ` Mark Brown
0 siblings, 1 reply; 14+ messages in thread
From: Cezary Rojewski @ 2026-09-08 17:49 UTC (permalink / raw)
To: phucduc.bui
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Jaroslav Kysela,
Takashi Iwai, Kees Cook, Kuninori Morimoto, Trevor Wu,
Douglas Anderson, linux-sound, linux-arm-kernel, linux-mediatek,
linux-kernel, Mark Brown, Matthias Brugger
On 9/7/2026 2:03 PM, phucduc.bui@gmail.com wrote:
> From: bui duc phuc <phucduc.bui@gmail.com>
>
> The return values from regmap_update_bits() are currently ignored
> by the clock and AFE control functions.
> Propagate the errors to allow callers to handle regmap update
> failures.
>
> Fixes: f6b026479b13 ("ASoC: mediatek: mt8188: support audio clock control")
> Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
> ---
> sound/soc/mediatek/mt8188/mt8188-afe-clk.c | 14 ++++----------
> 1 file changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/sound/soc/mediatek/mt8188/mt8188-afe-clk.c b/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
> index ecba13eda440..77511f6fba41 100644
> --- a/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
> +++ b/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
> @@ -564,9 +564,7 @@ static int mt8188_afe_enable_top_cg(struct mtk_base_afe *afe, unsigned int cg_ty
> unsigned int mask = get_top_cg_mask(cg_type);
> unsigned int val = get_top_cg_on_val(cg_type);
>
> - regmap_update_bits(afe->regmap, reg, mask, val);
> -
> - return 0;
> + return regmap_update_bits(afe->regmap, reg, mask, val);
> }
>
> static int mt8188_afe_disable_top_cg(struct mtk_base_afe *afe, unsigned int cg_type)
> @@ -575,9 +573,7 @@ static int mt8188_afe_disable_top_cg(struct mtk_base_afe *afe, unsigned int cg_t
> unsigned int mask = get_top_cg_mask(cg_type);
> unsigned int val = get_top_cg_off_val(cg_type);
>
> - regmap_update_bits(afe->regmap, reg, mask, val);
> -
> - return 0;
> + return regmap_update_bits(afe->regmap, reg, mask, val);
> }
>
> int mt8188_afe_enable_reg_rw_clk(struct mtk_base_afe *afe)
> @@ -617,14 +613,12 @@ int mt8188_afe_disable_reg_rw_clk(struct mtk_base_afe *afe)
>
> static int mt8188_afe_enable_afe_on(struct mtk_base_afe *afe)
> {
> - regmap_update_bits(afe->regmap, AFE_DAC_CON0, 0x1, 0x1);
> - return 0;
> + return regmap_update_bits(afe->regmap, AFE_DAC_CON0, 0x1, 0x1);
> }
>
> static int mt8188_afe_disable_afe_on(struct mtk_base_afe *afe)
> {
> - regmap_update_bits(afe->regmap, AFE_DAC_CON0, 0x1, 0x0);
> - return 0;
> + return regmap_update_bits(afe->regmap, AFE_DAC_CON0, 0x1, 0x0);
> }
>
> static int mt8188_afe_enable_a1sys(struct mtk_base_afe *afe)
I'd expect someone from Mediatek to verify this. While I agree with the
change, some drivers follow "ignore register update result" arch and,
what was previously ignored will now cause basic operations to fail.
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 3/7] ASoC: mediatek: mt8188: mt8188-afe-clk: Propagate regmap update errors
2026-09-08 17:49 ` Cezary Rojewski
@ 2026-09-08 18:52 ` Mark Brown
2026-09-09 9:15 ` AngeloGioacchino Del Regno
0 siblings, 1 reply; 14+ messages in thread
From: Mark Brown @ 2026-09-08 18:52 UTC (permalink / raw)
To: Cezary Rojewski
Cc: phucduc.bui, Liam Girdwood, AngeloGioacchino Del Regno,
Jaroslav Kysela, Takashi Iwai, Kees Cook, Kuninori Morimoto,
Trevor Wu, Douglas Anderson, linux-sound, linux-arm-kernel,
linux-mediatek, linux-kernel, Matthias Brugger
[-- Attachment #1: Type: text/plain, Size: 413 bytes --]
On Tue, Sep 08, 2026 at 07:49:00PM +0200, Cezary Rojewski wrote:
> I'd expect someone from Mediatek to verify this. While I agree with the
> change, some drivers follow "ignore register update result" arch and,
> what was previously ignored will now cause basic operations to fail.
We don't really get any review from Mediatek, AngeloGioacchino used to
try to cover things but it seems he got busy recently :(
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/7] ASoC: mediatek: mt8188: mt8188-afe-clk: Propagate regmap update errors
2026-09-08 18:52 ` Mark Brown
@ 2026-09-09 9:15 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 14+ messages in thread
From: AngeloGioacchino Del Regno @ 2026-09-09 9:15 UTC (permalink / raw)
To: Mark Brown, Cezary Rojewski
Cc: phucduc.bui, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
Kees Cook, Kuninori Morimoto, Trevor Wu, Douglas Anderson,
linux-sound, linux-arm-kernel, linux-mediatek, linux-kernel,
Matthias Brugger
On 9/8/26 20:52, Mark Brown wrote:
> On Tue, Sep 08, 2026 at 07:49:00PM +0200, Cezary Rojewski wrote:
>
>> I'd expect someone from Mediatek to verify this. While I agree with the
>> change, some drivers follow "ignore register update result" arch and,
>> what was previously ignored will now cause basic operations to fail.
>
> We don't really get any review from Mediatek, AngeloGioacchino used to
> try to cover things but it seems he got busy recently :(
Yeah, sorry about that, it's busy-busy-busy days here.
Also I had a summer break, so 1+1=ouch :-)
The changes are fine, those regmap updates always succeed, that's why it works,
and ignoring an error there would actually break things.
Cheers,
Angelo
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 4/7] ASoC: mediatek: mt8188: mt8188-afe-clk: Handle clock enable errors
2026-09-07 12:03 [PATCH 0/7] ASoC: mediatek: mt8188: Improve error handling phucduc.bui
` (2 preceding siblings ...)
2026-09-07 12:03 ` [PATCH 3/7] ASoC: mediatek: mt8188: mt8188-afe-clk: Propagate regmap update errors phucduc.bui
@ 2026-09-07 12:03 ` phucduc.bui
2026-09-07 12:03 ` [PATCH 5/7] ASoC: mediatek: mt8188: mt8188-afe-pcm: Handle runtime resume errors phucduc.bui
` (4 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: phucduc.bui @ 2026-09-07 12:03 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Jaroslav Kysela,
Takashi Iwai, Cezary Rojewski, Kees Cook, Kuninori Morimoto,
Trevor Wu, Douglas Anderson, linux-sound, linux-arm-kernel,
linux-mediatek, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Clock enable errors are currently ignored by several AFE clock
control functions.
Check the return values and roll back previously enabled clocks when
a subsequent clock enable fails.
Fixes: f6b026479b13 ("ASoC: mediatek: mt8188: support audio clock control")
Fixes: 9be0213a6858 ("ASoC: mediatek: mt8188: refine APLL control")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/mediatek/mt8188/mt8188-afe-clk.c | 69 ++++++++++++++++++----
1 file changed, 58 insertions(+), 11 deletions(-)
diff --git a/sound/soc/mediatek/mt8188/mt8188-afe-clk.c b/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
index 77511f6fba41..8b6dca22c8ed 100644
--- a/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
+++ b/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
@@ -579,22 +579,47 @@ static int mt8188_afe_disable_top_cg(struct mtk_base_afe *afe, unsigned int cg_t
int mt8188_afe_enable_reg_rw_clk(struct mtk_base_afe *afe)
{
struct mt8188_afe_private *afe_priv = afe->platform_priv;
-
+ int ret;
/* bus clock for AFE external access, like DRAM */
- mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_TOP_AUDIO_LOCAL_BUS_SEL]);
+ ret = mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_TOP_AUDIO_LOCAL_BUS_SEL]);
+ if (ret)
+ goto err_local_bus;
/* bus clock for AFE internal access, like AFE SRAM */
- mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_TOP_AUD_INTBUS_SEL]);
+ ret = mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_TOP_AUD_INTBUS_SEL]);
+ if (ret)
+ goto err_intbus;
/* audio 26m clock source */
- mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_ADSP_AUDIO_26M]);
+ ret = mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_ADSP_AUDIO_26M]);
+ if (ret)
+ goto err_26m;
/* AFE hw clock */
- mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_AFE]);
- mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_A1SYS_HP]);
- mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_A1SYS]);
+ ret = mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_AFE]);
+ if (ret)
+ goto err_afe;
+ ret = mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_A1SYS_HP]);
+ if (ret)
+ goto err_a1sys_hp;
+ ret = mt8188_afe_enable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_A1SYS]);
+ if (ret)
+ goto err_a1sys;
return 0;
+
+err_a1sys:
+ mt8188_afe_disable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_A1SYS_HP]);
+err_a1sys_hp:
+ mt8188_afe_disable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_AFE]);
+err_afe:
+ mt8188_afe_disable_clk(afe, afe_priv->clk[MT8188_CLK_ADSP_AUDIO_26M]);
+err_26m:
+ mt8188_afe_disable_clk(afe, afe_priv->clk[MT8188_CLK_TOP_AUD_INTBUS_SEL]);
+err_intbus:
+ mt8188_afe_disable_clk(afe, afe_priv->clk[MT8188_CLK_TOP_AUDIO_LOCAL_BUS_SEL]);
+err_local_bus:
+ return ret;
}
int mt8188_afe_disable_reg_rw_clk(struct mtk_base_afe *afe)
@@ -630,7 +655,13 @@ static int mt8188_afe_enable_a1sys(struct mtk_base_afe *afe)
if (ret)
return ret;
- return mt8188_afe_enable_top_cg(afe, MT8188_TOP_CG_A1SYS_TIMING);
+ ret = mt8188_afe_enable_top_cg(afe, MT8188_TOP_CG_A1SYS_TIMING);
+ if (ret) {
+ mt8188_afe_disable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_A1SYS]);
+ return ret;
+ }
+
+ return 0;
}
static int mt8188_afe_disable_a1sys(struct mtk_base_afe *afe)
@@ -651,7 +682,13 @@ static int mt8188_afe_enable_a2sys(struct mtk_base_afe *afe)
if (ret)
return ret;
- return mt8188_afe_enable_top_cg(afe, MT8188_TOP_CG_A2SYS_TIMING);
+ ret = mt8188_afe_enable_top_cg(afe, MT8188_TOP_CG_A2SYS_TIMING);
+ if (ret) {
+ mt8188_afe_disable_clk(afe, afe_priv->clk[MT8188_CLK_AUD_A2SYS]);
+ return ret;
+ }
+
+ return 0;
}
static int mt8188_afe_disable_a2sys(struct mtk_base_afe *afe)
@@ -739,8 +776,18 @@ int mt8188_apll2_disable(struct mtk_base_afe *afe)
int mt8188_afe_enable_main_clock(struct mtk_base_afe *afe)
{
- mt8188_afe_enable_top_cg(afe, MT8188_TOP_CG_26M_TIMING);
- mt8188_afe_enable_afe_on(afe);
+ int ret;
+
+ ret = mt8188_afe_enable_top_cg(afe, MT8188_TOP_CG_26M_TIMING);
+ if (ret)
+ return ret;
+
+ ret = mt8188_afe_enable_afe_on(afe);
+ if (ret) {
+ mt8188_afe_disable_top_cg(afe, MT8188_TOP_CG_26M_TIMING);
+ return ret;
+ }
+
return 0;
}
--
2.43.0
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 5/7] ASoC: mediatek: mt8188: mt8188-afe-pcm: Handle runtime resume errors
2026-09-07 12:03 [PATCH 0/7] ASoC: mediatek: mt8188: Improve error handling phucduc.bui
` (3 preceding siblings ...)
2026-09-07 12:03 ` [PATCH 4/7] ASoC: mediatek: mt8188: mt8188-afe-clk: Handle clock enable errors phucduc.bui
@ 2026-09-07 12:03 ` phucduc.bui
2026-09-07 12:03 ` [PATCH 6/7] ASoC: mediatek: mt8188: mt8188-afe-pcm: Drop redundant probe error messages phucduc.bui
` (3 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: phucduc.bui @ 2026-09-07 12:03 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Jaroslav Kysela,
Takashi Iwai, Cezary Rojewski, Kees Cook, Kuninori Morimoto,
Trevor Wu, Douglas Anderson, linux-sound, linux-arm-kernel,
linux-mediatek, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Errors from clock enable and regcache synchronization are currently
ignored during runtime resume.
Check the return values from mt8188_afe_enable_reg_rw_clk(),
regcache_sync(), and mt8188_afe_enable_main_clock(), and abort the
runtime resume if any of them fails.
On failure, disable the previously enabled reg_rw clocks and restore
the regmap to cache-only mode.
Fixes: bf106bf09376 ("ASoC: mediatek: mt8188: add platform driver")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c b/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c
index 7b1f5d05f4d6..f8cbe7bac36d 100644
--- a/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c
+++ b/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c
@@ -3030,22 +3030,33 @@ static int mt8188_afe_runtime_resume(struct device *dev)
struct mtk_base_afe *afe = dev_get_drvdata(dev);
struct mt8188_afe_private *afe_priv = afe->platform_priv;
struct arm_smccc_res res;
+ int ret;
arm_smccc_smc(MTK_SIP_AUDIO_CONTROL,
MTK_AUDIO_SMC_OP_DOMAIN_SIDEBANDS,
0, 0, 0, 0, 0, 0, &res);
- mt8188_afe_enable_reg_rw_clk(afe);
+ ret = mt8188_afe_enable_reg_rw_clk(afe);
+ if (ret)
+ return ret;
if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl)
- goto skip_regmap;
+ return 0;
regcache_cache_only(afe->regmap, false);
- regcache_sync(afe->regmap);
+ ret = regcache_sync(afe->regmap);
+ if (ret)
+ goto err;
+
+ ret = mt8188_afe_enable_main_clock(afe);
+ if (ret)
+ goto err;
- mt8188_afe_enable_main_clock(afe);
-skip_regmap:
return 0;
+err:
+ mt8188_afe_disable_reg_rw_clk(afe);
+ regcache_cache_only(afe->regmap, true);
+ return ret;
}
static int init_memif_priv_data(struct mtk_base_afe *afe)
--
2.43.0
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 6/7] ASoC: mediatek: mt8188: mt8188-afe-pcm: Drop redundant probe error messages
2026-09-07 12:03 [PATCH 0/7] ASoC: mediatek: mt8188: Improve error handling phucduc.bui
` (4 preceding siblings ...)
2026-09-07 12:03 ` [PATCH 5/7] ASoC: mediatek: mt8188: mt8188-afe-pcm: Handle runtime resume errors phucduc.bui
@ 2026-09-07 12:03 ` phucduc.bui
2026-09-07 12:03 ` [PATCH 7/7] ASoC: mediatek: mt8188: fix clk leak on error in audsys_clk_register phucduc.bui
` (2 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: phucduc.bui @ 2026-09-07 12:03 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Jaroslav Kysela,
Takashi Iwai, Cezary Rojewski, Kees Cook, Kuninori Morimoto,
Trevor Wu, Douglas Anderson, linux-sound, linux-arm-kernel,
linux-mediatek, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Several probe error paths print error messages that are already
reported by the called functions.
Return the original error directly for devm_platform_ioremap_resource(),
mt8188_afe_init_clock(), platform_get_irq(), and devm_request_irq()
instead of wrapping the errors with dev_err_probe().
Also remove the redundant "err_platform" warning from the component
registration error path.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c b/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c
index f8cbe7bac36d..efad0af977f4 100644
--- a/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c
+++ b/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c
@@ -3232,8 +3232,7 @@ static int mt8188_afe_pcm_dev_probe(struct platform_device *pdev)
afe->base_addr = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(afe->base_addr))
- return dev_err_probe(dev, PTR_ERR(afe->base_addr),
- "AFE base_addr not found\n");
+ return PTR_ERR(afe->base_addr);
infra_ao = syscon_regmap_lookup_by_phandle(dev->of_node,
"mediatek,infracfg");
@@ -3269,7 +3268,7 @@ static int mt8188_afe_pcm_dev_probe(struct platform_device *pdev)
/* initial audio related clock */
ret = mt8188_afe_init_clock(afe);
if (ret)
- return dev_err_probe(dev, ret, "init clock error");
+ return ret;
spin_lock_init(&afe_priv->afe_ctrl_lock);
@@ -3302,12 +3301,12 @@ static int mt8188_afe_pcm_dev_probe(struct platform_device *pdev)
/* request irq */
irq_id = platform_get_irq(pdev, 0);
if (irq_id < 0)
- return dev_err_probe(dev, irq_id, "no irq found");
+ return irq_id;
ret = devm_request_irq(dev, irq_id, mt8188_afe_irq_handler,
IRQF_TRIGGER_NONE, "asys-isr", (void *)afe);
if (ret)
- return dev_err_probe(dev, ret, "could not request_irq for asys-isr\n");
+ return ret;
/* init sub_dais */
INIT_LIST_HEAD(&afe->sub_dais);
@@ -3363,10 +3362,8 @@ static int mt8188_afe_pcm_dev_probe(struct platform_device *pdev)
/* register component */
ret = devm_snd_soc_register_component(dev, &mtk_afe_pcm_platform,
afe->dai_drivers, afe->num_dai_drivers);
- if (ret) {
- dev_warn(dev, "err_platform\n");
+ if (ret)
goto err_pm_put;
- }
mt8188_afe_init_registers(afe);
--
2.43.0
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 7/7] ASoC: mediatek: mt8188: fix clk leak on error in audsys_clk_register
2026-09-07 12:03 [PATCH 0/7] ASoC: mediatek: mt8188: Improve error handling phucduc.bui
` (5 preceding siblings ...)
2026-09-07 12:03 ` [PATCH 6/7] ASoC: mediatek: mt8188: mt8188-afe-pcm: Drop redundant probe error messages phucduc.bui
@ 2026-09-07 12:03 ` phucduc.bui
2026-09-08 17:54 ` [PATCH 0/7] ASoC: mediatek: mt8188: Improve error handling Cezary Rojewski
2026-09-09 9:15 ` AngeloGioacchino Del Regno
8 siblings, 0 replies; 14+ messages in thread
From: phucduc.bui @ 2026-09-07 12:03 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Jaroslav Kysela,
Takashi Iwai, Cezary Rojewski, Kees Cook, Kuninori Morimoto,
Trevor Wu, Douglas Anderson, linux-sound, linux-arm-kernel,
linux-mediatek, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
devm_add_action_or_reset() is called after the loop that registers gate
clocks. If kzalloc() fails mid-loop, the function returns -ENOMEM before
that call, so cleanup is never registered and all previously registered
clocks leak permanently.
Move devm_add_action_or_reset() before the loop so cleanup is always
scheduled. The clock from the current (failing) iteration is not yet
stored in afe_priv->lookup[i], so it still needs an explicit
clk_unregister_gate() call.
Fixes: fd67a7a1a22c ("ASoC: mediatek: mt8188: fix use-after-free in driver remove path")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/mediatek/mt8188/mt8188-audsys-clk.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/sound/soc/mediatek/mt8188/mt8188-audsys-clk.c b/sound/soc/mediatek/mt8188/mt8188-audsys-clk.c
index 972f097a13ca..9f3b3a777577 100644
--- a/sound/soc/mediatek/mt8188/mt8188-audsys-clk.c
+++ b/sound/soc/mediatek/mt8188/mt8188-audsys-clk.c
@@ -170,7 +170,7 @@ int mt8188_audsys_clk_register(struct mtk_base_afe *afe)
struct mt8188_afe_private *afe_priv = afe->platform_priv;
struct clk *clk;
struct clk_lookup *cl;
- int i;
+ int i, ret;
afe_priv->lookup = devm_kcalloc(afe->dev, CLK_AUD_NR_CLK,
sizeof(*afe_priv->lookup),
@@ -179,6 +179,10 @@ int mt8188_audsys_clk_register(struct mtk_base_afe *afe)
if (!afe_priv->lookup)
return -ENOMEM;
+ ret = devm_add_action_or_reset(afe->dev, mt8188_audsys_clk_unregister, afe);
+ if (ret)
+ return ret;
+
for (i = 0; i < ARRAY_SIZE(aud_clks); i++) {
const struct afe_gate *gate = &aud_clks[i];
@@ -194,8 +198,10 @@ int mt8188_audsys_clk_register(struct mtk_base_afe *afe)
/* add clk_lookup for devm_clk_get(SND_SOC_DAPM_CLOCK_SUPPLY) */
cl = kzalloc_obj(*cl);
- if (!cl)
+ if (!cl) {
+ clk_unregister_gate(clk);
return -ENOMEM;
+ }
cl->clk = clk;
cl->con_id = gate->name;
@@ -206,5 +212,5 @@ int mt8188_audsys_clk_register(struct mtk_base_afe *afe)
afe_priv->lookup[i] = cl;
}
- return devm_add_action_or_reset(afe->dev, mt8188_audsys_clk_unregister, afe);
+ return 0;
}
--
2.43.0
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 0/7] ASoC: mediatek: mt8188: Improve error handling
2026-09-07 12:03 [PATCH 0/7] ASoC: mediatek: mt8188: Improve error handling phucduc.bui
` (6 preceding siblings ...)
2026-09-07 12:03 ` [PATCH 7/7] ASoC: mediatek: mt8188: fix clk leak on error in audsys_clk_register phucduc.bui
@ 2026-09-08 17:54 ` Cezary Rojewski
2026-09-09 9:15 ` AngeloGioacchino Del Regno
8 siblings, 0 replies; 14+ messages in thread
From: Cezary Rojewski @ 2026-09-08 17:54 UTC (permalink / raw)
To: phucduc.bui
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Jaroslav Kysela,
Takashi Iwai, Kees Cook, Kuninori Morimoto, Trevor Wu,
Douglas Anderson, linux-sound, linux-arm-kernel, linux-mediatek,
linux-kernel, Mark Brown, Matthias Brugger
On 9/7/2026 2:03 PM, phucduc.bui@gmail.com wrote:
> From: bui duc phuc <phucduc.bui@gmail.com>
>
> Hi all,
>
> This series improves error handling in several parts of the MT8188 AFE
> driver.
> Propagate errors from clock, regmap, and runtime resume operations,
> remove redundant probe error messages, and fix clock cleanup on
> registration failure.
>
> Compile-tested only.
>
> Best regards,
> Phuc
>
> bui duc phuc (7):
> ASoC: mediatek: mt8188: mt8188-afe-clk: Propagate clock initialization
> errors
> ASoC: mediatek: mt8188: mt8188-afe-clk: Handle tuner clock enable
> errors
> ASoC: mediatek: mt8188: mt8188-afe-clk: Propagate regmap update errors
> ASoC: mediatek: mt8188: mt8188-afe-clk: Handle clock enable errors
> ASoC: mediatek: mt8188: mt8188-afe-pcm: Handle runtime resume errors
> ASoC: mediatek: mt8188: mt8188-afe-pcm: Drop redundant probe error
> messages
> ASoC: mediatek: mt8188: fix clk leak on error in audsys_clk_register
>
> sound/soc/mediatek/mt8188/mt8188-afe-clk.c | 115 +++++++++++++-----
> sound/soc/mediatek/mt8188/mt8188-afe-pcm.c | 34 ++++--
> sound/soc/mediatek/mt8188/mt8188-audsys-clk.c | 12 +-
> 3 files changed, 113 insertions(+), 48 deletions(-)
>
Yet another bunch of welcomed changes though at this point I'd expect
someone from Mediatek to participate and start testing the error paths.
Some permissiveness might have been intentional but we won't know until
someone from their dev team ACKs or NAKs.
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 0/7] ASoC: mediatek: mt8188: Improve error handling
2026-09-07 12:03 [PATCH 0/7] ASoC: mediatek: mt8188: Improve error handling phucduc.bui
` (7 preceding siblings ...)
2026-09-08 17:54 ` [PATCH 0/7] ASoC: mediatek: mt8188: Improve error handling Cezary Rojewski
@ 2026-09-09 9:15 ` AngeloGioacchino Del Regno
2026-09-10 4:33 ` Bui Duc Phuc
8 siblings, 1 reply; 14+ messages in thread
From: AngeloGioacchino Del Regno @ 2026-09-09 9:15 UTC (permalink / raw)
To: phucduc.bui, Mark Brown, Matthias Brugger
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Cezary Rojewski,
Kees Cook, Kuninori Morimoto, Trevor Wu, Douglas Anderson,
linux-sound, linux-arm-kernel, linux-mediatek, linux-kernel
On 9/7/26 14:03, phucduc.bui@gmail.com wrote:
> From: bui duc phuc <phucduc.bui@gmail.com>
>
> Hi all,
>
> This series improves error handling in several parts of the MT8188 AFE
> driver.
> Propagate errors from clock, regmap, and runtime resume operations,
> remove redundant probe error messages, and fix clock cleanup on
> registration failure.
>
> Compile-tested only.
>
> Best regards,
> Phuc
Series is
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 0/7] ASoC: mediatek: mt8188: Improve error handling
2026-09-09 9:15 ` AngeloGioacchino Del Regno
@ 2026-09-10 4:33 ` Bui Duc Phuc
0 siblings, 0 replies; 14+ messages in thread
From: Bui Duc Phuc @ 2026-09-10 4:33 UTC (permalink / raw)
To: AngeloGioacchino Del Regno
Cc: Mark Brown, Matthias Brugger, Liam Girdwood, Jaroslav Kysela,
Takashi Iwai, Cezary Rojewski, Kees Cook, Kuninori Morimoto,
Trevor Wu, Douglas Anderson, linux-sound, linux-arm-kernel,
linux-mediatek, linux-kernel
Hi Cezary, AngeloGioacchino
Thanks to both of you for reviewing the series.
Best regards,
Phuc
^ permalink raw reply [flat|nested] 14+ messages in thread