From: Zhang Rui <rui.zhang@intel.com>
To: linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com,
daniel.lezcano@linaro.org
Cc: linux-kernel@vger.kernel.org, srinivas.pandruvada@intel.com
Subject: [PATCH 13/15] powercap/intel_rapl: Introduce RAPL I/F type
Date: Thu, 16 Mar 2023 23:38:39 +0800 [thread overview]
Message-ID: <20230316153841.3666-14-rui.zhang@intel.com> (raw)
In-Reply-To: <20230316153841.3666-1-rui.zhang@intel.com>
Different RAPL Interfaces may have different primitive information and
rapl_defaults calls.
To better distinguish this difference in the RAPL framework code,
introduce a new enum to represent different types of RAPL Interfaces.
No functional change.
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
drivers/powercap/intel_rapl_common.c | 18 +++++++++++++-----
drivers/powercap/intel_rapl_msr.c | 2 ++
.../int340x_thermal/processor_thermal_rapl.c | 1 +
include/linux/intel_rapl.h | 6 ++++++
4 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/drivers/powercap/intel_rapl_common.c b/drivers/powercap/intel_rapl_common.c
index a6a7d048d0b4..7e79066bcbcb 100644
--- a/drivers/powercap/intel_rapl_common.c
+++ b/drivers/powercap/intel_rapl_common.c
@@ -177,7 +177,7 @@ struct rapl_defaults {
unsigned int psys_domain_energy_unit;
bool spr_psys_bits;
};
-static struct rapl_defaults *rapl_defaults;
+static struct rapl_defaults *rpd_msr;
static struct rapl_defaults *get_rpd(struct rapl_package *rp)
{
@@ -601,7 +601,7 @@ static u64 rapl_unit_xlate(struct rapl_domain *rd, enum unit_type type,
return div64_u64(value, scale);
}
-static struct rapl_primitive_info rpis_default[NR_RAPL_PRIMITIVES] = {
+static struct rapl_primitive_info rpi_msr[NR_RAPL_PRIMITIVES] = {
/* name, mask, shift, msr index, unit divisor */
[POWER_LIMIT1] = PRIMITIVE_INFO_INIT(POWER_LIMIT1, POWER_LIMIT1_MASK, 0,
RAPL_DOMAIN_REG_LIMIT, POWER_UNIT, 0),
@@ -670,8 +670,16 @@ static struct rapl_primitive_info *get_rpi(struct rapl_package *rp, int prim)
static int rapl_config(struct rapl_package *rp)
{
- rp->priv->rpd = (void *)rapl_defaults;
- rp->priv->rpi = (void *)rpis_default;
+ switch (rp->priv->type) {
+ /* MMIO I/F shares the same register layout as MSR registers */
+ case RAPL_IF_MMIO:
+ case RAPL_IF_MSR:
+ rp->priv->rpd = (void *)rpd_msr;
+ rp->priv->rpi = (void *)rpi_msr;
+ break;
+ default:
+ return -EINVAL;
+ }
return 0;
}
@@ -1536,7 +1544,7 @@ static int __init rapl_init(void)
id = x86_match_cpu(rapl_ids);
if (id) {
- rapl_defaults = (struct rapl_defaults *)id->driver_data;
+ rpd_msr = (struct rapl_defaults *)id->driver_data;
rapl_msr_platdev = platform_device_alloc("intel_rapl_msr", 0);
if (!rapl_msr_platdev)
diff --git a/drivers/powercap/intel_rapl_msr.c b/drivers/powercap/intel_rapl_msr.c
index 3e48e729050d..73c8bbcfc1bd 100644
--- a/drivers/powercap/intel_rapl_msr.c
+++ b/drivers/powercap/intel_rapl_msr.c
@@ -34,6 +34,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 },
@@ -50,6 +51,7 @@ static struct rapl_if_priv rapl_msr_priv_intel = {
};
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 },
diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_rapl.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_rapl.c
index 140fb85cfa7b..013f1633f082 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_rapl.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_rapl.c
@@ -97,6 +97,7 @@ int proc_thermal_rapl_add(struct pci_dev *pdev, struct proc_thermal_device *proc
rapl_regs->regs[domain][reg];
rapl_mmio_priv.limits[domain] = rapl_regs->limits[domain];
}
+ rapl_mmio_priv.type = RAPL_IF_MMIO;
rapl_mmio_priv.reg_unit = (u64)proc_priv->mmio_base + rapl_regs->reg_unit;
rapl_mmio_priv.read_raw = rapl_mmio_read_raw;
diff --git a/include/linux/intel_rapl.h b/include/linux/intel_rapl.h
index d92ded956140..e5a7b47ceac9 100644
--- a/include/linux/intel_rapl.h
+++ b/include/linux/intel_rapl.h
@@ -14,6 +14,11 @@
#include <linux/powercap.h>
#include <linux/cpuhotplug.h>
+enum rapl_if_type {
+ RAPL_IF_MSR, /* RAPL I/F using MSR registers */
+ RAPL_IF_MMIO, /* RAPL I/F using MMIO registers */
+};
+
enum rapl_domain_type {
RAPL_DOMAIN_PACKAGE, /* entire package/socket */
RAPL_DOMAIN_PP0, /* core power plane */
@@ -130,6 +135,7 @@ struct reg_action {
* @rpi: internal pointer to interface primitive info
*/
struct rapl_if_priv {
+ enum rapl_if_type type;
struct powercap_control_type *control_type;
enum cpuhp_state pcap_rapl_online;
u64 reg_unit;
--
2.25.1
next prev parent reply other threads:[~2023-03-16 15:44 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-16 15:38 [PATCH 0/15] powercap/intel_rapl: Introduce RAPL TPMI support Zhang Rui
2023-03-16 15:38 ` [PATCH 01/15] powercap/intel_rapl: Remove unused field in struct rapl_if_priv Zhang Rui
2023-03-16 15:38 ` [PATCH 02/15] powercap/intel_rapl: Allow probing without CPUID match Zhang Rui
2023-03-16 15:38 ` [PATCH 03/15] powercap/intel_rapl: Support per Interface rapl_defaults Zhang Rui
2023-03-30 17:54 ` Rafael J. Wysocki
2023-04-02 7:40 ` Zhang, Rui
2023-03-16 15:38 ` [PATCH 04/15] powercap/intel_rapl: Support per Interface primitive information Zhang Rui
2023-03-30 17:56 ` Rafael J. Wysocki
2023-04-02 7:43 ` Zhang, Rui
2023-04-03 17:51 ` Rafael J. Wysocki
2023-03-16 15:38 ` [PATCH 05/15] powercap/intel_rapl: Support per domain energy/power/time unit Zhang Rui
2023-03-16 15:38 ` [PATCH 06/15] powercap/intel_rapl: Use index to initialize primitive information Zhang Rui
2023-03-16 15:38 ` [PATCH 07/15] powercap/intel_rapl: Change primitive order Zhang Rui
2023-04-07 11:40 ` Rafael J. Wysocki
2023-03-16 15:38 ` [PATCH 08/15] powercap/intel_rapl: Use bitmap for Power Limits Zhang Rui
2023-03-16 15:38 ` [PATCH 09/15] powercap/intel_rapl: Cleanup Power Limits support Zhang Rui
2023-03-16 15:38 ` [PATCH 10/15] powercap/intel_rapl: Introduce per Power Limit lock Zhang Rui
2023-04-07 12:01 ` Rafael J. Wysocki
2023-03-16 15:38 ` [PATCH 11/15] powercap/intel_rapl: Remove redundant cpu parameter Zhang Rui
2023-03-16 15:38 ` [PATCH 12/15] powercap/intel_rapl: Make cpu optional for rapl_package Zhang Rui
2023-03-16 15:38 ` Zhang Rui [this message]
2023-03-16 15:38 ` [PATCH 14/15] powercap/intel_rapl: Introduce core support for TPMI interface Zhang Rui
2023-03-16 15:38 ` [PATCH 15/15] powercap/intel_rapl_tpmi: Introduce RAPL TPMI interface driver Zhang Rui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230316153841.3666-14-rui.zhang@intel.com \
--to=rui.zhang@intel.com \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=srinivas.pandruvada@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®