Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 281cfec

Browse files
committed
Merge branch 'thermal-intel'
Merge updates of Intel thermal drivers for 6.11-rc1: - Switch Intel thermal drivers to new Intel CPU model defines (Tony Luck). - Clean up the int3400 and int3403 drivers (Erick Archer and David Alan Gilbert). - Improve intel_pch_thermal kernel log messages printed during suspend to idle (Zhang Rui). - Make the intel_tcc_cooling driver use a model-specific bitmask for TCC offset (Ricardo Neri). - Add DLVR and MSI interrupt support for the Lunar Lake platform to the int340x thermal driver (Srinivas Pandruvada). - Enable workload type hints (WLT) support and power floor interrupt support for the Lunar Lake platform in int340x ((Srinivas Pandruvada). - Make the HFI thermal driver use package scope for HFI instances as per the Intel SDM (Zhang Rui). * thermal-intel: thermal: intel: hfi: Give HFI instances package scope thermal: intel: int340x: Enable WLT and power floor support for Lunar Lake thermal: intel: int340x: Support MSI interrupt for Lunar Lake thermal: intel: int340x: Remove unnecessary calls to free irq thermal: intel: int340x: Add DLVR support for Lunar Lake thermal: intel: int340x: Capability to map user space to firmware values thermal: intel: int340x: Cleanup of DLVR sysfs on driver remove thermal: intel: intel_tcc_cooling: Use a model-specific bitmask for TCC offset thermal: intel: intel_tcc: Add model checks for temperature registers thermal: intel: intel_pch: Improve cooling log thermal: int3403: remove unused struct 'int3403_performance_state' thermal: int3400: Use sizeof(*pointer) instead of sizeof(type) thermal: intel: intel_soc_dts_thermal: Switch to new Intel CPU model defines thermal: intel: intel_tcc_cooling: Switch to new Intel CPU model defines
2 parents ab33da3 + b755367 commit 281cfec

13 files changed

+419
-85
lines changed

drivers/thermal/intel/int340x_thermal/int3400_thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ static int int3400_thermal_probe(struct platform_device *pdev)
571571
if (!adev)
572572
return -ENODEV;
573573

574-
priv = kzalloc(sizeof(struct int3400_thermal_priv), GFP_KERNEL);
574+
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
575575
if (!priv)
576576
return -ENOMEM;
577577

drivers/thermal/intel/int340x_thermal/int3403_thermal.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,6 @@ struct int3403_sensor {
2525
struct int34x_thermal_zone *int340x_zone;
2626
};
2727

28-
struct int3403_performance_state {
29-
u64 performance;
30-
u64 power;
31-
u64 latency;
32-
u64 linear;
33-
u64 control;
34-
u64 raw_performace;
35-
char *raw_unit;
36-
int reserved;
37-
};
38-
3928
struct int3403_cdev {
4029
struct thermal_cooling_device *cdev;
4130
unsigned long max_state;

drivers/thermal/intel/int340x_thermal/processor_thermal_device.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,8 @@ void proc_thermal_mmio_remove(struct pci_dev *pdev, struct proc_thermal_device *
440440
proc_thermal_rapl_remove();
441441

442442
if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_FIVR ||
443-
proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_DVFS)
443+
proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_DVFS ||
444+
proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_DLVR)
444445
proc_thermal_rfim_remove(pdev);
445446

446447
if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_POWER_FLOOR)

drivers/thermal/intel/int340x_thermal/processor_thermal_device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct rapl_mmio_regs {
6565
#define PROC_THERMAL_FEATURE_DLVR 0x10
6666
#define PROC_THERMAL_FEATURE_WT_HINT 0x20
6767
#define PROC_THERMAL_FEATURE_POWER_FLOOR 0x40
68+
#define PROC_THERMAL_FEATURE_MSI_SUPPORT 0x80
6869

6970
#if IS_ENABLED(CONFIG_PROC_THERMAL_MMIO_RAPL)
7071
int proc_thermal_rapl_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);

drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c

Lines changed: 90 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ static struct proc_thermal_mmio_info proc_thermal_mmio_info[] = {
6363
{ PROC_THERMAL_MMIO_INT_STATUS_1, 0x7200, 8, 0x01 },
6464
};
6565

66+
/* List of supported MSI IDs (sources) */
67+
enum proc_thermal_msi_ids {
68+
PKG_THERMAL,
69+
DDR_THERMAL,
70+
THERM_POWER_FLOOR,
71+
WORKLOAD_CHANGE,
72+
MSI_THERMAL_MAX
73+
};
74+
75+
/* Stores IRQ associated with a MSI ID */
76+
static int proc_thermal_msi_map[MSI_THERMAL_MAX];
77+
6678
#define B0D4_THERMAL_NOTIFY_DELAY 1000
6779
static int notify_delay_ms = B0D4_THERMAL_NOTIFY_DELAY;
6880

@@ -146,22 +158,41 @@ static irqreturn_t proc_thermal_irq_thread_handler(int irq, void *devid)
146158
return IRQ_HANDLED;
147159
}
148160

161+
static int proc_thermal_match_msi_irq(int irq)
162+
{
163+
int i;
164+
165+
if (!use_msi)
166+
goto msi_fail;
167+
168+
for (i = 0; i < MSI_THERMAL_MAX; i++) {
169+
if (proc_thermal_msi_map[i] == irq)
170+
return i;
171+
}
172+
173+
msi_fail:
174+
return -EOPNOTSUPP;
175+
}
176+
149177
static irqreturn_t proc_thermal_irq_handler(int irq, void *devid)
150178
{
151179
struct proc_thermal_pci *pci_info = devid;
152180
struct proc_thermal_device *proc_priv;
153-
int ret = IRQ_NONE;
181+
int ret = IRQ_NONE, msi_id;
154182
u32 status;
155183

156184
proc_priv = pci_info->proc_priv;
157185

186+
msi_id = proc_thermal_match_msi_irq(irq);
187+
158188
if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_WT_HINT) {
159-
if (proc_thermal_check_wt_intr(pci_info->proc_priv))
189+
if (msi_id == WORKLOAD_CHANGE || proc_thermal_check_wt_intr(pci_info->proc_priv))
160190
ret = IRQ_WAKE_THREAD;
161191
}
162192

163193
if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_POWER_FLOOR) {
164-
if (proc_thermal_check_power_floor_intr(pci_info->proc_priv))
194+
if (msi_id == THERM_POWER_FLOOR ||
195+
proc_thermal_check_power_floor_intr(pci_info->proc_priv))
165196
ret = IRQ_WAKE_THREAD;
166197
}
167198

@@ -171,7 +202,7 @@ static irqreturn_t proc_thermal_irq_handler(int irq, void *devid)
171202
* interrupt before scheduling work function for thermal threshold.
172203
*/
173204
proc_thermal_mmio_read(pci_info, PROC_THERMAL_MMIO_INT_STATUS_0, &status);
174-
if (status) {
205+
if (msi_id == PKG_THERMAL || status) {
175206
/* Disable enable interrupt flag */
176207
proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_INT_ENABLE_0, 0);
177208
pkg_thermal_schedule_work(&pci_info->work);
@@ -245,6 +276,45 @@ static struct thermal_zone_params tzone_params = {
245276
.no_hwmon = true,
246277
};
247278

279+
static bool msi_irq;
280+
281+
static int proc_thermal_setup_msi(struct pci_dev *pdev, struct proc_thermal_pci *pci_info)
282+
{
283+
int ret, i, irq;
284+
285+
ret = pci_alloc_irq_vectors(pdev, 1, MSI_THERMAL_MAX, PCI_IRQ_MSI | PCI_IRQ_MSIX);
286+
if (ret < 0) {
287+
dev_err(&pdev->dev, "Failed to allocate vectors!\n");
288+
return ret;
289+
}
290+
291+
dev_info(&pdev->dev, "msi enabled:%d msix enabled:%d\n", pdev->msi_enabled,
292+
pdev->msix_enabled);
293+
294+
for (i = 0; i < MSI_THERMAL_MAX; i++) {
295+
irq = pci_irq_vector(pdev, i);
296+
297+
ret = devm_request_threaded_irq(&pdev->dev, irq, proc_thermal_irq_handler,
298+
proc_thermal_irq_thread_handler,
299+
0, KBUILD_MODNAME, pci_info);
300+
if (ret) {
301+
dev_err(&pdev->dev, "Request IRQ %d failed\n", irq);
302+
goto err_free_msi_vectors;
303+
}
304+
305+
proc_thermal_msi_map[i] = irq;
306+
}
307+
308+
msi_irq = true;
309+
310+
return 0;
311+
312+
err_free_msi_vectors:
313+
pci_free_irq_vectors(pdev);
314+
315+
return ret;
316+
}
317+
248318
static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
249319
{
250320
struct proc_thermal_device *proc_priv;
@@ -254,7 +324,6 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_
254324
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
255325
};
256326
int irq_flag = 0, irq, ret;
257-
bool msi_irq = false;
258327

259328
proc_priv = devm_kzalloc(&pdev->dev, sizeof(*proc_priv), GFP_KERNEL);
260329
if (!proc_priv)
@@ -300,27 +369,24 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_
300369
goto err_del_legacy;
301370
}
302371

303-
if (use_msi && (pdev->msi_enabled || pdev->msix_enabled)) {
304-
/* request and enable interrupt */
305-
ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
306-
if (ret < 0) {
307-
dev_err(&pdev->dev, "Failed to allocate vectors!\n");
308-
goto err_ret_tzone;
309-
}
372+
if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_MSI_SUPPORT)
373+
use_msi = true;
310374

311-
irq = pci_irq_vector(pdev, 0);
312-
msi_irq = true;
375+
if (use_msi) {
376+
ret = proc_thermal_setup_msi(pdev, pci_info);
377+
if (ret)
378+
goto err_ret_tzone;
313379
} else {
314380
irq_flag = IRQF_SHARED;
315381
irq = pdev->irq;
316-
}
317382

318-
ret = devm_request_threaded_irq(&pdev->dev, irq,
319-
proc_thermal_irq_handler, proc_thermal_irq_thread_handler,
320-
irq_flag, KBUILD_MODNAME, pci_info);
321-
if (ret) {
322-
dev_err(&pdev->dev, "Request IRQ %d failed\n", pdev->irq);
323-
goto err_free_vectors;
383+
ret = devm_request_threaded_irq(&pdev->dev, irq, proc_thermal_irq_handler,
384+
proc_thermal_irq_thread_handler, irq_flag,
385+
KBUILD_MODNAME, pci_info);
386+
if (ret) {
387+
dev_err(&pdev->dev, "Request IRQ %d failed\n", pdev->irq);
388+
goto err_ret_tzone;
389+
}
324390
}
325391

326392
ret = thermal_zone_device_enable(pci_info->tzone);
@@ -353,9 +419,6 @@ static void proc_thermal_pci_remove(struct pci_dev *pdev)
353419
proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_THRES_0, 0);
354420
proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_INT_ENABLE_0, 0);
355421

356-
devm_free_irq(&pdev->dev, pdev->irq, pci_info);
357-
pci_free_irq_vectors(pdev);
358-
359422
thermal_zone_device_unregister(pci_info->tzone);
360423
proc_thermal_mmio_remove(pdev, pci_info->proc_priv);
361424
if (!pci_info->no_legacy)
@@ -409,7 +472,9 @@ static SIMPLE_DEV_PM_OPS(proc_thermal_pci_pm, proc_thermal_pci_suspend,
409472
static const struct pci_device_id proc_thermal_pci_ids[] = {
410473
{ PCI_DEVICE_DATA(INTEL, ADL_THERMAL, PROC_THERMAL_FEATURE_RAPL |
411474
PROC_THERMAL_FEATURE_FIVR | PROC_THERMAL_FEATURE_DVFS | PROC_THERMAL_FEATURE_WT_REQ) },
412-
{ PCI_DEVICE_DATA(INTEL, LNLM_THERMAL, PROC_THERMAL_FEATURE_RAPL) },
475+
{ PCI_DEVICE_DATA(INTEL, LNLM_THERMAL, PROC_THERMAL_FEATURE_MSI_SUPPORT |
476+
PROC_THERMAL_FEATURE_RAPL | PROC_THERMAL_FEATURE_DLVR |
477+
PROC_THERMAL_FEATURE_WT_HINT | PROC_THERMAL_FEATURE_POWER_FLOOR) },
413478
{ PCI_DEVICE_DATA(INTEL, MTLP_THERMAL, PROC_THERMAL_FEATURE_RAPL |
414479
PROC_THERMAL_FEATURE_FIVR | PROC_THERMAL_FEATURE_DVFS | PROC_THERMAL_FEATURE_DLVR |
415480
PROC_THERMAL_FEATURE_WT_HINT | PROC_THERMAL_FEATURE_POWER_FLOOR) },

0 commit comments

Comments
 (0)