cpufreq: amd-pstate: fix kernel hang issue while amd-pstate unregistering
authorPerry Yuan <perry.yuan@amd.com>
Tue, 10 Jan 2023 15:10:29 +0000 (23:10 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 10 Jan 2023 19:31:08 +0000 (20:31 +0100)
In the amd_pstate_adjust_perf(), there is one cpufreq_cpu_get() call to
increase increments the kobject reference count of policy and make it as
busy. Therefore, a corresponding call to cpufreq_cpu_put() is needed to
decrement the kobject reference count back, it will resolve the kernel
hang issue when unregistering the amd-pstate driver and register the
`amd_pstate_epp` driver instance.

Fixes: 1d215f0319 ("cpufreq: amd-pstate: Add fast switch function for AMD P-State")
Acked-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Tested-by: Wyes Karny <wyes.karny@amd.com>
Signed-off-by: Perry Yuan <perry.yuan@amd.com>
Cc: 5.17+ <stable@vger.kernel.org> # 5.17+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/amd-pstate.c

index 204e39006dda8f102643ecd90eb45fbb3df70218..c17bd845f5fcb8afa9c64662f6a13903015ac815 100644 (file)
@@ -307,6 +307,7 @@ static void amd_pstate_adjust_perf(unsigned int cpu,
                max_perf = min_perf;
 
        amd_pstate_update(cpudata, min_perf, des_perf, max_perf, true);
+       cpufreq_cpu_put(policy);
 }
 
 static int amd_get_min_freq(struct amd_cpudata *cpudata)