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=1796130837; b=R5/6xwHDc1gyr1FtgaMay2l3T2DlNICQZhDi44B0Lrllz5Iqp7xPxfny7fqdsiuBZDOc D9MQ00slGEAkrcEKJIR+vdsD/OpyKWk1swugipFt/N1NTNpjOSkHvWrCRQGq0v8dCAjKt SXEvpTjb96t0XmvOAPI7Ava+hvnyS1pZ7uKVGlBkhxMc6QOCKG2TVuzcIudm+uw9xfpNF Xg7wUZc4c4N2/KJ7X5OfmKG+09aZm6SMkhoHb36qjL13f/eNRWPMfPNk9P16driizIl0h IA0drd+9SCTtWbUgeA6tgP5NOra+jNOi4pQrL5fVI/3gkHZ07T5J+gcCDt99xTUkeSg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796130837; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=WEak/uHxvi/yzkJl0Zp/8IXEyv/y5jGvbWY6vYvi26c=; b=Fd4lhtGLxxB87PZHAm0ZRSXn7RYfyRbumPJ58wSQBfWhMSddpqTBS4JSaWfRG2JfUclI dF3bS+P3rhNVQRcRvNy6uCMNhrpEs7gc4DSxvjLOUdS3pvrRCpVMEkO7vrwsLK7SEMTL9 5qRI8LGqVJ1Yk7e3VpnzN/AQovEqekoccKqIn8xgKDnLG2R3cyTMLFysn9OelTMLRdf3j O9L7AGYnE7JyCB9Jcd6TGQeDBbQKWvkpTvaV1jlCVnRsAsyXFE78+09pCV+s49vLUnOqv Zf447RH/HxZmdcrH92Pl5+dpzlWHX7LKUGqhG61/lpNr5PHzq3Y+6nSFfRd8wyK3E5Q== 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=NVGp9aKN; 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 6E113606A320; Tue, 1 Dec 2026 13:13:57 +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=NVGp9aKN Received: by smtp.kernel.org (Postfix) with ESMTPSA id 625531F00898; Tue, 1 Dec 2026 13:13:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796130836; bh=WEak/uHxvi/yzkJl0Zp/8IXEyv/y5jGvbWY6vYvi26c=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=NVGp9aKNeN23rcBE51ITrcRIVGWcuSIm02rt/5nRV+9wgEOq2/9l0g+b3BJmwXL/k xcuA5raF7BeG/zDFCZjBQXWO+dciBBfWJ6kkmSl6vctrwyuehWp3/P+CLn+f11pzBP hHJt4xbtfVYhViIQobS+IUEDYZ9Wds0X4DxWspd183v84WyFFdW57CLx1QwkddCPTE 78gj2ezRDyGK0Q0dHTt9lmzb4SJr/JjCr8nfBU5tTL6Ett2ba9zJ3wVJUQdcnhLB74 LQiIKo3nUlT68Hv8mS+h+fg8/Ti9AUo/ZTNx1pUI3b+PBWkgBykG0n+9uQt29khZLa a7MpUGwkkMj9w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 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: <20261201124753.196748-9-srinivas.kandagatla@oss.qualcomm.com> References: <20261201124753.196748-1-srinivas.kandagatla@oss.qualcomm.com> <20261201124753.196748-9-srinivas.kandagatla@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 13:13:54 +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: codecs: wsa884x: duplicate hwmon registration in wsa884x_probe() - [Medium] ASoC: codecs: wsa884x: missing hw_init check in wsa884x_get_temp() - [Low] ASoC: codecs: wsa884x: 0 degC cache sentinel collision in wsa884x_get_temp() -- commit 00e0327ff20a8e4f0dd3f6d78b99d67cb9827c8e Author: Srinivas Kandagatla ASoC: codecs: wsa884x: register the die temperature as a thermal zone This commit registers a tripless thermal zone for the WSA884x die temperature sensor and returns -EAGAIN to hwmon and THERMAL_TEMP_INVALID to the thermal zone when no temperature reading is available yet. > diff --git a/sound/soc/codecs/wsa884x.c b/sound/soc/codecs/wsa884x.c > index 91aa004d7137b..d0a00aced2208 100644 > --- a/sound/soc/codecs/wsa884x.c > +++ b/sound/soc/codecs/wsa884x.c [ ... ] > @@ -1935,8 +1936,10 @@ static int wsa884x_get_temp(struct wsa884x_priv *w= sa884x, long *temp) > 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 checking !wsa884x->temperature misidentify a valid cached 0 degC reading as uncached? wsa884x_get_temp() accepts readings from WSA884X_LOW_TEMP_THRESHOLD (-10) to WSA884X_HIGH_TEMP_THRESHOLD (150), so if 0 degC was cached before the PA turned on, reads while pa_on is true will return -EAGAIN to hwmon and THERMAL_TEMP_INVALID to the thermal zone. Also, wsa884x->temperature is an unsigned int, so caching a valid negative reading in [-10, -1] degC wraps around and overflows when multiplied by 1000 into signed long *temp. > @@ -2058,6 +2061,42 @@ static const struct hwmon_chip_info wsa884x_hwmon_= chip_info =3D { > .info =3D wsa884x_hwmon_info, > }; > =20 > +static int wsa884x_tz_get_temp(struct thermal_zone_device *tz, int *temp= _mdeg) > +{ > + struct wsa884x_priv *wsa884x =3D thermal_zone_device_priv(tz); > + long mdeg; > + int ret; > + > + /* > + * OTP trims read back as zero until the codec is initialised. Report > + * no reading rather than -EAGAIN, which makes the core poll the zone. > + */ > + if (!wsa884x->hw_init) { > + *temp_mdeg =3D THERMAL_TEMP_INVALID; > + return 0; > + } > + > + ret =3D wsa884x_get_temp(wsa884x, &mdeg); > + if (ret =3D=3D -EAGAIN) { > + *temp_mdeg =3D THERMAL_TEMP_INVALID; > + return 0; > + } > + if (ret) > + return ret; > + > + *temp_mdeg =3D (int)mdeg; > + return 0; > +} [Severity: Medium] Should the !wsa884x->hw_init check live inside wsa884x_get_temp() under wsa884x->sp_lock (returning -EAGAIN) instead of only in wsa884x_tz_get_temp()? The commit message says hwmon returns -EAGAIN until the codec is initialised, but wsa884x_hwmon_read() calls wsa884x_get_temp() directly without checking hw_init. If userspace reads hwmon before the SoundWire slave attaches (or after SDW_SLAVE_UNATTACHED clears hw_init), wsa884x_get_temp() calls pm_runtime_resume_and_get() -- which in wsa884x_runtime_resume() clears regcache_cache_only() and calls regcache_sync() on an unattached slave once the autosuspend timer expires -- and then returns -EINVAL when uncached OTP registers read as zero (d1 =3D=3D d2 =3D=3D 0), or caches a bogus reading from dmeas =3D 0 if the non-= volatile OTP registers were cached during an earlier attachment. Checking hw_init in wsa884x_tz_get_temp() without sp_lock can also race with wsa884x_update_status(SDW_SLAVE_UNATTACHED) and let wsa884x_get_temp() return -EINVAL to thermal_zone_recheck(), scheduling 250 ms polling. [ ... ] > @@ -2194,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, > + NULL); [Severity: Medium] Does passing NULL for tzp register a duplicate hwmon device for the same sensor? wsa884x_probe() already registers a hwmon device via devm_hwmon_device_register_with_info(). When tzp is NULL, thermal_zone_device_register_with_trips() calls thermal_add_hwmon_sysfs() when CONFIG_THERMAL_HWMON is enabled, creating a second hwmon device that causes userspace hwmon scanners to wake the codec and run the SoundWire temperature read sequence twice per scan while seeing -ENODATA on the thermal-hwmon bridge vs -EAGAIN on the native hwmon device. Passing a struct thermal_zone_params with .no_hwmon =3D true avoids the duplicate registration. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201124753.1967= 48-1-srinivas.kandagatla@oss.qualcomm.com?part=3D8