Skip to content

Commit e682b86

Browse files
spandruvadarafaeljw
authored andcommitted
thermal: int340x: Handle workload hint interrupts
On thermal device interrupt, if the interrupt is generated for passing workload hint, call the callback to pass notification to the user space. First call proc_thermal_check_wt_intr() to check interrupt, if this callback returns true, wake the IRQ thread to call proc_thermal_wt_intr_callback() to notify user space. Signed-off-by: Srinivas Pandruvada <[email protected]> [ rjw: Subject adjustment, changelog edits ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 4b029a8 commit e682b86

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,43 @@ static void pkg_thermal_schedule_work(struct delayed_work *work)
122122
schedule_delayed_work(work, ms);
123123
}
124124

125+
static irqreturn_t proc_thermal_irq_thread_handler(int irq, void *devid)
126+
{
127+
struct proc_thermal_pci *pci_info = devid;
128+
129+
proc_thermal_wt_intr_callback(pci_info->pdev, pci_info->proc_priv);
130+
131+
return IRQ_HANDLED;
132+
}
133+
125134
static irqreturn_t proc_thermal_irq_handler(int irq, void *devid)
126135
{
127136
struct proc_thermal_pci *pci_info = devid;
137+
struct proc_thermal_device *proc_priv;
138+
int ret = IRQ_HANDLED;
128139
u32 status;
129140

130-
proc_thermal_mmio_read(pci_info, PROC_THERMAL_MMIO_INT_STATUS_0, &status);
141+
proc_priv = pci_info->proc_priv;
131142

132-
/* Disable enable interrupt flag */
133-
proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_INT_ENABLE_0, 0);
134-
pci_write_config_byte(pci_info->pdev, 0xdc, 0x01);
143+
if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_WT_HINT) {
144+
if (proc_thermal_check_wt_intr(pci_info->proc_priv))
145+
ret = IRQ_WAKE_THREAD;
146+
}
135147

136-
pkg_thermal_schedule_work(&pci_info->work);
148+
/*
149+
* Since now there are two sources of interrupts: one from thermal threshold
150+
* and another from workload hint, add a check if there was really a threshold
151+
* interrupt before scheduling work function for thermal threshold.
152+
*/
153+
proc_thermal_mmio_read(pci_info, PROC_THERMAL_MMIO_INT_STATUS_0, &status);
154+
if (status) {
155+
/* Disable enable interrupt flag */
156+
proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_INT_ENABLE_0, 0);
157+
pci_write_config_byte(pci_info->pdev, 0xdc, 0x01);
158+
pkg_thermal_schedule_work(&pci_info->work);
159+
}
137160

138-
return IRQ_HANDLED;
161+
return ret;
139162
}
140163

141164
static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp)
@@ -270,7 +293,7 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_
270293
}
271294

272295
ret = devm_request_threaded_irq(&pdev->dev, irq,
273-
proc_thermal_irq_handler, NULL,
296+
proc_thermal_irq_handler, proc_thermal_irq_thread_handler,
274297
irq_flag, KBUILD_MODNAME, pci_info);
275298
if (ret) {
276299
dev_err(&pdev->dev, "Request IRQ %d failed\n", pdev->irq);
@@ -384,6 +407,8 @@ static struct pci_driver proc_thermal_pci_driver = {
384407

385408
module_pci_driver(proc_thermal_pci_driver);
386409

410+
MODULE_IMPORT_NS(INT340X_THERMAL);
411+
387412
MODULE_AUTHOR("Srinivas Pandruvada <[email protected]>");
388413
MODULE_DESCRIPTION("Processor Thermal Reporting Device Driver");
389414
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)