mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/4] ASoC: mediatek: Handle constraint return value in FE startup
@ 2026-10-07 11:08 phucduc.bui
  2026-10-07 11:08 ` [PATCH v2 1/4] ASoC: mediatek: common: " phucduc.bui
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: phucduc.bui @ 2026-10-07 11:08 UTC (permalink / raw)
  To: Mark Brown, AngeloGioacchino Del Regno, Trevor Wu
  Cc: Liam Girdwood, Matthias Brugger, Jaroslav Kysela, Takashi Iwai,
	Kuninori Morimoto, cassiogabrielcontato, Haotian Zhang,
	Christian Marangi, Cezary Rojewski, Cyril Chao, Tuo Li,
	Rosen Penev, Garlic Tseng, Alexandre Mergnat, Dan Carpenter,
	linux-sound, linux-arm-kernel, linux-mediatek, linux-kernel,
	bui duc phuc

From: bui duc phuc <phucduc.bui@gmail.com>

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.

Changes in v2:
 - Rename the patch subject.
 - Simplify the code change as suggested by Cezary. 

Best regards,
Phuc

bui duc phuc (4):
  ASoC: mediatek: common: Handle constraint return value in FE startup
  ASoC: mediatek: mt8188: Handle constraint return value in FE startup
  ASoC: mediatek: mt8189: Handle constraint return value in FE startup
  ASoC: mediatek: mt8365: Handle constraint return value in FE startup

 sound/soc/mediatek/common/mtk-afe-fe-dai.c | 8 +++++---
 sound/soc/mediatek/mt8188/mt8188-afe-pcm.c | 3 +++
 sound/soc/mediatek/mt8189/mt8189-afe-pcm.c | 8 +++++---
 sound/soc/mediatek/mt8365/mt8365-afe-pcm.c | 7 +++++--
 4 files changed, 18 insertions(+), 8 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/4] ASoC: mediatek: common: Handle constraint return value in FE startup
  2026-10-07 11:08 [PATCH v2 0/4] ASoC: mediatek: Handle constraint return value in FE startup phucduc.bui
@ 2026-10-07 11:08 ` phucduc.bui
  2026-10-07 11:08 ` [PATCH v2 2/4] ASoC: mediatek: mt8188: " phucduc.bui
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: phucduc.bui @ 2026-10-07 11:08 UTC (permalink / raw)
  To: Mark Brown, AngeloGioacchino Del Regno, Trevor Wu
  Cc: Liam Girdwood, Matthias Brugger, Jaroslav Kysela, Takashi Iwai,
	Kuninori Morimoto, cassiogabrielcontato, Haotian Zhang,
	Christian Marangi, Cezary Rojewski, Cyril Chao, Tuo Li,
	Rosen Penev, Garlic Tseng, Alexandre Mergnat, Dan Carpenter,
	linux-sound, linux-arm-kernel, linux-mediatek, linux-kernel,
	bui duc phuc

From: bui duc phuc <phucduc.bui@gmail.com>

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")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
 sound/soc/mediatek/common/mtk-afe-fe-dai.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sound/soc/mediatek/common/mtk-afe-fe-dai.c b/sound/soc/mediatek/common/mtk-afe-fe-dai.c
index 948f606cbaf2..ec99bc4a5d5e 100644
--- a/sound/soc/mediatek/common/mtk-afe-fe-dai.c
+++ b/sound/soc/mediatek/common/mtk-afe-fe-dai.c
@@ -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);
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 2/4] ASoC: mediatek: mt8188: Handle constraint return value in FE startup
  2026-10-07 11:08 [PATCH v2 0/4] ASoC: mediatek: Handle constraint return value in FE startup phucduc.bui
  2026-10-07 11:08 ` [PATCH v2 1/4] ASoC: mediatek: common: " phucduc.bui
@ 2026-10-07 11:08 ` phucduc.bui
  2026-10-07 11:08 ` [PATCH v2 3/4] ASoC: mediatek: mt8189: " phucduc.bui
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: phucduc.bui @ 2026-10-07 11:08 UTC (permalink / raw)
  To: Mark Brown, AngeloGioacchino Del Regno, Trevor Wu
  Cc: Liam Girdwood, Matthias Brugger, Jaroslav Kysela, Takashi Iwai,
	Kuninori Morimoto, cassiogabrielcontato, Haotian Zhang,
	Christian Marangi, Cezary Rojewski, Cyril Chao, Tuo Li,
	Rosen Penev, Garlic Tseng, Alexandre Mergnat, Dan Carpenter,
	linux-sound, linux-arm-kernel, linux-mediatek, linux-kernel,
	bui duc phuc

From: bui duc phuc <phucduc.bui@gmail.com>

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")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---

Changes in v2:
 - Simplify the code change as suggested by Cezary. 

 sound/soc/mediatek/mt8188/mt8188-afe-pcm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c b/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c
index 4010879ad1d3..b2d935ae8668 100644
--- a/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c
+++ b/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c
@@ -320,6 +320,9 @@ static int mt8188_afe_fe_startup(struct snd_pcm_substream *substream,
 					   MT8188_MEMIF_DL7_MAX_PERIOD_SIZE);
 	if (ret < 0)
 		dev_dbg(afe->dev, "hw_constraint_minmax failed\n");
+	else
+		ret = 0;
+
 out:
 	return ret;
 }
-- 
2.43.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 3/4] ASoC: mediatek: mt8189: Handle constraint return value in FE startup
  2026-10-07 11:08 [PATCH v2 0/4] ASoC: mediatek: Handle constraint return value in FE startup phucduc.bui
  2026-10-07 11:08 ` [PATCH v2 1/4] ASoC: mediatek: common: " phucduc.bui
  2026-10-07 11:08 ` [PATCH v2 2/4] ASoC: mediatek: mt8188: " phucduc.bui
@ 2026-10-07 11:08 ` phucduc.bui
  2026-10-07 11:08 ` [PATCH v2 4/4] ASoC: mediatek: mt8365: " phucduc.bui
  2026-10-07 14:03 ` [PATCH v2 0/4] ASoC: mediatek: " Cezary Rojewski
  4 siblings, 0 replies; 6+ messages in thread
From: phucduc.bui @ 2026-10-07 11:08 UTC (permalink / raw)
  To: Mark Brown, AngeloGioacchino Del Regno, Trevor Wu
  Cc: Liam Girdwood, Matthias Brugger, Jaroslav Kysela, Takashi Iwai,
	Kuninori Morimoto, cassiogabrielcontato, Haotian Zhang,
	Christian Marangi, Cezary Rojewski, Cyril Chao, Tuo Li,
	Rosen Penev, Garlic Tseng, Alexandre Mergnat, Dan Carpenter,
	linux-sound, linux-arm-kernel, linux-mediatek, linux-kernel,
	bui duc phuc

From: bui duc phuc <phucduc.bui@gmail.com>

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")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
 sound/soc/mediatek/mt8189/mt8189-afe-pcm.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sound/soc/mediatek/mt8189/mt8189-afe-pcm.c b/sound/soc/mediatek/mt8189/mt8189-afe-pcm.c
index c0f340a6cc09..eefa96b701a5 100644
--- a/sound/soc/mediatek/mt8189/mt8189-afe-pcm.c
+++ b/sound/soc/mediatek/mt8189/mt8189-afe-pcm.c
@@ -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,
-- 
2.43.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 4/4] ASoC: mediatek: mt8365: Handle constraint return value in FE startup
  2026-10-07 11:08 [PATCH v2 0/4] ASoC: mediatek: Handle constraint return value in FE startup phucduc.bui
                   ` (2 preceding siblings ...)
  2026-10-07 11:08 ` [PATCH v2 3/4] ASoC: mediatek: mt8189: " phucduc.bui
@ 2026-10-07 11:08 ` phucduc.bui
  2026-10-07 14:03 ` [PATCH v2 0/4] ASoC: mediatek: " Cezary Rojewski
  4 siblings, 0 replies; 6+ messages in thread
From: phucduc.bui @ 2026-10-07 11:08 UTC (permalink / raw)
  To: Mark Brown, AngeloGioacchino Del Regno, Trevor Wu
  Cc: Liam Girdwood, Matthias Brugger, Jaroslav Kysela, Takashi Iwai,
	Kuninori Morimoto, cassiogabrielcontato, Haotian Zhang,
	Christian Marangi, Cezary Rojewski, Cyril Chao, Tuo Li,
	Rosen Penev, Garlic Tseng, Alexandre Mergnat, Dan Carpenter,
	linux-sound, linux-arm-kernel, linux-mediatek, linux-kernel,
	bui duc phuc

From: bui duc phuc <phucduc.bui@gmail.com>

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")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
 sound/soc/mediatek/mt8365/mt8365-afe-pcm.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/sound/soc/mediatek/mt8365/mt8365-afe-pcm.c b/sound/soc/mediatek/mt8365/mt8365-afe-pcm.c
index e9497246f37c..314235557fdf 100644
--- a/sound/soc/mediatek/mt8365/mt8365-afe-pcm.c
+++ b/sound/soc/mediatek/mt8365/mt8365-afe-pcm.c
@@ -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,
-- 
2.43.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/4] ASoC: mediatek: Handle constraint return value in FE startup
  2026-10-07 11:08 [PATCH v2 0/4] ASoC: mediatek: Handle constraint return value in FE startup phucduc.bui
                   ` (3 preceding siblings ...)
  2026-10-07 11:08 ` [PATCH v2 4/4] ASoC: mediatek: mt8365: " phucduc.bui
@ 2026-10-07 14:03 ` Cezary Rojewski
  4 siblings, 0 replies; 6+ messages in thread
From: Cezary Rojewski @ 2026-10-07 14:03 UTC (permalink / raw)
  To: phucduc.bui
  Cc: Liam Girdwood, Matthias Brugger, Jaroslav Kysela, Takashi Iwai,
	Kuninori Morimoto, cassiogabrielcontato, Haotian Zhang,
	Christian Marangi, Cyril Chao, Tuo Li, Rosen Penev, Garlic Tseng,
	Alexandre Mergnat, Dan Carpenter, linux-sound, linux-arm-kernel,
	linux-mediatek, linux-kernel, Mark Brown,
	AngeloGioacchino Del Regno, Trevor Wu

On 10/7/2026 1:08 PM, phucduc.bui@gmail.com wrote:
> From: bui duc phuc <phucduc.bui@gmail.com>
> 
> 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.
> 
> Changes in v2:
>  - Rename the patch subject.
>  - Simplify the code change as suggested by Cezary. 
Thank you for the update. The snd_pcm_hw_constraint_xxx() finding is a
good catch.

Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-10-07 14:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-07 11:08 [PATCH v2 0/4] ASoC: mediatek: Handle constraint return value in FE startup phucduc.bui
2026-10-07 11:08 ` [PATCH v2 1/4] ASoC: mediatek: common: " phucduc.bui
2026-10-07 11:08 ` [PATCH v2 2/4] ASoC: mediatek: mt8188: " phucduc.bui
2026-10-07 11:08 ` [PATCH v2 3/4] ASoC: mediatek: mt8189: " phucduc.bui
2026-10-07 11:08 ` [PATCH v2 4/4] ASoC: mediatek: mt8365: " phucduc.bui
2026-10-07 14:03 ` [PATCH v2 0/4] ASoC: mediatek: " Cezary Rojewski

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®