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=1796130994; b=wsEQZCMpTrlbrFqQwriWgHCoKfndyBZYHWjkwN6I0h989tJbFZqUgLBnvCoKNVNlGWo7 yJwyUs0ruz41dEqAtcSdn81hmz82IdXzefEbubRSC78IJH6UU/jZXkMCmDOsiBuRV6UQM aV4HaEjCerkcp7aRNFjWs/uOC3sz2SfgLRvLzjiGIqhpeoMj2e7Sy+hiaepdmmfFKl6ZP TrpwjSfI/IBUbyMwOv95Dv7PCkUJyzBvlp2Nm2MXOrG9q3NUF4J0UTdZEBPOobJsEJARD L7pYf8fYHEsLpG6no5TRi1q2h/NGAAgs4nnOXw6Fg5B2JfFGlj0fPNxkPn9jqg9N2qA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796130994; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=nx7y5ahYr+tcBfvF2r8HFrGKKLPhG9OYYQsa8ZbnzDo=; b=XrhYEUtZ1sVcQP/RBdcRN9uYsYWqV352roGOtcLkzU9jB0rOz2FOmtX5Zwkz8WQmq7KH 9pR/XpRxxaXpDLCfxOwOyR1IjmgcLJIpbsK/Pdl6+zKwJbIrhpM/cJj6ikKqi0dZlMM9d VJ8kYizxNasDRAlj8mvPKSTQOaj6Z1TXwIAVpDlnn0h5vdLf5DnG/YlG3qN6Ft1ZsGbOl w1bkS2/gIaFpjs6hxNw5vpdN9Kwa74zm6rGcFVud42uHBYu+3e24/rrO0syC5x+WdvVN/ kU3Hk098tOEmW91w7bnhLUDsK2vr7lyfKrGQZGvxPDo8ibGVVIRrvdzy0M4gWgHaXrw== 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=XwdV1gY6; 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 01CE0606A31A; Tue, 1 Dec 2026 13:16: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=XwdV1gY6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 134051F0089F; Tue, 1 Dec 2026 13:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796130993; bh=nx7y5ahYr+tcBfvF2r8HFrGKKLPhG9OYYQsa8ZbnzDo=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=XwdV1gY6RKW1JpFmIr8wYY2b+jPNzLKI8Ht6j+HvkFbEiqZ0HcKMLJh/x63xajQpL MzW4HTun1aL2xdIc+XfPgOtPLaZXEeE8wiulUwfrUEz0EpRUtIaiu1OdHhpDoWc+Of YWM2eBR8ozuOSqHHkOz4qPJiZ5hh6KHGasySunoOPw4YRnAz1UxhJhwW5nfNCGQNGe yb1UFG7B8M/Ne420aDZTEmUtiDgD18I97f0EyJPvuCuXH9b/MoIecUzi1A2Qd8zXCK aqcxgFPGxzzNQxYWAWaTJftr6mSMibrhXDgxWQ+MrMT/QvxZLARlqM/3fnozfH0YxE 2VHcCGoJFaUvw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 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: <20261201124753.196748-15-srinivas.kandagatla@oss.qualcomm.com> References: <20261201124753.196748-1-srinivas.kandagatla@oss.qualcomm.com> <20261201124753.196748-15-srinivas.kandagatla@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 13:16:32 +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 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 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/aud= ioreach.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]); > } > =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; > + } [Severity: Low] Can an event with num_ch =3D=3D 0 clear the cached sp_vi_r0t0_cfg calibrati= on? q6apm_vi_calibration_event() permits an event payload with zero cali_param entries and passes num_ch =3D 0. In that case the channel loop does not ru= n, 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, > =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 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 !=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 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 r= xwq Also, because sp_vi_r0t0_cfg.num_ch !=3D 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201124753.1967= 48-1-srinivas.kandagatla@oss.qualcomm.com?part=3D14