Skip to content

Commit 8d6955e

Browse files
lan0017ij-intel
authored andcommitted
platform/x86/intel-uncore-freq: Fix missing uncore sysfs during CPU hotplug
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: dbce412 ("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>
1 parent 9f5595d commit 8d6955e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,13 @@ static int uncore_event_cpu_online(unsigned int cpu)
146146
{
147147
struct uncore_data *data;
148148
int target;
149+
int ret;
149150

150151
/* Check if there is an online cpu in the package for uncore MSR */
151152
target = cpumask_any_and(&uncore_cpu_mask, topology_die_cpumask(cpu));
152153
if (target < nr_cpu_ids)
153154
return 0;
154155

155-
/* Use this CPU on this die as a control CPU */
156-
cpumask_set_cpu(cpu, &uncore_cpu_mask);
157-
158156
data = uncore_get_instance(cpu);
159157
if (!data)
160158
return 0;
@@ -163,7 +161,14 @@ static int uncore_event_cpu_online(unsigned int cpu)
163161
data->die_id = topology_die_id(cpu);
164162
data->domain_id = UNCORE_DOMAIN_ID_INVALID;
165163

166-
return uncore_freq_add_entry(data, cpu);
164+
ret = uncore_freq_add_entry(data, cpu);
165+
if (ret)
166+
return ret;
167+
168+
/* Use this CPU on this die as a control CPU */
169+
cpumask_set_cpu(cpu, &uncore_cpu_mask);
170+
171+
return 0;
167172
}
168173

169174
static int uncore_event_cpu_offline(unsigned int cpu)

0 commit comments

Comments
 (0)