From: sashiko-bot@kernel.org
To: "Srinivas Kandagatla" <srinivas.kandagatla@oss.qualcomm.com>
Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 14/24] ASoC: qcom: audioreach: send cached R0/T0 to the VI module in normal mode
Date: Mon, 30 Nov 2026 21:36:32 +0000 [thread overview]
Message-ID: <sashiko-outbox-242011@kernel.org> (raw)
In-Reply-To: <20261130212258.7376-15-srinivas.kandagatla@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] ASoC: qcom: audioreach: inconsistent mode check in
audioreach_speaker_protection_vi()
- [Medium] ASoC: qcom: audioreach: sp_vi_r0t0_cfg_lock held across
q6apm_send_cmd_sync()
- [Low] ASoC: qcom: audioreach: zero-channel VI event wipes cached R0/T0
in audioreach_vi_calibration_event()
--
commit b2b7f0ee63ba7619972f12d82d084b408eebb459
Author: Ravi Hothi <ravi.hothi@oss.qualcomm.com>
ASoC: qcom: audioreach: send cached R0/T0 to the VI module in normal mode
This commit caches per-speaker R0/T0 values from userspace or successful VI
calibration runs and sends them via PARAM_ID_SP_TH_VI_R0T0_CFG when
configuring the VI module in normal operation mode.
> diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c
> index 130298a287496..0701006278094 100644
> --- a/sound/soc/qcom/qdsp6/audioreach.c
> +++ b/sound/soc/qcom/qdsp6/audioreach.c
[ ... ]
> @@ -1632,6 +1730,14 @@ void audioreach_vi_calibration_event(struct device *dev,
> i, r0_int, r0_frac, sp_vi_r0.r0_cali_q24[i]);
> }
>
> + /* Only a run where every speaker succeeded gives a usable R0/T0 set */
> + if (success) {
> + guard(mutex)(&sp_vi_r0t0_cfg_lock);
> + sp_vi_r0t0_cfg.num_ch = num_ch;
> + for (i = 0; i < num_ch; i++)
> + sp_vi_r0t0_cfg.r0_cali_q24[i] = cali->cali_param[i].r0_cali_q24;
> + }
> +
> dev_info(dev, "VI calibration complete: %s\n", success ? "success" : "failed");
>
> /* Edge-triggered: the mode auto-returns to Normal on terminal state. */
[Severity: Low]
Can a zero-channel calibration event wipe out a valid cached
sp_vi_r0t0_cfg?
q6apm_vi_calibration_event() allows payloads with zero cali_param entries
or cali->num_ch == 0 and passes num_ch == 0 to
audioreach_vi_calibration_event():
sound/soc/qcom/qdsp6/q6apm.c:q6apm_vi_calibration_event() {
...
num_ch = (payload_size - sizeof(*event) - sizeof(*cali)) / sizeof(cali->cali_param[0]);
num_ch = min_t(u32, cali->num_ch, num_ch);
num_ch = min_t(u32, num_ch, MAX_SP_VI_SPEAKERS);
audioreach_vi_calibration_event(dev, cali, num_ch);
}
When num_ch is 0, the per-channel loop does not run, leaving both decisive
and success true. That overwrites sp_vi_r0t0_cfg.num_ch with 0, causing
later normal-mode setups to treat R0/T0 as unconfigured and silently skip
sending PARAM_ID_SP_TH_VI_R0T0_CFG.
> @@ -1776,6 +1882,70 @@ static int audioreach_speaker_protection_vi(struct q6apm_graph *graph,
>
> kfree(pkt);
>
> + if (rc)
> + return rc;
> +
> + if (sp_operation_mode == PARAM_ID_SP_VI_OP_MODE_NORMAL) {
[Severity: Medium]
Should this check the local mode variable rather than re-reading
sp_operation_mode?
audioreach_speaker_protection_vi() snapshots mode =
READ_ONCE(sp_operation_mode) at entry and uses it to configure
PARAM_ID_SP_VI_OP_MODE_CFG before blocking in q6apm_send_cmd_sync(). If
audioreach_trigger_sp_calibration() or the calibration watchdog changes
sp_operation_mode while that first IPC is in flight, this second check acts
on a different mode than the one just programmed into the DSP VI module,
either skipping PARAM_ID_SP_TH_VI_R0T0_CFG for a module configured in
normal mode or sending normal-mode R0/T0 to a module configured for
calibration.
> + struct apm_module_sp_th_vi_r0t0_cfg *r0t0_cfg;
> + int r0t0_sz;
> +
> + guard(mutex)(&sp_vi_r0t0_cfg_lock);
> +
> + if (!sp_vi_r0t0_cfg.num_ch)
> + return 0;
> +
> + if (sp_vi_r0t0_cfg.num_ch != num_speakers) {
> + dev_err(graph->dev,
> + "SP R0T0 is for %u speakers, graph has %u\n",
> + sp_vi_r0t0_cfg.num_ch, num_speakers);
> + return -EINVAL;
> + }
> +
> + r0t0_sz = APM_SP_TH_VI_R0T0_CFG_PSIZE(sp_vi_r0t0_cfg.num_ch);
> + pkt = audioreach_alloc_apm_cmd_pkt(r0t0_sz, APM_CMD_SET_CFG, 0);
> + if (IS_ERR(pkt))
> + return PTR_ERR(pkt);
> +
> + p = (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE;
> +
> + r0t0_cfg = p;
> + param_data = &r0t0_cfg->param_data;
> + param_data->module_instance_id = module->instance_id;
> + param_data->error_code = 0;
> + param_data->param_id = PARAM_ID_SP_TH_VI_R0T0_CFG;
> + param_data->param_size = r0t0_sz - APM_MODULE_PARAM_DATA_SIZE;
> +
> + r0t0_cfg->cfg.num_ch = sp_vi_r0t0_cfg.num_ch;
> + for (i = 0; i < sp_vi_r0t0_cfg.num_ch; i++) {
> + r0t0_cfg->cfg.r0t0_cfg[i].r0_cali_q24 = sp_vi_r0t0_cfg.r0_cali_q24[i];
> + r0t0_cfg->cfg.r0t0_cfg[i].t0_cali_q6 = sp_vi_r0t0_cfg.t0_cali_q6[i];
> + r0t0_cfg->cfg.r0t0_cfg[i].reserved = 0;
> + }
> +
> + rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
[Severity: Medium]
Can holding sp_vi_r0t0_cfg_lock across q6apm_send_cmd_sync() stall the APR
RX workqueue until the command times out?
All incoming GPR packets on apr->rx_list are dispatched sequentially by a
single work item on apr->rxwq, including both EVENT_ID_VI_PER_SPKR_CALIBRATION
events and the command response that wakes q6apm_send_cmd_sync():
CPU0 kworker (apr->rxwq)
audioreach_speaker_protection_vi()
mutex_lock(&sp_vi_r0t0_cfg_lock)
q6apm_send_cmd_sync()
wait_event_timeout(apm->wait, ...)
apr_rxwq()
...
audioreach_vi_calibration_event()
mutex_lock(&sp_vi_r0t0_cfg_lock)
<-- blocks apr->rxwq; cannot
deliver apm->wait response
If a decisive calibration event arrives ahead of the APM_CMD_SET_CFG
response (for example, if the calibration watchdog resets sp_operation_mode
to normal while a calibration run is finishing), apr->rxwq blocks on
sp_vi_r0t0_cfg_lock and q6apm_send_cmd_sync() fails with -ETIMEDOUT after 5
seconds. Snapshotting sp_vi_r0t0_cfg into a local copy under
sp_vi_r0t0_cfg_lock before sending the packet avoids holding the mutex
across the IPC.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130212258.7376-1-srinivas.kandagatla@oss.qualcomm.com?part=14
next prev parent reply other threads:[~2026-11-30 21:36 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 21:22 [PATCH v3 00/24] ASoC: qcom: AudioReach Active speaker protection for WSA88xx Srinivas Kandagatla
2026-11-30 21:22 ` [PATCH v3 01/24] ASoC: soc-core: bump MAX_DEFAULT_CH_MAP_SIZE to 18 Srinivas Kandagatla
2026-11-30 21:22 ` [PATCH v3 02/24] ASoC: soc-pcm: add multi_direction_codecs link flag Srinivas Kandagatla
2026-11-30 21:22 ` [PATCH v3 03/24] ASoC: soc-dai: export snd_soc_dai_stream_valid Srinivas Kandagatla
2026-11-30 21:22 ` [PATCH v3 04/24] ASoC: qcom: sdw: add per-direction stream runtimes for multi_direction links Srinivas Kandagatla
2026-11-30 21:22 ` [PATCH v3 05/24] ASoC: dt-bindings: qcom,wsa8840: allow one sound DAI cell Srinivas Kandagatla
2026-11-30 21:22 ` [PATCH v3 06/24] ASoC: codecs: wsa884x: add VI sense capture DAI Srinivas Kandagatla
2026-11-30 21:36 ` sashiko-bot
2026-11-30 21:22 ` [PATCH v3 07/24] ASoC: codecs: wsa883x: " Srinivas Kandagatla
2026-11-30 21:36 ` sashiko-bot
2026-11-30 21:22 ` [PATCH v3 08/24] ASoC: codecs: wsa884x: register the die temperature as a thermal zone Srinivas Kandagatla
2026-11-30 21:39 ` sashiko-bot
2026-11-30 21:22 ` [PATCH v3 09/24] ASoC: qcom: audioreach: add control link support to graphs Srinivas Kandagatla
2026-11-30 21:41 ` sashiko-bot
2026-11-30 21:22 ` [PATCH v3 10/24] ASoC: qcom: audioreach: run VI module in calibration mode with per-speaker events Srinivas Kandagatla
2026-11-30 21:22 ` [PATCH v3 11/24] ASoC: qcom: q6apm-dai: add S32_LE format support Srinivas Kandagatla
2026-11-30 21:22 ` [PATCH v3 12/24] ASoC: qcom: audioreach: cache VI calibration results per speaker Srinivas Kandagatla
2026-11-30 21:31 ` sashiko-bot
2026-11-30 21:22 ` [PATCH v3 13/24] ASoC: qcom: audioreach: add speaker protection calibration trigger infrastructure Srinivas Kandagatla
2026-11-30 21:34 ` sashiko-bot
2026-11-30 21:22 ` [PATCH v3 14/24] ASoC: qcom: audioreach: send cached R0/T0 to the VI module in normal mode Srinivas Kandagatla
2026-11-30 21:36 ` sashiko-bot [this message]
2026-11-30 21:22 ` [PATCH v3 15/24] ASoC: qcom: audioreach: send static cfg blobs to speaker protection modules Srinivas Kandagatla
2026-11-30 21:41 ` sashiko-bot
2026-11-30 21:22 ` [PATCH v3 16/24] ASoC: qcom: audioreach: add speaker protection mixer controls Srinivas Kandagatla
2026-11-30 21:22 ` [PATCH v3 17/24] ASoC: qcom: audioreach: pin SPEAKER_PROTECTION_VI media format Srinivas Kandagatla
2026-11-30 21:22 ` [PATCH v3 18/24] ASoC: qcom: audioreach: add live speaker temperature (T0) readback Srinivas Kandagatla
2026-11-30 21:39 ` sashiko-bot
2026-11-30 21:22 ` [PATCH v3 19/24] ASoC: qcom: audioreach: add speaker protection calibration state control Srinivas Kandagatla
2026-11-30 21:47 ` sashiko-bot
2026-11-30 21:22 ` [PATCH v3 20/24] ASoC: qcom: x1e80100: carry WSA VI feedback on the WSA Playback BE link Srinivas Kandagatla
2026-11-30 21:22 ` [PATCH v3 21/24] ASoC: qcom: x1e80100: register WSA speaker thermal zones for speaker protection Srinivas Kandagatla
2026-11-30 21:41 ` sashiko-bot
2026-11-30 21:22 ` [PATCH v3 22/24] arm64: dts: qcom: glymur-crd: add WSA speaker protection VI feedback Srinivas Kandagatla
2026-11-30 21:43 ` sashiko-bot
2026-11-30 21:22 ` [PATCH v3 23/24] arm64: dts: qcom: mahua-t14s: " Srinivas Kandagatla
2026-11-30 21:43 ` sashiko-bot
2026-11-30 21:22 ` [PATCH v3 24/24] arm64: dts: qcom: x1e78100-t14s: " Srinivas Kandagatla
2026-11-30 21:45 ` 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=sashiko-outbox-242011@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=srinivas.kandagatla@oss.qualcomm.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