Skip to contentSkip to conversation

ASoC: mediatek: Return 0 from FE startup on success

PATCH In review [email protected] 3 participants 12 messages Oct 6 – Oct 14

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ASoC: mediatek: Return 0 from FE startup on success

From: bui duc phuc <[email protected]>

Hi all,

Some FE startup callbacks may return a positive value from constraint helpers, but ASoC expects 0 on success. This can cause .shutdown() to be skipped during rollback.

Return 0 explicitly on success.

Compile-tested only.

Best regards,
Phuc

bui duc phuc (4):
ASoC: mediatek: common: return 0 from mtk_afe_fe_startup() on success
ASoC: mediatek: mt8188: return 0 from mt8188_afe_fe_startup() on
success
ASoC: mediatek: mt8189:return 0 from mt8189_fe_startup() on success
ASoC: mediatek: mt8365: return 0 from mt8365_afe_fe_startup() on
success

 sound/soc/mediatek/common/mtk-afe-fe-dai.c | 8 +++++---
 sound/soc/mediatek/mt8188/mt8188-afe-pcm.c | 5 ++++-
 sound/soc/mediatek/mt8189/mt8189-afe-pcm.c | 8 +++++---
 sound/soc/mediatek/mt8365/mt8365-afe-pcm.c | 7 +++++--
 4 files changed, 19 insertions(+), 9 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/4 ASoC: mediatek: common: return 0 from mtk_afe_fe_startup() on success

From: bui duc phuc <[email protected]>

snd_pcm_hw_constraint_integer() may return 1, which is then returned from mtk_afe_fe_startup(). ASoC only treats 0 as success when marking the DAI as started, so .shutdown() can be skipped on rollback.

Return 0 explicitly on success.

Fixes 283b612429a2 ("ASoC: mediatek: implement mediatek common structure")
---
 sound/soc/mediatek/common/mtk-afe-fe-dai.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
sound/soc/mediatek/common/mtk-afe-fe-dai.c +5 -3
index 948f606cbaf2..ec99bc4a5d5e 100644
@@ -75,8 +75,10 @@ int mtk_afe_fe_startup(struct snd_pcm_substream *substream,
 
 	ret = snd_pcm_hw_constraint_integer(runtime,
 					    SNDRV_PCM_HW_PARAM_PERIODS);
-	if (ret < 0)
+	if (ret < 0) {
 		dev_err(afe->dev, "snd_pcm_hw_constraint_integer failed\n");
+		return ret;
+	}
 
 	/* dynamic allocate irq to memif */
 	if (memif->irq_usage < 0) {
@@ -88,10 +90,10 @@ int mtk_afe_fe_startup(struct snd_pcm_substream *substream,
 		} else {
 			dev_err(afe->dev, "%s() error: no more asys irq\n",
 				__func__);
-			ret = -EBUSY;
+			return -EBUSY;
 		}
 	}
-	return ret;
+	return 0;
 }
 EXPORT_SYMBOL_GPL(mtk_afe_fe_startup);
 
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/4 ASoC: mediatek: mt8188: return 0 from mt8188_afe_fe_startup() on success

In reply to [email protected]

From: bui duc phuc <[email protected]>

snd_pcm_hw_constraint_minmax() may return 1, which is then returned from mt8188_afe_fe_startup(). ASoC only treats 0 as success when marking the DAI as started, so .shutdown() can be skipped on rollback.

Return 0 explicitly on success.

Fixes bf106bf09376 ("ASoC: mediatek: mt8188: add platform driver")
---
 sound/soc/mediatek/mt8188/mt8188-afe-pcm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c +4 -1
index 4010879ad1d3..87d6098caf99 100644
@@ -318,8 +318,11 @@ static int mt8188_afe_fe_startup(struct snd_pcm_substream *substream,
 	ret = snd_pcm_hw_constraint_minmax(runtime,
 					   SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 1,
 					   MT8188_MEMIF_DL7_MAX_PERIOD_SIZE);
-	if (ret < 0)
+	if (ret >= 0)
+		ret = 0;
+	else
 		dev_dbg(afe->dev, "hw_constraint_minmax failed\n");
+
 out:
 	return ret;
 }
Signature · 1 line
2.43.0
#3 lore raw

Re: [PATCH 2/4] ASoC: mediatek: mt8188: return 0 from mt8188_afe_fe_startup() on success

sound/soc/mediatek/mt8188/mt8188-afe-pcm.c static int mt8188_afe_fe_startup(struct snd_pcm_substream *substream, · line 324

Quoted 11 lines · On 10/6/2026 12:16 PM, [email protected] wrote:
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c +3 -1
@@ -318,8 +318,11 @@ static int mt8188_afe_fe_startup(struct snd_pcm_substream *substream,
 	ret = snd_pcm_hw_constraint_minmax(runtime,
 					   SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 1,
 					   MT8188_MEMIF_DL7_MAX_PERIOD_SIZE);
-	if (ret < 0)
+	if (ret >= 0)
+		ret = 0;
+	else
 		dev_dbg(afe->dev, "hw_constraint_minmax failed\n");

You can reduce the delta by leaving the original if-statement as-is and following it up with:

	else
		ret = 0;
Quoted 4 lines
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c +1 -0
+
 out:
 	return ret;
 }
#4 lore raw

Re: [PATCH 2/4] ASoC: mediatek: mt8188: return 0 from mt8188_afe_fe_startup() on success

Hi Cezary,

Quoted 6 lines

You can reduce the delta by leaving the original if-statement as-is and following it up with:

        else
                ret = 0;

Thanks, I'll make this change and include it in v2.

Best regards,
Phuc

#5 lore raw

PATCH 3/4 ASoC: mediatek: mt8189:return 0 from mt8189_fe_startup() on success

In reply to [email protected]

From: bui duc phuc <[email protected]>

snd_pcm_hw_constraint_integer() may return 1, which is then returned from mt8189_fe_startup(). ASoC only treats 0 as success when marking the DAI as started, so .shutdown() can be skipped on rollback.

Return 0 explicitly on success.

Fixes 7eb153585598 ("ASoC: mediatek: mt8189: add platform driver")
---
 sound/soc/mediatek/mt8189/mt8189-afe-pcm.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
sound/soc/mediatek/mt8189/mt8189-afe-pcm.c +5 -3
index c0f340a6cc09..eefa96b701a5 100644
@@ -155,8 +155,10 @@ static int mt8189_fe_startup(struct snd_pcm_substream *substream,
 
 	ret = snd_pcm_hw_constraint_integer(runtime,
 					    SNDRV_PCM_HW_PARAM_PERIODS);
-	if (ret < 0)
+	if (ret < 0) {
 		dev_warn(afe->dev, "snd_pcm_hw_constraint_integer failed\n");
+		return ret;
+	}
 
 	/* dynamic allocate irq to memif */
 	if (memif->irq_usage < 0) {
@@ -168,11 +170,11 @@ static int mt8189_fe_startup(struct snd_pcm_substream *substream,
 		} else {
 			dev_err(afe->dev, "%s() error: no more asys irq\n",
 				__func__);
-			ret = -EBUSY;
+			return -EBUSY;
 		}
 	}
 
-	return ret;
+	return 0;
 }
 
 static void mt8189_fe_shutdown(struct snd_pcm_substream *substream,
Signature · 1 line
2.43.0
#6 lore raw

Re: [PATCH 3/4] ASoC: mediatek: mt8189:return 0 from mt8189_fe_startup() on success

Quoted 5 lines · On 10/6/2026 12:16 PM, [email protected] wrote:

From: bui duc phuc <[email protected]>

snd_pcm_hw_constraint_integer() may return 1, which is then returned from mt8189_fe_startup(). ASoC only treats 0 as success when marking the DAI as started, so .shutdown() can be skipped on rollback.

Nothing major here, just the missing space between 'mt8189:return' in the title.

IMHO the title could be made more explicit as you're in fact fixing how the snd_pcm_hw_constraint_xxx() is handled by the driver. "Return 0 from (...)" misses the point.

Kind regards,
Czarek

#7 lore raw

Re: [PATCH 3/4] ASoC: mediatek: mt8189:return 0 from mt8189_fe_startup() on success

Hi Cezary,

Quoted 6 lines

Nothing major here, just the missing space between 'mt8189:return' in the title.

IMHO the title could be made more explicit as you're in fact fixing how the snd_pcm_hw_constraint_xxx() is handled by the driver. "Return 0 from (...)" misses the point.

Thanks. I'll fix the missing space and update the title to:

ASoC: mediatek: mt8189: Handle constraint return value in FE startup

in v2.

Best regards,
Phuc

#8 lore raw

PATCH 4/4 ASoC: mediatek: mt8365: return 0 from mt8365_afe_fe_startup() on success

In reply to [email protected]

From: bui duc phuc <[email protected]>

snd_pcm_hw_constraint_integer() may return 1, which is then returned from mt8365_afe_fe_startup(). ASoC only treats 0 as success when marking the DAI as started, so .shutdown() can be skipped on rollback.

Return 0 explicitly on success.

Fixes e1991d102bc2 ("ASoC: mediatek: mt8365: Add the AFE driver support")
---
 sound/soc/mediatek/mt8365/mt8365-afe-pcm.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
sound/soc/mediatek/mt8365/mt8365-afe-pcm.c +5 -2
index e9497246f37c..314235557fdf 100644
@@ -514,11 +514,14 @@ static int mt8365_afe_fe_startup(struct snd_pcm_substream *substream,
 	snd_soc_set_runtime_hwparams(substream, afe->mtk_afe_hardware);
 
 	ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
-	if (ret < 0)
+	if (ret < 0) {
 		dev_err(afe->dev, "snd_pcm_hw_constraint_integer failed\n");
+		return ret;
+	}
 
 	mt8365_afe_enable_main_clk(afe);
-	return ret;
+
+	return 0;
 }
 
 static void mt8365_afe_fe_shutdown(struct snd_pcm_substream *substream,
Signature · 1 line
2.43.0
maintainer
#9 lore raw
In reply to [email protected]
Quoted 11 lines · On Tue, 06 Oct 2026 17:16:02 +0700, [email protected] wrote:

ASoC: mediatek: Return 0 from FE startup on success

From: bui duc phuc <[email protected]>

Hi all,

Some FE startup callbacks may return a positive value from constraint helpers, but ASoC expects 0 on success. This can cause .shutdown() to be skipped during rollback.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.4

Thanks!

[1/4] ASoC: mediatek: common: return 0 from mtk_afe_fe_startup() on success

      https://git.kernel.org/broonie/sound/c/5bbd6696d75e
[2/4] ASoC: mediatek: mt8188: return 0 from mt8188_afe_fe_startup() on success
      https://git.kernel.org/broonie/sound/c/b6b3dbee98f1
[3/4] ASoC: mediatek: mt8189:return 0 from mt8189_fe_startup() on success
      https://git.kernel.org/broonie/sound/c/f63317c826c4
[4/4] ASoC: mediatek: mt8365: return 0 from mt8365_afe_fe_startup() on success
      https://git.kernel.org/broonie/sound/c/240f11af9c80

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

maintainer
#10 lore raw
In reply to [email protected]
Quoted 11 lines · On Tue, 06 Oct 2026 17:16:02 +0700, [email protected] wrote:

ASoC: mediatek: Return 0 from FE startup on success

From: bui duc phuc <[email protected]>

Hi all,

Some FE startup callbacks may return a positive value from constraint helpers, but ASoC expects 0 on success. This can cause .shutdown() to be skipped during rollback.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.4

Thanks!

[1/4] ASoC: mediatek: common: return 0 from mtk_afe_fe_startup() on success

      https://git.kernel.org/broonie/sound/c/5bbd6696d75e
[2/4] ASoC: mediatek: mt8188: return 0 from mt8188_afe_fe_startup() on success
      https://git.kernel.org/broonie/sound/c/b6b3dbee98f1
[3/4] ASoC: mediatek: mt8189:return 0 from mt8189_fe_startup() on success
      https://git.kernel.org/broonie/sound/c/f63317c826c4
[4/4] ASoC: mediatek: mt8365: return 0 from mt8365_afe_fe_startup() on success
      https://git.kernel.org/broonie/sound/c/240f11af9c80

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark