Linux-PM Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] powercap/intel_rapl: add support for Sapphire Rapids
@ 2020-06-29  5:34 Zhang Rui
  2020-06-30 18:44 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang Rui @ 2020-06-29  5:34 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, Zhang Rui

RAPL on SPR behaves similar to HSW server, except that SPR uses a fixed
energy unit (1 Joule) for the PSYS RAPL domain.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/powercap/intel_rapl_common.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/powercap/intel_rapl_common.c b/drivers/powercap/intel_rapl_common.c
index 61a63a16b5e7..b739ce4f390d 100644
--- a/drivers/powercap/intel_rapl_common.c
+++ b/drivers/powercap/intel_rapl_common.c
@@ -93,6 +93,7 @@ struct rapl_defaults {
 	u64 (*compute_time_window)(struct rapl_package *rp, u64 val,
 				    bool to_raw);
 	unsigned int dram_domain_energy_unit;
+	unsigned int psys_domain_energy_unit;
 };
 static struct rapl_defaults *rapl_defaults;
 
@@ -533,12 +534,23 @@ static void rapl_init_domains(struct rapl_package *rp)
 		for (j = 0; j < RAPL_DOMAIN_REG_MAX; j++)
 			rd->regs[j] = rp->priv->regs[i][j];
 
-		if (i == RAPL_DOMAIN_DRAM) {
+		switch (i) {
+		case RAPL_DOMAIN_DRAM:
 			rd->domain_energy_unit =
 			    rapl_defaults->dram_domain_energy_unit;
 			if (rd->domain_energy_unit)
 				pr_info("DRAM domain energy unit %dpj\n",
 					rd->domain_energy_unit);
+			break;
+		case RAPL_DOMAIN_PLATFORM:
+			rd->domain_energy_unit =
+			    rapl_defaults->psys_domain_energy_unit;
+			if (rd->domain_energy_unit)
+				pr_info("Platform domain energy unit %dpj\n",
+					rd->domain_energy_unit);
+			break;
+		default:
+			break;
 		}
 		rd++;
 	}
@@ -919,6 +931,14 @@ static const struct rapl_defaults rapl_defaults_hsw_server = {
 	.dram_domain_energy_unit = 15300,
 };
 
+static const struct rapl_defaults rapl_defaults_spr_server = {
+	.check_unit = rapl_check_unit_core,
+	.set_floor_freq = set_floor_freq_default,
+	.compute_time_window = rapl_compute_time_window_core,
+	.dram_domain_energy_unit = 15300,
+	.psys_domain_energy_unit = 1000000000,
+};
+
 static const struct rapl_defaults rapl_defaults_byt = {
 	.floor_freq_reg_addr = IOSF_CPU_POWER_BUDGET_CTL_BYT,
 	.check_unit = rapl_check_unit_atom,
@@ -978,6 +998,7 @@ static const struct x86_cpu_id rapl_ids[] __initconst = {
 	X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE_L,		&rapl_defaults_core),
 	X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE,		&rapl_defaults_core),
 	X86_MATCH_INTEL_FAM6_MODEL(TIGERLAKE_L,		&rapl_defaults_core),
+	X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X,	&rapl_defaults_spr_server),
 
 	X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT,	&rapl_defaults_byt),
 	X86_MATCH_INTEL_FAM6_MODEL(ATOM_AIRMONT,	&rapl_defaults_cht),
-- 
2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] powercap/intel_rapl: add support for Sapphire Rapids
  2020-06-29  5:34 [PATCH] powercap/intel_rapl: add support for Sapphire Rapids Zhang Rui
@ 2020-06-30 18:44 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2020-06-30 18:44 UTC (permalink / raw)
  To: Zhang Rui; +Cc: Rafael J. Wysocki, Linux PM

On Mon, Jun 29, 2020 at 8:57 PM Zhang Rui <rui.zhang@intel.com> wrote:
>
> RAPL on SPR behaves similar to HSW server, except that SPR uses a fixed
> energy unit (1 Joule) for the PSYS RAPL domain.
>
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> ---
>  drivers/powercap/intel_rapl_common.c | 23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/powercap/intel_rapl_common.c b/drivers/powercap/intel_rapl_common.c
> index 61a63a16b5e7..b739ce4f390d 100644
> --- a/drivers/powercap/intel_rapl_common.c
> +++ b/drivers/powercap/intel_rapl_common.c
> @@ -93,6 +93,7 @@ struct rapl_defaults {
>         u64 (*compute_time_window)(struct rapl_package *rp, u64 val,
>                                     bool to_raw);
>         unsigned int dram_domain_energy_unit;
> +       unsigned int psys_domain_energy_unit;
>  };
>  static struct rapl_defaults *rapl_defaults;
>
> @@ -533,12 +534,23 @@ static void rapl_init_domains(struct rapl_package *rp)
>                 for (j = 0; j < RAPL_DOMAIN_REG_MAX; j++)
>                         rd->regs[j] = rp->priv->regs[i][j];
>
> -               if (i == RAPL_DOMAIN_DRAM) {
> +               switch (i) {
> +               case RAPL_DOMAIN_DRAM:
>                         rd->domain_energy_unit =
>                             rapl_defaults->dram_domain_energy_unit;
>                         if (rd->domain_energy_unit)
>                                 pr_info("DRAM domain energy unit %dpj\n",
>                                         rd->domain_energy_unit);
> +                       break;
> +               case RAPL_DOMAIN_PLATFORM:
> +                       rd->domain_energy_unit =
> +                           rapl_defaults->psys_domain_energy_unit;
> +                       if (rd->domain_energy_unit)
> +                               pr_info("Platform domain energy unit %dpj\n",
> +                                       rd->domain_energy_unit);
> +                       break;
> +               default:
> +                       break;
>                 }
>                 rd++;
>         }
> @@ -919,6 +931,14 @@ static const struct rapl_defaults rapl_defaults_hsw_server = {
>         .dram_domain_energy_unit = 15300,
>  };
>
> +static const struct rapl_defaults rapl_defaults_spr_server = {
> +       .check_unit = rapl_check_unit_core,
> +       .set_floor_freq = set_floor_freq_default,
> +       .compute_time_window = rapl_compute_time_window_core,
> +       .dram_domain_energy_unit = 15300,
> +       .psys_domain_energy_unit = 1000000000,
> +};
> +
>  static const struct rapl_defaults rapl_defaults_byt = {
>         .floor_freq_reg_addr = IOSF_CPU_POWER_BUDGET_CTL_BYT,
>         .check_unit = rapl_check_unit_atom,
> @@ -978,6 +998,7 @@ static const struct x86_cpu_id rapl_ids[] __initconst = {
>         X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE_L,         &rapl_defaults_core),
>         X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE,           &rapl_defaults_core),
>         X86_MATCH_INTEL_FAM6_MODEL(TIGERLAKE_L,         &rapl_defaults_core),
> +       X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X,    &rapl_defaults_spr_server),
>
>         X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT,     &rapl_defaults_byt),
>         X86_MATCH_INTEL_FAM6_MODEL(ATOM_AIRMONT,        &rapl_defaults_cht),
> --

Applied as 5.9 material, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-29  5:34 [PATCH] powercap/intel_rapl: add support for Sapphire Rapids Zhang Rui
2020-06-30 18:44 ` Rafael J. Wysocki

Linux-PM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-pm/0 linux-pm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-pm linux-pm/ https://lore.kernel.org/linux-pm \
		linux-pm@vger.kernel.org
	public-inbox-index linux-pm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-pm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git