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=1796074292; b=1CjRf26VV0TlQ1YVmR03nkDpw5SvOU0H8Cq01OnbNEN2Nwxp9MhdGcFEDMFJ59pb99KH mcXKENhHAKCDeOovLJJOIBWdOOJdnYmqRCVDpfLhFFp+ULR78l0Trxx20jkyXGXyYrWp2 28l5axO/1gRjMToySD2HTf+WQYo8nivUladgbRL89d4R2kpUEIvJlrbr9E+p6Bh8bczHS xaCtnLjQLUherJhn/0DH07OMtyINVTjc21BU5WDqL+GCS8gBJ9MXda+ghb5A9rzv+pkCd 8i3a8zaP3hhwa938iprkW+Dvzos++GvnjBpBi51g9HBKheAo0rLnaXYzSmTeSTi7LAQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796074292; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=K+RvRaaM6eAZUd1MTKqmjpCjDLmEws4KuIbTntvwopo=; b=BOWeYoPjcS0a93xoTHAd3LtAOilSt6XyPNbATTr0nPlO6z2KrjmwIJBbMQPc4V5DAoKH 8eU0stcShjiVsqYXxAq1VeANwdpIjmyuaN4F1K9mNkR82jYsyxDkIbe84iLbbi9vQCSfe j1QceZyQjXyM7ZpMtYpRBVNd2cvY4F1f/4MVEtWBhi0nLI9n2sy3A2sVkDvt0LuzjvsYI qPtpdrqOb0WTx0DSqDJDyKcSo//UChS7AWfBmxoI8OoBm9QvDtj5duUls+nIicROTJ4pT axD1GntTlXSVSephHFpZxvNH2Gyo6YlqiM2NdVvbal+2qSCtPoKst+WnfX8TnaOse2A== 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=FaZu3yCz; 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 33A3C606A31A; Mon, 30 Nov 2026 21:31:31 +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=FaZu3yCz Received: by smtp.kernel.org (Postfix) with ESMTPSA id 796561F00929; Mon, 30 Nov 2026 21:31:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796074291; bh=K+RvRaaM6eAZUd1MTKqmjpCjDLmEws4KuIbTntvwopo=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=FaZu3yCzwZsI/VDuOmqrrdkCYg1HugWD/w/MFWjye32Q9is7M+xEcBtV9a6BOGG5q UXGXi4/t5qKSFVewQ/Apg6vEH3VC4nRixxr63ZoBxhvmgM/OLzieeAQSlC4aSuezHt UQ8laiXq9RpzT3HXMbosq5I91wNckmCGuvBiY0Adtn2Ca3qVjYMllKnywbm45HbQPj e/MSLNwOWiRdPFJ3gxyXV2+AeS1ViXenDuatx4iJjH83Cei8B/tE1BhoxpyQLKGiAE C4cyeDoJ0qT8bFpY32Zd82+a4aI6aQssSa+qFK0JG4vfuhnGpUPlQs1DTwxk0PSFFn HOBb1CQO7E7lQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 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: <20261130212258.7376-13-srinivas.kandagatla@oss.qualcomm.com> References: <20261130212258.7376-1-srinivas.kandagatla@oss.qualcomm.com> <20261130212258.7376-13-srinivas.kandagatla@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 21:31:31 +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 success on num_ch =3D=3D 0 in audioreach_vi_calibration_event() - [Low] ASoC: qcom: audioreach: negative Q24 misformatting in sp_vi_q24_to_int_frac() -- commit d2345fffe188cfdf8d7406ef014a481b337ee1a8 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 is recorded when all speakers reach a terminal state. > diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/aud= ioreach.c > index fbb9e3c4b84ae..2b5c083b8ae56 100644 > --- a/sound/soc/qcom/qdsp6/audioreach.c > +++ b/sound/soc/qcom/qdsp6/audioreach.c [ ... ] > @@ -1462,16 +1482,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() misformat negative Q24 values? For a negative s32 with a non-zero fractional part, val >> 24 rounds toward negative infinity and val & 0xffffff extracts the positive two's-complement offset above that floor, so -0.250 ohms (-0x00400000) is split into -1 and 750 and logged as -1.750 ohms when an out-of-range R0 is reported on VI_CALIBRATION_STATE_FAILED. > + > +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] Can an event with num_ch =3D=3D 0 wipe the cached R0 values and prematurely finish an armed run as SP_VI_CALI_SUCCESS? q6apm_vi_calibration_event() clamps num_ch from above to MAX_SP_VI_SPEAKERS but does not reject num_ch =3D=3D 0 when cali->num_ch is 0 or the payload h= as no cali_param entries. Because decisive and success start as true, a call with num_ch =3D=3D 0 clears sp_vi_r0.r0_cali_q24, skips the per-channel loo= p, disarms sp_vi_r0.armed so later events from the run are ignored, and records SP_VI_CALI_SUCCESS with sp_vi_r0.num_ch =3D 0. Guarding against !num_ch || num_ch > MAX_SP_VI_SPEAKERS at the top of audioreach_vi_calibration_event() would also protect the fixed-size sp_vi_r0 arrays from direct callers. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130212258.7376= -1-srinivas.kandagatla@oss.qualcomm.com?part=3D12