Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <rui.zhang@intel.com>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://patch.msgid.link/20240930081801.28502-6-rui.zhang@intel.com
[ rjw: Subject edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Zhang Rui and committed by
Rafael J. Wysocki
bfc6819e f517ff17

+22 -44
+22 -44
drivers/thermal/intel/int340x_thermal/processor_thermal_rapl.c
··· 19 19 .limits[RAPL_DOMAIN_DRAM] = BIT(POWER_LIMIT2), 20 20 }; 21 21 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 - 58 22 static int rapl_mmio_read_raw(int cpu, struct reg_action *ra) 59 23 { 60 24 if (!ra->reg.mmio) ··· 46 82 int proc_thermal_rapl_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv) 47 83 { 48 84 const struct rapl_mmio_regs *rapl_regs = &rapl_mmio_default; 85 + struct rapl_package *rp; 49 86 enum rapl_domain_reg_id reg; 50 87 enum rapl_domain_type domain; 51 88 int ret; ··· 74 109 return PTR_ERR(rapl_mmio_priv.control_type); 75 110 } 76 111 77 - ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "powercap/rapl:online", 78 - rapl_mmio_cpu_online, rapl_mmio_cpu_down_prep); 79 - if (ret < 0) { 80 - powercap_unregister_control_type(rapl_mmio_priv.control_type); 81 - rapl_mmio_priv.control_type = NULL; 82 - return ret; 112 + /* Register a RAPL package device for package 0 which is always online */ 113 + rp = rapl_find_package_domain(0, &rapl_mmio_priv, false); 114 + if (rp) { 115 + ret = -EEXIST; 116 + goto err; 83 117 } 84 - rapl_mmio_priv.pcap_rapl_online = ret; 118 + 119 + rp = rapl_add_package(0, &rapl_mmio_priv, false); 120 + if (IS_ERR(rp)) { 121 + ret = PTR_ERR(rp); 122 + goto err; 123 + } 85 124 86 125 return 0; 126 + 127 + err: 128 + powercap_unregister_control_type(rapl_mmio_priv.control_type); 129 + rapl_mmio_priv.control_type = NULL; 130 + return ret; 87 131 } 88 132 EXPORT_SYMBOL_GPL(proc_thermal_rapl_add); 89 133 90 134 void proc_thermal_rapl_remove(void) 91 135 { 136 + struct rapl_package *rp; 137 + 92 138 if (IS_ERR_OR_NULL(rapl_mmio_priv.control_type)) 93 139 return; 94 140 95 - cpuhp_remove_state(rapl_mmio_priv.pcap_rapl_online); 141 + rp = rapl_find_package_domain(0, &rapl_mmio_priv, false); 142 + if (rp) 143 + rapl_remove_package(rp); 96 144 powercap_unregister_control_type(rapl_mmio_priv.control_type); 97 145 } 98 146 EXPORT_SYMBOL_GPL(proc_thermal_rapl_remove);