ASoC: mediatek: Handle constraint return value in FE startup
Subsystems (3)
v2 cover ASoC: mediatek: Handle constraint return value in FE startup
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.
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(-)
Signature · 1 line
2.43.0
PATCH v2 1/4 ASoC: mediatek: common: Handle constraint return value in FE startup
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.
--- 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
@@ -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
PATCH v2 2/4 ASoC: mediatek: mt8188: Handle constraint return value in FE startup
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.
---
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(+)
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c +3 -0
@@ -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; }
Signature · 1 line
2.43.0
PATCH v2 3/4 ASoC: mediatek: mt8189: Handle constraint return value in FE startup
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.
--- 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
@@ -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
PATCH v2 4/4 ASoC: mediatek: mt8365: Handle constraint return value in FE startup
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.
--- 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
@@ -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
Quoted 8 lines · On 10/7/2026 1:08 PM, [email protected] wrote:
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.
Quoted 7 lines
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.
Hi Cezary.
Thank you for the review.
Quoted 4 lines
Thank you for the update. The
snd_pcm_hw_constraint_xxx()finding is a good catch.Reviewed-by Cezary Rojewski <[email protected]>
I actually found this issue thanks to Mark's review in another thread, where he pointed out a subtle issue with the return value.
Best regards,
Phuc
Mark Brown
maintainerQuoted 11 lines · On Wed, 07 Oct 2026 18:08:54 +0700, [email protected] wrote:
ASoC: mediatek: Handle constraint return value in FE startup
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: Handle constraint return value in FE startup
https://git.kernel.org/broonie/sound/c/5fcdb40a4776 [2/4] ASoC: mediatek: mt8188: Handle constraint return value in FE startup https://git.kernel.org/broonie/sound/c/71253751586b [3/4] ASoC: mediatek: mt8189: Handle constraint return value in FE startup https://git.kernel.org/broonie/sound/c/1f234d33e42e [4/4] ASoC: mediatek: mt8365: Handle constraint return value in FE startup https://git.kernel.org/broonie/sound/c/8de3f4e8e811
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