From: sashiko-bot@kernel.org
To: "Mohammad Rafi Shaik" <mohammad.rafi.shaik@oss.qualcomm.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v4 2/3] ASoC: qcom: q6apm-lpass-dais: Add MI2S clock control
Date: Sat, 11 Jul 2026 13:09:01 +0000 [thread overview]
Message-ID: <20260711130901.BA95A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260711125740.3083236-3-mohammad.rafi.shaik@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Premature destruction of clocks due to inverted devm teardown order causes hardware lockups.
- [Medium] Passing an error pointer to clk_put() during probe deferral triggers a kernel warning.
--
--- Patch [2]: [PATCH v4 2/3] ASoC: qcom: q6apm-lpass-dais: Add MI2S clock control ---
commit 6c55573f944d5c7be58034df873c5691188ba0f2
Author: Mohammad Rafi Shaik <mohammad.rafi.shaik@oss.qualcomm.com>
ASoC: qcom: q6apm-lpass-dais: Add MI2S clock control
This commit adds MI2S clock control within q6apm-lpass DAIs, including
handling of MCLK, BCLK, and ECLK via the DAI .set_sysclk callback.
Each MI2S port now retrieves its clock handles from the device tree,
allowing per-port clock configuration and proper enable/disable during
startup and shutdown.
> diff --git a/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c b/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c
> index 006b283484d9e..5743586ffda1e 100644
> --- a/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c
> +++ b/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c
[ ... ]
> @@ -297,6 +409,65 @@ static const struct snd_soc_component_driver q6apm_lpass_dai_component = {
> .remove_order = SND_SOC_COMP_ORDER_FIRST,
> };
>
> +static int of_q6apm_parse_dai_data(struct device *dev,
> + struct q6apm_lpass_dai_data *data)
> +{
> + int ret;
> +
> + for_each_child_of_node_scoped(dev->of_node, node) {
> + struct q6apm_dai_priv_data *priv;
> + int id;
> +
> + ret = of_property_read_u32(node, "reg", &id);
> + if (ret || id < 0 || id >= APM_PORT_MAX) {
> + dev_err(dev, "valid dai id not found:%d\n", ret);
> + continue;
> + }
> +
> + switch (id) {
> + /* MI2S specific properties */
> + case PRIMARY_MI2S_RX ... QUATERNARY_MI2S_TX:
> + case QUINARY_MI2S_RX ... QUINARY_MI2S_TX:
> + case SENARY_MI2S_RX ... SENARY_MI2S_TX:
> + priv = &data->priv[id];
> + priv->mclk = of_clk_get_by_name(node, "mclk");
> + if (IS_ERR(priv->mclk)) {
> + if (PTR_ERR(priv->mclk) == -EPROBE_DEFER) {
> + q6apm_lpass_dai_put_clocks(data);
[Severity: Medium]
Will this pass an error pointer to clk_put() during probe deferral?
If of_clk_get_by_name() returns -EPROBE_DEFER, the error pointer is stored
in priv->mclk. When q6apm_lpass_dai_put_clocks() is immediately called for
cleanup, it iterates over all ports and calls clk_put() on any non-NULL
clock pointer:
q6apm_lpass_dai_put_clocks() {
...
if (dai_data->priv[i].mclk) {
clk_put(dai_data->priv[i].mclk);
...
}
Since an ERR_PTR evaluates as true, clk_put() is called with the error
pointer, which will trigger a WARN_ON_ONCE(IS_ERR(clk)) in the core clock
code.
> + return dev_err_probe(dev, PTR_ERR(priv->mclk),
> + "unable to get mi2s mclk\n");
> + }
> + priv->mclk = NULL;
> + }
[ ... ]
> @@ -317,7 +492,18 @@ static int q6apm_lpass_dai_dev_probe(struct platform_device *pdev)
> cfg.q6hdmi_ops = &q6hdmi_ops;
> dais = q6dsp_audio_ports_set_config(dev, &cfg, &num_dais);
>
> - return devm_snd_soc_register_component(dev, &q6apm_lpass_dai_component, dais, num_dais);
> + ret = devm_snd_soc_register_component(dev, &q6apm_lpass_dai_component, dais, num_dais);
> + if (ret)
> + q6apm_lpass_dai_put_clocks(dai_data);
> +
> + return ret;
> +}
> +
> +static void q6apm_lpass_dai_dev_remove(struct platform_device *pdev)
> +{
> + struct q6apm_lpass_dai_data *dai_data = dev_get_drvdata(&pdev->dev);
> +
> + q6apm_lpass_dai_put_clocks(dai_data);
[Severity: High]
Does this premature destruction of clocks due to an inverted devm teardown
order cause hardware lockups?
Because the ALSA component is registered using
devm_snd_soc_register_component(), its unregistration is deferred to the
devres cleanup phase, which runs after this .remove() callback returns.
If the driver is unbound while audio is actively streaming, .remove()
manually invokes q6apm_lpass_dai_put_clocks(), which turns off and frees
the MI2S clocks while the DSP is actively executing a graph on the bus.
The ALSA component attempts to cleanly stop the DSP graph only during
devres cleanup, but by then the physical clocks are already cut, which
can lead to DSP crashes or NOC (Network-on-Chip) errors.
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260711125740.3083236-1-mohammad.rafi.shaik@oss.qualcomm.com?part=2
next prev parent reply other threads:[~2026-07-11 13:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-11 12:57 [PATCH v4 0/3] ASoC: qcom: qdsp6: Add MI2S clock control Mohammad Rafi Shaik
2026-07-11 12:57 ` [PATCH v4 1/3] ASoC: dt-bindings: qcom,q6apm-lpass-dais: Document DAI subnode Mohammad Rafi Shaik
2026-07-11 13:04 ` sashiko-bot
2026-07-11 15:11 ` Krzysztof Kozlowski
2026-07-12 6:44 ` Mohammad Rafi Shaik
2026-07-12 8:11 ` Krzysztof Kozlowski
2026-07-12 8:45 ` Mohammad Rafi Shaik
2026-07-11 12:57 ` [PATCH v4 2/3] ASoC: qcom: q6apm-lpass-dais: Add MI2S clock control Mohammad Rafi Shaik
2026-07-11 13:09 ` sashiko-bot [this message]
2026-07-11 12:57 ` [PATCH v4 3/3] ASoC: qcom: sc8280xp: enhance machine driver for board-specific config Mohammad Rafi Shaik
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=20260711130901.BA95A1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=mohammad.rafi.shaik@oss.qualcomm.com \
--cc=robh@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox