]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
cpufreq: Fix get_cpu_device() failure in add_cpu_dev_symlink()
authorXiongfeng Wang <wangxiongfeng2@huawei.com>
Mon, 29 Nov 2021 08:02:48 +0000 (16:02 +0800)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 4 Jan 2022 08:49:06 +0000 (09:49 +0100)
commit2da3e586b8c0212bdb8c29b27fc98c1d141ed960
tree57848402642d31cae5faf800d904a70c0437ddea
parent8409129ed69ba5d5a1cc483f564c8f653eb7709d
cpufreq: Fix get_cpu_device() failure in add_cpu_dev_symlink()

BugLink: https://bugs.launchpad.net/bugs/1953731
commit 2c1b5a84669d2477d8fffe9136e86a2cff591729 upstream.

When I hot added a CPU, I found 'cpufreq' directory was not created
below /sys/devices/system/cpu/cpuX/.

It is because get_cpu_device() failed in add_cpu_dev_symlink().

cpufreq_add_dev() is the .add_dev callback of a CPU subsys interface.
It will be called when the CPU device registered into the system.
The call chain is as follows:

  register_cpu()
  ->device_register()
   ->device_add()
    ->bus_probe_device()
     ->cpufreq_add_dev()

But only after the CPU device has been registered, we can get the
CPU device by get_cpu_device(), otherwise it will return NULL.

Since we already have the CPU device in cpufreq_add_dev(), pass
it to add_cpu_dev_symlink().

I noticed that the 'kobj' of the CPU device has been added into
the system before cpufreq_add_dev().

Fixes: 2f0ba790df51 ("cpufreq: Fix creation of symbolic links to policy directories")
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/cpufreq/cpufreq.c