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=1796302390; b=CS5zUkBlcSrq9iYZYr0FsahLQmORwYUCY6SjY86rXbT0b+g4jRamdrQCrfDH5scUVwLE JDc65UCkBDH5iSmwLPSDU7QdiP3w0vvROL0KGXvrP2Jdxn/xbbhGHZVb8a71/1PS0Dj0Q OHlDyEiuJ+iLWpPbjI/ZNzTrsRq8KzEHMGSGh/fMax9o/MooQH+e77h3huLA81DyHzsdZ BNNMopQ8V/xhpyJksXTNRubFhh5M1ljCNPtl9kVXHDavG8kQxd1NU9gUEdBKjUJNU6j28 iUMCTeLZfhoDC1XpQGUh/yJTqJxOH+uMfAUNPsIVPzHJ2MqrFJhU6HLti8sbOnliFhg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796302390; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=kbfOnH5DKzIVNSarXUkETesuuvMzdWz3vQ0PVYv/Wts=; b=AuITZNluuEHfBIQI3qFh3BEQWtTGXTz0akWwAo4fMYGzI2/PUSC34b19C1aVceUFcUnd zbrANT4/NsQ88hlTx3cNQN03WgRqVRCgtdJC71iOHBgLdivkEKn17ShogyQLB9Zlv+BYP c7oOlku9avy5duMVmfW/l1aYHMO0lhJgi6JVUzX9/OKRa9TVuD+WEfqxx/AhcgVa81Od3 H+tJPXBhKLSkUgMm9t2Yw85IzOFXraApjv/ct6SLr0juR+Aur8tN1K8hv7MIf7wS5fg94 T2GJ4yNrrpSO1dg4jfe4EfeDy94098H7KuxwHfG+uLE7GUb7tauQTIKHPW7lesep1Ww== 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=nBAUYfQI; 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 2ED7C606A32C for ; Thu, 3 Dec 2026 12:53:10 +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=nBAUYfQI Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE8A91F00893; Thu, 3 Dec 2026 12:53:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796302390; bh=kbfOnH5DKzIVNSarXUkETesuuvMzdWz3vQ0PVYv/Wts=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=nBAUYfQIc5l4rc0RIXjdwWgkquLWjYLOC41bdDxzSu83wIWP0V22cQdvN4D86AkRI qFY4rZOAhwcQWR6vNtxXH/5k3aoGbmRhjjFQQKLKaK4JQF046oebT4eBMKirTloZpK Wc4pR0R8O3BjIbbqXljlOz+NgYcidmVKckBDFA9mAJT8afCweFHgue56RjVXbKpbnc G0P1MNqOfP2uLp7BsFakxRWIDXgOXpVtY/WCSH9NWs1Za32C9DxDhdaXM25RkR1wLI qRSS/2xiCrA7Tynkp0RYeTgIT6FTn/NQLBNuXwvcO8dOaET+BaH1DYbAaKbLbDLV7l UdLs9suohRlMA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 4/4] thermal/drivers/mediatek: Add MT6797 support Reply-To: sashiko-reviews@lists.linux.dev To: "Ben Grisdale" Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261203-mt6797-thermal-support-v1-4-19595fe11814@protonmail.ch> References: <20261203-mt6797-thermal-support-v1-0-19595fe11814@protonmail.ch> <20261203-mt6797-thermal-support-v1-4-19595fe11814@protonmail.ch> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 12:53:09 +0000 X-Mailing-List: devicetree@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] thermal/mediatek: negative signed left shift in raw_to_mcelsius_v1_5() - [Medium] thermal/mediatek: raw_to_mcelsius_v1_5() returns 0 instead of invalid temp -- commit f202360240c2d8c5a36415fdb23e266d0c8c9198 Author: Roman Vivchar thermal/drivers/mediatek: Add MT6797 support This commit adds MT6797 thermal controller support to the MediaTek AUXADC thermal driver, wiring it to the v1.5 temperature conversion formula and registering the mediatek,mt6797-thermal compatible. > diff --git a/drivers/thermal/mediatek/auxadc_thermal.c b/drivers/thermal/= mediatek/auxadc_thermal.c > index 319ab741e325b..a8d22af7d4ea6 100644 > --- a/drivers/thermal/mediatek/auxadc_thermal.c > +++ b/drivers/thermal/mediatek/auxadc_thermal.c [ ... ] > @@ -623,6 +672,51 @@ static const struct mtk_thermal_data mt2712_thermal_= data =3D { > .version =3D MTK_THERMAL_V1, > }; > =20 > +/* > + * The MT6797 thermal controller has six banks. Each bank can read up to > + * four temperature sensors simultaneously. It has a total of 4 > + * temperature sensors used across its banks. > + */ > +static const struct mtk_thermal_data mt6797_thermal_data =3D { [ ... ] > + .version =3D MTK_THERMAL_V1_5, [Severity: Medium] Does selecting MTK_THERMAL_V1_5 trigger undefined behavior from a negative signed left shift in raw_to_mcelsius_v1_5()? Because MediaTek thermal sensors have a negative temperature coefficient, s32 tmp is negative at normal operating temperatures above the calibration room temperature (default 20 C). MT6797 is the first SoC to use raw_to_mcelsius_v1_5(): drivers/thermal/mediatek/auxadc_thermal.c:raw_to_mcelsius_v1_5() { ... tmp =3D tmp - (tmp << 1); return (format_2 + tmp) * 100; } Left-shifting a negative signed integer triggers UBSAN shift-out-of-bounds splats (or traps under CONFIG_UBSAN_TRAP) on every temperature read. Returning (format_2 - tmp) * 100, matching raw_to_mcelsius_v2(), avoids the shift. [Severity: Medium] Can raw_to_mcelsius_v1_5() also report a bogus 0 C reading instead of -ENODATA when an MSR register reads 0? Right after mtk_thermal_probe() registers the thermal zone, TEMP_MSR0..3 can read 0 until the first AUXADC conversion completes (up to 60 ms). raw_to_mcelsius_v1_5() short-circuits raw =3D=3D 0 to return 0 mC, which passes mtk_thermal_temp_is_valid() in mtk_thermal_bank_temperature() instead of being converted to THERMAL_TEMP_INVALID. That causes thermal_zone_get_temp() to return 0 C rather than -ENODATA, and max() across banks will mask valid sub-zero temperatures with 0 C. Returning THERMAL_TEMP_INVALID when raw =3D=3D 0 (or dropping the early return so mtk_thermal_temp_is_valid() rejects it) would prevent this. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203-mt6797-the= rmal-support-v1-0-19595fe11814@protonmail.ch?part=3D4