Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: phucduc.bui@gmail.com
Cc: devicetree@vger.kernel.org, wsa+renesas@sang-engineering.com,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v4 08/10] ASoC: renesas: fsi: refactor clock initialization
Date: Fri, 05 Jun 2026 14:04:12 +0000	[thread overview]
Message-ID: <20260605140412.CB2A81F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260605121955.105661-9-phucduc.bui@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [High] Missing cleanup for previously allocated FSIA DMA channels if FSIB clock initialization fails in probe.

Pre-existing issues:
- [High] The DAI trigger callback executes sleeping clock operations while holding a PCM spinlock.
--

commit 7a2af4d59dffa88627e517f84d651b199bf13ef8
Author: bui duc phuc <phucduc.bui@gmail.com>

ASoC: renesas: fsi: refactor clock initialization

This commit moves the fsi_clk_init() function call from fsi_dai_set_fmt()
into the fsi_probe() path. It aims to ensure that clock resources are
validated early during the driver probe rather than deferring the lookup
to hardware configuration.

> diff --git a/sound/soc/renesas/fsi.c b/sound/soc/renesas/fsi.c
> index a2d7d17dd2bb0..3f303e15e8351 100644
> --- a/sound/soc/renesas/fsi.c
> +++ b/sound/soc/renesas/fsi.c

[ ... ]

> @@ -898,6 +904,11 @@ static int fsi_clk_set_rate_cpg(struct device *dev,
>  	int ackmd, bpfmd;
>  	int ret = -EINVAL;
>  
> +	if (!ick || !div) {
> +		dev_err(dev, "ick clock or div clock is missing\n");
> +		return -EINVAL;
> +	}
> +

[Severity: High]
This isn't a bug introduced by this patch, but does this clock initialization
path ultimately lead to sleeping while atomic?

The ASoC framework invokes fsi_dai_trigger() in an atomic context with the
PCM stream spinlock held and IRQs disabled. For the start command, the call
chain executes:

fsi_dai_trigger()
  fsi_hw_startup()
    fsi_clk_enable()
      fsi_clk_set_rate_cpg()
        clk_set_rate()

clk_set_rate() attempts to acquire the global prepare_lock mutex in the common
clock framework, which will trigger a scheduling-while-atomic panic when
called from the atomic trigger path.

[ ... ]

> @@ -1985,6 +2000,9 @@ static int fsi_probe(struct platform_device *pdev)
>  	fsi->master	= master;
>  	fsi_port_info_init(fsi, &info.port_b);
>  	fsi_handler_init(fsi, &info.port_b);
> +	ret = fsi_clk_init(&pdev->dev, fsi);
> +	if (ret)
> +		return ret;
>  	ret = fsi_stream_probe(fsi, &pdev->dev);
>  	if (ret < 0) {
>  		dev_err(&pdev->dev, "FSIB stream probe failed\n");

[Severity: High]
If this fails, does the direct return bypass the cleanup for FSIA?

Earlier in fsi_probe(), FSIA is probed and successfully allocates
non-devres managed DMA channels. If fsi_clk_init() subsequently fails for
FSIB (for example, returning -EPROBE_DEFER for an unavailable clock), the
error path directly returns instead of executing the cleanup routine.

Would this lead to a permanent leak of the DMA channels and other stream
resources allocated for FSIA? Might a goto statement targeting the exit_fsia
label be needed here so that fsi_stream_remove() can safely clean up?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260605121955.105661-1-phucduc.bui@gmail.com?part=8

  reply	other threads:[~2026-06-05 14:04 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-05 12:19 [PATCH v4 00/10] ASoC: renesas: fsi: Fix system hang by adding SPU clock phucduc.bui
2026-06-05 12:19 ` [PATCH v4 01/10] ASoC: dt-bindings: renesas,fsi: add support multiple clocks phucduc.bui
2026-06-05 12:30   ` sashiko-bot
2026-06-05 12:19 ` [PATCH v4 02/10] ARM: dts: renesas: r8a7740: Add clocks for FSI phucduc.bui
2026-06-05 12:19 ` [PATCH v4 03/10] ASoC: renesas: fsi: Fix trigger stop ordering phucduc.bui
2026-06-05 12:52   ` sashiko-bot
2026-06-05 12:19 ` [PATCH v4 04/10] ASoC: renesas: fsi: Move fsi_stream_is_working() phucduc.bui
2026-06-05 13:04   ` sashiko-bot
2026-06-05 12:19 ` [PATCH v4 05/10] ASoC: renesas: fsi: Fix register access from in-flight IRQ after shutdown phucduc.bui
2026-06-05 13:20   ` sashiko-bot
2026-06-05 12:19 ` [PATCH v4 06/10] ASoC: renesas: fsi: Move fsi_clk_init() phucduc.bui
2026-06-05 13:32   ` sashiko-bot
2026-06-05 12:19 ` [PATCH v4 07/10] ASoC: renesas: fsi: Use devm_clk_get_optional() for optional clocks phucduc.bui
2026-06-05 12:19 ` [PATCH v4 08/10] ASoC: renesas: fsi: refactor clock initialization phucduc.bui
2026-06-05 14:04   ` sashiko-bot [this message]
2026-06-05 12:19 ` [PATCH v4 09/10] ASoC: renesas: fsi: add fsi_clk_prepare/unprepare() phucduc.bui
2026-06-05 14:21   ` sashiko-bot
2026-06-05 12:19 ` [PATCH v4 10/10] ASoC: renesas: fsi: Add SPU clock control in hw_startup/shutdown phucduc.bui
2026-06-05 14:21   ` Mark Brown
2026-06-05 22:29     ` Bui Duc Phuc
2026-06-05 14:32   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260605140412.CB2A81F00898@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=phucduc.bui@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wsa+renesas@sang-engineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox