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 v4 14/24] ASoC: qcom: audioreach: send cached R0/T0 to the VI module in normal mode
Date: Tue, 01 Dec 2026 13:16:32 +0000 [thread overview]
Message-ID: <sashiko-outbox-243370@kernel.org> (raw)
In-Reply-To: <20261201124753.196748-15-srinivas.kandagatla@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] ASoC: qcom: audioreach: stale mode read 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 event wipes cached R0/T0
calibration
--
commit df081ac561da2f8cde68c4521af0c5c828726b29
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 calibration values from userspace or
successful VI calibration runs and sends them to the DSP via
PARAM_ID_SP_TH_VI_R0T0_CFG when configuring the VI module in normal mode.
> diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c
> index dd0b70013a0ec..19e00563c7834 100644
> --- a/sound/soc/qcom/qdsp6/audioreach.c
> +++ b/sound/soc/qcom/qdsp6/audioreach.c
[ ... ]
> @@ -1606,6 +1704,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;
> + }
[Severity: Low]
Can an event with num_ch == 0 clear the cached sp_vi_r0t0_cfg calibration?
q6apm_vi_calibration_event() permits an event payload with zero cali_param
entries and passes num_ch = 0. In that case the channel loop does not run,
decisive and success stay true, and sp_vi_r0t0_cfg.num_ch is overwritten
with 0, causing later normal-mode runs to treat R0/T0 as unconfigured and
skip sending PARAM_ID_SP_TH_VI_R0T0_CFG.
> @@ -1750,6 +1856,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 program
PARAM_ID_SP_VI_OP_MODE_CFG in the first q6apm_send_cmd_sync() call. If
sp_operation_mode changes while that blocking command is in flight (for
example via audioreach_trigger_sp_calibration() or the calibration
watchdog), this branch disagrees with the mode just configured on the DSP: a
normal-mode graph can skip sending PARAM_ID_SP_TH_VI_R0T0_CFG, or a
calibration-mode graph can receive normal-mode R0/T0 configuration.
> + 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
single-threaded apr->rxwq workqueue until the command times out?
All incoming GPR packets on apr->rx_list, including both
EVENT_ID_VI_PER_SPKR_CALIBRATION events and the GPR_BASIC_RSP_RESULT
response that wakes q6apm_send_cmd_sync(), are processed sequentially on the
single-threaded apr->rxwq workqueue:
CPU0 apr->rxwq
audioreach_speaker_protection_vi()
mutex_lock(&sp_vi_r0t0_cfg_lock)
q6apm_send_cmd_sync()
audioreach_send_cmd_sync()
apr_rxwq()
...
audioreach_vi_calibration_event()
mutex_lock(&sp_vi_r0t0_cfg_lock)
wait_event_timeout(apm->wait, ...) <-- waits 5s; response stuck on rxwq
Also, because sp_vi_r0t0_cfg.num_ch != num_speakers is checked only after
the first q6apm_send_cmd_sync() has already sent
PARAM_ID_SP_VI_OP_MODE_CFG, PARAM_ID_SP_VI_CHANNEL_MAP_CFG, and
PARAM_ID_SP_VI_EX_MODE_CFG, returning -EINVAL here still leaves the VI
module partly configured on the DSP. Validating and snapshotting
sp_vi_r0t0_cfg under sp_vi_r0t0_cfg_lock before sending the first command
would avoid both issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201124753.196748-1-srinivas.kandagatla@oss.qualcomm.com?part=14
next prev parent reply other threads:[~2026-12-01 13:16 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 12:47 [PATCH v4 00/24] ASoC: qcom: AudioReach Active speaker protection for WSA88xx Srinivas Kandagatla
2026-12-01 12:47 ` [PATCH v4 01/24] ASoC: soc-core: bump MAX_DEFAULT_CH_MAP_SIZE to 18 Srinivas Kandagatla
2026-12-01 12:47 ` [PATCH v4 02/24] ASoC: soc-pcm: add multi_direction_codecs link flag Srinivas Kandagatla
2026-12-01 12:47 ` [PATCH v4 03/24] ASoC: soc-dai: export snd_soc_dai_stream_valid Srinivas Kandagatla
2026-12-01 12:47 ` [PATCH v4 04/24] ASoC: qcom: sdw: add per-direction stream runtimes for multi_direction links Srinivas Kandagatla
2026-12-01 12:47 ` [PATCH v4 05/24] ASoC: dt-bindings: qcom,wsa8840: allow one sound DAI cell Srinivas Kandagatla
2026-12-01 12:47 ` [PATCH v4 06/24] ASoC: codecs: wsa884x: add VI sense capture DAI Srinivas Kandagatla
2026-12-01 13:03 ` sashiko-bot
2026-12-01 12:47 ` [PATCH v4 07/24] ASoC: codecs: wsa883x: " Srinivas Kandagatla
2026-12-01 13:03 ` sashiko-bot
2026-12-01 12:47 ` [PATCH v4 08/24] ASoC: codecs: wsa884x: register the die temperature as a thermal zone Srinivas Kandagatla
2026-12-01 13:13 ` sashiko-bot
2026-12-01 12:47 ` [PATCH v4 09/24] ASoC: qcom: audioreach: add control link support to graphs Srinivas Kandagatla
2026-12-01 13:09 ` sashiko-bot
2026-12-01 12:47 ` [PATCH v4 10/24] ASoC: qcom: audioreach: run VI module in calibration mode with per-speaker events Srinivas Kandagatla
2026-12-01 12:47 ` [PATCH v4 11/24] ASoC: qcom: q6apm-dai: add S32_LE format support Srinivas Kandagatla
2026-12-01 12:47 ` [PATCH v4 12/24] ASoC: qcom: audioreach: cache VI calibration results per speaker Srinivas Kandagatla
2026-12-01 13:10 ` sashiko-bot
2026-12-01 12:47 ` [PATCH v4 13/24] ASoC: qcom: audioreach: add speaker protection calibration trigger infrastructure Srinivas Kandagatla
2026-12-01 13:12 ` sashiko-bot
2026-12-01 12:47 ` [PATCH v4 14/24] ASoC: qcom: audioreach: send cached R0/T0 to the VI module in normal mode Srinivas Kandagatla
2026-12-01 13:16 ` sashiko-bot [this message]
2026-12-01 12:47 ` [PATCH v4 15/24] ASoC: qcom: audioreach: send static cfg blobs to speaker protection modules Srinivas Kandagatla
2026-12-01 13:16 ` sashiko-bot
2026-12-01 12:47 ` [PATCH v4 16/24] ASoC: qcom: audioreach: add speaker protection mixer controls Srinivas Kandagatla
2026-12-01 12:47 ` [PATCH v4 17/24] ASoC: qcom: audioreach: pin SPEAKER_PROTECTION_VI media format Srinivas Kandagatla
2026-12-01 12:47 ` [PATCH v4 18/24] ASoC: qcom: audioreach: add live speaker temperature (T0) readback Srinivas Kandagatla
2026-12-01 12:47 ` [PATCH v4 19/24] ASoC: qcom: audioreach: add speaker protection calibration state control Srinivas Kandagatla
2026-12-01 12:47 ` [PATCH v4 20/24] ASoC: qcom: x1e80100: carry WSA VI feedback on the WSA Playback BE link Srinivas Kandagatla
2026-12-01 12:47 ` [PATCH v4 21/24] ASoC: qcom: x1e80100: register WSA speaker thermal zones for speaker protection Srinivas Kandagatla
2026-12-01 12:47 ` [PATCH v4 22/24] arm64: dts: qcom: glymur-crd: add WSA speaker protection VI feedback Srinivas Kandagatla
2026-12-01 12:47 ` [PATCH v4 23/24] arm64: dts: qcom: mahua-t14s: " Srinivas Kandagatla
2026-12-01 12:47 ` [PATCH v4 24/24] arm64: dts: qcom: x1e78100-t14s: " Srinivas Kandagatla
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-243370@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