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 08/15] powercap/intel_rapl: Use bitmap for Power Limits
Date: Thu, 16 Mar 2023 23:38:34 +0800 [thread overview]
Message-ID: <20230316153841.3666-9-rui.zhang@intel.com> (raw)
In-Reply-To: <20230316153841.3666-1-rui.zhang@intel.com>
Currently, a RAPL package is registered with the number of Power Limits
supported in each RAPL domain. But this doesn't tell which Power Limits
are available. Using the number of Power Limits supported to guess the
availability of each Power Limit is fragile.
Use bitmap to represent the availability of each Power Limit.
Note that PL1 is mandatory thus it does not need to be set explicitly by
the RAPL Interface drivers.
No functional change intended.
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
drivers/powercap/intel_rapl_common.c | 14 ++++++--------
drivers/powercap/intel_rapl_msr.c | 6 +++---
.../intel/int340x_thermal/processor_thermal_rapl.c | 4 ++--
3 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/drivers/powercap/intel_rapl_common.c b/drivers/powercap/intel_rapl_common.c
index 3a8940d3bec8..0935a10b093e 100644
--- a/drivers/powercap/intel_rapl_common.c
+++ b/drivers/powercap/intel_rapl_common.c
@@ -574,20 +574,18 @@ static void rapl_init_domains(struct rapl_package *rp)
rapl_domain_names[i]);
rd->id = i;
+
+ /* PL1 is supported by default */
+ rp->priv->limits[i] |= BIT(POWER_LIMIT1);
rd->rpl[0].prim_id = PL1_ENABLE;
rd->rpl[0].name = pl1_name;
- /*
- * The PL2 power domain is applicable for limits two
- * and limits three
- */
- if (rp->priv->limits[i] >= 2) {
+ if (rp->priv->limits[i] & BIT(POWER_LIMIT2)) {
rd->rpl[1].prim_id = PL2_ENABLE;
rd->rpl[1].name = pl2_name;
}
- /* Enable PL4 domain if the total power limits are three */
- if (rp->priv->limits[i] == 3) {
+ if (rp->priv->limits[i] & BIT(POWER_LIMIT4)) {
rd->rpl[2].prim_id = PL4_ENABLE;
rd->rpl[2].name = pl4_name;
}
@@ -762,7 +760,7 @@ static int rapl_read_data_raw(struct rapl_domain *rd,
cpu = rd->rp->lead_cpu;
/* domain with 2 limits has different bit */
- if (prim == FW_LOCK && rd->rp->priv->limits[rd->id] == 2) {
+ if (prim == FW_LOCK && (rd->rp->priv->limits[rd->id] & BIT(POWER_LIMIT2))) {
rpi->mask = POWER_HIGH_LOCK;
rpi->shift = 63;
}
diff --git a/drivers/powercap/intel_rapl_msr.c b/drivers/powercap/intel_rapl_msr.c
index bc6adda58883..e78460620340 100644
--- a/drivers/powercap/intel_rapl_msr.c
+++ b/drivers/powercap/intel_rapl_msr.c
@@ -45,8 +45,8 @@ 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 = {
@@ -167,7 +167,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");
diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_rapl.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_rapl.c
index a205221ec8df..e070239106f5 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_rapl.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_rapl.c
@@ -15,8 +15,8 @@ static const struct rapl_mmio_regs rapl_mmio_default = {
.reg_unit = 0x5938,
.regs[RAPL_DOMAIN_PACKAGE] = { 0x59a0, 0x593c, 0x58f0, 0, 0x5930},
.regs[RAPL_DOMAIN_DRAM] = { 0x58e0, 0x58e8, 0x58ec, 0, 0},
- .limits[RAPL_DOMAIN_PACKAGE] = 2,
- .limits[RAPL_DOMAIN_DRAM] = 2,
+ .limits[RAPL_DOMAIN_PACKAGE] = BIT(POWER_LIMIT2),
+ .limits[RAPL_DOMAIN_DRAM] = BIT(POWER_LIMIT2),
};
static int rapl_mmio_cpu_online(unsigned int cpu)
--
2.25.1
next prev parent reply other threads:[~2023-03-16 15:43 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 ` Zhang Rui [this message]
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 ` [PATCH 13/15] powercap/intel_rapl: Introduce RAPL I/F type Zhang Rui
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-9-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®