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 v2 19/24] ASoC: qcom: audioreach: add speaker protection calibration state control
Date: Sun, 22 Nov 2026 16:37:40 +0000 [thread overview]
Message-ID: <sashiko-outbox-228110@kernel.org> (raw)
In-Reply-To: <20261122161437.5994-20-srinivas.kandagatla@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [Medium] ASoC: qcom: audioreach: early return in
audioreach_vi_calibration_abort()
- [Medium] ASoC: qcom: audioreach: uncanceled sp_cal_watchdog work on
module removal
- [Medium] ASoC: qcom: audioreach: unsynchronized sp_operation_mode
reads across sleep
- [Low] ASoC: qcom: audioreach: commit message omits calibrate control
and abort logic
- [Low] ASoC: qcom: mode reset before cancel in
audioreach_sp_finish_calibration()
--
commit e3b1c2c58754c22248379e200349ec50156d0cf4
Author: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
> ASoC: qcom: audioreach: add speaker protection calibration state control
>
> Add a read-only "Speaker Protection Calibration State" control with
> each speaker's last calibration state, so userspace can follow a run.
>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
[Severity: Low]
This isn't a bug, but the commit title and message only mention adding the
read-only "Speaker Protection Calibration State" control. Should the
changelog also describe the "Speaker Protection Calibrate" trigger control
and the VI calibration abort handling on graph stop and close added in
this patch?
> diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c
> index 2bb56933b9de4..f1e454062ece3 100644
> --- a/sound/soc/qcom/qdsp6/audioreach.c
> +++ b/sound/soc/qcom/qdsp6/audioreach.c
[ ... ]
> @@ -1805,6 +1825,46 @@ void audioreach_vi_calibration_event(struct device *dev,
> audioreach_sp_finish_calibration();
> }
>
> +/* A run cut short never reports a final state, close it out */
> +void audioreach_vi_calibration_abort(struct device *dev)
> +{
> + unsigned int i;
> +
> + guard(mutex)(&sp_vi_r0_lock);
> +
> + if (!sp_vi_r0.armed)
> + return;
> +
> + sp_vi_r0.armed = false;
> +
> + /* The DSP never reported on this run: keep the previous result */
> + if (!memchr_inv(sp_vi_r0.seen_states, 0, sizeof(sp_vi_r0.seen_states)))
> + return;
[Severity: Medium]
Does returning here skip audioreach_sp_finish_calibration() when a run is
aborted before the DSP sends any event?
When a graph is closed without ever starting (as noted in
q6apm_graph_close()) or stopped before the first calibration event
arrives, sp_vi_r0.seen_states is still all zeros. Returning early leaves
sp_operation_mode stuck in PARAM_ID_SP_VI_OP_MODE_CALIBRATION and
sp_cal_watchdog pending for 60 seconds, so retries of "Speaker Protection
Calibrate" fail with -EBUSY and any normal playback started during that
window configures the DSP in Calibration mode instead of Normal mode.
> +
> + sp_vi_r0.state = SP_VI_CALI_ABORTED;
> +
> + for (i = 0; i < MAX_SP_VI_SPEAKERS; i++) {
> + u32 state = sp_vi_r0.last_state[i];
> +
> + /* Slot never reported: not part of this run */
> + if (!sp_vi_r0.seen_states[i])
> + continue;
> +
> + if (sp_vi_cali_state_is_terminal(state))
> + continue;
> +
> + dev_info(dev, "VI calibration channel %u: aborted while %s\n",
> + i, sp_vi_cali_state_name(state));
> + sp_vi_r0.last_state[i] = VI_CALIBRATION_STATE_INACTIVE;
> + }
> +
> + dev_info(dev, "VI calibration aborted: graph stopped before the DSP finished\n");
> +
> + /* Edge-triggered: the mode auto-returns to Normal on abort too. */
> + audioreach_sp_finish_calibration();
> +}
> +EXPORT_SYMBOL_GPL(audioreach_vi_calibration_abort);
[Severity: Low]
Can audioreach_sp_finish_calibration() cancel a newly scheduled watchdog
if userspace triggers another calibration run concurrently?
sound/soc/qcom/qdsp6/audioreach.c:audioreach_sp_finish_calibration() {
WRITE_ONCE(sp_operation_mode, PARAM_ID_SP_VI_OP_MODE_NORMAL);
cancel_delayed_work(&sp_cal_watchdog);
}
CPU0 CPU1
audioreach_sp_finish_calibration()
WRITE_ONCE(sp_operation_mode,
..._NORMAL)
audioreach_put_sp_calibrate()
audioreach_trigger_sp_calibration()
cmpxchg(&sp_operation_mode, ...)
schedule_delayed_work(&sp_cal_watchdog, ...)
cancel_delayed_work(&sp_cal_watchdog) <-- cancels new run's watchdog
Also, because cancel_delayed_work() is non-synchronous, an already running
audioreach_sp_cal_watchdog_fn() from the finishing run can execute its
cmpxchg() after CPU1 re-arms calibration and reset sp_operation_mode back
to Normal. Calling cancel_delayed_work_sync(&sp_cal_watchdog) before
resetting sp_operation_mode avoids both races.
> diff --git a/sound/soc/qcom/qdsp6/topology.c b/sound/soc/qcom/qdsp6/topology.c
> index 0e28c68c735d2..a19efbb889a8e 100644
> --- a/sound/soc/qcom/qdsp6/topology.c
> +++ b/sound/soc/qcom/qdsp6/topology.c
> @@ -1548,6 +1548,45 @@ static int audioreach_get_sp_t0(struct snd_kcontrol *kcontrol,
[ ... ]
> +static int audioreach_put_sp_calibrate(struct snd_kcontrol *kcontrol,
> + struct snd_ctl_elem_value *ucontrol)
> +{
> + if (!ucontrol->value.integer.value[0])
> + return 0;
> +
> + return audioreach_trigger_sp_calibration() ? : 1;
> +}
[Severity: Medium]
Can sp_cal_watchdog fire after snd-q6apm is unloaded?
audioreach_put_sp_calibrate() exposes audioreach_trigger_sp_calibration()
to userspace, which schedules the static 60-second sp_cal_watchdog delayed
work. Neither apm_remove() nor q6apm_audio_remove() cancels
sp_cal_watchdog with cancel_delayed_work_sync(), so unbinding the driver
and unloading snd-q6apm while the watchdog is pending leaves the timer
queued in unmapped module memory and causes a use-after-free crash when it
fires.
> +
> static const struct snd_kcontrol_new audioreach_sp_telemetry_controls[] = {
[ ... ]
> + {
> + /*
> + * Write-only edge trigger. Writing 1 arms a calibration run
> + * for the next (or current) WSA playback graph; the mode
> + * returns to Normal on its own once the DSP reports terminal
> + * state, on graph abort, or on the watchdog timeout.
> + */
> + .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> + .name = "Speaker Protection Calibrate",
> + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
> + SNDRV_CTL_ELEM_ACCESS_VOLATILE,
> + .info = audioreach_info_sp_calibrate,
> + .get = audioreach_get_sp_calibrate,
> + .put = audioreach_put_sp_calibrate,
> + },
> };
[Severity: Medium]
Can concurrent changes to sp_operation_mode while a graph is being
prepared send an inconsistent configuration to the DSP?
With "Speaker Protection Calibrate" and audioreach_vi_calibration_abort()
now able to flip sp_operation_mode at runtime without serialization
against q6apm_graph_media_format_pcm(), sp_operation_mode can change while
GPR commands sleep:
sound/soc/qcom/qdsp6/audioreach.c:audioreach_speaker_protection_vi() {
u32 mode = READ_ONCE(sp_operation_mode);
...
op_cfg->cfg.operation_mode = mode;
...
rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
...
if (sp_operation_mode == PARAM_ID_SP_VI_OP_MODE_NORMAL) {
audioreach_speaker_protection_vi() snapshots sp_operation_mode into mode
for event registration and PARAM_ID_SP_VI_OP_MODE_CFG, but re-reads the
global sp_operation_mode after q6apm_send_cmd_sync() sleeps when deciding
whether to send PARAM_ID_SP_TH_VI_R0T0_CFG. In addition,
audioreach_speaker_protection() and audioreach_speaker_protection_vi()
each read sp_operation_mode separately across sleeping GPR calls during
the same graph preparation, so a mode transition in between configures one
module in Normal mode and the other in Calibration mode.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261122161437.5994-1-srinivas.kandagatla@oss.qualcomm.com?part=19
next prev parent reply other threads:[~2026-11-22 16:37 UTC|newest]
Thread overview: 82+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 17:14 [RFC PATCH 00/23] ASoC: qcom: AudioReach Active speaker protection for WSA884x Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 01/23] ASoC: soc-core: allow default ch_maps on links with more than 8 DAIs Srinivas Kandagatla
2026-11-15 17:36 ` Mark Brown
2026-11-15 21:04 ` Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 02/23] ASoC: soc-pcm: add multi_direction_codecs link flag Srinivas Kandagatla
2026-11-15 17:36 ` Mark Brown
2026-11-15 21:04 ` Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 03/23] ASoC: qcom: sdw: add per-direction stream runtimes for multi_direction links Srinivas Kandagatla
2026-11-15 17:36 ` Mark Brown
2026-11-15 21:04 ` Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 04/23] ASoC: dt-bindings: qcom,wsa8840: allow one sound DAI cell Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 05/23] ASoC: codecs: wsa884x: add VI sense capture DAI Srinivas Kandagatla
2026-11-15 17:36 ` Mark Brown
2026-11-15 21:03 ` Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 06/23] ASoC: codecs: wsa884x: register the die temperature as a thermal zone Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 07/23] ASoC: qcom: audioreach: add control link support to graphs Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 08/23] ASoC: qcom: audioreach: run VI module in calibration mode with per-speaker events Srinivas Kandagatla
2026-11-15 17:36 ` Mark Brown
2026-11-15 21:04 ` Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 09/23] ASoC: qcom: q6apm-dai: add S32_LE format support Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 10/23] ASoC: qcom: audioreach: support up to four speakers in VI feedback Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 11/23] ASoC: qcom: audioreach: cache VI calibration results per speaker Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 12/23] ASoC: qcom: audioreach: make the speaker protection operation mode configurable Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 13/23] ASoC: qcom: audioreach: send cached R0/T0 to the VI module in normal mode Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 14/23] ASoC: qcom: audioreach: send static cfg blobs to speaker protection modules Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 15/23] ASoC: qcom: audioreach: add speaker protection mixer controls Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 16/23] ASoC: qcom: audioreach: pin SPEAKER_PROTECTION_VI media format Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 17/23] ASoC: qcom: audioreach: add live speaker temperature (T0) readback Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 18/23] ASoC: qcom: audioreach: add speaker protection calibration state control Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 19/23] ASoC: qcom: audioreach: keep the last VI calibration result until the DSP reports Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 20/23] ASoC: qcom: x1e80100: carry WSA VI feedback on the WSA Playback BE link Srinivas Kandagatla
2026-11-15 17:36 ` Mark Brown
2026-11-15 21:03 ` Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 21/23] ASoC: qcom: x1e80100: register WSA speaker thermal zones for speaker protection Srinivas Kandagatla
2026-10-23 17:14 ` [RFC PATCH 22/23] arm64: dts: qcom: glymur-crd: add WSA speaker protection VI feedback Srinivas Kandagatla
2026-10-28 13:38 ` Konrad Dybcio
2026-10-28 21:59 ` Srinivas Kandagatla
2026-10-29 8:17 ` Konrad Dybcio
2026-10-23 17:14 ` [RFC PATCH 23/23] arm64: dts: qcom: mahua-t14s: " Srinivas Kandagatla
2026-10-28 12:39 ` [RFC PATCH 00/23] ASoC: qcom: AudioReach Active speaker protection for WSA884x Mark Brown
2026-10-28 16:31 ` Fabian Renn-Giles
2026-10-28 21:56 ` Srinivas Kandagatla
2026-11-15 22:07 ` Srinivas Kandagatla
2026-11-22 16:14 ` [PATCH v2 00/24] ASoC: qcom: AudioReach Active speaker protection for WSA88xx Srinivas Kandagatla
2026-11-22 16:14 ` [PATCH v2 01/24] ASoC: soc-core: always allocate default ch_maps Srinivas Kandagatla
2026-11-22 16:31 ` sashiko-bot
2026-11-22 16:14 ` [PATCH v2 02/24] ASoC: soc-pcm: add multi_direction_codecs link flag Srinivas Kandagatla
2026-11-22 16:14 ` [PATCH v2 03/24] ASoC: soc-dai: export snd_soc_dai_stream_valid Srinivas Kandagatla
2026-11-22 16:14 ` [PATCH v2 04/24] ASoC: qcom: sdw: add per-direction stream runtimes for multi_direction links Srinivas Kandagatla
2026-11-22 16:38 ` sashiko-bot
2026-11-22 16:14 ` [PATCH v2 05/24] ASoC: dt-bindings: qcom,wsa8840: allow one sound DAI cell Srinivas Kandagatla
2026-11-22 16:14 ` [PATCH v2 06/24] ASoC: codecs: wsa884x: add VI sense capture DAI Srinivas Kandagatla
2026-11-22 16:28 ` sashiko-bot
2026-11-22 16:14 ` [PATCH v2 07/24] ASoC: codecs: wsa883x: " Srinivas Kandagatla
2026-11-22 16:28 ` sashiko-bot
2026-11-22 16:14 ` [PATCH v2 08/24] ASoC: codecs: wsa884x: register the die temperature as a thermal zone Srinivas Kandagatla
2026-11-22 16:28 ` sashiko-bot
2026-11-22 16:14 ` [PATCH v2 09/24] ASoC: qcom: audioreach: add control link support to graphs Srinivas Kandagatla
2026-11-22 16:32 ` sashiko-bot
2026-11-22 16:14 ` [PATCH v2 10/24] ASoC: qcom: audioreach: run VI module in calibration mode with per-speaker events Srinivas Kandagatla
2026-11-22 16:14 ` [PATCH v2 11/24] ASoC: qcom: q6apm-dai: add S32_LE format support Srinivas Kandagatla
2026-11-22 16:14 ` [PATCH v2 12/24] ASoC: qcom: audioreach: cache VI calibration results per speaker Srinivas Kandagatla
2026-11-22 16:22 ` sashiko-bot
2026-11-22 16:14 ` [PATCH v2 13/24] ASoC: qcom: audioreach: add speaker protection calibration trigger infrastructure Srinivas Kandagatla
2026-11-22 16:31 ` sashiko-bot
2026-11-22 16:14 ` [PATCH v2 14/24] ASoC: qcom: audioreach: send cached R0/T0 to the VI module in normal mode Srinivas Kandagatla
2026-11-22 16:28 ` sashiko-bot
2026-11-22 16:14 ` [PATCH v2 15/24] ASoC: qcom: audioreach: send static cfg blobs to speaker protection modules Srinivas Kandagatla
2026-11-22 16:31 ` sashiko-bot
2026-11-22 16:14 ` [PATCH v2 16/24] ASoC: qcom: audioreach: add speaker protection mixer controls Srinivas Kandagatla
2026-11-22 16:14 ` [PATCH v2 17/24] ASoC: qcom: audioreach: pin SPEAKER_PROTECTION_VI media format Srinivas Kandagatla
2026-11-22 16:14 ` [PATCH v2 18/24] ASoC: qcom: audioreach: add live speaker temperature (T0) readback Srinivas Kandagatla
2026-11-22 16:37 ` sashiko-bot
2026-11-22 16:14 ` [PATCH v2 19/24] ASoC: qcom: audioreach: add speaker protection calibration state control Srinivas Kandagatla
2026-11-22 16:37 ` sashiko-bot [this message]
2026-11-22 16:14 ` [PATCH v2 20/24] ASoC: qcom: x1e80100: carry WSA VI feedback on the WSA Playback BE link Srinivas Kandagatla
2026-11-22 16:14 ` [PATCH v2 21/24] ASoC: qcom: x1e80100: register WSA speaker thermal zones for speaker protection Srinivas Kandagatla
2026-11-22 16:14 ` [PATCH v2 22/24] arm64: dts: qcom: glymur-crd: add WSA speaker protection VI feedback Srinivas Kandagatla
2026-11-22 16:39 ` sashiko-bot
2026-11-22 16:14 ` [PATCH v2 23/24] arm64: dts: qcom: mahua-t14s: " Srinivas Kandagatla
2026-11-22 16:14 ` [PATCH v2 24/24] arm64: dts: qcom: x1e78100-t14s: " Srinivas Kandagatla
2026-11-22 16:37 ` 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-228110@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