Skip to content

Commit bfc6819

Browse files
zhang-ruirafaeljw
authored andcommitted
thermal: intel: int340x: processor: Remove MMIO RAPL CPU hotplug support
CPU0/package0 is always online and the MMIO RAPL driver runs on single package systems only, so there is no need to handle CPU hotplug in it. Always register a RAPL package device for package 0 and remove the unnecessary CPU hotplug support. Signed-off-by: Zhang Rui <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Link: https://patch.msgid.link/[email protected] [ rjw: Subject edits ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent f517ff1 commit bfc6819

File tree

1 file changed

+22
-44
lines changed

1 file changed

+22
-44
lines changed

drivers/thermal/intel/int340x_thermal/processor_thermal_rapl.c

Lines changed: 22 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,6 @@ static const struct rapl_mmio_regs rapl_mmio_default = {
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)