aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSherry Hurwitz <sherry.hurwitz@amd.com>2017-06-20 03:08:42 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-06-26 19:43:22 -0400
commit902bef73faa99b8c024e0f18c6199872b7cccb52 (patch)
treef235b3a54098e33402dbee96d95ef4bb01758f9b /tools
parent6ae78b4e7c276e5306897269443f66cb4d86e47f (diff)
cpupower: Add support for new AMD family 0x17
Add support for new AMD family 0x17 - Add bit field changes to the msr_pstate structure - Add the new formula for the calculation of cof - Changed method to access to CpbDis Signed-off-by: Sherry Hurwitz <sherry.hurwitz@amd.com> Acked-by: Thomas Renninger <trenn@suse.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/power/cpupower/utils/helpers/amd.c31
-rw-r--r--tools/power/cpupower/utils/helpers/helpers.h2
-rw-r--r--tools/power/cpupower/utils/helpers/misc.c22
3 files changed, 44 insertions, 11 deletions
diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c
index 6437ef39aeea..5fd5c5b8c7b8 100644
--- a/tools/power/cpupower/utils/helpers/amd.c
+++ b/tools/power/cpupower/utils/helpers/amd.c
@@ -26,6 +26,15 @@ union msr_pstate {
26 unsigned res3:21; 26 unsigned res3:21;
27 unsigned en:1; 27 unsigned en:1;
28 } bits; 28 } bits;
29 struct {
30 unsigned fid:8;
31 unsigned did:6;
32 unsigned vid:8;
33 unsigned iddval:8;
34 unsigned idddiv:2;
35 unsigned res1:30;
36 unsigned en:1;
37 } fam17h_bits;
29 unsigned long long val; 38 unsigned long long val;
30}; 39};
31 40
@@ -35,6 +44,8 @@ static int get_did(int family, union msr_pstate pstate)
35 44
36 if (family == 0x12) 45 if (family == 0x12)
37 t = pstate.val & 0xf; 46 t = pstate.val & 0xf;
47 else if (family == 0x17)
48 t = pstate.fam17h_bits.did;
38 else 49 else
39 t = pstate.bits.did; 50 t = pstate.bits.did;
40 51
@@ -44,16 +55,20 @@ static int get_did(int family, union msr_pstate pstate)
44static int get_cof(int family, union msr_pstate pstate) 55static int get_cof(int family, union msr_pstate pstate)
45{ 56{
46 int t; 57 int t;
47 int fid, did; 58 int fid, did, cof;
48 59
49 did = get_did(family, pstate); 60 did = get_did(family, pstate);
50 61 if (family == 0x17) {
51 t = 0x10; 62 fid = pstate.fam17h_bits.fid;
52 fid = pstate.bits.fid; 63 cof = 200 * fid / did;
53 if (family == 0x11) 64 } else {
54 t = 0x8; 65 t = 0x10;
55 66 fid = pstate.bits.fid;
56 return (100 * (fid + t)) >> did; 67 if (family == 0x11)
68 t = 0x8;
69 cof = (100 * (fid + t)) >> did;
70 }
71 return cof;
57} 72}
58 73
59/* Needs: 74/* Needs:
diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h
index afb66f80554e..799a18be60aa 100644
--- a/tools/power/cpupower/utils/helpers/helpers.h
+++ b/tools/power/cpupower/utils/helpers/helpers.h
@@ -70,6 +70,8 @@ enum cpupower_cpu_vendor {X86_VENDOR_UNKNOWN = 0, X86_VENDOR_INTEL,
70#define CPUPOWER_CAP_IS_SNB 0x00000020 70#define CPUPOWER_CAP_IS_SNB 0x00000020
71#define CPUPOWER_CAP_INTEL_IDA 0x00000040 71#define CPUPOWER_CAP_INTEL_IDA 0x00000040
72 72
73#define CPUPOWER_AMD_CPBDIS 0x02000000
74
73#define MAX_HW_PSTATES 10 75#define MAX_HW_PSTATES 10
74 76
75struct cpupower_cpu_info { 77struct cpupower_cpu_info {
diff --git a/tools/power/cpupower/utils/helpers/misc.c b/tools/power/cpupower/utils/helpers/misc.c
index 6952a6abd1e5..601d719d4e60 100644
--- a/tools/power/cpupower/utils/helpers/misc.c
+++ b/tools/power/cpupower/utils/helpers/misc.c
@@ -2,11 +2,14 @@
2 2
3#include "helpers/helpers.h" 3#include "helpers/helpers.h"
4 4
5#define MSR_AMD_HWCR 0xc0010015
6
5int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active, 7int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active,
6 int *states) 8 int *states)
7{ 9{
8 struct cpupower_cpu_info cpu_info; 10 struct cpupower_cpu_info cpu_info;
9 int ret; 11 int ret;
12 unsigned long long val;
10 13
11 *support = *active = *states = 0; 14 *support = *active = *states = 0;
12 15
@@ -16,9 +19,22 @@ int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active,
16 19
17 if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_CBP) { 20 if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_CBP) {
18 *support = 1; 21 *support = 1;
19 ret = amd_pci_get_num_boost_states(active, states); 22
20 if (ret) 23 /* AMD Family 0x17 does not utilize PCI D18F4 like prior
21 return ret; 24 * families and has no fixed discrete boost states but
25 * has Hardware determined variable increments instead.
26 */
27
28 if (cpu_info.family == 0x17) {
29 if (!read_msr(cpu, MSR_AMD_HWCR, &val)) {
30 if (!(val & CPUPOWER_AMD_CPBDIS))
31 *active = 1;
32 }
33 } else {
34 ret = amd_pci_get_num_boost_states(active, states);
35 if (ret)
36 return ret;
37 }
22 } else if (cpupower_cpu_info.caps & CPUPOWER_CAP_INTEL_IDA) 38 } else if (cpupower_cpu_info.caps & CPUPOWER_CAP_INTEL_IDA)
23 *support = *active = 1; 39 *support = *active = 1;
24 return 0; 40 return 0;