Skip to content

Commit 523aefb

Browse files
nfrapradogregkh
authored andcommitted
thermal/drivers/mediatek/lvts: Disable low offset IRQ for minimum threshold
[ Upstream commit fa17ff8 ] In order to get working interrupts, a low offset value needs to be configured. The minimum value for it is 20 Celsius, which is what is configured when there's no lower thermal trip (ie the thermal core passes -INT_MAX as low trip temperature). However, when the temperature gets that low and fluctuates around that value it causes an interrupt storm. Prevent that interrupt storm by not enabling the low offset interrupt if the low threshold is the minimum one. Cc: [email protected] Fixes: 77354ea ("thermal/drivers/mediatek/lvts_thermal: Don't leave threshold zeroed") Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Nícolas F. R. A. Prado <[email protected]> Link: https://lore.kernel.org/r/20250113-mt8192-lvts-filtered-suspend-fix-v2-3-07a25200c7c6@collabora.com Signed-off-by: Daniel Lezcano <[email protected]> [ Adapted interrupt mask definitions ] Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1ee0e14 commit 523aefb

File tree

1 file changed

+36
-14
lines changed

1 file changed

+36
-14
lines changed

drivers/thermal/mediatek/lvts_thermal.c

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,14 @@
6666
#define LVTS_TSSEL_CONF 0x13121110
6767
#define LVTS_CALSCALE_CONF 0x300
6868

69-
#define LVTS_MONINT_OFFSET_SENSOR0 0xC
70-
#define LVTS_MONINT_OFFSET_SENSOR1 0x180
71-
#define LVTS_MONINT_OFFSET_SENSOR2 0x3000
72-
#define LVTS_MONINT_OFFSET_SENSOR3 0x3000000
69+
#define LVTS_MONINT_OFFSET_HIGH_INTEN_SENSOR0 BIT(3)
70+
#define LVTS_MONINT_OFFSET_HIGH_INTEN_SENSOR1 BIT(8)
71+
#define LVTS_MONINT_OFFSET_HIGH_INTEN_SENSOR2 BIT(13)
72+
#define LVTS_MONINT_OFFSET_HIGH_INTEN_SENSOR3 BIT(25)
73+
#define LVTS_MONINT_OFFSET_LOW_INTEN_SENSOR0 BIT(2)
74+
#define LVTS_MONINT_OFFSET_LOW_INTEN_SENSOR1 BIT(7)
75+
#define LVTS_MONINT_OFFSET_LOW_INTEN_SENSOR2 BIT(12)
76+
#define LVTS_MONINT_OFFSET_LOW_INTEN_SENSOR3 BIT(24)
7377

7478
#define LVTS_INT_SENSOR0 0x0009001F
7579
#define LVTS_INT_SENSOR1 0x001203E0
@@ -329,23 +333,41 @@ static int lvts_get_temp(struct thermal_zone_device *tz, int *temp)
329333

330334
static void lvts_update_irq_mask(struct lvts_ctrl *lvts_ctrl)
331335
{
332-
u32 masks[] = {
333-
LVTS_MONINT_OFFSET_SENSOR0,
334-
LVTS_MONINT_OFFSET_SENSOR1,
335-
LVTS_MONINT_OFFSET_SENSOR2,
336-
LVTS_MONINT_OFFSET_SENSOR3,
336+
static const u32 high_offset_inten_masks[] = {
337+
LVTS_MONINT_OFFSET_HIGH_INTEN_SENSOR0,
338+
LVTS_MONINT_OFFSET_HIGH_INTEN_SENSOR1,
339+
LVTS_MONINT_OFFSET_HIGH_INTEN_SENSOR2,
340+
LVTS_MONINT_OFFSET_HIGH_INTEN_SENSOR3,
341+
};
342+
static const u32 low_offset_inten_masks[] = {
343+
LVTS_MONINT_OFFSET_LOW_INTEN_SENSOR0,
344+
LVTS_MONINT_OFFSET_LOW_INTEN_SENSOR1,
345+
LVTS_MONINT_OFFSET_LOW_INTEN_SENSOR2,
346+
LVTS_MONINT_OFFSET_LOW_INTEN_SENSOR3,
337347
};
338348
u32 value = 0;
339349
int i;
340350

341351
value = readl(LVTS_MONINT(lvts_ctrl->base));
342352

343-
for (i = 0; i < ARRAY_SIZE(masks); i++) {
353+
for (i = 0; i < ARRAY_SIZE(high_offset_inten_masks); i++) {
344354
if (lvts_ctrl->sensors[i].high_thresh == lvts_ctrl->high_thresh
345-
&& lvts_ctrl->sensors[i].low_thresh == lvts_ctrl->low_thresh)
346-
value |= masks[i];
347-
else
348-
value &= ~masks[i];
355+
&& lvts_ctrl->sensors[i].low_thresh == lvts_ctrl->low_thresh) {
356+
/*
357+
* The minimum threshold needs to be configured in the
358+
* OFFSETL register to get working interrupts, but we
359+
* don't actually want to generate interrupts when
360+
* crossing it.
361+
*/
362+
if (lvts_ctrl->low_thresh == -INT_MAX) {
363+
value &= ~low_offset_inten_masks[i];
364+
value |= high_offset_inten_masks[i];
365+
} else {
366+
value |= low_offset_inten_masks[i] | high_offset_inten_masks[i];
367+
}
368+
} else {
369+
value &= ~(low_offset_inten_masks[i] | high_offset_inten_masks[i]);
370+
}
349371
}
350372

351373
writel(value, LVTS_MONINT(lvts_ctrl->base));

0 commit comments

Comments
 (0)