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=1796391290; b=oyIGwoytuD38uKm3W079+hGC1E74cS2T2RxJ2wYiTKwJZvUSc9r9wF6l26SVlqJklX2x v9Qx72ggmLGwmQEq38EDnZgAHlblHfCr7Fjmc4rIPoyvicMVlYmdnpx45cBB9lCeGjXRS b5msLZUigi3cpmgl+HTozDyI5eo02APwybLAKLQHk3PeWWs6xcTu/1RW54/zzqN43DOCf zQ/LJPgSlTdR2RP5iL/23ZzW2rudZPK6XsOk0qsTgEqTnqUO1bAXkrSRHs/5Qx6CX/nYQ zJ5fJhL44UT3raHpiA/y6V7tdfL0Z8GAh36bDPXuchiPpg5HH3nQb+FE4UubgMoEWJQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796391290; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=HvmPv6vJuAGVNtyxqe5kY7CQVEfKBkqFOqsdSpH3me4=; b=lKtHOZld/TR9vr477ex4XYInAYO/Mqf7O5NTxcSypScnTE+gaVryc4Z87fjvRcenFsEv 5jGO7KuswzmfYMwaLi7sfawPmhzUEW8WuMFRpxOfcFfJWKwLos9Sqbmiddhb4ip3rNiWq IV+epqp+A4Z99TuOwe/RRA+eQHqckLWWLY2lRjxbi6mJRu4g6hEPtxuFMu+Va+8liJ0gz fSiWeWXpj8o1b5xJtL1XFIiHctjgSefKoHRc05WA9qVey9GMbclQVD9iRZ2GWov09mH3o QSBjVjClYL2l+cpQExYru0TpOiH+cOxtM70nVlF25I4NF6FBIaykC5aRTKjHuyJzueA== 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="V5C/GDFC"; 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 D909B606A686; Fri, 4 Dec 2026 13:34:50 +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=V5C/GDFC Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5B9D1F000C2; Fri, 4 Dec 2026 13:34:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796391290; bh=HvmPv6vJuAGVNtyxqe5kY7CQVEfKBkqFOqsdSpH3me4=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=V5C/GDFCruioP6Aay9ZkJsOCaUaF4GueDNctJiaPXI2I12UmHidMM9C+rmenrcGsy 1grYhUiZsaJa1XvYgHj+78DbhYwlP8GQIKuiiraG3y2irpXUj+mTRd4Yqe0X101sZu UP0unJiw7Vcg+1gGPWx0CxdVpw53qYMpylje7gEo2XSpMt++sZFtDteITUGsM2dsXy /jR3+ahhhQFAc+McNezvNf6+0ITKjm22sF+v2DFBice872PiNyOghj93EVM29Px4JK 7Axu2983/4qfU5Tx7OOJPztOmi8YtGRADOR8+Z8FmDzfUmDVvWeh1OrqxOGKfdpKXI HBdGafC/bEMsQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v5 08/24] ASoC: codecs: wsa884x: register the die temperature as a thermal zone 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: <20261204113101.1141644-9-srinivas.kandagatla@oss.qualcomm.com> References: <20261204113101.1141644-1-srinivas.kandagatla@oss.qualcomm.com> <20261204113101.1141644-9-srinivas.kandagatla@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 13:34:49 +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 4 potential issues to consider: - [Medium] ASoC: codecs: wsa884x: data race and TOCTOU on hw_init in wsa884x_get_temp() - [Medium] ASoC: wsa884x: enabling tripless thermal zone wakes idle codecs on resume - [Low] ASoC: codecs: wsa884x: unrelated wsa884x_vi_hw_params() change in commit - [Low] ASoC: codecs: wsa884x: 0 degC cache sentinel collision in wsa884x_get_temp() -- commit 513c87fe3e3a0f98ef09430a4d09e5f54d857839 Author: Srinivas Kandagatla ASoC: codecs: wsa884x: register the die temperature as a thermal zone This commit registers a tripless thermal zone for the WSA884x amplifier die temperature so in-kernel speaker protection can look it up by name, and updates wsa884x_get_temp() to return -EAGAIN before initialization or when the PA is on without a cached reading. > diff --git a/sound/soc/codecs/wsa884x.c b/sound/soc/codecs/wsa884x.c > index abf9d88ec7a8a..e5813ed139b34 100644 > --- a/sound/soc/codecs/wsa884x.c > +++ b/sound/soc/codecs/wsa884x.c [ ... ] > @@ -1779,21 +1780,19 @@ static int wsa884x_vi_hw_params(struct snd_pcm_su= bstream *substream, > struct snd_soc_dai *dai) > { > struct wsa884x_priv *wsa884x =3D dev_get_drvdata(dai->dev); > - unsigned int num_ports =3D 0; > =20 > + if (!wsa884x->port_enable[WSA884X_PORT_VISENSE]) > + return 0; > + > + wsa884x->vi_port_config =3D wsa884x_pconfig[WSA884X_PORT_VISENSE]; > wsa884x->vi_sconfig.frame_rate =3D params_rate(params); > wsa884x->vi_sconfig.ch_count =3D 2; > wsa884x->vi_sconfig.bps =3D 1; > wsa884x->vi_sconfig.type =3D SDW_STREAM_PDM; > wsa884x->vi_sconfig.direction =3D SDW_DATA_DIR_TX; > =20 > - if (wsa884x->port_enable[WSA884X_PORT_VISENSE]) { > - wsa884x->vi_port_config =3D wsa884x_pconfig[WSA884X_PORT_VISENSE]; > - num_ports =3D 1; > - } > - > return sdw_stream_add_slave(wsa884x->slave, &wsa884x->vi_sconfig, > - &wsa884x->vi_port_config, num_ports, > + &wsa884x->vi_port_config, 1, > wsa884x->vi_sruntime); > } [Severity: Low] This change to wsa884x_vi_hw_params() is unrelated to thermal zone registration and is not mentioned in the commit message. Should it be folded into commit "ASoC: codecs: wsa884x: add VI sense capture DAI" or split into its own patch? [ ... ] > @@ -1934,11 +1933,17 @@ static int wsa884x_get_temp(struct wsa884x_priv *= wsa884x, long *temp) > =20 > guard(mutex)(&wsa884x->sp_lock); > =20 > + /* OTP trims read back as zero until the codec is initialised. */ > + if (!wsa884x->hw_init) > + return -EAGAIN; [Severity: Medium] Can wsa884x->hw_init race with SoundWire status updates here? wsa884x_get_temp() reads hw_init under wsa884x->sp_lock, while wsa884x_init() sets it and wsa884x_update_status() clears it under slave->sdw_dev_lock: CPU0 (temp read) CPU1 (SoundWire status) wsa884x_get_temp() mutex_lock(&wsa884x->sp_lock) if (!wsa884x->hw_init) sdw_update_slave_status() mutex_lock(&slave->sdw_dev_lock) wsa884x_update_status(...) wsa884x->hw_init =3D false regcache_cache_only(..., true) mutex_unlock(&slave->sdw_dev_lock) pm_runtime_resume_and_get() regcache_sync() <-- runs on unattached slave regmap_read(WSA884X_OTP_REG_*) <-- d1 =3D=3D d2 =3D=3D 0, returns -EINVAL Returning -EINVAL from a thermal zone read also feeds into thermal_zone_recheck(), which polls the zone with backoff until disabling it. On an attach transition, the plain read also lacks acquire/release ordering against wsa884x_init(). Note that taking sp_lock inside wsa884x_update_status() would risk an ABBA deadlock with pm_runtime_resume_and_get() -> swrm_runtime_resume() -> sdw_handle_slave_status() -> sdw_update_slave_status(). > if (wsa884x->pa_on) { > /* > * Reading temperature is possible only when Power Amplifier is > - * off. Report last cached data. > + * off. Report last cached data if we have one, -EAGAIN otherwise. > */ > + if (!wsa884x->temperature) > + return -EAGAIN; > *temp =3D wsa884x->temperature * 1000; > return 0; > } [Severity: Low] Does using zero as the uncached sentinel reject a valid cached reading of 0 degC? wsa884x_get_temp() caches values across WSA884X_LOW_TEMP_THRESHOLD (-10) to WSA884X_HIGH_TEMP_THRESHOLD (150), so a cached 0 degC reading fails with -EAGAIN in hwmon and -ENODATA via thermal_zone_get_temp() while pa_on is true. Because wsa884x->temperature is an unsigned int, cached negative temperatures in [-10, -1] also wrap when multiplied by 1000 before widening to long on 64-bit hwmon reads. Making temperature a signed int with a separate bool validity flag (or initializing it to an out-of-range sentinel such as THERMAL_TEMP_INVALID) avoids both issues. [ ... ] > @@ -2196,6 +2233,35 @@ static int wsa884x_probe(struct sdw_slave *pdev, > if (ret) > return ret; > =20 > + if (IS_REACHABLE(CONFIG_THERMAL)) { > + char tz_name[THERMAL_NAME_LENGTH]; > + struct thermal_zone_device *tz; > + > + /* > + * Register after runtime PM is enabled, as the zone is read > + * right away. dev_name() is too long for a zone name. > + */ > + scnprintf(tz_name, sizeof(tz_name), "wsa-%d-%u", > + pdev->bus->id, pdev->id.unique_id); > + tz =3D thermal_tripless_zone_device_register(tz_name, > + wsa884x, > + &wsa884x_tz_ops, > + &wsa884x_tzp); > + if (IS_ERR(tz)) { > + dev_warn(dev, > + "thermal zone '%s' registration failed (%ld); SP T0 kcontrol will r= ead 0 for this codec\n", > + tz_name, PTR_ERR(tz)); > + } else { > + ret =3D devm_add_action_or_reset(dev, > + wsa884x_tz_unregister, > + tz); > + if (ret) > + return ret; > + > + thermal_zone_device_enable(tz); [Severity: Medium] Does calling thermal_zone_device_enable(tz) wake every idle WSA884x amplifier and its parent Qualcomm SoundWire controller on every system resume? Because wsa884x and qcom_swrm only implement runtime PM, an idle amplifier stays runtime-suspended across system suspend/resume with hw_init true and pa_on false. On every system resume, dpm_complete() -> thermal_pm_complete() -> thermal_zone_device_resume() -> __thermal_zone_device_update() invokes wsa884x_tz_get_temp() whenever tz->mode is THERMAL_DEVICE_ENABLED, calling pm_runtime_resume_and_get() only to discard the reading for a tripless zone. If that resume read returns any error other than -EAGAIN (such as -EINVAL or a runtime resume failure), __thermal_zone_device_update() also calls thermal_zone_recheck(), repeatedly waking and polling the codec with exponential backoff up to 120 seconds before disabling the zone. Leaving the zone in its default THERMAL_DEVICE_DISABLED state avoids resume updates while keeping thermal_zone_get_zone_by_name(), thermal_zone_get_temp(), and sysfs temp reads working. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204113101.1141= 644-1-srinivas.kandagatla@oss.qualcomm.com?part=3D8