]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
platform/x86/intel-uncore-freq: Fix missing uncore sysfs during CPU hotplug
authorShouye Liu <shouyeliu@tencent.com>
Thu, 17 Apr 2025 03:23:21 +0000 (11:23 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 9 May 2025 07:43:53 +0000 (09:43 +0200)
commit 8d6955ed76e8a47115f2ea1d9c263ee6f505d737 upstream.

In certain situations, the sysfs for uncore may not be present when all
CPUs in a package are offlined and then brought back online after boot.

This issue can occur if there is an error in adding the sysfs entry due
to a memory allocation failure. Retrying to bring the CPUs online will
not resolve the issue, as the uncore_cpu_mask is already set for the
package before the failure condition occurs.

This issue does not occur if the failure happens during module
initialization, as the module will fail to load in the event of any
error.

To address this, ensure that the uncore_cpu_mask is not set until the
successful return of uncore_freq_add_entry().

Fixes: dbce412a7733 ("platform/x86/intel-uncore-freq: Split common and enumeration part")
Signed-off-by: Shouye Liu <shouyeliu@tencent.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250417032321.75580-1-shouyeliu@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c

index a3b25253b6fdebe0e3d29f9af3ac95bab7cf9915..2c9c5cc7d854edb5cfbfcf841c4812f40dac4387 100644 (file)
@@ -121,15 +121,13 @@ static int uncore_event_cpu_online(unsigned int cpu)
 {
        struct uncore_data *data;
        int target;
+       int ret;
 
        /* Check if there is an online cpu in the package for uncore MSR */
        target = cpumask_any_and(&uncore_cpu_mask, topology_die_cpumask(cpu));
        if (target < nr_cpu_ids)
                return 0;
 
-       /* Use this CPU on this die as a control CPU */
-       cpumask_set_cpu(cpu, &uncore_cpu_mask);
-
        data = uncore_get_instance(cpu);
        if (!data)
                return 0;
@@ -138,7 +136,14 @@ static int uncore_event_cpu_online(unsigned int cpu)
        data->die_id = topology_die_id(cpu);
        data->domain_id = UNCORE_DOMAIN_ID_INVALID;
 
-       return uncore_freq_add_entry(data, cpu);
+       ret = uncore_freq_add_entry(data, cpu);
+       if (ret)
+               return ret;
+
+       /* Use this CPU on this die as a control CPU */
+       cpumask_set_cpu(cpu, &uncore_cpu_mask);
+
+       return 0;
 }
 
 static int uncore_event_cpu_offline(unsigned int cpu)