powercap/rapl: add support for ValleyView Soc
PATCH 1/1 powercap/rapl: add support for ValleyView Soc
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.
--- drivers/powercap/intel_rapl.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/powercap/intel_rapl.c +11 -2
@@ -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 */
Signature · 1 line
1.8.1.2
Rafael J. Wysocki
AppliedQuoted 7 lines · 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 <[email protected]>
Queued up for 3.14, thanks!
Quoted 43 lines
--- drivers/powercap/intel_rapl.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)drivers/powercap/intel_rapl.c +11
-2@@ -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 */
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Quoted 10 lines · Rafael J. Wysocki
drivers/powercap/intel_rapl.c static void package_power_limit_irq_restore(int package_id) · line 955
Quoted 8 lines · Jacob Pan
drivers/powercap/intel_rapl.c +1
-0@@ -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
Quoted 14 lines · Vince Weaver
Quoted 10 lines · Rafael J. Wysocki
drivers/powercap/intel_rapl.c static void package_power_limit_irq_restore(int package_id) · line 955
Quoted 8 lines · Jacob Pan
drivers/powercap/intel_rapl.c +1
-0@@ -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...
Quoted 4 lines
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/cpuinfowithout also having to remember what a VLV is.
I guess you can prepare a patch for that?
Rafael