* [PATCH 0/3] ASoC: stm32: spdifrx: Fix resource handling and startup
@ 2026-11-27 9:23 phucduc.bui
2026-11-27 9:23 ` [PATCH 1/3] ASoC: stm32: spdifrx: Use devm helpers and drop remove callback phucduc.bui
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: phucduc.bui @ 2026-11-27 9:23 UTC (permalink / raw)
To: Mark Brown, Olivier Moysan
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Arnaud Pouliquen,
Maxime Coquelin, linux-sound, linux-stm32, linux-arm-kernel,
linux-kernel, Alexandre Torgue, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Hi all,
This series improves resource management and error handling in the
STM32 SPDIFRX driver.
It also fixes the refcount handling on synchronization failure and
ensures the clock is enabled before setting the substream pointer.
Compile-tested only.
Best regards,
Phuc
bui duc phuc (3):
ASoC: stm32: spdifrx: Use devm helpers and drop remove callback
ASoC: stm32: spdifrx: Fix refcount on sync failure
ASoC: stm32: spdifrx: Enable clock before setting substream
sound/soc/stm/stm32_spdifrx.c | 87 ++++++++++++-----------------------
1 file changed, 30 insertions(+), 57 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 12+ messages in thread* [PATCH 1/3] ASoC: stm32: spdifrx: Use devm helpers and drop remove callback 2026-11-27 9:23 [PATCH 0/3] ASoC: stm32: spdifrx: Fix resource handling and startup phucduc.bui @ 2026-11-27 9:23 ` phucduc.bui 2026-12-01 8:52 ` Olivier MOYSAN 2026-11-27 9:23 ` [PATCH 2/3] ASoC: stm32: spdifrx: Fix refcount on sync failure phucduc.bui 2026-11-27 9:23 ` [PATCH 3/3] ASoC: stm32: spdifrx: Enable clock before setting substream phucduc.bui 2 siblings, 1 reply; 12+ messages in thread From: phucduc.bui @ 2026-11-27 9:23 UTC (permalink / raw) To: Mark Brown, Olivier Moysan Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Arnaud Pouliquen, Maxime Coquelin, linux-sound, linux-stm32, linux-arm-kernel, linux-kernel, Alexandre Torgue, bui duc phuc From: bui duc phuc <phucduc.bui@gmail.com> Use devm helpers to manage the DMA channel, DMA buffer, runtime PM, PCM and component registration. This allows removing the remove callback and simplifies error handling in the probe function. Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> --- sound/soc/stm/stm32_spdifrx.c | 67 +++++++++-------------------------- 1 file changed, 16 insertions(+), 51 deletions(-) diff --git a/sound/soc/stm/stm32_spdifrx.c b/sound/soc/stm/stm32_spdifrx.c index f6f7d4aaa94d..467c3c583a00 100644 --- a/sound/soc/stm/stm32_spdifrx.c +++ b/sound/soc/stm/stm32_spdifrx.c @@ -396,24 +396,16 @@ static int stm32_spdifrx_dma_ctrl_register(struct device *dev, { int ret; - spdifrx->ctrl_chan = dma_request_chan(dev, "rx-ctrl"); + spdifrx->ctrl_chan = devm_dma_request_chan(dev, "rx-ctrl"); if (IS_ERR(spdifrx->ctrl_chan)) return dev_err_probe(dev, PTR_ERR(spdifrx->ctrl_chan), "dma_request_chan error\n"); - spdifrx->dmab = devm_kzalloc_obj(dev, struct snd_dma_buffer); + spdifrx->dmab = snd_devm_alloc_pages(dev, SNDRV_DMA_TYPE_DEV_IRAM, + SPDIFRX_CSR_BUF_LENGTH); if (!spdifrx->dmab) return -ENOMEM; - spdifrx->dmab->dev.type = SNDRV_DMA_TYPE_DEV_IRAM; - spdifrx->dmab->dev.dev = dev; - ret = snd_dma_alloc_pages(spdifrx->dmab->dev.type, dev, - SPDIFRX_CSR_BUF_LENGTH, spdifrx->dmab); - if (ret < 0) { - dev_err(dev, "snd_dma_alloc_pages returned error %d\n", ret); - return ret; - } - spdifrx->slave_config.direction = DMA_DEV_TO_MEM; spdifrx->slave_config.src_addr = (dma_addr_t)(spdifrx->phys_addr + STM32_SPDIFRX_CSR); @@ -919,26 +911,10 @@ static int stm32_spdifrx_parse_of(struct platform_device *pdev, return 0; } -static void stm32_spdifrx_remove(struct platform_device *pdev) -{ - struct stm32_spdifrx_data *spdifrx = platform_get_drvdata(pdev); - - if (!IS_ERR(spdifrx->ctrl_chan)) - dma_release_channel(spdifrx->ctrl_chan); - - if (spdifrx->dmab) - snd_dma_free_pages(spdifrx->dmab); - - snd_dmaengine_pcm_unregister(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); - pm_runtime_disable(&pdev->dev); -} - static int stm32_spdifrx_probe(struct platform_device *pdev) { struct stm32_spdifrx_data *spdifrx; struct reset_control *rst; - const struct snd_dmaengine_pcm_config *pcm_config = NULL; u32 ver, idr; int ret; @@ -978,46 +954,36 @@ static int stm32_spdifrx_probe(struct platform_device *pdev) udelay(2); reset_control_deassert(rst); - pcm_config = &stm32_spdifrx_pcm_config; - ret = snd_dmaengine_pcm_register(&pdev->dev, pcm_config, 0); - if (ret) - return ret; - - ret = snd_soc_register_component(&pdev->dev, - &stm32_spdifrx_component, - stm32_spdifrx_dai, - ARRAY_SIZE(stm32_spdifrx_dai)); - if (ret) { - snd_dmaengine_pcm_unregister(&pdev->dev); - return ret; - } - ret = stm32_spdifrx_dma_ctrl_register(&pdev->dev, spdifrx); if (ret) - goto error; + return ret; ret = regmap_read(spdifrx->regmap, STM32_SPDIFRX_IDR, &idr); if (ret) - goto error; + return ret; if (idr == SPDIFRX_IPIDR_NUMBER) { ret = regmap_read(spdifrx->regmap, STM32_SPDIFRX_VERR, &ver); if (ret) - goto error; + return ret; dev_dbg(&pdev->dev, "SPDIFRX version: %lu.%lu registered\n", FIELD_GET(SPDIFRX_VERR_MAJ_MASK, ver), FIELD_GET(SPDIFRX_VERR_MIN_MASK, ver)); } - pm_runtime_enable(&pdev->dev); + ret = devm_pm_runtime_enable(&pdev->dev); + if (ret) + return ret; - return ret; + ret = devm_snd_dmaengine_pcm_register(&pdev->dev, &stm32_spdifrx_pcm_config, 0); + if (ret) + return ret; -error: - stm32_spdifrx_remove(pdev); - - return ret; + return devm_snd_soc_register_component(&pdev->dev, + &stm32_spdifrx_component, + stm32_spdifrx_dai, + ARRAY_SIZE(stm32_spdifrx_dai)); } MODULE_DEVICE_TABLE(of, stm32_spdifrx_ids); @@ -1052,7 +1018,6 @@ static struct platform_driver stm32_spdifrx_driver = { .pm = pm_ptr(&stm32_spdifrx_pm_ops), }, .probe = stm32_spdifrx_probe, - .remove = stm32_spdifrx_remove, }; module_platform_driver(stm32_spdifrx_driver); -- 2.43.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] ASoC: stm32: spdifrx: Use devm helpers and drop remove callback 2026-11-27 9:23 ` [PATCH 1/3] ASoC: stm32: spdifrx: Use devm helpers and drop remove callback phucduc.bui @ 2026-12-01 8:52 ` Olivier MOYSAN 2026-12-01 11:41 ` Mark Brown 0 siblings, 1 reply; 12+ messages in thread From: Olivier MOYSAN @ 2026-12-01 8:52 UTC (permalink / raw) To: phucduc.bui, Mark Brown Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Arnaud Pouliquen, Maxime Coquelin, linux-sound, linux-stm32, linux-arm-kernel, linux-kernel, Alexandre Torgue Hi, On 11/27/26 10:23, phucduc.bui@gmail.com wrote: > From: bui duc phuc <phucduc.bui@gmail.com> > > Use devm helpers to manage the DMA channel, DMA buffer, runtime PM, > PCM and component registration. > > This allows removing the remove callback and simplifies error > handling in the probe function. > > Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> > --- > sound/soc/stm/stm32_spdifrx.c | 67 +++++++++-------------------------- > 1 file changed, 16 insertions(+), 51 deletions(-) > > diff --git a/sound/soc/stm/stm32_spdifrx.c b/sound/soc/stm/stm32_spdifrx.c > index f6f7d4aaa94d..467c3c583a00 100644 > --- a/sound/soc/stm/stm32_spdifrx.c > +++ b/sound/soc/stm/stm32_spdifrx.c > @@ -396,24 +396,16 @@ static int stm32_spdifrx_dma_ctrl_register(struct device *dev, > { > int ret; > > - spdifrx->ctrl_chan = dma_request_chan(dev, "rx-ctrl"); > + spdifrx->ctrl_chan = devm_dma_request_chan(dev, "rx-ctrl"); > if (IS_ERR(spdifrx->ctrl_chan)) > return dev_err_probe(dev, PTR_ERR(spdifrx->ctrl_chan), > "dma_request_chan error\n"); > > - spdifrx->dmab = devm_kzalloc_obj(dev, struct snd_dma_buffer); > + spdifrx->dmab = snd_devm_alloc_pages(dev, SNDRV_DMA_TYPE_DEV_IRAM, > + SPDIFRX_CSR_BUF_LENGTH); > if (!spdifrx->dmab) > return -ENOMEM; > > - spdifrx->dmab->dev.type = SNDRV_DMA_TYPE_DEV_IRAM; > - spdifrx->dmab->dev.dev = dev; > - ret = snd_dma_alloc_pages(spdifrx->dmab->dev.type, dev, > - SPDIFRX_CSR_BUF_LENGTH, spdifrx->dmab); > - if (ret < 0) { > - dev_err(dev, "snd_dma_alloc_pages returned error %d\n", ret); > - return ret; > - } > - > spdifrx->slave_config.direction = DMA_DEV_TO_MEM; > spdifrx->slave_config.src_addr = (dma_addr_t)(spdifrx->phys_addr + > STM32_SPDIFRX_CSR); > @@ -919,26 +911,10 @@ static int stm32_spdifrx_parse_of(struct platform_device *pdev, > return 0; > } > > -static void stm32_spdifrx_remove(struct platform_device *pdev) > -{ > - struct stm32_spdifrx_data *spdifrx = platform_get_drvdata(pdev); > - > - if (!IS_ERR(spdifrx->ctrl_chan)) > - dma_release_channel(spdifrx->ctrl_chan); > - > - if (spdifrx->dmab) > - snd_dma_free_pages(spdifrx->dmab); > - > - snd_dmaengine_pcm_unregister(&pdev->dev); > - snd_soc_unregister_component(&pdev->dev); > - pm_runtime_disable(&pdev->dev); > -} > - > static int stm32_spdifrx_probe(struct platform_device *pdev) > { > struct stm32_spdifrx_data *spdifrx; > struct reset_control *rst; > - const struct snd_dmaengine_pcm_config *pcm_config = NULL; > u32 ver, idr; > int ret; > > @@ -978,46 +954,36 @@ static int stm32_spdifrx_probe(struct platform_device *pdev) > udelay(2); > reset_control_deassert(rst); > > - pcm_config = &stm32_spdifrx_pcm_config; > - ret = snd_dmaengine_pcm_register(&pdev->dev, pcm_config, 0); > - if (ret) > - return ret; > - > - ret = snd_soc_register_component(&pdev->dev, > - &stm32_spdifrx_component, > - stm32_spdifrx_dai, > - ARRAY_SIZE(stm32_spdifrx_dai)); > - if (ret) { > - snd_dmaengine_pcm_unregister(&pdev->dev); > - return ret; > - } > - > ret = stm32_spdifrx_dma_ctrl_register(&pdev->dev, spdifrx); > if (ret) > - goto error; > + return ret; > > ret = regmap_read(spdifrx->regmap, STM32_SPDIFRX_IDR, &idr); > if (ret) > - goto error; > + return ret; > > if (idr == SPDIFRX_IPIDR_NUMBER) { > ret = regmap_read(spdifrx->regmap, STM32_SPDIFRX_VERR, &ver); > if (ret) > - goto error; > + return ret; > > dev_dbg(&pdev->dev, "SPDIFRX version: %lu.%lu registered\n", > FIELD_GET(SPDIFRX_VERR_MAJ_MASK, ver), > FIELD_GET(SPDIFRX_VERR_MIN_MASK, ver)); > } > > - pm_runtime_enable(&pdev->dev); > + ret = devm_pm_runtime_enable(&pdev->dev); > + if (ret) > + return ret; > > - return ret; > + ret = devm_snd_dmaengine_pcm_register(&pdev->dev, &stm32_spdifrx_pcm_config, 0); > + if (ret) > + return ret; > > -error: > - stm32_spdifrx_remove(pdev); > - > - return ret; > + return devm_snd_soc_register_component(&pdev->dev, > + &stm32_spdifrx_component, > + stm32_spdifrx_dai, > + ARRAY_SIZE(stm32_spdifrx_dai)); > } > > MODULE_DEVICE_TABLE(of, stm32_spdifrx_ids); > @@ -1052,7 +1018,6 @@ static struct platform_driver stm32_spdifrx_driver = { > .pm = pm_ptr(&stm32_spdifrx_pm_ops), > }, > .probe = stm32_spdifrx_probe, > - .remove = stm32_spdifrx_remove, > }; > > module_platform_driver(stm32_spdifrx_driver); Reviewed-by: Olivier Moysan <olivier.moysan@foss.st.com> Best regards Olivier ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] ASoC: stm32: spdifrx: Use devm helpers and drop remove callback 2026-12-01 8:52 ` Olivier MOYSAN @ 2026-12-01 11:41 ` Mark Brown 0 siblings, 0 replies; 12+ messages in thread From: Mark Brown @ 2026-12-01 11:41 UTC (permalink / raw) To: Olivier MOYSAN Cc: phucduc.bui, Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Arnaud Pouliquen, Maxime Coquelin, linux-sound, linux-stm32, linux-arm-kernel, linux-kernel, Alexandre Torgue [-- Attachment #1: Type: text/plain, Size: 516 bytes --] On Tue, Dec 01, 2026 at 09:52:25AM +0100, Olivier MOYSAN wrote: > Hi, > > On 11/27/26 10:23, phucduc.bui@gmail.com wrote: > > From: bui duc phuc <phucduc.bui@gmail.com> > > > > Use devm helpers to manage the DMA channel, DMA buffer, runtime PM, > > PCM and component registration. Please delete unneeded context from mails when replying. Doing this makes it much easier to find your reply in the message, helping ensure it won't be missed by people scrolling through the irrelevant quoted material. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/3] ASoC: stm32: spdifrx: Fix refcount on sync failure 2026-11-27 9:23 [PATCH 0/3] ASoC: stm32: spdifrx: Fix resource handling and startup phucduc.bui 2026-11-27 9:23 ` [PATCH 1/3] ASoC: stm32: spdifrx: Use devm helpers and drop remove callback phucduc.bui @ 2026-11-27 9:23 ` phucduc.bui 2026-11-27 9:34 ` sashiko-bot 2026-11-30 17:18 ` Olivier MOYSAN 2026-11-27 9:23 ` [PATCH 3/3] ASoC: stm32: spdifrx: Enable clock before setting substream phucduc.bui 2 siblings, 2 replies; 12+ messages in thread From: phucduc.bui @ 2026-11-27 9:23 UTC (permalink / raw) To: Mark Brown, Olivier Moysan Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Arnaud Pouliquen, Maxime Coquelin, linux-sound, linux-stm32, linux-arm-kernel, linux-kernel, Alexandre Torgue, bui duc phuc From: bui duc phuc <phucduc.bui@gmail.com> Roll back the refcount when starting synchronization fails. Disable interrupts if no users remain. Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> --- sound/soc/stm/stm32_spdifrx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sound/soc/stm/stm32_spdifrx.c b/sound/soc/stm/stm32_spdifrx.c index 467c3c583a00..ba6c715750aa 100644 --- a/sound/soc/stm/stm32_spdifrx.c +++ b/sound/soc/stm/stm32_spdifrx.c @@ -358,9 +358,15 @@ static int stm32_spdifrx_start_sync(struct stm32_spdifrx_data *spdifrx) cr_mask |= SPDIFRX_CR_SPDIFEN_MASK; ret = regmap_update_bits(spdifrx->regmap, STM32_SPDIFRX_CR, cr_mask, cr); - if (ret < 0) + if (ret < 0) { dev_err(&spdifrx->pdev->dev, "Failed to start synchronization\n"); + spdifrx->refcount--; + if (!spdifrx->refcount) + regmap_update_bits(spdifrx->regmap, + STM32_SPDIFRX_IMR, + SPDIFRX_XIMR_MASK, 0); + } } return ret; -- 2.43.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] ASoC: stm32: spdifrx: Fix refcount on sync failure 2026-11-27 9:23 ` [PATCH 2/3] ASoC: stm32: spdifrx: Fix refcount on sync failure phucduc.bui @ 2026-11-27 9:34 ` sashiko-bot 2026-11-27 9:41 ` Bui Duc Phuc 2026-11-30 17:18 ` Olivier MOYSAN 1 sibling, 1 reply; 12+ messages in thread From: sashiko-bot @ 2026-11-27 9:34 UTC (permalink / raw) To: phucduc.bui; +Cc: linux-sound Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] ASoC: stm32: spdifrx: missing Fixes trailer for stm32_spdifrx_start_sync() fix -- commit ae61d099c35451778ed63b763187aaa9cf5f2bbb Author: bui duc phuc <phucduc.bui@gmail.com> > ASoC: stm32: spdifrx: Fix refcount on sync failure > > Roll back the refcount when starting synchronization fails. > Disable interrupts if no users remain. > > Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> [Severity: Low] This fixes the refcount and interrupt mask leak in stm32_spdifrx_start_sync() introduced by commit 03e4d5d56fa5 ("ASoC: stm32: Add SPDIFRX support"). Should this include: Fixes: 03e4d5d56fa5 ("ASoC: stm32: Add SPDIFRX support") -- Sashiko AI review · https://sashiko.dev/#/patchset/20261127092345.12383-1-phucduc.bui@gmail.com?part=2 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] ASoC: stm32: spdifrx: Fix refcount on sync failure 2026-11-27 9:34 ` sashiko-bot @ 2026-11-27 9:41 ` Bui Duc Phuc 0 siblings, 0 replies; 12+ messages in thread From: Bui Duc Phuc @ 2026-11-27 9:41 UTC (permalink / raw) To: sashiko-reviews; +Cc: linux-sound > [Severity: Low] > This fixes the refcount and interrupt mask leak in > stm32_spdifrx_start_sync() introduced by commit 03e4d5d56fa5 ("ASoC: > stm32: Add SPDIFRX support"). Should this include: > > Fixes: 03e4d5d56fa5 ("ASoC: stm32: Add SPDIFRX support") > I don't think it's particularly important for this low-severity issue, but I'm happy to add the Fixes tag if the maintainer thinks it's necessary. I've been getting quite a lot of stable backport notifications for my previous patches, so I'm trying to be a bit more selective with Fixes tags now. :) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] ASoC: stm32: spdifrx: Fix refcount on sync failure 2026-11-27 9:23 ` [PATCH 2/3] ASoC: stm32: spdifrx: Fix refcount on sync failure phucduc.bui 2026-11-27 9:34 ` sashiko-bot @ 2026-11-30 17:18 ` Olivier MOYSAN 2026-12-01 8:35 ` Bui Duc Phuc 1 sibling, 1 reply; 12+ messages in thread From: Olivier MOYSAN @ 2026-11-30 17:18 UTC (permalink / raw) To: phucduc.bui, Mark Brown Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Arnaud Pouliquen, Maxime Coquelin, linux-sound, linux-stm32, linux-arm-kernel, linux-kernel, Alexandre Torgue Hi, Thanks for your patches. On 11/27/26 10:23, phucduc.bui@gmail.com wrote: > From: bui duc phuc <phucduc.bui@gmail.com> > > Roll back the refcount when starting synchronization fails. > Disable interrupts if no users remain. > > Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> > --- > sound/soc/stm/stm32_spdifrx.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/sound/soc/stm/stm32_spdifrx.c b/sound/soc/stm/stm32_spdifrx.c > index 467c3c583a00..ba6c715750aa 100644 > --- a/sound/soc/stm/stm32_spdifrx.c > +++ b/sound/soc/stm/stm32_spdifrx.c > @@ -358,9 +358,15 @@ static int stm32_spdifrx_start_sync(struct stm32_spdifrx_data *spdifrx) > cr_mask |= SPDIFRX_CR_SPDIFEN_MASK; > ret = regmap_update_bits(spdifrx->regmap, STM32_SPDIFRX_CR, > cr_mask, cr); > - if (ret < 0) > + if (ret < 0) { > dev_err(&spdifrx->pdev->dev, > "Failed to start synchronization\n"); > + spdifrx->refcount--; > + if (!spdifrx->refcount) > + regmap_update_bits(spdifrx->regmap, > + STM32_SPDIFRX_IMR, > + SPDIFRX_XIMR_MASK, 0); > + } > } > > return ret; stm32_spdifrx_start_sync() is called in both control and data path. The patch fixes the stm32_spdifrx_get_ctrl_data() path but it seems that it can break the stm32_spdifrx_trigger path. If the trigger START fails (on SPDIFRX_CR update), ALSA calls trigger STOP and runs stm32_spdifrx_stop() a second time. The refcount goes to -1, so stm32_spdifrx_stop() returns early and the spdifrx is never disabled. An alternate could be to ensure that stm32_spdifrx_stop() is called in stm32_spdifrx_get_ctrl_data() when stm32_spdifrx_start_sync() fails. Below is the suggested change: --- a/sound/soc/stm/stm32_spdifrx.c +++ b/sound/soc/stm/stm32_spdifrx.c @@ -322,16 +322,17 @@ static int stm32_spdifrx_start_sync(struct stm32_spdifrx_data *spdifrx) { int cr, cr_mask, imr, ret; + guard(spinlock_irqsave)(&spdifrx->lock); + + /* Callers always balance refcount with stm32_spdifrx_stop(). */ + spdifrx->refcount++; + /* Enable IRQs */ imr = SPDIFRX_IMR_IFEIE | SPDIFRX_IMR_SYNCDIE | SPDIFRX_IMR_PERRIE; ret = regmap_update_bits(spdifrx->regmap, STM32_SPDIFRX_IMR, imr, imr); if (ret) return ret; - guard(spinlock_irqsave)(&spdifrx->lock); - - spdifrx->refcount++; - regmap_read(spdifrx->regmap, STM32_SPDIFRX_CR, &cr); if (!(cr & SPDIFRX_CR_SPDIFEN_MASK)) { @@ -480,7 +481,7 @@ static int stm32_spdifrx_get_ctrl_data(struct stm32_spdifrx_data *spdifrx) ret = stm32_spdifrx_start_sync(spdifrx); if (ret < 0) - goto end; + goto stop; if (wait_for_completion_interruptible_timeout(&spdifrx->cs_completion, msecs_to_jiffies(100)) @@ -489,6 +490,7 @@ static int stm32_spdifrx_get_ctrl_data(struct stm32_spdifrx_data *spdifrx) ret = -EAGAIN; } +stop: stm32_spdifrx_stop(spdifrx); stm32_spdifrx_dma_ctrl_stop(spdifrx); I realize that cleanup path needs to be at least re-ordered. I will think about another patch to fix this. Regards Olivier ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] ASoC: stm32: spdifrx: Fix refcount on sync failure 2026-11-30 17:18 ` Olivier MOYSAN @ 2026-12-01 8:35 ` Bui Duc Phuc 0 siblings, 0 replies; 12+ messages in thread From: Bui Duc Phuc @ 2026-12-01 8:35 UTC (permalink / raw) To: Olivier MOYSAN Cc: Mark Brown, Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Arnaud Pouliquen, Maxime Coquelin, linux-sound, linux-stm32, linux-arm-kernel, linux-kernel, Alexandre Torgue Hi Olivier, Thanks for the review, you're right about the trigger path. > > I realize that cleanup path needs to be at least re-ordered. > I will think about another patch to fix this. > I'll drop this patch and leave the refcount/cleanup rework to you. The other two patches will be resent as v2. Best regards, Phuc ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] ASoC: stm32: spdifrx: Enable clock before setting substream 2026-11-27 9:23 [PATCH 0/3] ASoC: stm32: spdifrx: Fix resource handling and startup phucduc.bui 2026-11-27 9:23 ` [PATCH 1/3] ASoC: stm32: spdifrx: Use devm helpers and drop remove callback phucduc.bui 2026-11-27 9:23 ` [PATCH 2/3] ASoC: stm32: spdifrx: Fix refcount on sync failure phucduc.bui @ 2026-11-27 9:23 ` phucduc.bui 2026-11-27 9:28 ` sashiko-bot 2 siblings, 1 reply; 12+ messages in thread From: phucduc.bui @ 2026-11-27 9:23 UTC (permalink / raw) To: Mark Brown, Olivier Moysan Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Arnaud Pouliquen, Maxime Coquelin, linux-sound, linux-stm32, linux-arm-kernel, linux-kernel, Alexandre Torgue, bui duc phuc From: bui duc phuc <phucduc.bui@gmail.com> Enable the clock before assigning the substream to avoid leaving a stale substream pointer if clock enabling fails. Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> --- sound/soc/stm/stm32_spdifrx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sound/soc/stm/stm32_spdifrx.c b/sound/soc/stm/stm32_spdifrx.c index ba6c715750aa..1d62a6fdc472 100644 --- a/sound/soc/stm/stm32_spdifrx.c +++ b/sound/soc/stm/stm32_spdifrx.c @@ -753,14 +753,16 @@ static int stm32_spdifrx_startup(struct snd_pcm_substream *substream, struct stm32_spdifrx_data *spdifrx = snd_soc_dai_get_drvdata(cpu_dai); int ret; + ret = clk_prepare_enable(spdifrx->kclk); + if (ret) { + dev_err(&spdifrx->pdev->dev, "Enable kclk failed: %d\n", ret); + return ret; + } + scoped_guard(spinlock_irqsave, &spdifrx->irq_lock) spdifrx->substream = substream; - ret = clk_prepare_enable(spdifrx->kclk); - if (ret) - dev_err(&spdifrx->pdev->dev, "Enable kclk failed: %d\n", ret); - - return ret; + return 0; } static int stm32_spdifrx_hw_params(struct snd_pcm_substream *substream, -- 2.43.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] ASoC: stm32: spdifrx: Enable clock before setting substream 2026-11-27 9:23 ` [PATCH 3/3] ASoC: stm32: spdifrx: Enable clock before setting substream phucduc.bui @ 2026-11-27 9:28 ` sashiko-bot 2026-11-27 9:41 ` Bui Duc Phuc 0 siblings, 1 reply; 12+ messages in thread From: sashiko-bot @ 2026-11-27 9:28 UTC (permalink / raw) To: phucduc.bui; +Cc: linux-sound Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] ASoC: stm32: spdifrx: missing Fixes trailer on bug-fix commit -- commit d1f8e52fc45d0e44e5727d051ea0cae138dd34fd Author: bui duc phuc <phucduc.bui@gmail.com> > ASoC: stm32: spdifrx: Enable clock before setting substream > > Enable the clock before assigning the substream to avoid leaving > a stale substream pointer if clock enabling fails. > > Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> [Severity: Low] This fixes a bug introduced when the driver was added. Should the commit message include a Fixes tag? Fixes: 03e4d5d56fa5 ("ASoC: stm32: Add SPDIFRX support") -- Sashiko AI review · https://sashiko.dev/#/patchset/20261127092345.12383-1-phucduc.bui@gmail.com?part=3 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] ASoC: stm32: spdifrx: Enable clock before setting substream 2026-11-27 9:28 ` sashiko-bot @ 2026-11-27 9:41 ` Bui Duc Phuc 0 siblings, 0 replies; 12+ messages in thread From: Bui Duc Phuc @ 2026-11-27 9:41 UTC (permalink / raw) To: sashiko-reviews; +Cc: linux-sound > > [Severity: Low] > This fixes a bug introduced when the driver was added. Should the commit > message include a Fixes tag? > > Fixes: 03e4d5d56fa5 ("ASoC: stm32: Add SPDIFRX support") > I don't think it's particularly important for this low-severity issue, but I'm happy to add the Fixes tag if the maintainer thinks it's necessary. I've been getting quite a lot of stable backport notifications for my previous patches, so I'm trying to be a bit more selective with Fixes tags now. :) ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-12-01 11:41 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-27 9:23 [PATCH 0/3] ASoC: stm32: spdifrx: Fix resource handling and startup phucduc.bui 2026-11-27 9:23 ` [PATCH 1/3] ASoC: stm32: spdifrx: Use devm helpers and drop remove callback phucduc.bui 2026-12-01 8:52 ` Olivier MOYSAN 2026-12-01 11:41 ` Mark Brown 2026-11-27 9:23 ` [PATCH 2/3] ASoC: stm32: spdifrx: Fix refcount on sync failure phucduc.bui 2026-11-27 9:34 ` sashiko-bot 2026-11-27 9:41 ` Bui Duc Phuc 2026-11-30 17:18 ` Olivier MOYSAN 2026-12-01 8:35 ` Bui Duc Phuc 2026-11-27 9:23 ` [PATCH 3/3] ASoC: stm32: spdifrx: Enable clock before setting substream phucduc.bui 2026-11-27 9:28 ` sashiko-bot 2026-11-27 9:41 ` Bui Duc Phuc
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.