linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powercap/rapl: add support for ValleyView Soc
@ 2013-12-11 22:39 Jacob Pan
  2013-12-22  1:06 ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Jacob Pan @ 2013-12-11 22:39 UTC (permalink / raw)
  To: LKML, Linux PM, Srinivas Pandruvada, Rafael Wysocki
  Cc: Gavin Hindman, Triplett, Josh, Jacob Pan

This patch adds support for RAPL on Intel ValleyView based SoC
platforms, such as Baytrail.

Besides adding CPU ID, special energy unit encoding is handled
for ValleyView.

Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
---
 drivers/powercap/intel_rapl.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/powercap/intel_rapl.c b/drivers/powercap/intel_rapl.c
index 2a786c5..3c67683 100644
--- a/drivers/powercap/intel_rapl.c
+++ b/drivers/powercap/intel_rapl.c
@@ -833,6 +833,11 @@ static int rapl_write_data_raw(struct rapl_domain *rd,
 	return 0;
 }
 
+static const struct x86_cpu_id energy_unit_quirk_ids[] = {
+	{ X86_VENDOR_INTEL, 6, 0x37},/* VLV */
+	{}
+};
+
 static int rapl_check_unit(struct rapl_package *rp, int cpu)
 {
 	u64 msr_val;
@@ -853,8 +858,11 @@ static int rapl_check_unit(struct rapl_package *rp, int cpu)
 	 * time unit: 1/time_unit_divisor Seconds
 	 */
 	value = (msr_val & ENERGY_UNIT_MASK) >> ENERGY_UNIT_OFFSET;
-	rp->energy_unit_divisor = 1 << value;
-
+	/* some CPUs have different way to calculate energy unit */
+	if (x86_match_cpu(energy_unit_quirk_ids))
+		rp->energy_unit_divisor = 1000000 / (1 << value);
+	else
+		rp->energy_unit_divisor = 1 << value;
 
 	value = (msr_val & POWER_UNIT_MASK) >> POWER_UNIT_OFFSET;
 	rp->power_unit_divisor = 1 << value;
@@ -941,6 +949,7 @@ static void package_power_limit_irq_restore(int package_id)
 static const struct x86_cpu_id rapl_ids[] = {
 	{ X86_VENDOR_INTEL, 6, 0x2a},/* SNB */
 	{ X86_VENDOR_INTEL, 6, 0x2d},/* SNB EP */
+	{ X86_VENDOR_INTEL, 6, 0x37},/* VLV */
 	{ X86_VENDOR_INTEL, 6, 0x3a},/* IVB */
 	{ X86_VENDOR_INTEL, 6, 0x45},/* HSW */
 	/* TODO: Add more CPU IDs after testing */
-- 
1.8.1.2


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

* Re: [PATCH] powercap/rapl: add support for ValleyView Soc
  2013-12-11 22:39 [PATCH] powercap/rapl: add support for ValleyView Soc Jacob Pan
@ 2013-12-22  1:06 ` Rafael J. Wysocki
  2013-12-22 19:22   ` Vince Weaver
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2013-12-22  1:06 UTC (permalink / raw)
  To: Jacob Pan
  Cc: LKML, Linux PM, Srinivas Pandruvada, Rafael Wysocki,
	Gavin Hindman, Triplett, Josh

On Wednesday, December 11, 2013 02:39:27 PM Jacob Pan wrote:
> This patch adds support for RAPL on Intel ValleyView based SoC
> platforms, such as Baytrail.
> 
> Besides adding CPU ID, special energy unit encoding is handled
> for ValleyView.
> 
> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>

Queued up for 3.14, thanks!

> ---
>  drivers/powercap/intel_rapl.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/powercap/intel_rapl.c b/drivers/powercap/intel_rapl.c
> index 2a786c5..3c67683 100644
> --- a/drivers/powercap/intel_rapl.c
> +++ b/drivers/powercap/intel_rapl.c
> @@ -833,6 +833,11 @@ static int rapl_write_data_raw(struct rapl_domain *rd,
>  	return 0;
>  }
>  
> +static const struct x86_cpu_id energy_unit_quirk_ids[] = {
> +	{ X86_VENDOR_INTEL, 6, 0x37},/* VLV */
> +	{}
> +};
> +
>  static int rapl_check_unit(struct rapl_package *rp, int cpu)
>  {
>  	u64 msr_val;
> @@ -853,8 +858,11 @@ static int rapl_check_unit(struct rapl_package *rp, int cpu)
>  	 * time unit: 1/time_unit_divisor Seconds
>  	 */
>  	value = (msr_val & ENERGY_UNIT_MASK) >> ENERGY_UNIT_OFFSET;
> -	rp->energy_unit_divisor = 1 << value;
> -
> +	/* some CPUs have different way to calculate energy unit */
> +	if (x86_match_cpu(energy_unit_quirk_ids))
> +		rp->energy_unit_divisor = 1000000 / (1 << value);
> +	else
> +		rp->energy_unit_divisor = 1 << value;
>  
>  	value = (msr_val & POWER_UNIT_MASK) >> POWER_UNIT_OFFSET;
>  	rp->power_unit_divisor = 1 << value;
> @@ -941,6 +949,7 @@ static void package_power_limit_irq_restore(int package_id)
>  static const struct x86_cpu_id rapl_ids[] = {
>  	{ X86_VENDOR_INTEL, 6, 0x2a},/* SNB */
>  	{ X86_VENDOR_INTEL, 6, 0x2d},/* SNB EP */
> +	{ X86_VENDOR_INTEL, 6, 0x37},/* VLV */
>  	{ X86_VENDOR_INTEL, 6, 0x3a},/* IVB */
>  	{ X86_VENDOR_INTEL, 6, 0x45},/* HSW */
>  	/* TODO: Add more CPU IDs after testing */
> 
-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

* Re: [PATCH] powercap/rapl: add support for ValleyView Soc
  2013-12-22  1:06 ` Rafael J. Wysocki
@ 2013-12-22 19:22   ` Vince Weaver
  2013-12-22 21:21     ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Vince Weaver @ 2013-12-22 19:22 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Jacob Pan, LKML, Linux PM, Srinivas Pandruvada, Rafael Wysocki,
	Gavin Hindman, Triplett, Josh

On Sun, 22 Dec 2013, Rafael J. Wysocki wrote:
> On Wednesday, December 11, 2013 02:39:27 PM Jacob Pan wrote:

> > @@ -941,6 +949,7 @@ static void package_power_limit_irq_restore(int package_id)
> >  static const struct x86_cpu_id rapl_ids[] = {
> >  	{ X86_VENDOR_INTEL, 6, 0x2a},/* SNB */
> >  	{ X86_VENDOR_INTEL, 6, 0x2d},/* SNB EP */
> > +	{ X86_VENDOR_INTEL, 6, 0x37},/* VLV */
> >  	{ X86_VENDOR_INTEL, 6, 0x3a},/* IVB */
> >  	{ X86_VENDOR_INTEL, 6, 0x45},/* HSW */
> >  	/* TODO: Add more CPU IDs after testing */

This isn't a problem introduced in this patch, but it made me notice it...

Would it really hurt anyone to spell out the architectures here, rather
than using obscure 3-letter abbreviations?  It's bad enough trying to
map the hex model numbers to the decimal ones in /proc/cpuinfo without
also having to remember what a VLV is.

Vince

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

* Re: [PATCH] powercap/rapl: add support for ValleyView Soc
  2013-12-22 19:22   ` Vince Weaver
@ 2013-12-22 21:21     ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2013-12-22 21:21 UTC (permalink / raw)
  To: Vince Weaver
  Cc: Jacob Pan, LKML, Linux PM, Srinivas Pandruvada, Rafael Wysocki,
	Gavin Hindman, Triplett, Josh

On Sunday, December 22, 2013 02:22:48 PM Vince Weaver wrote:
> On Sun, 22 Dec 2013, Rafael J. Wysocki wrote:
> > On Wednesday, December 11, 2013 02:39:27 PM Jacob Pan wrote:
> 
> > > @@ -941,6 +949,7 @@ static void package_power_limit_irq_restore(int package_id)
> > >  static const struct x86_cpu_id rapl_ids[] = {
> > >  	{ X86_VENDOR_INTEL, 6, 0x2a},/* SNB */
> > >  	{ X86_VENDOR_INTEL, 6, 0x2d},/* SNB EP */
> > > +	{ X86_VENDOR_INTEL, 6, 0x37},/* VLV */
> > >  	{ X86_VENDOR_INTEL, 6, 0x3a},/* IVB */
> > >  	{ X86_VENDOR_INTEL, 6, 0x45},/* HSW */
> > >  	/* TODO: Add more CPU IDs after testing */
> 
> This isn't a problem introduced in this patch, but it made me notice it...
> 
> Would it really hurt anyone to spell out the architectures here, rather
> than using obscure 3-letter abbreviations?  It's bad enough trying to
> map the hex model numbers to the decimal ones in /proc/cpuinfo without
> also having to remember what a VLV is.

I guess you can prepare a patch for that?

Rafael


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

end of thread, other threads:[~2013-12-22 21:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-11 22:39 [PATCH] powercap/rapl: add support for ValleyView Soc Jacob Pan
2013-12-22  1:06 ` Rafael J. Wysocki
2013-12-22 19:22   ` Vince Weaver
2013-12-22 21:21     ` Rafael J. Wysocki

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).