All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mohammad Rafi Shaik" <mohammad.rafi.shaik@oss.qualcomm.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 4/6] ASoC: qcom: lpass-rx-macro: Add shikra compatible
Date: Thu, 10 Sep 2026 09:59:58 +0000	[thread overview]
Message-ID: <20260910095959.46DD51F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260910-add_shikra_support-v2-4-fdd2129c696c@oss.qualcomm.com>

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

Pre-existing issues:
- [High] Data race on `rx_mclk_users` and MCLK enablement due to lack of synchronization across CCF and DAPM contexts.
--

commit 3459bbdd1dba9dbf895d5d3272f789b95e526f28
Author: Mohammad Rafi Shaik <mohammad.rafi.shaik@oss.qualcomm.com>

ASoC: qcom: lpass-rx-macro: Add shikra compatible

This commit adds shikra RX macro compatible data and hooks it into the
existing LPASS codec v4.1 flow. It reuses the v2.5 register access helpers
and bypasses the FS counter before enabling MCLK for codec versions 4.1
and later.

> diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c
> index 2e74ec1a52f8a..83372123c9018 100644
> --- a/sound/soc/codecs/lpass-rx-macro.c
> +++ b/sound/soc/codecs/lpass-rx-macro.c
[ ... ]
> @@ -2045,6 +2047,16 @@ static int rx_macro_mclk_enable(struct rx_macro *rx, bool mclk_enable)
>  					   CDC_RX_CLK_MCLK2_ENABLE);
>  			regmap_update_bits(regmap, CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL,
>  					   CDC_RX_FS_MCLK_CNT_CLR_MASK, 0x00);
> +
> +			/*
> +			 * From LPASS codec v4.1 onwards the FS counter has to be
> +			 * bypassed before it is enabled, otherwise the fsgen
> +			 * output does not come up.
> +			 */
> +			if (rx->codec_version >= LPASS_CODEC_VERSION_4_1)
> +				regmap_set_bits(regmap, CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL,
> +						CDC_RX_FS_CNT_BYPASS);
> +

[Severity: High]
This is a pre-existing issue, but is there a risk of a data race on
rx_mclk_users and the MCLK enablement here?

It looks like this shared state is being read and mutated without a driver
lock across different contexts. For example, an unprivileged user can trigger
DAPM events (e.g., via amixer or PCM start) which calls into this function
through rx_macro_mclk_event(). Concurrently, the Soundwire runtime PM or
clock framework can call into this via swclk_gate_enable().

If both paths invoke rx_macro_mclk_enable() simultaneously, could a
read-modify-write race on rx->rx_mclk_users occur, leading to lost increments
or decrements?

If the increments are lost, can this result in the hardware clock being
prematurely disabled while a subsystem (like the Soundwire master) still
expects it to be running? Accessing unclocked registers on Qualcomm platforms
typically triggers an XPU violation, which might lead to an unrecoverable
kernel panic.

Would it make sense to introduce a lock to protect rx_mclk_users and the
corresponding register updates in this function?

>  			regmap_update_bits(regmap, CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL,
>  					   CDC_RX_FS_MCLK_CNT_EN_MASK,
>  					   CDC_RX_FS_MCLK_CNT_ENABLE);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260910-add_shikra_support-v2-0-fdd2129c696c@oss.qualcomm.com?part=4

  reply	other threads:[~2026-09-10  9:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10  9:46 [PATCH v2 0/6] ASoC: qcom: Add shikra LPASS RX/VA macro support Mohammad Rafi Shaik
2026-09-10  9:46 ` [PATCH v2 1/6] ASoC: dt-bindings: qcom: Add Shikra RX and VA macro compatibles Mohammad Rafi Shaik
2026-09-10  9:53   ` sashiko-bot
2026-09-13  8:48   ` Krzysztof Kozlowski
2026-09-13  8:49     ` Krzysztof Kozlowski
2026-09-10  9:46 ` [PATCH v2 2/6] ASoC: qcom: lpass-macro-common: Add missing v2.9 version string Mohammad Rafi Shaik
2026-09-10  9:46 ` [PATCH v2 3/6] ASoC: qcom: lpass-macro-common: Add LPASS codec version 4.1 Mohammad Rafi Shaik
2026-09-13  8:46   ` Krzysztof Kozlowski
2026-09-10  9:46 ` [PATCH v2 4/6] ASoC: qcom: lpass-rx-macro: Add shikra compatible Mohammad Rafi Shaik
2026-09-10  9:59   ` sashiko-bot [this message]
2026-09-10  9:46 ` [PATCH v2 5/6] ASoC: qcom: lpass-va-macro: " Mohammad Rafi Shaik
2026-09-10 10:03   ` sashiko-bot
2026-09-10  9:46 ` [PATCH v2 6/6] ASoC: qcom: lpass-va-macro: Add SoundWire microphone mux support Mohammad Rafi Shaik
2026-09-10 10:00   ` 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=20260910095959.46DD51F000FF@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 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.