From: sashiko-bot@kernel.org
To: phucduc.bui@gmail.com
Cc: linux-sunxi@lists.linux.dev
Subject: Re: [PATCH v3 3/3] ASoC: sunxi: sun4i-spdif: Reorder clock enable sequence
Date: Tue, 02 Jun 2026 12:15:54 +0000 [thread overview]
Message-ID: <20260602121554.861081F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260602114437.50324-4-phucduc.bui@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Unbinding the driver while an audio stream is active will cause a fatal bus fault because hardware is suspended before the ASoC component is unregistered.
--
commit 811edbc583bdf36ef4938bd44bba42ed394e19bd
Author: bui duc phuc <phucduc.bui@gmail.com>
ASoC: sunxi: sun4i-spdif: Reorder clock enable sequence
Reorder the runtime resume clock enable sequence to match the hardware
dependency and ensure symmetry with the suspend path.
The APB bus clock drives the register interface and must be enabled before
the functional module clock. This aligns the resume sequence to be the
exact reverse of the suspend sequence.
> diff --git a/sound/soc/sunxi/sun4i-spdif.c b/sound/soc/sunxi/sun4i-spdif.c
> index f54eb14c9ed86..102db1a2afbb8 100644
> --- a/sound/soc/sunxi/sun4i-spdif.c
> +++ b/sound/soc/sunxi/sun4i-spdif.c
> @@ -643,15 +643,15 @@ static int sun4i_spdif_runtime_suspend(struct device *dev)
>
> static int sun4i_spdif_runtime_resume(struct device *dev)
> {
[ ... ]
> - ret = clk_prepare_enable(host->spdif_clk);
> - if (ret)
> - return ret;
> ret = clk_prepare_enable(host->apb_clk);
> if (ret)
> - clk_disable_unprepare(host->spdif_clk);
> + return ret;
> + ret = clk_prepare_enable(host->spdif_clk);
> + if (ret)
> + clk_disable_unprepare(host->apb_clk);
>
> return ret;
> }
[Severity: High]
This isn't a bug introduced by this patch, but unbinding the driver while an
audio stream is active can cause a fatal bus fault.
Looking at sun4i_spdif_remove(), it manually disables PM and suspends the
hardware:
sun4i_spdif_remove() {
pm_runtime_disable(&pdev->dev);
if (!pm_runtime_status_suspended(&pdev->dev))
sun4i_spdif_runtime_suspend(&pdev->dev);
}
Because devres unregisters the ASoC component after sun4i_spdif_remove()
returns, the ALSA core responds to the unregistration by tearing down the
active stream. This invokes callbacks like sun4i_spdif_trigger() with
SNDRV_PCM_TRIGGER_STOP:
sun4i_spdif_trigger() {
case SNDRV_PCM_TRIGGER_STOP:
...
sun4i_snd_txctrl_off(substream, host);
break;
}
This tries to write to the device registers via regmap to disable
transmission. Since the APB bus clock was already disabled in
sun4i_spdif_remove(), accessing the registers causes a Data Abort and panics
the kernel.
Could the PM teardown be managed using devm_add_action_or_reset(), registered
immediately after pm_runtime_enable() and before component registration, to
ensure the ASoC component is fully unregistered before the clocks are turned
off?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260602114437.50324-1-phucduc.bui@gmail.com?part=3
prev parent reply other threads:[~2026-06-02 12:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 11:44 [PATCH v3 0/3] ASoC: sunxi: sun4i-spdif: Cleanup and runtime PM improvements phucduc.bui
2026-06-02 11:44 ` [PATCH v3 1/3] ASoC: sunxi: sun4i-spdif: Use guard() for spin locks phucduc.bui
2026-06-02 11:44 ` [PATCH v3 2/3] ASoC: sunxi: sun4i-spdif: Resume device before kcontrol register access phucduc.bui
2026-06-02 11:44 ` [PATCH v3 3/3] ASoC: sunxi: sun4i-spdif: Reorder clock enable sequence phucduc.bui
2026-06-02 12:15 ` sashiko-bot [this message]
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=20260602121554.861081F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=phucduc.bui@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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 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.