Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] thermal/drivers/mediatek/lvts: CALSCALE, overflow, trip, and IRQ fixes
@ 2026-12-03  2:19 Ilia Snezhkov via B4 Relay
  2026-12-03  2:19 ` [PATCH v2 1/5] thermal/drivers/mediatek/lvts: write LVTS_CALSCALE in configure Ilia Snezhkov via B4 Relay
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Ilia Snezhkov via B4 Relay @ 2026-12-03  2:19 UTC (permalink / raw)
  To: daniel.lezcano, rafael, rui.zhang, lukasz.luba
  Cc: matthias.bgg, angelogioacchino.delregno, bchihi, nfraprado,
	linux-pm, linux-mediatek, linux-arm-kernel, phone-devel,
	linux-kernel

This five-patch series fixes bugs in
drivers/thermal/mediatek/lvts_thermal.c:

1. Write LVTS_CALSCALE_CONF (0x300) to LVTS_CALSCALE instead of
   overwriting a local variable and discarding it.
2. Avoid 32-bit overflow, negative left shift, and unsigned wraparound
   in lvts_temp_to_raw_mt7988().
3. Serialize lvts_set_trips() with a per-controller spinlock_t so
   concurrent updates across sibling thermal zones cannot race on
   shared thresholds or LVTS_MONINT.
4. Recompute shared controller thresholds safely across sibling sensors
   (excluding INT_MAX from winning high_thresh, falling back to the
   next highest finite sibling on cooldown, matching low/high IRQ masks
   independently, skipping lvts_temp_to_raw(INT_MAX), and masking
   offset IRQs before writing LVTS_OFFSETL/LVTS_OFFSETH).
5. Check lvts_ctrl->sensors[i].tz before calling
   thermal_zone_device_update() in lvts_ctrl_irq_handler().

---
v1: https://lore.kernel.org/r/20261126005321.71799-1-iasnezhkov@gmail.com

Changes in v2:
- Split the INT_MAX trip handling out of patch 2/5 so patch 2/5 only
  fixes lvts_temp_to_raw_mt7988() (now returning 0 early when
  golden_temp_offset - temperature <= 0 to avoid shifting a negative
  s64) and corrected the golden_temp boundary example in its commit
  message (LVTS_GOLDEN_TEMP_MAX is 62, not 64).
- Added patch 4/5 combining the INT_MAX trip handling with full sibling
  threshold recomputation (lvts_recompute_thresh()), independent
  low/high IRQ mask matching, leaving LVTS_OFFSETH untouched when
  new_high == INT_MAX, and masking offset IRQs before writing
  LVTS_OFFSETL/LVTS_OFFSETH.
- Shortened patch subjects and normalized prefix to
  "thermal/drivers/mediatek/lvts:".

Testing note:
- Patches 1, 2, 3, and 5 were regression-tested on MT6789 hardware
  (iKKO MindOne, factory golden_temp = 60) in an out-of-tree port of
  lvts_thermal.c on ACK 6.18 (the unpopulated-tz IRQ path in patch 5
  was not directly triggered on this hardware).
- The exact lvts_temp_to_raw_mt7988() boundary cases and the patch 4/5
  lvts_recompute_thresh() / MMIO write-ordering state machine were
  verified in a host userspace test harness under ASan and UBSan, not
  directly on mainline hardware.

Found and drafted with an AI coding assistant.

Ilia Snezhkov (5):
  thermal/drivers/mediatek/lvts: write LVTS_CALSCALE in configure
  thermal/drivers/mediatek/lvts: fix 32-bit overflow in temp_to_raw
  thermal/drivers/mediatek/lvts: serialize lvts_set_trips() per ctrl
  thermal/drivers/mediatek/lvts: recompute shared trips and mask first
  thermal/drivers/mediatek/lvts: skip sensors without tz in IRQ

 drivers/thermal/mediatek/lvts_thermal.c | 220 +++++++++++++++---------
 1 file changed, 142 insertions(+), 78 deletions(-)

-- 
2.54.0 (Apple Git-157)





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-12-03  2:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03  2:19 [PATCH v2 0/5] thermal/drivers/mediatek/lvts: CALSCALE, overflow, trip, and IRQ fixes Ilia Snezhkov via B4 Relay
2026-12-03  2:19 ` [PATCH v2 1/5] thermal/drivers/mediatek/lvts: write LVTS_CALSCALE in configure Ilia Snezhkov via B4 Relay
2026-12-03  2:19 ` [PATCH v2 2/5] thermal/drivers/mediatek/lvts: fix 32-bit overflow in temp_to_raw Ilia Snezhkov via B4 Relay
2026-12-03  2:19 ` [PATCH v2 3/5] thermal/drivers/mediatek/lvts: serialize lvts_set_trips() per ctrl Ilia Snezhkov via B4 Relay
2026-12-03  2:20 ` [PATCH v2 4/5] thermal/drivers/mediatek/lvts: recompute shared trips and mask first Ilia Snezhkov via B4 Relay
2026-12-03  2:20 ` [PATCH v2 5/5] thermal/drivers/mediatek/lvts: skip sensors without tz in IRQ Ilia Snezhkov via B4 Relay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox