linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] cpufreq: intel_pstate: Base frequency attribute
@ 2018-10-12 16:43 Srinivas Pandruvada
  2018-10-12 16:43 ` [PATCH v3 1/3] ACPI / CPPC: Add support for guaranteed performance Srinivas Pandruvada
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Srinivas Pandruvada @ 2018-10-12 16:43 UTC (permalink / raw)
  To: corbet, rjw, lenb, viresh.kumar, robert.moore, erik.schmauss
  Cc: juri.lelli, linux-doc, linux-kernel, linux-acpi, linux-pm, devel,
	pprakash, george.cherian, Srinivas Pandruvada

This series presents base frequency to cpufreq sysfs when intel_pstate
is in use in HWP mode.

Changes:
v3:
- Update documentation
v2
- Removed guaranteed attribute addition to acpi_cppc sysfs
- Using the cppc_acpi interface to get base frequency and present

Srinivas Pandruvada (3):
  ACPI / CPPC: Add support for guaranteed performance
  cpufreq: intel_pstate: Add base_frequency attribute
  Documentation: intel_pstate: Add base_frequency information

 Documentation/admin-guide/pm/intel_pstate.rst |  4 ++
 drivers/acpi/cppc_acpi.c                      |  8 +++-
 drivers/cpufreq/intel_pstate.c                | 38 +++++++++++++++++++
 include/acpi/cppc_acpi.h                      |  1 +
 4 files changed, 49 insertions(+), 2 deletions(-)

-- 
2.17.1


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

* [PATCH v3 1/3] ACPI / CPPC: Add support for guaranteed performance
  2018-10-12 16:43 [PATCH v3 0/3] cpufreq: intel_pstate: Base frequency attribute Srinivas Pandruvada
@ 2018-10-12 16:43 ` Srinivas Pandruvada
  2018-10-12 16:43 ` [PATCH v3 2/3] cpufreq: intel_pstate: Add base_frequency attribute Srinivas Pandruvada
  2018-10-12 16:44 ` [PATCH v3 3/3] Documentation: intel_pstate: Add base_frequency information Srinivas Pandruvada
  2 siblings, 0 replies; 6+ messages in thread
From: Srinivas Pandruvada @ 2018-10-12 16:43 UTC (permalink / raw)
  To: corbet, rjw, lenb, viresh.kumar, robert.moore, erik.schmauss
  Cc: juri.lelli, linux-doc, linux-kernel, linux-acpi, linux-pm, devel,
	pprakash, george.cherian, Srinivas Pandruvada

The Continuous Performance Control Package can have guaranteed performance
field. Add support to read guaranteed performance.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/acpi/cppc_acpi.c | 8 ++++++--
 include/acpi/cppc_acpi.h | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index d9ce4b162e2c..217a782c3e55 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -1061,9 +1061,9 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
 {
 	struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum);
 	struct cpc_register_resource *highest_reg, *lowest_reg,
-		*lowest_non_linear_reg, *nominal_reg,
+		*lowest_non_linear_reg, *nominal_reg, *guaranteed_reg,
 		*low_freq_reg = NULL, *nom_freq_reg = NULL;
-	u64 high, low, nom, min_nonlinear, low_f = 0, nom_f = 0;
+	u64 high, low, guaranteed, nom, min_nonlinear, low_f = 0, nom_f = 0;
 	int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum);
 	struct cppc_pcc_data *pcc_ss_data = NULL;
 	int ret = 0, regs_in_pcc = 0;
@@ -1079,6 +1079,7 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
 	nominal_reg = &cpc_desc->cpc_regs[NOMINAL_PERF];
 	low_freq_reg = &cpc_desc->cpc_regs[LOWEST_FREQ];
 	nom_freq_reg = &cpc_desc->cpc_regs[NOMINAL_FREQ];
+	guaranteed_reg = &cpc_desc->cpc_regs[GUARANTEED_PERF];
 
 	/* Are any of the regs PCC ?*/
 	if (CPC_IN_PCC(highest_reg) || CPC_IN_PCC(lowest_reg) ||
@@ -1107,6 +1108,9 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
 	cpc_read(cpunum, nominal_reg, &nom);
 	perf_caps->nominal_perf = nom;
 
+	cpc_read(cpunum, guaranteed_reg, &guaranteed);
+	perf_caps->guaranteed_perf = guaranteed;
+
 	cpc_read(cpunum, lowest_non_linear_reg, &min_nonlinear);
 	perf_caps->lowest_nonlinear_perf = min_nonlinear;
 
diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h
index 8e0b8250a139..cf59e6210d27 100644
--- a/include/acpi/cppc_acpi.h
+++ b/include/acpi/cppc_acpi.h
@@ -104,6 +104,7 @@ enum cppc_regs {
  * today.
  */
 struct cppc_perf_caps {
+	u32 guaranteed_perf;
 	u32 highest_perf;
 	u32 nominal_perf;
 	u32 lowest_perf;
-- 
2.17.1


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

* [PATCH v3 2/3] cpufreq: intel_pstate: Add base_frequency attribute
  2018-10-12 16:43 [PATCH v3 0/3] cpufreq: intel_pstate: Base frequency attribute Srinivas Pandruvada
  2018-10-12 16:43 ` [PATCH v3 1/3] ACPI / CPPC: Add support for guaranteed performance Srinivas Pandruvada
@ 2018-10-12 16:43 ` Srinivas Pandruvada
  2018-10-12 16:44 ` [PATCH v3 3/3] Documentation: intel_pstate: Add base_frequency information Srinivas Pandruvada
  2 siblings, 0 replies; 6+ messages in thread
From: Srinivas Pandruvada @ 2018-10-12 16:43 UTC (permalink / raw)
  To: corbet, rjw, lenb, viresh.kumar, robert.moore, erik.schmauss
  Cc: juri.lelli, linux-doc, linux-kernel, linux-acpi, linux-pm, devel,
	pprakash, george.cherian, Srinivas Pandruvada

Present base_frequency to user space via cpufreq sysfs when HWP is in
use.

This HWP base frequency is read from HWP Capabilities MSR, if platform
doesn't have ACPI _CPC object. On most of the HWP platforms the _CPC
object will point to the HWP Capabilities MSR using address space id as
"Functional Fixed Hardware". But the address space id can be simply
ACPI_TYPE_INTEGER, where the platform firmware can modify this value
based on the system constraints.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/cpufreq/intel_pstate.c | 38 ++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index b6a1aadaff9f..2a99e2fd9412 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -373,10 +373,28 @@ static void intel_pstate_set_itmt_prio(int cpu)
 		}
 	}
 }
+
+static int intel_pstate_get_cppc_guranteed(int cpu)
+{
+	struct cppc_perf_caps cppc_perf;
+	int ret;
+
+	ret = cppc_get_perf_caps(cpu, &cppc_perf);
+	if (ret)
+		return ret;
+
+	return cppc_perf.guaranteed_perf;
+}
+
 #else
 static void intel_pstate_set_itmt_prio(int cpu)
 {
 }
+
+static int intel_pstate_get_cppc_guranteed(int cpu)
+{
+	return -ENOTSUPP;
+}
 #endif
 
 static void intel_pstate_init_acpi_perf_limits(struct cpufreq_policy *policy)
@@ -699,9 +717,29 @@ static ssize_t show_energy_performance_preference(
 
 cpufreq_freq_attr_rw(energy_performance_preference);
 
+static ssize_t show_base_frequency(struct cpufreq_policy *policy, char *buf)
+{
+	struct cpudata *cpu;
+	u64 cap;
+	int ratio;
+
+	ratio = intel_pstate_get_cppc_guranteed(policy->cpu);
+	if (ratio <= 0) {
+		rdmsrl_on_cpu(policy->cpu, MSR_HWP_CAPABILITIES, &cap);
+		ratio = HWP_GUARANTEED_PERF(cap);
+	}
+
+	cpu = all_cpu_data[policy->cpu];
+
+	return sprintf(buf, "%d\n", ratio * cpu->pstate.scaling);
+}
+
+cpufreq_freq_attr_ro(base_frequency);
+
 static struct freq_attr *hwp_cpufreq_attrs[] = {
 	&energy_performance_preference,
 	&energy_performance_available_preferences,
+	&base_frequency,
 	NULL,
 };
 
-- 
2.17.1


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

* [PATCH v3 3/3] Documentation: intel_pstate: Add base_frequency information
  2018-10-12 16:43 [PATCH v3 0/3] cpufreq: intel_pstate: Base frequency attribute Srinivas Pandruvada
  2018-10-12 16:43 ` [PATCH v3 1/3] ACPI / CPPC: Add support for guaranteed performance Srinivas Pandruvada
  2018-10-12 16:43 ` [PATCH v3 2/3] cpufreq: intel_pstate: Add base_frequency attribute Srinivas Pandruvada
@ 2018-10-12 16:44 ` Srinivas Pandruvada
  2018-10-15  8:53   ` Rafael J. Wysocki
  2 siblings, 1 reply; 6+ messages in thread
From: Srinivas Pandruvada @ 2018-10-12 16:44 UTC (permalink / raw)
  To: corbet, rjw, lenb, viresh.kumar, robert.moore, erik.schmauss
  Cc: juri.lelli, linux-doc, linux-kernel, linux-acpi, linux-pm, devel,
	pprakash, george.cherian, Srinivas Pandruvada

Updated documentation to explain base_frequency attribute.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 Documentation/admin-guide/pm/intel_pstate.rst | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/admin-guide/pm/intel_pstate.rst b/Documentation/admin-guide/pm/intel_pstate.rst
index 8f1d3de449b5..14a5505e073e 100644
--- a/Documentation/admin-guide/pm/intel_pstate.rst
+++ b/Documentation/admin-guide/pm/intel_pstate.rst
@@ -465,6 +465,10 @@ Next, the following policy attributes have special meaning if
 	policy for the time interval between the last two invocations of the
 	driver's utilization update callback by the CPU scheduler for that CPU.
 
+``base_frequency``
+	When present, shows the base frequency of the CPU. Any frequency above
+	this will be in the turbo frequency range.
+
 The meaning of these attributes in the `passive mode <Passive Mode_>`_ is the
 same as for other scaling drivers.
 
-- 
2.17.1


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

* Re: [PATCH v3 3/3] Documentation: intel_pstate: Add base_frequency information
  2018-10-12 16:44 ` [PATCH v3 3/3] Documentation: intel_pstate: Add base_frequency information Srinivas Pandruvada
@ 2018-10-15  8:53   ` Rafael J. Wysocki
  2018-10-15 15:49     ` Srinivas Pandruvada
  0 siblings, 1 reply; 6+ messages in thread
From: Rafael J. Wysocki @ 2018-10-15  8:53 UTC (permalink / raw)
  To: Srinivas Pandruvada
  Cc: Jonathan Corbet, Rafael J. Wysocki, Len Brown, Viresh Kumar,
	Robert Moore, Schmauss, Erik, Juri Lelli,
	open list:DOCUMENTATION, Linux Kernel Mailing List,
	ACPI Devel Maling List, Linux PM, devel, Prashanth Prakash,
	George Cherian

On Fri, Oct 12, 2018 at 6:44 PM Srinivas Pandruvada
<srinivas.pandruvada@linux.intel.com> wrote:
>
> Updated documentation to explain base_frequency attribute.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
>  Documentation/admin-guide/pm/intel_pstate.rst | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/Documentation/admin-guide/pm/intel_pstate.rst b/Documentation/admin-guide/pm/intel_pstate.rst
> index 8f1d3de449b5..14a5505e073e 100644
> --- a/Documentation/admin-guide/pm/intel_pstate.rst
> +++ b/Documentation/admin-guide/pm/intel_pstate.rst
> @@ -465,6 +465,10 @@ Next, the following policy attributes have special meaning if
>         policy for the time interval between the last two invocations of the
>         driver's utilization update callback by the CPU scheduler for that CPU.
>
> +``base_frequency``
> +       When present, shows the base frequency of the CPU. Any frequency above
> +       this will be in the turbo frequency range.
> +

This isn't entirely correct, because base_frequency is not present in
the passive mode (and it is not present for the other drivers for that
matter).

>  The meaning of these attributes in the `passive mode <Passive Mode_>`_ is the
>  same as for other scaling drivers.

Instead, I would say:

"One more policy attribute is present if the `HWP feature is enabled
in the processor <Active Mode With HWP_>`_:"

here and I would add the description of the attribute below.

Thanks,
Rafael

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

* Re: [PATCH v3 3/3] Documentation: intel_pstate: Add base_frequency information
  2018-10-15  8:53   ` Rafael J. Wysocki
@ 2018-10-15 15:49     ` Srinivas Pandruvada
  0 siblings, 0 replies; 6+ messages in thread
From: Srinivas Pandruvada @ 2018-10-15 15:49 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Jonathan Corbet, Rafael J. Wysocki, Len Brown, Viresh Kumar,
	Robert Moore, Schmauss, Erik, Juri Lelli,
	open list:DOCUMENTATION, Linux Kernel Mailing List,
	ACPI Devel Maling List, Linux PM, devel, Prashanth Prakash,
	George Cherian

On Mon, 2018-10-15 at 10:53 +0200, Rafael J. Wysocki wrote:
> On Fri, Oct 12, 2018 at 6:44 PM Srinivas Pandruvada
> <srinivas.pandruvada@linux.intel.com> wrote:
> > 
> > Updated documentation to explain base_frequency attribute.
> > 
> > Signed-off-by: Srinivas Pandruvada <
> > srinivas.pandruvada@linux.intel.com>
> > ---
> >  Documentation/admin-guide/pm/intel_pstate.rst | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/Documentation/admin-guide/pm/intel_pstate.rst
> > b/Documentation/admin-guide/pm/intel_pstate.rst
> > index 8f1d3de449b5..14a5505e073e 100644
> > --- a/Documentation/admin-guide/pm/intel_pstate.rst
> > +++ b/Documentation/admin-guide/pm/intel_pstate.rst
> > @@ -465,6 +465,10 @@ Next, the following policy attributes have
> > special meaning if
> >         policy for the time interval between the last two
> > invocations of the
> >         driver's utilization update callback by the CPU scheduler
> > for that CPU.
> > 
> > +``base_frequency``
> > +       When present, shows the base frequency of the CPU. Any
> > frequency above
> > +       this will be in the turbo frequency range.
> > +
> 
> This isn't entirely correct, because base_frequency is not present in
> the passive mode (and it is not present for the other drivers for
> that
> matter).
That's why it said, "when present". This keeps door open to add to
other modes too in future if needed.

Thanks,
Srinivas

> 
> >  The meaning of these attributes in the `passive mode <Passive
> > Mode_>`_ is the
> >  same as for other scaling drivers.
> 
> Instead, I would say:
> 
> "One more policy attribute is present if the `HWP feature is enabled
> in the processor <Active Mode With HWP_>`_:"
> 
> here and I would add the description of the attribute below.
> 
> Thanks,
> Rafael


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

end of thread, other threads:[~2018-10-15 15:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-12 16:43 [PATCH v3 0/3] cpufreq: intel_pstate: Base frequency attribute Srinivas Pandruvada
2018-10-12 16:43 ` [PATCH v3 1/3] ACPI / CPPC: Add support for guaranteed performance Srinivas Pandruvada
2018-10-12 16:43 ` [PATCH v3 2/3] cpufreq: intel_pstate: Add base_frequency attribute Srinivas Pandruvada
2018-10-12 16:44 ` [PATCH v3 3/3] Documentation: intel_pstate: Add base_frequency information Srinivas Pandruvada
2018-10-15  8:53   ` Rafael J. Wysocki
2018-10-15 15:49     ` Srinivas Pandruvada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).