Skip to content

Commit fbe7ef3

Browse files
committed
Merge tag 'thermal-6.10-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull thermal control fixes from Rafael Wysocki: "These fix the Mediatek lvts_thermal driver, the Intel int340x driver, and the thermal core (two issues related to system suspend). Specifics: - Remove the filtered mode for mt8188 from lvts_thermal as it is not supported on this platform and fail the lvts_thermal initialization when the golden temperature is zero as that means the efuse data is not correctly set (Julien Panis) - Update the processor_thermal part of the Intel int340x driver to support shared interrupts as the processor thermal device interrupt may in fact be shared with PCI devices (Srinivas Pandruvada) - Synchronize the suspend-prepare and post-suspend actions of the thermal PM notifier to avoid a destructive race condition and change the priority of that notifier to the minimum to avoid interference between the work items spawned by it and the other PM notifiers during system resume (Rafael Wysocki)" * tag 'thermal-6.10-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: thermal: int340x: processor_thermal: Support shared interrupts thermal: core: Change PM notifier priority to the minimum thermal: core: Synchronize suspend-prepare and post-suspend actions thermal/drivers/mediatek/lvts_thermal: Return error in case of invalid efuse data thermal/drivers/mediatek/lvts_thermal: Remove filtered mode for mt8188
2 parents 66cc544 + 096597c commit fbe7ef3

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed

drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static irqreturn_t proc_thermal_irq_handler(int irq, void *devid)
150150
{
151151
struct proc_thermal_pci *pci_info = devid;
152152
struct proc_thermal_device *proc_priv;
153-
int ret = IRQ_HANDLED;
153+
int ret = IRQ_NONE;
154154
u32 status;
155155

156156
proc_priv = pci_info->proc_priv;
@@ -175,6 +175,7 @@ static irqreturn_t proc_thermal_irq_handler(int irq, void *devid)
175175
/* Disable enable interrupt flag */
176176
proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_INT_ENABLE_0, 0);
177177
pkg_thermal_schedule_work(&pci_info->work);
178+
ret = IRQ_HANDLED;
178179
}
179180

180181
pci_write_config_byte(pci_info->pdev, 0xdc, 0x01);

drivers/thermal/mediatek/lvts_thermal.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,11 @@ static int lvts_golden_temp_init(struct device *dev, u8 *calib,
769769
*/
770770
gt = (((u32 *)calib)[0] >> lvts_data->gt_calib_bit_offset) & 0xff;
771771

772-
if (gt && gt < LVTS_GOLDEN_TEMP_MAX)
772+
/* A zero value for gt means that device has invalid efuse data */
773+
if (!gt)
774+
return -ENODATA;
775+
776+
if (gt < LVTS_GOLDEN_TEMP_MAX)
773777
golden_temp = gt;
774778

775779
golden_temp_offset = golden_temp * 500 + lvts_data->temp_offset;
@@ -1458,7 +1462,6 @@ static const struct lvts_ctrl_data mt8188_lvts_mcu_data_ctrl[] = {
14581462
},
14591463
VALID_SENSOR_MAP(1, 1, 1, 1),
14601464
.offset = 0x0,
1461-
.mode = LVTS_MSR_FILTERED_MODE,
14621465
},
14631466
{
14641467
.lvts_sensor = {
@@ -1469,7 +1472,6 @@ static const struct lvts_ctrl_data mt8188_lvts_mcu_data_ctrl[] = {
14691472
},
14701473
VALID_SENSOR_MAP(1, 1, 0, 0),
14711474
.offset = 0x100,
1472-
.mode = LVTS_MSR_FILTERED_MODE,
14731475
}
14741476
};
14751477

@@ -1483,7 +1485,6 @@ static const struct lvts_ctrl_data mt8188_lvts_ap_data_ctrl[] = {
14831485
},
14841486
VALID_SENSOR_MAP(0, 1, 0, 0),
14851487
.offset = 0x0,
1486-
.mode = LVTS_MSR_FILTERED_MODE,
14871488
},
14881489
{
14891490
.lvts_sensor = {
@@ -1496,7 +1497,6 @@ static const struct lvts_ctrl_data mt8188_lvts_ap_data_ctrl[] = {
14961497
},
14971498
VALID_SENSOR_MAP(1, 1, 1, 0),
14981499
.offset = 0x100,
1499-
.mode = LVTS_MSR_FILTERED_MODE,
15001500
},
15011501
{
15021502
.lvts_sensor = {
@@ -1507,7 +1507,6 @@ static const struct lvts_ctrl_data mt8188_lvts_ap_data_ctrl[] = {
15071507
},
15081508
VALID_SENSOR_MAP(1, 1, 0, 0),
15091509
.offset = 0x200,
1510-
.mode = LVTS_MSR_FILTERED_MODE,
15111510
},
15121511
{
15131512
.lvts_sensor = {
@@ -1518,7 +1517,6 @@ static const struct lvts_ctrl_data mt8188_lvts_ap_data_ctrl[] = {
15181517
},
15191518
VALID_SENSOR_MAP(1, 1, 0, 0),
15201519
.offset = 0x300,
1521-
.mode = LVTS_MSR_FILTERED_MODE,
15221520
}
15231521
};
15241522

drivers/thermal/thermal_core.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,7 @@ thermal_zone_device_register_with_trips(const char *type,
14061406
ida_init(&tz->ida);
14071407
mutex_init(&tz->lock);
14081408
init_completion(&tz->removal);
1409+
init_completion(&tz->resume);
14091410
id = ida_alloc(&thermal_tz_ida, GFP_KERNEL);
14101411
if (id < 0) {
14111412
result = id;
@@ -1651,6 +1652,9 @@ static void thermal_zone_device_resume(struct work_struct *work)
16511652
thermal_zone_device_init(tz);
16521653
__thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
16531654

1655+
complete(&tz->resume);
1656+
tz->resuming = false;
1657+
16541658
mutex_unlock(&tz->lock);
16551659
}
16561660

@@ -1668,6 +1672,20 @@ static int thermal_pm_notify(struct notifier_block *nb,
16681672
list_for_each_entry(tz, &thermal_tz_list, node) {
16691673
mutex_lock(&tz->lock);
16701674

1675+
if (tz->resuming) {
1676+
/*
1677+
* thermal_zone_device_resume() queued up for
1678+
* this zone has not acquired the lock yet, so
1679+
* release it to let the function run and wait
1680+
* util it has done the work.
1681+
*/
1682+
mutex_unlock(&tz->lock);
1683+
1684+
wait_for_completion(&tz->resume);
1685+
1686+
mutex_lock(&tz->lock);
1687+
}
1688+
16711689
tz->suspended = true;
16721690

16731691
mutex_unlock(&tz->lock);
@@ -1685,6 +1703,9 @@ static int thermal_pm_notify(struct notifier_block *nb,
16851703

16861704
cancel_delayed_work(&tz->poll_queue);
16871705

1706+
reinit_completion(&tz->resume);
1707+
tz->resuming = true;
1708+
16881709
/*
16891710
* Replace the work function with the resume one, which
16901711
* will restore the original work function and schedule
@@ -1709,6 +1730,12 @@ static int thermal_pm_notify(struct notifier_block *nb,
17091730

17101731
static struct notifier_block thermal_pm_nb = {
17111732
.notifier_call = thermal_pm_notify,
1733+
/*
1734+
* Run at the lowest priority to avoid interference between the thermal
1735+
* zone resume work items spawned by thermal_pm_notify() and the other
1736+
* PM notifiers.
1737+
*/
1738+
.priority = INT_MIN,
17121739
};
17131740

17141741
static int __init thermal_init(void)

drivers/thermal/thermal_core.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ struct thermal_governor {
5555
* @type: the thermal zone device type
5656
* @device: &struct device for this thermal zone
5757
* @removal: removal completion
58+
* @resume: resume completion
5859
* @trip_temp_attrs: attributes for trip points for sysfs: trip temperature
5960
* @trip_type_attrs: attributes for trip points for sysfs: trip type
6061
* @trip_hyst_attrs: attributes for trip points for sysfs: trip hysteresis
@@ -89,13 +90,15 @@ struct thermal_governor {
8990
* @poll_queue: delayed work for polling
9091
* @notify_event: Last notification event
9192
* @suspended: thermal zone suspend indicator
93+
* @resuming: indicates whether or not thermal zone resume is in progress
9294
* @trips: array of struct thermal_trip objects
9395
*/
9496
struct thermal_zone_device {
9597
int id;
9698
char type[THERMAL_NAME_LENGTH];
9799
struct device device;
98100
struct completion removal;
101+
struct completion resume;
99102
struct attribute_group trips_attribute_group;
100103
struct thermal_attr *trip_temp_attrs;
101104
struct thermal_attr *trip_type_attrs;
@@ -123,6 +126,7 @@ struct thermal_zone_device {
123126
struct delayed_work poll_queue;
124127
enum thermal_notify_event notify_event;
125128
bool suspended;
129+
bool resuming;
126130
#ifdef CONFIG_THERMAL_DEBUGFS
127131
struct thermal_debugfs *debugfs;
128132
#endif

0 commit comments

Comments
 (0)