Skip to content

Commit e643eda

Browse files
committed
Merge tag 'pm-6.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management fixes from Rafael Wysocki: "These address two issues in the TPMI module of the Intel RAPL power capping driver and one issue in the processor part of the Intel int340x thermal driver, update a CPU ID list and register definitions needed for RAPL PL4 support and remove some unused code. Specifics: - Fix the TPMI_RAPL_REG_DOMAIN_INFO register offset in the TPMI part of the Intel RAPL power capping driver, make it ignore minor hardware version mismatches (which only indicate exposing additional features) and update register definitions in it to enable PL4 support (Zhang Rui) - Add Arrow Lake-U to the list of processors supporting PL4 in the MSR part of the Intel RAPL power capping driver (Sumeet Pawnikar) - Remove excess pci_disable_device() calls from the processor part of the int340x thermal driver to address a warning triggered during module unload and remove unused CPU hotplug code related to RAPL support from it (Zhang Rui)" * tag 'pm-6.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: thermal: intel: int340x: processor: Add MMIO RAPL PL4 support thermal: intel: int340x: processor: Remove MMIO RAPL CPU hotplug support powercap: intel_rapl_msr: Add PL4 support for Arrowlake-U powercap: intel_rapl_tpmi: Ignore minor version change thermal: intel: int340x: processor: Fix warning during module unload powercap: intel_rapl_tpmi: Fix bogus register reading
2 parents f8fafb6 + 3fb0eea commit e643eda

File tree

4 files changed

+40
-52
lines changed

4 files changed

+40
-52
lines changed

drivers/powercap/intel_rapl_msr.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ static const struct x86_cpu_id pl4_support_ids[] = {
147147
X86_MATCH_VFM(INTEL_RAPTORLAKE_P, NULL),
148148
X86_MATCH_VFM(INTEL_METEORLAKE, NULL),
149149
X86_MATCH_VFM(INTEL_METEORLAKE_L, NULL),
150+
X86_MATCH_VFM(INTEL_ARROWLAKE_U, NULL),
150151
{}
151152
};
152153

drivers/powercap/intel_rapl_tpmi.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#include <linux/module.h>
1616
#include <linux/slab.h>
1717

18-
#define TPMI_RAPL_VERSION 1
18+
#define TPMI_RAPL_MAJOR_VERSION 0
19+
#define TPMI_RAPL_MINOR_VERSION 1
1920

2021
/* 1 header + 10 registers + 5 reserved. 8 bytes for each. */
2122
#define TPMI_RAPL_DOMAIN_SIZE 128
@@ -154,11 +155,21 @@ static int parse_one_domain(struct tpmi_rapl_package *trp, u32 offset)
154155
tpmi_domain_size = tpmi_domain_header >> 16 & 0xff;
155156
tpmi_domain_flags = tpmi_domain_header >> 32 & 0xffff;
156157

157-
if (tpmi_domain_version != TPMI_RAPL_VERSION) {
158-
pr_warn(FW_BUG "Unsupported version:%d\n", tpmi_domain_version);
158+
if (tpmi_domain_version == TPMI_VERSION_INVALID) {
159+
pr_warn(FW_BUG "Invalid version\n");
159160
return -ENODEV;
160161
}
161162

163+
if (TPMI_MAJOR_VERSION(tpmi_domain_version) != TPMI_RAPL_MAJOR_VERSION) {
164+
pr_warn(FW_BUG "Unsupported major version:%ld\n",
165+
TPMI_MAJOR_VERSION(tpmi_domain_version));
166+
return -ENODEV;
167+
}
168+
169+
if (TPMI_MINOR_VERSION(tpmi_domain_version) > TPMI_RAPL_MINOR_VERSION)
170+
pr_info("Ignore: Unsupported minor version:%ld\n",
171+
TPMI_MINOR_VERSION(tpmi_domain_version));
172+
162173
/* Domain size: in unit of 128 Bytes */
163174
if (tpmi_domain_size != 1) {
164175
pr_warn(FW_BUG "Invalid Domain size %d\n", tpmi_domain_size);
@@ -181,7 +192,7 @@ static int parse_one_domain(struct tpmi_rapl_package *trp, u32 offset)
181192
pr_warn(FW_BUG "System domain must support Domain Info register\n");
182193
return -ENODEV;
183194
}
184-
tpmi_domain_info = readq(trp->base + offset + TPMI_RAPL_REG_DOMAIN_INFO);
195+
tpmi_domain_info = readq(trp->base + offset + TPMI_RAPL_REG_DOMAIN_INFO * 8);
185196
if (!(tpmi_domain_info & TPMI_RAPL_DOMAIN_ROOT))
186197
return 0;
187198
domain_type = RAPL_DOMAIN_PLATFORM;

drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_
416416
if (!pci_info->no_legacy)
417417
proc_thermal_remove(proc_priv);
418418
proc_thermal_mmio_remove(pdev, proc_priv);
419-
pci_disable_device(pdev);
420419

421420
return ret;
422421
}
@@ -438,7 +437,6 @@ static void proc_thermal_pci_remove(struct pci_dev *pdev)
438437
proc_thermal_mmio_remove(pdev, pci_info->proc_priv);
439438
if (!pci_info->no_legacy)
440439
proc_thermal_remove(proc_priv);
441-
pci_disable_device(pdev);
442440
}
443441

444442
#ifdef CONFIG_PM_SLEEP

drivers/thermal/intel/int340x_thermal/processor_thermal_rapl.c

Lines changed: 24 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,48 +13,12 @@ static struct rapl_if_priv rapl_mmio_priv;
1313

1414
static const struct rapl_mmio_regs rapl_mmio_default = {
1515
.reg_unit = 0x5938,
16-
.regs[RAPL_DOMAIN_PACKAGE] = { 0x59a0, 0x593c, 0x58f0, 0, 0x5930},
16+
.regs[RAPL_DOMAIN_PACKAGE] = { 0x59a0, 0x593c, 0x58f0, 0, 0x5930, 0x59b0},
1717
.regs[RAPL_DOMAIN_DRAM] = { 0x58e0, 0x58e8, 0x58ec, 0, 0},
18-
.limits[RAPL_DOMAIN_PACKAGE] = BIT(POWER_LIMIT2),
18+
.limits[RAPL_DOMAIN_PACKAGE] = BIT(POWER_LIMIT2) | BIT(POWER_LIMIT4),
1919
.limits[RAPL_DOMAIN_DRAM] = BIT(POWER_LIMIT2),
2020
};
2121

22-
static int rapl_mmio_cpu_online(unsigned int cpu)
23-
{
24-
struct rapl_package *rp;
25-
26-
/* mmio rapl supports package 0 only for now */
27-
if (topology_physical_package_id(cpu))
28-
return 0;
29-
30-
rp = rapl_find_package_domain_cpuslocked(cpu, &rapl_mmio_priv, true);
31-
if (!rp) {
32-
rp = rapl_add_package_cpuslocked(cpu, &rapl_mmio_priv, true);
33-
if (IS_ERR(rp))
34-
return PTR_ERR(rp);
35-
}
36-
cpumask_set_cpu(cpu, &rp->cpumask);
37-
return 0;
38-
}
39-
40-
static int rapl_mmio_cpu_down_prep(unsigned int cpu)
41-
{
42-
struct rapl_package *rp;
43-
int lead_cpu;
44-
45-
rp = rapl_find_package_domain_cpuslocked(cpu, &rapl_mmio_priv, true);
46-
if (!rp)
47-
return 0;
48-
49-
cpumask_clear_cpu(cpu, &rp->cpumask);
50-
lead_cpu = cpumask_first(&rp->cpumask);
51-
if (lead_cpu >= nr_cpu_ids)
52-
rapl_remove_package_cpuslocked(rp);
53-
else if (rp->lead_cpu == cpu)
54-
rp->lead_cpu = lead_cpu;
55-
return 0;
56-
}
57-
5822
static int rapl_mmio_read_raw(int cpu, struct reg_action *ra)
5923
{
6024
if (!ra->reg.mmio)
@@ -82,6 +46,7 @@ static int rapl_mmio_write_raw(int cpu, struct reg_action *ra)
8246
int proc_thermal_rapl_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv)
8347
{
8448
const struct rapl_mmio_regs *rapl_regs = &rapl_mmio_default;
49+
struct rapl_package *rp;
8550
enum rapl_domain_reg_id reg;
8651
enum rapl_domain_type domain;
8752
int ret;
@@ -109,25 +74,38 @@ int proc_thermal_rapl_add(struct pci_dev *pdev, struct proc_thermal_device *proc
10974
return PTR_ERR(rapl_mmio_priv.control_type);
11075
}
11176

112-
ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "powercap/rapl:online",
113-
rapl_mmio_cpu_online, rapl_mmio_cpu_down_prep);
114-
if (ret < 0) {
115-
powercap_unregister_control_type(rapl_mmio_priv.control_type);
116-
rapl_mmio_priv.control_type = NULL;
117-
return ret;
77+
/* Register a RAPL package device for package 0 which is always online */
78+
rp = rapl_find_package_domain(0, &rapl_mmio_priv, false);
79+
if (rp) {
80+
ret = -EEXIST;
81+
goto err;
82+
}
83+
84+
rp = rapl_add_package(0, &rapl_mmio_priv, false);
85+
if (IS_ERR(rp)) {
86+
ret = PTR_ERR(rp);
87+
goto err;
11888
}
119-
rapl_mmio_priv.pcap_rapl_online = ret;
12089

12190
return 0;
91+
92+
err:
93+
powercap_unregister_control_type(rapl_mmio_priv.control_type);
94+
rapl_mmio_priv.control_type = NULL;
95+
return ret;
12296
}
12397
EXPORT_SYMBOL_GPL(proc_thermal_rapl_add);
12498

12599
void proc_thermal_rapl_remove(void)
126100
{
101+
struct rapl_package *rp;
102+
127103
if (IS_ERR_OR_NULL(rapl_mmio_priv.control_type))
128104
return;
129105

130-
cpuhp_remove_state(rapl_mmio_priv.pcap_rapl_online);
106+
rp = rapl_find_package_domain(0, &rapl_mmio_priv, false);
107+
if (rp)
108+
rapl_remove_package(rp);
131109
powercap_unregister_control_type(rapl_mmio_priv.control_type);
132110
}
133111
EXPORT_SYMBOL_GPL(proc_thermal_rapl_remove);

0 commit comments

Comments
 (0)