Re: [PATCH] thermal/drivers/tegra: Sign-extend the extracted shifted_cp
From: Svyatoslav Ryhel
Date: Sun Nov 22 2026 - 02:12:46 EST
нд, 22 лист. 2026 р. о 07:12 EMCP333 via B4 Relay
<devnull+emcp.enser.io@xxxxxxxxxx> пише:
>
> From: EMCP333 <emcp@xxxxxxxx>
>
> tegra_calc_shared_calib() extracts shifted_cp from its mask and shift,
> then throws that value away on the next line and sign-extends the raw
> fuse word instead:
>
> shifted_cp = (val & tfuse->fuse_shift_cp_mask) >>
> tfuse->fuse_shift_cp_shift;
> shifted_cp = sign_extend32(val, 5);
>
> shifted_ft, two lines above, is sign-extended from the extracted value,
> which shows the intent.
>
> This was harmless while every supported SoC placed the field at bit 0:
> tegra124, tegra132 and tegra210 all have fuse_shift_cp_shift = 0, so the
> masked extraction and sign_extend32(val, 5) name the same bits. Tegra114
> has fuse_shift_cp_mask = 0x3f << 10 and fuse_shift_cp_shift = 10, so it
> reads bits [5:0] of FUSE_VSENSOR_CALIB instead, which belong to base_cp.
> actual_temp_cp, and with it the THERMA/THERMB coefficients programmed into
> SENSOR_CONFIG2, come out wrong. The hardware then flags most conversions
> as overflowed and never publishes them.
>
> On a Tegra Note 7 (Tegra114) seven of the eight sensors report an
> overflow with TEMP_VALID = 0, their thermctl group registers stay at
> zero, and cpu-thermal, gpu-thermal and pllx-thermal read 0 in sysfs. Only
> mem-thermal reads a temperature. cpu-thermal carries the passive trip and
> the cpufreq cooling device, so software throttling never engages. The
> hardware thermtrip compares against the sensors directly and is not
> affected.
>
> With this change all four zones read plausible, distinct and moving
> temperatures (cpu 32.5-33.5, gpu 30.5-31, pllx 34-35.5, mem 31-31.5 C on
> an idle unit).
>
> The code and this changelog were prepared with the help of an AI coding
> assistant. The submitter has reviewed both and takes responsibility for
> them.
>
> Fixes: 65b6d57c24ed ("thermal: tegra: split tegra_soctherm driver")
> Signed-off-by: EMCP333 <emcp@xxxxxxxx>
> ---
> drivers/thermal/tegra/soctherm-fuse.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/tegra/soctherm-fuse.c b/drivers/thermal/tegra/soctherm-fuse.c
> index 8d37cd8c91..2de1d0cb67 100644
> --- a/drivers/thermal/tegra/soctherm-fuse.c
> +++ b/drivers/thermal/tegra/soctherm-fuse.c
> @@ -102,7 +102,7 @@ int tegra_calc_shared_calib(const struct tegra_soctherm_fuse *tfuse,
>
> shifted_cp = (val & tfuse->fuse_shift_cp_mask) >>
> tfuse->fuse_shift_cp_shift;
> - shifted_cp = sign_extend32(val, 5);
> + shifted_cp = sign_extend32(shifted_cp, 5);
>
> shared->actual_temp_cp = 2 * NOMINAL_CALIB_CP + shifted_cp;
> shared->actual_temp_ft = 2 * tfuse->nominal_calib_ft + shifted_ft;
>
> ---
> base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
> change-id: 20261122-b4-tegra-soctherm-shifted-cp-a3b27f666f1d
>
> Best regards,
> --
> EMCP333 <emcp@xxxxxxxx>
>
>
I wonder if this is AI slopped, or straight up stolen?
Existing patch sent 6th of Nov 2026:
https://lore.kernel.org/lkml/20261106-upstream-soctherm-t114-v1-1-c875d1921084@xxxxxxxxxxxxxxxxxx/