]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
platform/x86/intel-uncore-freq: Fix current_freq_khz after CPU hotplug
authorGuixiong Wei <weiguixiong@bytedance.com>
Tue, 2 Jun 2026 02:07:52 +0000 (10:07 +0800)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Wed, 10 Jun 2026 11:51:55 +0000 (14:51 +0300)
When the last CPU of a legacy uncore die goes offline,
uncore_freq_remove_die_entry() clears control_cpu. During CPU hotplug
re-add, uncore_freq_add_entry() still populates sysfs attributes before
assigning the new control CPU. As a result, the current frequency read
returns -ENXIO and current_freq_khz is omitted from the recreated sysfs
group.

Assign control_cpu before the initial read paths and before
create_attr_group() so sysfs recreation uses the new online CPU. If
sysfs creation fails, restore control_cpu to -1 to keep the error path
state consistent.

Fixes: 4d73c6772ab7 ("platform/x86: intel-uncore-freq: Conditionally create attribute for read frequency")
Cc: stable@vger.kernel.org
Signed-off-by: Guixiong Wei <weiguixiong@bytedance.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://patch.msgid.link/20260602020752.3126-1-weiguixiong@bytedance.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c

index 3b554418a7a3c1e1242c6dd38600c8967a62365b..4bcafedf68ef893cfa4ffcc370fb6267be741baf 100644 (file)
@@ -285,15 +285,20 @@ int uncore_freq_add_entry(struct uncore_data *data, int cpu)
                          data->package_id, data->die_id);
        }
 
+       /*
+        * Set the control CPU before any read path so entry recreation after CPU
+        * hotplug can populate read-only attributes from the new online CPU.
+        */
+       data->control_cpu = cpu;
        uncore_read(data, &data->initial_min_freq_khz, UNCORE_INDEX_MIN_FREQ);
        uncore_read(data, &data->initial_max_freq_khz, UNCORE_INDEX_MAX_FREQ);
 
        ret = create_attr_group(data, data->name);
        if (ret) {
+               data->control_cpu = -1;
                if (data->domain_id != UNCORE_DOMAIN_ID_INVALID)
                        ida_free(&intel_uncore_ida, data->seqnum_id);
        } else {
-               data->control_cpu = cpu;
                data->valid = true;
        }