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=1796130648; b=Dds3/8qix95BMeAPVDCNc8fEVnIEToa6nCtEt3Tj774LsA+ooxBx163tTGW+8Q6IDANq Lt6tFXrR1fo9lefzKq6pvxqMopmpevn12hq6/7LgaGw9QpSv8jlFehrdNH5rRIEAfkGB0 n58G2z1kYOAuEB42XDCBUwMPMgQxCfV05Am/oGUlTdJgsHMks3Xe+7cmpKCfGH1GhwTrM dkR4+HeWaxBdYju1QYoJBSKw9scFhGn4qEzD9gMGHgiuMVb93jFp5Ihw26xjMGJNb3LWN 0gVKaS1RkYqx3tLRKN4YyOqKkxQh7GdUeMUsPXBQvxXQpRO34ocr2pApsJgQZVLTV4A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796130648; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=W5JOEICjpTeH6iTed0/K3HG9n+S52BoWUKrz702LpbA=; b=q+sN7Yq0WlwzDrRQADG8GLwXPgCvYNAY1CAFTxHnCC4q3TegkQwVEq9O97Y9DccKr1q7 fFjdV4MCYng8E0jC8E5bmDU49E3CBpAoLaUe1yx8RiG2TEjdjkhiYXV/Cd/mAefDlu4sf XZjPcPY3mSiQuO+4F5F13gTMCzEbxDlO52A3yH3fnl7D4hA/KrxmDi4gvsTgl9ZlLlzyh aK8uFgSMVMhLWyevkgM/nz4cgHLFD3JUfrDyqKy+RRWKVR1HpXSVENDcSjLTnHcrDhMTA rAzAqgdEPEpUVlGW4/aWMjr4/VSy4MqrimIMsCzfYxEHuNUFaR0r/MAsb2qJVH/cTHw== 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=oUXjLj8i; 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 69852606A31A; Tue, 1 Dec 2026 13:10:48 +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=oUXjLj8i Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FFF81F00898; Tue, 1 Dec 2026 13:10:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796130648; bh=W5JOEICjpTeH6iTed0/K3HG9n+S52BoWUKrz702LpbA=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=oUXjLj8iXriiJZWW5UUPvM2NPRZctFDcZHC+Ab7Xu3AzTZSUEld2tFxn7fy7nbobZ rGPGDscCTb3kXe9lh2/2RpYFo7FSBV110mrU6pZhjbVm8sFtQ9kopdmtRHKYyBTvR4 hv3TY0Hn9Fm6Sc+5BklknMP5rBbzOQZlmhQwMp6evA3TRrWoyQVSDBQ/p4EQUCDVRA qmiQHAX8vmNh79VjR/3ONLrlhvCtn8QF4ILc6E3dXzAVejdtXK9CjtkstMOmTyY2U7 F53/8pNNY4U/5oP9ojU5/rVquqOBEOwZRGGN5zE2PrGIs4RS/mV6tCnEGXMz4/XPRq RvuYO+N3z1OsQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 12/24] ASoC: qcom: audioreach: cache VI calibration results per speaker 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-13-srinivas.kandagatla@oss.qualcomm.com> References: <20261201124753.196748-1-srinivas.kandagatla@oss.qualcomm.com> <20261201124753.196748-13-srinivas.kandagatla@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 13:10:47 +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 2 potential issues to consider: - [Medium] ASoC: qcom: audioreach: false calibration success when num_ch is 0 - [Low] ASoC: qcom: audioreach: broken negative Q24 format in sp_vi_q24_to_int_frac() -- commit d42dd2e274b061eaf9d1d04ab1acceb12bc8b91c Author: Ravi Hothi ASoC: qcom: audioreach: cache VI calibration results per speaker This commit adds a mutex-protected per-speaker cache for VI calibration events so state transitions are logged once per speaker and the measured R0 values are recorded once all speakers reach a terminal state. > diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/aud= ioreach.c > index aea482270c26a..c48ba63448dbd 100644 > --- a/sound/soc/qcom/qdsp6/audioreach.c > +++ b/sound/soc/qcom/qdsp6/audioreach.c [ ... ] > @@ -1436,16 +1456,112 @@ static int audioreach_gain_set(struct q6apm_grap= h *graph, [ ... ] > +static int sp_vi_q24_to_int_frac(s32 val, int *frac) > +{ > + *frac =3D (int)(((s64)(val & 0xffffff) * 1000) >> 24); > + > + return val >> 24; > +} [Severity: Low] Does sp_vi_q24_to_int_frac() format negative Q24 values wrongly when an out-of-range negative R0 is logged on VI_CALIBRATION_STATE_FAILED? For a negative two's-complement s32 with a fractional part, val >> 24 floors toward negative infinity and val & 0xffffff yields the positive offset above that floor (1000 - |frac|), so -0.250 ohms (-0x00400000) is printed via %d.%03d as -1.750 ohms. > + > +void audioreach_vi_calibration_event(struct device *dev, > + const struct event_id_vi_per_spkr_calibration *cali, > + u32 num_ch) > +{ > + bool decisive =3D true; > + bool success =3D true; > + unsigned int i; > + u32 bit; > + > + guard(mutex)(&sp_vi_r0_lock); > + > + if (!sp_vi_r0.armed) > + return; > + > + /* First event of this run: drop the previous result */ > + if (!memchr_inv(sp_vi_r0.seen_states, 0, sizeof(sp_vi_r0.seen_states)))= { > + sp_vi_r0.state =3D SP_VI_CALI_RUNNING; > + sp_vi_r0.num_ch =3D 0; > + memset(sp_vi_r0.r0_cali_q24, 0, sizeof(sp_vi_r0.r0_cali_q24)); > + } > + > + for (i =3D 0; i < num_ch; i++) { > + u32 state =3D cali->cali_param[i].state; > =20 > - /* Raised every frame; keep the per-event log at debug level */ > - for (i =3D 0; i < num_ch; i++) > - dev_dbg(dev, "VI calibration channel %u: state %u\n", > - i, cali->cali_param[i].state); > + if (sp_vi_cali_state_is_failure(state)) > + success =3D false; > + else if (!sp_vi_cali_state_is_terminal(state)) > + decisive =3D false; > + > + bit =3D BIT(min_t(u32, state, SP_VI_CALI_UNKNOWN_STATE_BIT)); > + if (!(sp_vi_r0.seen_states[i] & bit)) { > + sp_vi_r0.seen_states[i] |=3D bit; > + dev_info(dev, "VI calibration channel %u: %s\n", > + i, sp_vi_cali_state_name(state)); > + } > + } > + > + if (!decisive) > + return; > + > + sp_vi_r0.armed =3D false; > + sp_vi_r0.state =3D success ? SP_VI_CALI_SUCCESS : SP_VI_CALI_FAILED; > + sp_vi_r0.num_ch =3D num_ch; [Severity: Medium] What happens in audioreach_vi_calibration_event() if num_ch is 0? q6apm_vi_calibration_event() clamps num_ch from above by MAX_SP_VI_SPEAKERS, but does not reject 0 when cali->num_ch is 0 or the event payload carries no cali_param entry: 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); } With num_ch =3D=3D 0, the first-event check clears any previous sp_vi_r0 result, the per-channel loop executes zero iterations leaving decisive and success true, and the run is disarmed and recorded as SP_VI_CALI_SUCCESS with sp_vi_r0.num_ch =3D 0, causing later events from the run to be ignored. Validating !num_ch || num_ch > MAX_SP_VI_SPEAKERS at the start of audioreach_vi_calibration_event() would avoid this. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201124753.1967= 48-1-srinivas.kandagatla@oss.qualcomm.com?part=3D12