Linux Sound subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: yass27106 <yass27106@gmail.com>
Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 2/2] ASoC: qcom: lpass macro / soundwire: retry deferred clock acquisition
Date: Fri, 13 Nov 2026 13:43:25 +0000	[thread overview]
Message-ID: <sashiko-outbox-212916@kernel.org> (raw)
In-Reply-To: <90d9d32bd8d44c4f97ca3af4e1bc5481@gmail.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] ASoC: qcom: 30s sleep in clk_get_retry() stalls sequential
  probe
- [High] soundwire: qcom: unused clk_get_retry_optional() breaks -Werror
  build
- [High] ASoC: qcom: missing Signed-off-by trailer and commit message
  body
- [Low] ASoC: qcom: duplicate clk_get_retry() helpers across five
  drivers
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [High] soundwire: qcom: ignored clk_prepare_enable() return values [1]
--

commit e7d8a177bfe78eb7a13933e19bc2397f7ed88249
Author: yass27106 <yass27106@gmail.com>

> ASoC: qcom: lpass macro / soundwire: retry deferred clock acquisition
> 
> drivers/soundwire/qcom.c           | 37 +++++++++++++++++++++++-
>  sound/soc/codecs/lpass-rx-macro.c  | 45 ++++++++++++++++++++++++++----
>  sound/soc/codecs/lpass-tx-macro.c  | 45 ++++++++++++++++++++++++++----
>  sound/soc/codecs/lpass-va-macro.c  | 43 +++++++++++++++++++++++++---
>  sound/soc/codecs/lpass-wsa-macro.c | 45 ++++++++++++++++++++++++++----
>  5 files changed, 195 insertions(+), 20 deletions(-)

[Severity: High]
This commit is missing a Signed-off-by trailer and a changelog description
explaining the problem and the reason for the change; the commit body only
contains a diffstat.

> diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
> index c31d921f679f9..afb71624dae2a 100644
> --- a/drivers/soundwire/qcom.c
> +++ b/drivers/soundwire/qcom.c
> @@ -21,6 +21,41 @@
>  #include <sound/pcm_params.h>
>  #include <sound/soc.h>
>  #include "bus.h"
> +#include <linux/delay.h>
> +
> +/*
> + * Bounded retry for deferred clock providers. Clock-provider registration
> + * does not trigger deferred-probe retries, so a consumer that loses the
> + * probe-order race stays deferred forever. Wait up to 30 s for providers
> + * that are registered milliseconds later.
> + */
> +static struct clk *clk_get_retry(struct device *dev, const char *id)
> +{
> +	struct clk *c;
> +	int i;
> +
> +	for (i = 0; i < 60; i++) {
> +		c = devm_clk_get(dev, id);
> +		if (!IS_ERR(c) || PTR_ERR(c) != -EPROBE_DEFER)
> +			return c;
> +		msleep(500);
> +	}
> +	return c;
> +}

[Severity: High]
Won't sleeping for 30 seconds in clk_get_retry() and clk_get_retry_optional()
on -EPROBE_DEFER stall the same thread that needs to probe the clock
provider?

When any clock provider finishes probing, really_probe() -> driver_bound()
calls driver_deferred_probe_trigger() to schedule deferred_probe_work.
Because none of these drivers set PROBE_PREFER_ASYNCHRONOUS, both initial
probing in do_initcalls() and retries in deferred_probe_work_func() run
sequentially on a single thread.

In both link order and Device Tree node order, consumers are queued before
their suppliers: wsa_macro_probe(), rx_macro_probe(), and tx_macro_probe()
request the fsgen clock registered by va_macro_probe(), and qcom_swrm_probe()
requests the iface clock registered by the macro drivers.  Sleeping inside the
consumer's probe callback blocks the initcall or deferred_probe_work thread
from advancing to probe the supplier, guaranteeing the clock cannot appear
during the 30-second sleep while holding device_lock(dev) (and active power
domains in va_macro_probe()).

> +
> +static struct clk *clk_get_retry_optional(struct device *dev, const char *id)
> +{
> +	struct clk *c;
> +	int i;
> +
> +	for (i = 0; i < 60; i++) {
> +		c = devm_clk_get_optional(dev, id);
> +		if (!IS_ERR(c) || PTR_ERR(c) != -EPROBE_DEFER)
> +			return c;
> +		msleep(500);
> +	}
> +	return c;
> +}

[Severity: High]
Does clk_get_retry_optional() have any callers in drivers/soundwire/qcom.c?
qcom_swrm_probe() only calls clk_get_retry(), so defining
clk_get_retry_optional() here triggers a -Wunused-function warning and breaks
builds with CONFIG_WERROR=y.

> @@ -1669,7 +1704,7 @@ static int qcom_swrm_probe(struct platform_device *pdev)
>  		goto err_init;
>  	}
>  
> -	ctrl->hclk = devm_clk_get(dev, "iface");
> +	ctrl->hclk = clk_get_retry(dev, "iface");
>  	if (IS_ERR(ctrl->hclk)) {
>  		ret = dev_err_probe(dev, PTR_ERR(ctrl->hclk), "unable to get iface clock\n");
>  		goto err_init;

[Severity: High]
This problem wasn't introduced by this patch, but clk_prepare_enable() on
ctrl->hclk is called without checking its return value in qcom_swrm_probe(),
qcom_swrm_irq_handler(), and swrm_runtime_resume() [1]:

drivers/soundwire/qcom.c:qcom_swrm_irq_handler() {
	...
	clk_prepare_enable(ctrl->hclk);

	ctrl->reg_read(ctrl, ctrl->reg_layout[SWRM_REG_INTERRUPT_STATUS],
		       &intr_sts);
	...
}

If clk_prepare_enable() fails, subsequent MMIO reads and writes access
unclocked SoundWire controller registers, triggering a synchronous external
abort on Qualcomm platforms.

> diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c
> index ab8a1c2b0489b..c953054eb7a38 100644
> --- a/sound/soc/codecs/lpass-rx-macro.c
> +++ b/sound/soc/codecs/lpass-rx-macro.c
> @@ -18,6 +18,41 @@
>  #include <linux/clk-provider.h>
>  
>  #include "lpass-macro-common.h"
> +#include <linux/delay.h>
> +
> +/*
> + * Bounded retry for deferred clock providers. Clock-provider registration
> + * does not trigger deferred-probe retries, so a consumer that loses the
> + * probe-order race stays deferred forever. Wait up to 30 s for providers
> + * that are registered milliseconds later.
> + */
> +static struct clk *clk_get_retry(struct device *dev, const char *id)
> +{
> +	struct clk *c;
> +	int i;
> +
> +	for (i = 0; i < 60; i++) {
> +		c = devm_clk_get(dev, id);
> +		if (!IS_ERR(c) || PTR_ERR(c) != -EPROBE_DEFER)
> +			return c;
> +		msleep(500);
> +	}
> +	return c;
> +}
> +
> +static struct clk *clk_get_retry_optional(struct device *dev, const char *id)
> +{
> +	struct clk *c;
> +	int i;
> +
> +	for (i = 0; i < 60; i++) {
> +		c = devm_clk_get_optional(dev, id);
> +		if (!IS_ERR(c) || PTR_ERR(c) != -EPROBE_DEFER)
> +			return c;
> +		msleep(500);
> +	}
> +	return c;
> +}

[Severity: Low]
clk_get_retry() and clk_get_retry_optional() are duplicated verbatim across
drivers/soundwire/qcom.c, lpass-rx-macro.c, lpass-tx-macro.c,
lpass-va-macro.c, and lpass-wsa-macro.c, even though the four LPASS macro
drivers already share lpass-macro-common.h.

[1] https://sashiko.dev/#/bug/linux-f65cddc9-08ff-4531-9acf-76981d74d914

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/01b2c920412848ab85493acc2d4f5fc1@gmail.com?part=2

  reply	other threads:[~2026-11-13 13:43 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 13:24 [PATCH 0/2] qcom: add Asus Vivobook 16 X1607QA DT + LPASS audio clock retry yass27106
2026-11-13 13:24 ` [PATCH 1/2] arm64: dts: qcom: add device tree for Asus Vivobook 16 X1607QA yass27106
2026-11-13 13:24   ` [PATCH 2/2] ASoC: qcom: lpass macro / soundwire: retry deferred clock acquisition yass27106
2026-11-13 13:43     ` sashiko-bot [this message]
2026-11-13 15:04     ` Mark Brown
2026-11-13 13:39   ` [PATCH 1/2] arm64: dts: qcom: add device tree for Asus Vivobook 16 X1607QA sashiko-bot
2026-11-13 15:44   ` Krzysztof Kozlowski
2026-11-13 20:33     ` [PATCH 1/2] arm64: dts: qcom: add device tree for Asus Vivobook 16 X1607QA — v2 series Daniel Carter
2026-11-13 20:33       ` [PATCH v2 1/3] dt-bindings: qcom: document Asus Vivobook 16 X1607QA Daniel Carter
2026-11-13 20:33         ` [PATCH v2 2/3] arm64: dts: qcom: add device tree for " Daniel Carter
2026-11-13 20:33           ` [PATCH v2 3/3] ASoC: qcom: lpass macro / soundwire: retry deferred clock acquisition Daniel Carter
2026-11-13 20:47             ` sashiko-bot
2026-11-13 20:51           ` [PATCH v2 2/3] arm64: dts: qcom: add device tree for Asus Vivobook 16 X1607QA sashiko-bot
2026-11-13 20:39         ` [PATCH v2 1/3] dt-bindings: qcom: document " sashiko-bot
2026-11-13 21:02       ` [PATCH v2 1/3] arm64: dts: qcom: add device tree for Asus Vivobook 16 X1607QA - v3 series Daniel Carter
2026-11-13 21:02         ` [PATCH v3 1/4] dt-bindings: qcom: document Asus Vivobook 16 X1607QA Daniel Carter
2026-11-13 21:02           ` [PATCH v3 2/4] arm64: dts: qcom: add device tree for " Daniel Carter
2026-11-13 21:02             ` [PATCH v3 3/4] ASoC: qcom: lpass macro / soundwire: asynchronous probe with clock retry Daniel Carter
2026-11-13 21:02               ` [PATCH v3 4/4] soundwire: qcom: check clk_prepare_enable() return values Daniel Carter
2026-11-13 21:19                 ` sashiko-bot
2026-11-13 21:19               ` [PATCH v3 3/4] ASoC: qcom: lpass macro / soundwire: asynchronous probe with clock retry sashiko-bot
2026-11-13 21:06           ` [PATCH v3 1/4] dt-bindings: qcom: document Asus Vivobook 16 X1607QA Mark Brown
2026-11-13 21:17             ` Daniel Carter
2026-11-13 21:29               ` Mark Brown

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=sashiko-outbox-212916@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=yass27106@gmail.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