]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
powercap: intel_rapl: Fix locking in TPMI RAPL
authorZhang Rui <rui.zhang@intel.com>
Wed, 31 Jan 2024 11:37:09 +0000 (19:37 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Apr 2024 13:28:19 +0000 (15:28 +0200)
commitd6c83ee705a136a78a2b9e7e2a79d5945a546d43
treec951847429d13d66e97d3061b5bf45e4a58ace25
parentc4c2f7e672e780be0bb867bd7e18ca53d16bc8da
powercap: intel_rapl: Fix locking in TPMI RAPL

[ Upstream commit 1aa09b9379a7a644cd2f75ae0bac82b8783df600 ]

The RAPL framework uses CPU hotplug locking to protect the rapl_packages
list and rp->lead_cpu to guarantee that

 1. the RAPL package device is not unprobed and freed
 2. the cached rp->lead_cpu is always valid

for operations like powercap sysfs accesses.

Current RAPL APIs assume being called from CPU hotplug callbacks which
hold the CPU hotplug lock, but TPMI RAPL driver invokes the APIs in the
driver's .probe() function without acquiring the CPU hotplug lock.

Fix the problem by providing both locked and lockless versions of RAPL
APIs.

Fixes: 9eef7f9da928 ("powercap: intel_rapl: Introduce RAPL TPMI interface driver")
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Cc: 6.5+ <stable@vger.kernel.org> # 6.5+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/powercap/intel_rapl_common.c
drivers/powercap/intel_rapl_msr.c
drivers/thermal/intel/int340x_thermal/processor_thermal_rapl.c
include/linux/intel_rapl.h