From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796131648; b=r/Qav3PlRLY/GCx6L/nFCqeGWcwRhKe+b+QhUONABCVeKUU52qdz2Vyuyn/bG9oI/nPd SQZ5w4XpmaaSXhRlFuytnQ183wTyuajPud891CvnT1lNzzn7ap7/74ldr5ryKW95G2zVH u9sNfqMfPvI8AWVtYUVgcZZE9TZbWspmxbN2D16/Ll8gwWG9F1HOm58Votmo8dEiaqGJR wB1ZSds69gg1PELfVHgiwu5THGlgzcXM0Nh3hGikzkTECVqJCJ6csiXtQ37ue7PuNr7+H 43U6RQzf/9IhjdJTme2hGPveXouT5HZU+7XqEopMNyph22HDhaCcycS1n9br0s9UlJw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796131648; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Uj4B517mhYgdtx7caHLhIvNmWqpTL1PFuv6Qt62BBAM=; b=KqDTIyAwL8LSass02uWfV50jZyROrmQBZGsfZ7cyKjpI3r1dct7W8VuTvxi+5lH87SSa qVcjIJ9HN+JmDC145QwFpSeQSdA8axg6nGb2HAKhboWdpWiRDXHcgBoS7kcnfS1FiVE4u 7eNdGDvNierh81kcGkwrBEBm5Zi6xhShGf5i12GSqHYfM2t0pZwIxhxi2ExdBc+x+RS/y TepXvPOEjzTDeETXQsPwolW7SZP0YnD2uU98DD56tWyLsU+ooxLcwAmD+xeBe8ugiJcw2 k9XFMc18daqBdtbT3nKHlPExA8+GG5aDtVOno2VWyym+IKjrUxZ0IO3i4rB6YyR+udA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="NqH/qDLr"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6C3E606A32A; Tue, 1 Dec 2026 13:27:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NqH/qDLr Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5142E1F000C1; Tue, 1 Dec 2026 13:27:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796131647; bh=Uj4B517mhYgdtx7caHLhIvNmWqpTL1PFuv6Qt62BBAM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=NqH/qDLrvG+As36Hamsu7g/Qpr/C8et8e0mfbE6iYTWeY7DFUsrtOqdPASMOMRtJR 2Y9UrkugT3piZ4pg4PPUrXP3GXarK/uBbPeClxQ3JG6fibk5uPgpOmfcA3RwK4RaDg ZG/fWoT6/ewR8i++hhcaZw3+9h2iNOh75slgVuRYqfO3A3ecLTC9ng6NwxUTDti5kT dtwcT6PpxhPLXTwmC+bMPk0MRBRcac57eVf+/9sdqBZ7LtHvt0lt/kJNsbtG4DnLEI 92sXVLyp0ZK+1lblk32BePJAxoC+LpPP+LieEX6beFuV7Hs1Y8FYXBiWYSK5aE6kCd si8q4UqA3c6Qg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 19/24] ASoC: qcom: audioreach: add speaker protection calibration state control Reply-To: sashiko-reviews@lists.linux.dev To: "Srinivas Kandagatla" Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261201124753.196748-20-srinivas.kandagatla@oss.qualcomm.com> References: <20261201124753.196748-1-srinivas.kandagatla@oss.qualcomm.com> <20261201124753.196748-20-srinivas.kandagatla@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 13:27:26 +0000 X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 6 potential issues to consider: - [Medium] ASoC: qcom: audioreach: early return in audioreach_vi_calibration_abort() - [Medium] ASoC: qcom: audioreach: uncancelled sp_cal_watchdog work on module removal - [Medium] ASoC: qcom: audioreach: unsynchronized sp_operation_mode reads across sleep - [Low] ASoC: qcom: mode reset before cancel in audioreach_sp_finish_calibration() - [Low] ASoC: qcom: audioreach: commit message omits calibrate control and abort logic - [Low] ASoC: qcom: audioreach: stale last_state in audioreach_vi_calibration_event() -- commit 697d5e439356354d15a2690401fd91d27d7875e4 Author: Srinivas Kandagatla > 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 [Severity: Low] This isn't a bug, but the commit title and message only describe the "Speaker Protection Calibration State" control and do not mention adding the "Speaker Protection Calibrate" trigger control or the VI calibration abort handling on graph stop and close. > diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/aud= ioreach.c > index 3974191f9c536..cf30c18fa25ff 100644 > --- a/sound/soc/qcom/qdsp6/audioreach.c > +++ b/sound/soc/qcom/qdsp6/audioreach.c [ ... ] > @@ -1718,6 +1736,8 @@ void audioreach_vi_calibration_event(struct device = *dev, > for (i =3D 0; i < num_ch; i++) { > u32 state =3D cali->cali_param[i].state; > =20 > + sp_vi_r0.last_state[i] =3D state; > + > if (sp_vi_cali_state_is_failure(state)) > success =3D false; > else if (!sp_vi_cali_state_is_terminal(state)) [Severity: Low] Does audioreach_vi_calibration_event() leave stale entries in sp_vi_r0.last_state[] when a new run has fewer channels than a previous run? When the first event of a run arrives, audioreach_vi_calibration_event() clears sp_vi_r0.r0_cali_q24, but not sp_vi_r0.last_state. The loop above only updates slots 0 .. num_ch - 1, while audioreach_get_sp_vi_cal_state() copies all MAX_SP_VI_SPEAKERS entries to userspace. Zeroing sp_vi_r0.last_state alongside sp_vi_r0.r0_cali_q24 on the first event would avoid reporting stale states for unused speaker slots. > @@ -1780,6 +1800,46 @@ void audioreach_vi_calibration_event(struct device= *dev, > audioreach_sp_finish_calibration(); > } > =20 > +/* 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 =3D 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 before audioreach_sp_finish_calibration() leave sp_operation_mode stuck in PARAM_ID_SP_VI_OP_MODE_CALIBRATION when a run is aborted before the first DSP event arrives? When a graph is closed without ever starting (such as on a prepare failure covered by q6apm_graph_close()) or stopped before the DSP sends its first calibration event, sp_vi_r0.seen_states is all zeros. Returning early skips audioreach_sp_finish_calibration(), leaving sp_operation_mode in Calibration mode and sp_cal_watchdog pending for up to 60 seconds. During that window, retrying "Speaker Protection Calibrate" fails with -EBUSY, and any normal playback configures the DSP in Calibration mode without normal R0/T0 thermal protection. Calling audioreach_sp_finish_calibration() before the seen_states check would reset the mode and cancel the watchdog while still keeping the previous calibration result. > diff --git a/sound/soc/qcom/qdsp6/topology.c b/sound/soc/qcom/qdsp6/topol= ogy.c > index a8fdd73cdecdd..16327961d6c1b 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_kcontro= l *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? Exposing audioreach_trigger_sp_calibration() through this control lets userspace schedule the 60-second sp_cal_watchdog delayed work, but apm_remove() does not call cancel_delayed_work_sync(&sp_cal_watchdog) on driver teardown (and audioreach_sp_finish_calibration() only uses cancel_delayed_work()). Unbinding and unloading snd-q6apm while the watchdog is pending or running will execute audioreach_sp_cal_watchdog_fn() in unmapped module memory. [Severity: Low] Can audioreach_sp_finish_calibration() cancel the watchdog of a newly triggered calibration run or race with an in-flight watchdog callback? 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); } Because sp_operation_mode is reset to NORMAL before cancel_delayed_work(), a concurrent audioreach_put_sp_calibrate() can race as follows: CPU0 CPU1 audioreach_vi_calibration_abort() audioreach_sp_finish_calibration() WRITE_ONCE(sp_operation_mode, ..._NORMAL) audioreach_put_sp_calibrate() audioreach_trigger_sp_calibration() cmpxchg(&sp_operation_mode, ..._NORMAL, ..._CALIBRATION) schedule_delayed_work( &sp_cal_watchdog, ...) cancel_delayed_work(&sp_cal_watchdog) <-- cancels new run's watchdog In addition, because cancel_delayed_work() does not wait for an executing audioreach_sp_cal_watchdog_fn(), an in-flight watchdog from the old run can cmpxchg sp_operation_mode back to NORMAL after CPU1 has armed the new run. [Severity: Medium] Can a concurrent sp_operation_mode change while graph setup sleeps leave the DSP speaker protection modules inconsistently configured? audioreach_put_sp_calibrate(), audioreach_vi_calibration_abort() and audioreach_sp_cal_watchdog_fn() update sp_operation_mode without serializing against graph preparation: sound/soc/qcom/qdsp6/audioreach.c:audioreach_speaker_protection_vi() { u32 mode =3D READ_ONCE(sp_operation_mode); ... op_cfg->cfg.operation_mode =3D mode; ... rc =3D q6apm_send_cmd_sync(graph->apm, pkt, 0); ... if (sp_operation_mode =3D=3D PARAM_ID_SP_VI_OP_MODE_NORMAL) { audioreach_speaker_protection_vi() snapshots sp_operation_mode into mode to register events and send PARAM_ID_SP_VI_OP_MODE_CFG, then sleeps in q6apm_send_cmd_sync(), and re-reads sp_operation_mode afterward. If audioreach_put_sp_calibrate() switches sp_operation_mode from NORMAL to CALIBRATION during that sleep, the VI module is placed in NORMAL mode without calibration events registered, but the second check sees CALIBRATION and skips sending PARAM_ID_SP_TH_VI_R0T0_CFG. Likewise, audioreach_speaker_protection() and audioreach_speaker_protection_vi() read sp_operation_mode independently across sleeping GPR commands, so the two modules can be configured for different modes on the same graph. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201124753.1967= 48-1-srinivas.kandagatla@oss.qualcomm.com?part=3D19