Skip to content

Commit d9ef02e

Browse files
committed
Merge tag 'thermal-6.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull thermal control fixes from Rafael Wysocki: "These fix a few issues related to the MSI IRQs management in the int340x thermal driver, fix a thermal core issue that may lead to missing trip point crossing events and update the thermal core documentation. Specifics: - Fix MSI error path cleanup in int340x, allow it to work with a subset of thermal MSI IRQs if some of them are not working and make it free all MSI IRQs on module exit (Srinivas Pandruvada) - Fix a thermal core issue that may lead to missing trip point crossing events in some cases when thermal_zone_set_trips() is used and update the thermal core documentation (Rafael Wysocki)" * tag 'thermal-6.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: thermal: core: Update thermal zone registration documentation thermal: trip: Avoid skipping trips in thermal_zone_set_trips() thermal: intel: int340x: Free MSI IRQ vectors on module exit thermal: intel: int340x: Allow limited thermal MSI support thermal: intel: int340x: Fix kernel warning during MSI cleanup
2 parents 041b106 + a090742 commit d9ef02e

File tree

3 files changed

+54
-44
lines changed

3 files changed

+54
-44
lines changed

Documentation/driver-api/thermal/sysfs-api.rst

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ Generic Thermal Sysfs driver How To
44

55
Written by Sujith Thomas <[email protected]>, Zhang Rui <[email protected]>
66

7-
Updated: 2 January 2008
8-
97
Copyright (c) 2008 Intel Corporation
108

119

@@ -38,23 +36,23 @@ temperature) and throttle appropriate devices.
3836

3937
::
4038

41-
struct thermal_zone_device
42-
*thermal_zone_device_register(char *type,
43-
int trips, int mask, void *devdata,
44-
struct thermal_zone_device_ops *ops,
45-
const struct thermal_zone_params *tzp,
46-
int passive_delay, int polling_delay))
39+
struct thermal_zone_device *
40+
thermal_zone_device_register_with_trips(const char *type,
41+
const struct thermal_trip *trips,
42+
int num_trips, void *devdata,
43+
const struct thermal_zone_device_ops *ops,
44+
const struct thermal_zone_params *tzp,
45+
unsigned int passive_delay,
46+
unsigned int polling_delay)
4747
48-
This interface function adds a new thermal zone device (sensor) to
48+
This interface function adds a new thermal zone device (sensor) to the
4949
/sys/class/thermal folder as `thermal_zone[0-*]`. It tries to bind all the
50-
thermal cooling devices registered at the same time.
50+
thermal cooling devices registered to it at the same time.
5151

5252
type:
5353
the thermal zone type.
5454
trips:
55-
the total number of trip points this thermal zone supports.
56-
mask:
57-
Bit string: If 'n'th bit is set, then trip point 'n' is writable.
55+
the table of trip points for this thermal zone.
5856
devdata:
5957
device private data
6058
ops:
@@ -67,32 +65,29 @@ temperature) and throttle appropriate devices.
6765
.get_temp:
6866
get the current temperature of the thermal zone.
6967
.set_trips:
70-
set the trip points window. Whenever the current temperature
71-
is updated, the trip points immediately below and above the
72-
current temperature are found.
73-
.get_mode:
74-
get the current mode (enabled/disabled) of the thermal zone.
75-
76-
- "enabled" means the kernel thermal management is
77-
enabled.
78-
- "disabled" will prevent kernel thermal driver action
79-
upon trip points so that user applications can take
80-
charge of thermal management.
81-
.set_mode:
82-
set the mode (enabled/disabled) of the thermal zone.
83-
.get_trip_type:
84-
get the type of certain trip point.
85-
.get_trip_temp:
86-
get the temperature above which the certain trip point
87-
will be fired.
68+
set the trip points window. Whenever the current temperature
69+
is updated, the trip points immediately below and above the
70+
current temperature are found.
71+
.change_mode:
72+
change the mode (enabled/disabled) of the thermal zone.
73+
.set_trip_temp:
74+
set the temperature of a given trip point.
75+
.get_crit_temp:
76+
get the critical temperature for this thermal zone.
8877
.set_emul_temp:
89-
set the emulation temperature which helps in debugging
90-
different threshold temperature points.
78+
set the emulation temperature which helps in debugging
79+
different threshold temperature points.
80+
.get_trend:
81+
get the trend of most recent zone temperature changes.
82+
.hot:
83+
hot trip point crossing handler.
84+
.critical:
85+
critical trip point crossing handler.
9186
tzp:
9287
thermal zone platform parameters.
9388
passive_delay:
94-
number of milliseconds to wait between polls when
95-
performing passive cooling.
89+
number of milliseconds to wait between polls when performing passive
90+
cooling.
9691
polling_delay:
9792
number of milliseconds to wait between polls when checking
9893
whether trip points have been crossed (0 for interrupt driven systems).

drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,20 +278,32 @@ static struct thermal_zone_params tzone_params = {
278278

279279
static bool msi_irq;
280280

281+
static void proc_thermal_free_msi(struct pci_dev *pdev, struct proc_thermal_pci *pci_info)
282+
{
283+
int i;
284+
285+
for (i = 0; i < MSI_THERMAL_MAX; i++) {
286+
if (proc_thermal_msi_map[i])
287+
devm_free_irq(&pdev->dev, proc_thermal_msi_map[i], pci_info);
288+
}
289+
290+
pci_free_irq_vectors(pdev);
291+
}
292+
281293
static int proc_thermal_setup_msi(struct pci_dev *pdev, struct proc_thermal_pci *pci_info)
282294
{
283-
int ret, i, irq;
295+
int ret, i, irq, count;
284296

285-
ret = pci_alloc_irq_vectors(pdev, 1, MSI_THERMAL_MAX, PCI_IRQ_MSI | PCI_IRQ_MSIX);
286-
if (ret < 0) {
297+
count = pci_alloc_irq_vectors(pdev, 1, MSI_THERMAL_MAX, PCI_IRQ_MSI | PCI_IRQ_MSIX);
298+
if (count < 0) {
287299
dev_err(&pdev->dev, "Failed to allocate vectors!\n");
288-
return ret;
300+
return count;
289301
}
290302

291303
dev_info(&pdev->dev, "msi enabled:%d msix enabled:%d\n", pdev->msi_enabled,
292304
pdev->msix_enabled);
293305

294-
for (i = 0; i < MSI_THERMAL_MAX; i++) {
306+
for (i = 0; i < count; i++) {
295307
irq = pci_irq_vector(pdev, i);
296308

297309
ret = devm_request_threaded_irq(&pdev->dev, irq, proc_thermal_irq_handler,
@@ -310,7 +322,7 @@ static int proc_thermal_setup_msi(struct pci_dev *pdev, struct proc_thermal_pci
310322
return 0;
311323

312324
err_free_msi_vectors:
313-
pci_free_irq_vectors(pdev);
325+
proc_thermal_free_msi(pdev, pci_info);
314326

315327
return ret;
316328
}
@@ -397,7 +409,7 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_
397409

398410
err_free_vectors:
399411
if (msi_irq)
400-
pci_free_irq_vectors(pdev);
412+
proc_thermal_free_msi(pdev, pci_info);
401413
err_ret_tzone:
402414
thermal_zone_device_unregister(pci_info->tzone);
403415
err_del_legacy:
@@ -419,6 +431,9 @@ static void proc_thermal_pci_remove(struct pci_dev *pdev)
419431
proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_THRES_0, 0);
420432
proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_INT_ENABLE_0, 0);
421433

434+
if (msi_irq)
435+
proc_thermal_free_msi(pdev, pci_info);
436+
422437
thermal_zone_device_unregister(pci_info->tzone);
423438
proc_thermal_mmio_remove(pdev, pci_info->proc_priv);
424439
if (!pci_info->no_legacy)

drivers/thermal/thermal_trip.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ void thermal_zone_set_trips(struct thermal_zone_device *tz)
8888
return;
8989

9090
for_each_trip_desc(tz, td) {
91-
if (td->threshold < tz->temperature && td->threshold > low)
91+
if (td->threshold <= tz->temperature && td->threshold > low)
9292
low = td->threshold;
9393

94-
if (td->threshold > tz->temperature && td->threshold < high)
94+
if (td->threshold >= tz->temperature && td->threshold < high)
9595
high = td->threshold;
9696
}
9797

0 commit comments

Comments
 (0)