Unverified Commit 8c1d9cf9 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!4648 [OLK-5.10] Intel: backport TPMI RAPL driver for GNR/SRF

Merge Pull Request from: @xiaolong-wang-intel 
 
Backport TPMI RAPL driver support on Intel Birch Stream (BHS) platforms (including GNR and SRF) to OLK-5.10, including the following commits from upstream Linux kernel v6.5 and dependencies:
49776c71 powercap: RAPL: Fix a NULL vs IS_ERR() bug
9eef7f9d powercap: intel_rapl: Introduce RAPL TPMI interface driver
e12dee18 powercap: intel_rapl: Introduce core support for TPMI interface
b4288ce7 powercap: intel_rapl: Introduce RAPL I/F type
bf44b901 powercap: intel_rapl: Make cpu optional for rapl_package
  65348ba2 powercap: intel_rapl: Use topology interface in rapl_init_domains()
693c1d78 powercap: intel_rapl: Remove redundant cpu parameter
f442bd27 powercap: intel_rapl: Add support for lock bit per Power Limit
9050a9cd powercap: intel_rapl: Cleanup Power Limits support
a38f300b powercap: intel_rapl: Use bitmap for Power Limits
  a5923b6c thermal: int340x: processor_thermal: Refactor MMIO interface.
045610c3 powercap: intel_rapl: Change primitive order
11edbe5c powercap: intel_rapl: Use index to initialize primitive information
cb532e72 powercap: intel_rapl: Support per domain energy/power/time unit
  59cafa72 powercap: intel_rapl: remove redundant store to value after multiply
98ff639a powercap: intel_rapl: Support per Interface primitive information
e8e28c2a powercap: intel_rapl: Support per Interface rapl_defaults
  88ffce95 powercap: intel_rapl: Use topology interface in rapl_add_package()
1488ac99 powercap: intel_rapl: Allow probing without CPUID match
31cb1304 powercap: intel_rapl: Remove unused field in struct rapl_if_priv

Intel-kernel issue:
https://gitee.com/openeuler/intel-kernel/issues/I92135

Test:
/sys/devices/virtual/powercap/intel-rapl/ will be available on Intel GNR/SRF platforms after this patchset is merged.

Known issue:
N/A

Default config change:
+CONFIG_INTEL_RAPL_TPMI=m 
 
Link:https://gitee.com/openeuler/kernel/pulls/4648

 

Reviewed-by: default avatarJason Zeng <jason.zeng@intel.com>
Reviewed-by: default avatarAichun Shi <aichun.shi@intel.com>
Reviewed-by: default avatarLiu Chao <liuchao173@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents 13188fc5 c7466302
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7252,6 +7252,7 @@ CONFIG_PWM_LPSS_PLATFORM=m
CONFIG_POWERCAP=y
CONFIG_INTEL_RAPL_CORE=m
CONFIG_INTEL_RAPL=m
CONFIG_INTEL_RAPL_TPMI=m
# CONFIG_IDLE_INJECT is not set
# CONFIG_MCB is not set

+14 −0
Original line number Diff line number Diff line
@@ -35,6 +35,20 @@ config INTEL_RAPL
	  controller, CPU core (Power Plane 0), graphics uncore (Power Plane
	  1), etc.

config INTEL_RAPL_TPMI
	tristate "Intel RAPL Support via TPMI Interface"
	depends on X86
	depends on INTEL_TPMI
	select INTEL_RAPL_CORE
	help
	  This enables support for the Intel Running Average Power Limit (RAPL)
	  technology via TPMI interface, which allows power limits to be enforced
	  and monitored.

	  In RAPL, the platform level settings are divided into domains for
	  fine grained control. These domains include processor package, DRAM
	  controller, platform, etc.

config IDLE_INJECT
	bool "Idle injection framework"
	depends on CPU_IDLE
+1 −0
Original line number Diff line number Diff line
@@ -2,4 +2,5 @@
obj-$(CONFIG_POWERCAP)	+= powercap_sys.o
obj-$(CONFIG_INTEL_RAPL_CORE) += intel_rapl_common.o
obj-$(CONFIG_INTEL_RAPL) += intel_rapl_msr.o
obj-$(CONFIG_INTEL_RAPL_TPMI) += intel_rapl_tpmi.o
obj-$(CONFIG_IDLE_INJECT) += idle_inject.o
+529 −398

File changed.

Preview size limit exceeded, changes collapsed.

+8 −6
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
static struct rapl_if_priv *rapl_msr_priv;

static struct rapl_if_priv rapl_msr_priv_intel = {
	.type = RAPL_IF_MSR,
	.reg_unit = MSR_RAPL_POWER_UNIT,
	.regs[RAPL_DOMAIN_PACKAGE] = {
		MSR_PKG_POWER_LIMIT, MSR_PKG_ENERGY_STATUS, MSR_PKG_PERF_STATUS, 0, MSR_PKG_POWER_INFO },
@@ -44,11 +45,12 @@ static struct rapl_if_priv rapl_msr_priv_intel = {
		MSR_DRAM_POWER_LIMIT, MSR_DRAM_ENERGY_STATUS, MSR_DRAM_PERF_STATUS, 0, MSR_DRAM_POWER_INFO },
	.regs[RAPL_DOMAIN_PLATFORM] = {
		MSR_PLATFORM_POWER_LIMIT, MSR_PLATFORM_ENERGY_STATUS, 0, 0, 0},
	.limits[RAPL_DOMAIN_PACKAGE] = 2,
	.limits[RAPL_DOMAIN_PLATFORM] = 2,
	.limits[RAPL_DOMAIN_PACKAGE] = BIT(POWER_LIMIT2),
	.limits[RAPL_DOMAIN_PLATFORM] = BIT(POWER_LIMIT2),
};

static struct rapl_if_priv rapl_msr_priv_amd = {
	.type = RAPL_IF_MSR,
	.reg_unit = MSR_AMD_RAPL_POWER_UNIT,
	.regs[RAPL_DOMAIN_PACKAGE] = {
		0, MSR_AMD_PKG_ENERGY_STATUS, 0, 0, 0 },
@@ -67,9 +69,9 @@ static int rapl_cpu_online(unsigned int cpu)
{
	struct rapl_package *rp;

	rp = rapl_find_package_domain(cpu, rapl_msr_priv);
	rp = rapl_find_package_domain(cpu, rapl_msr_priv, true);
	if (!rp) {
		rp = rapl_add_package(cpu, rapl_msr_priv);
		rp = rapl_add_package(cpu, rapl_msr_priv, true);
		if (IS_ERR(rp))
			return PTR_ERR(rp);
	}
@@ -82,7 +84,7 @@ static int rapl_cpu_down_prep(unsigned int cpu)
	struct rapl_package *rp;
	int lead_cpu;

	rp = rapl_find_package_domain(cpu, rapl_msr_priv);
	rp = rapl_find_package_domain(cpu, rapl_msr_priv, true);
	if (!rp)
		return 0;

@@ -160,7 +162,7 @@ static int rapl_msr_probe(struct platform_device *pdev)
	rapl_msr_priv->write_raw = rapl_msr_write_raw;

	if (id) {
		rapl_msr_priv->limits[RAPL_DOMAIN_PACKAGE] = 3;
		rapl_msr_priv->limits[RAPL_DOMAIN_PACKAGE] |= BIT(POWER_LIMIT4);
		rapl_msr_priv->regs[RAPL_DOMAIN_PACKAGE][RAPL_DOMAIN_REG_PL4] =
			MSR_VR_CURRENT_CONFIG;
		pr_info("PL4 support detected.\n");
Loading