Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sarath Ganapathiraju" <sarath.ganapathiraju@oss.qualcomm.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH 2/2] ASoC: Add LPASS VA CSR heartbeat pulse clock
Date: Mon, 13 Jul 2026 20:16:24 +0000	[thread overview]
Message-ID: <20260713201624.99C8D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260714-master-v1-2-1ebe5993225e@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Uninitialized stack variable `val` is evaluated if `regmap_read()` fails in `heartbeat_pulse_is_enabled()`.
- [High] The clock enable/disable callbacks use a standard regmap and Maple Tree cache, leading to lock nesting violations and 'sleeping in atomic context' panics on PREEMPT_RT.
- [Medium] The return values of `regmap_write` and `regmap_update_bits` are silently ignored in `heartbeat_pulse_enable`.
--

--- Patch [2]: [PATCH 2/2] ASoC: Add LPASS VA CSR heartbeat pulse clock ---
commit 7fe84986850c91283daded46e6a43a50beacfb9f
Author: Sarath Ganapathiraju <sarath.ganapathiraju@oss.qualcomm.com>

ASoC: Add LPASS VA CSR heartbeat pulse clock

This commit adds the LPASS VA CSR driver to model the rate generator
as a clock provider. This enables automatic enable and disable via
the clock framework during runtime PM resume and suspend.

> diff --git a/sound/soc/codecs/lpass-va-csr.c b/sound/soc/codecs/lpass-va-csr.c
> new file mode 100644
> index 0000000000000..14aec8f941008
> --- /dev/null
> +++ b/sound/soc/codecs/lpass-va-csr.c
[ ... ]
> +static int heartbeat_pulse_enable(struct clk_hw *hw)
> +{
> +	struct lpass_va_csr *csr = to_lpass_va_csr(hw);
> +
> +	regmap_write(csr->regmap, LPASS_RATE_GEN_COUNTER_0, csr->data->counter_0);
> +	regmap_write(csr->regmap, LPASS_RATE_GEN_DELAY, csr->data->delay);
> +	regmap_update_bits(csr->regmap, LPASS_RATE_GEN_CTRL,
> +			   LPASS_RG_CTRL_EN, LPASS_RG_CTRL_EN);
> +
> +	return 0;

[Severity: Medium]
Does this function unintentionally mask hardware or cache errors? By ignoring
the return values from regmap_write() and regmap_update_bits() and
unconditionally returning 0, the clock framework might assume the clock is
enabled even if the hardware write or cache allocation failed.

> +}
[ ... ]
> +static int heartbeat_pulse_is_enabled(struct clk_hw *hw)
> +{
> +	struct lpass_va_csr *csr = to_lpass_va_csr(hw);
> +	unsigned int val;
> +
> +	regmap_read(csr->regmap, LPASS_RATE_GEN_CTRL, &val);
> +
> +	return !!(val & LPASS_RG_CTRL_EN);

[Severity: High]
Could this evaluate uninitialized memory if the regmap read fails? If
regmap_read() returns an error, the stack variable val is left untouched,
which might result in the clock framework registering an incorrect initial
hardware state.

> +}
> +
> +static const struct clk_ops heartbeat_pulse_ops = {
> +	.enable = heartbeat_pulse_enable,
> +	.disable = heartbeat_pulse_disable,
> +	.is_enabled = heartbeat_pulse_is_enabled,
> +};

[Severity: High]
Is it safe to use a standard regmap and maple tree cache in atomic clock
callbacks? The common clock framework invokes .enable, .disable, and
.is_enabled callbacks under the enable_lock raw spinlock with interrupts
disabled.

However, the regmap configuration omits use_raw_spinlock = true:

static const struct regmap_config lpass_rate_gen_regmap_config = {
	...
	.cache_type = REGCACHE_MAPLE,
};

This means the regmap operations rely on a standard spinlock. On preempt-rt
kernels, a standard spinlock is a sleepable rt_mutex, which could cause lock
nesting violations and kernel panics when acquired inside an atomic context.
Additionally, the REGCACHE_MAPLE cache type allocates memory and uses its own
standard spinlock.

Should these callbacks be moved to .prepare and .unprepare instead, which run
under a sleepable mutex context?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260714-master-v1-0-1ebe5993225e@oss.qualcomm.com?part=2

  reply	other threads:[~2026-07-13 20:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13 20:05 [PATCH 0/2] ASoC: Add LPASS VA CSR HeartBeat pulse clock support Sarath Ganapathiraju via B4 Relay
2026-07-13 20:05 ` [PATCH 1/2] ASoC: dt-bindings: qcom,lpass-va-csr: Add HeartBeat pulse clock Sarath Ganapathiraju via B4 Relay
2026-07-13 20:13   ` sashiko-bot
2026-07-13 21:22   ` Rob Herring (Arm)
2026-07-14  8:07   ` Srinivas Kandagatla
2026-07-13 20:05 ` [PATCH 2/2] ASoC: Add LPASS VA CSR heartbeat " Sarath Ganapathiraju via B4 Relay
2026-07-13 20:16   ` sashiko-bot [this message]
2026-07-14  6:53   ` Konrad Dybcio

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=20260713201624.99C8D1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sarath.ganapathiraju@oss.qualcomm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox