Loading
powercap: intel_rapl: Fix locking in TPMI RAPL
mainline inclusion from mainline-v6.9-rc1 commit 1aa09b9379a7a644cd2f75ae0bac82b8783df600 category: bugfix bugzilla: https://gitee.com/openeuler/intel-kernel/issues/IA85P6 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=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. Intel-SIG: commit 1aa09b9379a7 powercap: intel_rapl: Fix locking in TPMI RAPL Backport Intel RAPL driver bugfixes up to upstream v6.9. Change the locks from guard macros to cpus_read_lock()/cpus_read_unlock() function pairs to avoid backporting the cleanup framework. Fixes: 9eef7f9d ("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> [ Xiaolong Wang: solve conflicts and amend commit log ] Signed-off-by:
Xiaolong Wang <xiaolong.wang@intel.com>