]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
thermal: intel: int340x: processor: Remove MMIO RAPL CPU hotplug support
authorZhang Rui <rui.zhang@intel.com>
Mon, 30 Sep 2024 08:18:00 +0000 (16:18 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 8 Oct 2024 19:39:33 +0000 (21:39 +0200)
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>
drivers/thermal/intel/int340x_thermal/processor_thermal_rapl.c

index e9aa9e23aab9ec9db2e17206ac8bc51a67f862d4..769510e748c0b24bede2d5eeb5f3e4267bbafe97 100644 (file)
@@ -19,42 +19,6 @@ static const struct rapl_mmio_regs rapl_mmio_default = {
        .limits[RAPL_DOMAIN_DRAM] = BIT(POWER_LIMIT2),
 };
 
-static int rapl_mmio_cpu_online(unsigned int cpu)
-{
-       struct rapl_package *rp;
-
-       /* mmio rapl supports package 0 only for now */
-       if (topology_physical_package_id(cpu))
-               return 0;
-
-       rp = rapl_find_package_domain_cpuslocked(cpu, &rapl_mmio_priv, true);
-       if (!rp) {
-               rp = rapl_add_package_cpuslocked(cpu, &rapl_mmio_priv, true);
-               if (IS_ERR(rp))
-                       return PTR_ERR(rp);
-       }
-       cpumask_set_cpu(cpu, &rp->cpumask);
-       return 0;
-}
-
-static int rapl_mmio_cpu_down_prep(unsigned int cpu)
-{
-       struct rapl_package *rp;
-       int lead_cpu;
-
-       rp = rapl_find_package_domain_cpuslocked(cpu, &rapl_mmio_priv, true);
-       if (!rp)
-               return 0;
-
-       cpumask_clear_cpu(cpu, &rp->cpumask);
-       lead_cpu = cpumask_first(&rp->cpumask);
-       if (lead_cpu >= nr_cpu_ids)
-               rapl_remove_package_cpuslocked(rp);
-       else if (rp->lead_cpu == cpu)
-               rp->lead_cpu = lead_cpu;
-       return 0;
-}
-
 static int rapl_mmio_read_raw(int cpu, struct reg_action *ra)
 {
        if (!ra->reg.mmio)
@@ -82,6 +46,7 @@ static int rapl_mmio_write_raw(int cpu, struct reg_action *ra)
 int proc_thermal_rapl_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv)
 {
        const struct rapl_mmio_regs *rapl_regs = &rapl_mmio_default;
+       struct rapl_package *rp;
        enum rapl_domain_reg_id reg;
        enum rapl_domain_type domain;
        int ret;
@@ -109,25 +74,38 @@ int proc_thermal_rapl_add(struct pci_dev *pdev, struct proc_thermal_device *proc
                return PTR_ERR(rapl_mmio_priv.control_type);
        }
 
-       ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "powercap/rapl:online",
-                               rapl_mmio_cpu_online, rapl_mmio_cpu_down_prep);
-       if (ret < 0) {
-               powercap_unregister_control_type(rapl_mmio_priv.control_type);
-               rapl_mmio_priv.control_type = NULL;
-               return ret;
+       /* Register a RAPL package device for package 0 which is always online */
+       rp = rapl_find_package_domain(0, &rapl_mmio_priv, false);
+       if (rp) {
+               ret = -EEXIST;
+               goto err;
+       }
+
+       rp = rapl_add_package(0, &rapl_mmio_priv, false);
+       if (IS_ERR(rp)) {
+               ret = PTR_ERR(rp);
+               goto err;
        }
-       rapl_mmio_priv.pcap_rapl_online = ret;
 
        return 0;
+
+err:
+       powercap_unregister_control_type(rapl_mmio_priv.control_type);
+       rapl_mmio_priv.control_type = NULL;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(proc_thermal_rapl_add);
 
 void proc_thermal_rapl_remove(void)
 {
+       struct rapl_package *rp;
+
        if (IS_ERR_OR_NULL(rapl_mmio_priv.control_type))
                return;
 
-       cpuhp_remove_state(rapl_mmio_priv.pcap_rapl_online);
+       rp = rapl_find_package_domain(0, &rapl_mmio_priv, false);
+       if (rp)
+               rapl_remove_package(rp);
        powercap_unregister_control_type(rapl_mmio_priv.control_type);
 }
 EXPORT_SYMBOL_GPL(proc_thermal_rapl_remove);