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=1796074593; b=lBJ6Dpzj7fDf4ccVnOvdGPIP350zQMnCjgOWlem1/Gw9efu1MtqTVtpHiwQ6+vE1NxTI V7s/DA68Uo1xcD79e3NosF8mqhhzr5ZL7eJtIYq29rKxkbK5PTbWL4SvozhTgpcKC5R0i lOZ+O74ltB0dcuX66Cb2zSobWBZ15+lSNPCOA9y3Ersrzk7Lqe8AzQpSxc7OSRJoZS0Ss lvZls/MqmFfQRWPgf3S4f5yBZ4fblxPN+LGZReOwsJKzcqlRLLZmXX9TmCodnQ+L2Mxml 0n+3k4CQpN98xz4oCa+5xQH2Oz2/+HuWtzxymaUT3STTin5kvWy+dQTi91JKHGr6JwA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796074593; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=lzaccVUiBsIhjHd2/6X97oH6APVcYUQguuJ90npC+gY=; b=KwXq+NgtZ5Gx7v1c85+Rp49Ye3XwVgZp0Wu3D1RWTcLtkcVlZHnEV6AwFVF9Td3QujRy Hz93sr1b8VJrMfKteJ3rJS5m9hE9RYKvlNnM/YfTNckbM6DEwEd6qghvQS8283NImTLaH CjVTs+zpncU2Eb64+lOyVA4G2oYqWkUyCfbu3XRFqApC/itdzuFnn1TR6xb2OHGHcqJHW /vJEdLPEBhHaIOvgfM5bA/X/Wbk4fPOJWbYI3EcKWE0z4W6Dgh4iu2y28pFmFzBFk0HWT KVox481QOrOJIBEUV1yppvkufgygiWkCnewKxH8RE/MBLL2y1raD14T5krTghhzyqhA== 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=K6MDccuV; 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 9E4EB606A31A; Mon, 30 Nov 2026 21:36:33 +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=K6MDccuV Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79A691F000C1; Mon, 30 Nov 2026 21:36:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796074593; bh=lzaccVUiBsIhjHd2/6X97oH6APVcYUQguuJ90npC+gY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=K6MDccuVGlzFHMKzcutcPHxu0Lzx2LuIUczUp3xtURP2ZIijWioBpVV7qyOFktAcX bXTU6zeOHOhELRqjEt7B/+NkWZiDxQsncw0Cmrd5rRfEuBsSQCdLZqQDfpW1W9m5ul NLN43HF5+r+e5tpTLaWzBdbuaRn6njVjOEwOkt8qy7XunWuA1+XHN33M4u0Wbi9wmi dJ+ir/1/QCjQRkE4uooXZfsW6Ge6375jVxkMZmdBkbk4dWohGWUDGFqoFpKsXRUpU3 IvdIkufvHhznBrs6cUtMtKFj0cMFKaHCnTpDc39zT92g24w9x8X9EK2NsIrwAODs6E 5ZeG/bLzMhy6w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 14/24] ASoC: qcom: audioreach: send cached R0/T0 to the VI module in normal mode 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: <20261130212258.7376-15-srinivas.kandagatla@oss.qualcomm.com> References: <20261130212258.7376-1-srinivas.kandagatla@oss.qualcomm.com> <20261130212258.7376-15-srinivas.kandagatla@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 21:36:32 +0000 X-Mailing-List: devicetree@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 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 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/aud= ioreach.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]); > } > =20 > + /* 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 =3D num_ch; > + for (i =3D 0; i < num_ch; i++) > + sp_vi_r0t0_cfg.r0_cali_q24[i] =3D cali->cali_param[i].r0_cali_q24; > + } > + > dev_info(dev, "VI calibration complete: %s\n", success ? "success" : "f= ailed"); > =20 > /* 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 =3D=3D 0 and passes num_ch =3D=3D 0 to audioreach_vi_calibration_event(): sound/soc/qcom/qdsp6/q6apm.c:q6apm_vi_calibration_event() { ... num_ch =3D (payload_size - sizeof(*event) - sizeof(*cali)) / sizeof(cali->= cali_param[0]); num_ch =3D min_t(u32, cali->num_ch, num_ch); num_ch =3D 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, > =20 > kfree(pkt); > =20 > + if (rc) > + return rc; > + > + if (sp_operation_mode =3D=3D 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 =3D 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 !=3D 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 =3D APM_SP_TH_VI_R0T0_CFG_PSIZE(sp_vi_r0t0_cfg.num_ch); > + pkt =3D audioreach_alloc_apm_cmd_pkt(r0t0_sz, APM_CMD_SET_CFG, 0); > + if (IS_ERR(pkt)) > + return PTR_ERR(pkt); > + > + p =3D (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; > + > + r0t0_cfg =3D p; > + param_data =3D &r0t0_cfg->param_data; > + param_data->module_instance_id =3D module->instance_id; > + param_data->error_code =3D 0; > + param_data->param_id =3D PARAM_ID_SP_TH_VI_R0T0_CFG; > + param_data->param_size =3D r0t0_sz - APM_MODULE_PARAM_DATA_SIZE; > + > + r0t0_cfg->cfg.num_ch =3D sp_vi_r0t0_cfg.num_ch; > + for (i =3D 0; i < sp_vi_r0t0_cfg.num_ch; i++) { > + r0t0_cfg->cfg.r0t0_cfg[i].r0_cali_q24 =3D sp_vi_r0t0_cfg.r0_cali_q24[= i]; > + r0t0_cfg->cfg.r0t0_cfg[i].t0_cali_q6 =3D sp_vi_r0t0_cfg.t0_cali_q6[i]; > + r0t0_cfg->cfg.r0t0_cfg[i].reserved =3D 0; > + } > + > + rc =3D 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_CALIBRAT= ION 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130212258.7376= -1-srinivas.kandagatla@oss.qualcomm.com?part=3D14