diff options
Diffstat (limited to 'tools/power/cpupower/utils')
-rw-r--r-- | tools/power/cpupower/utils/cpuidle-info.c | 12 | ||||
-rw-r--r-- | tools/power/cpupower/utils/helpers/amd.c | 4 | ||||
-rw-r--r-- | tools/power/cpupower/utils/helpers/helpers.h | 11 | ||||
-rw-r--r-- | tools/power/cpupower/utils/helpers/pci.c | 35 | ||||
-rw-r--r-- | tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c | 25 |
5 files changed, 44 insertions, 43 deletions
diff --git a/tools/power/cpupower/utils/cpuidle-info.c b/tools/power/cpupower/utils/cpuidle-info.c index b028267c1376..8145af5f93a6 100644 --- a/tools/power/cpupower/utils/cpuidle-info.c +++ b/tools/power/cpupower/utils/cpuidle-info.c | |||
@@ -35,17 +35,9 @@ static void cpuidle_cpu_output(unsigned int cpu, int verbose) | |||
35 | printf(_("CPU %u: Can't read idle state info\n"), cpu); | 35 | printf(_("CPU %u: Can't read idle state info\n"), cpu); |
36 | return; | 36 | return; |
37 | } | 37 | } |
38 | tmp = sysfs_get_idlestate_name(cpu, idlestates - 1); | ||
39 | if (!tmp) { | ||
40 | printf(_("Could not determine max idle state %u\n"), | ||
41 | idlestates - 1); | ||
42 | return; | ||
43 | } | ||
44 | |||
45 | printf(_("Number of idle states: %d\n"), idlestates); | 38 | printf(_("Number of idle states: %d\n"), idlestates); |
46 | |||
47 | printf(_("Available idle states:")); | 39 | printf(_("Available idle states:")); |
48 | for (idlestate = 1; idlestate < idlestates; idlestate++) { | 40 | for (idlestate = 0; idlestate < idlestates; idlestate++) { |
49 | tmp = sysfs_get_idlestate_name(cpu, idlestate); | 41 | tmp = sysfs_get_idlestate_name(cpu, idlestate); |
50 | if (!tmp) | 42 | if (!tmp) |
51 | continue; | 43 | continue; |
@@ -57,7 +49,7 @@ static void cpuidle_cpu_output(unsigned int cpu, int verbose) | |||
57 | if (!verbose) | 49 | if (!verbose) |
58 | return; | 50 | return; |
59 | 51 | ||
60 | for (idlestate = 1; idlestate < idlestates; idlestate++) { | 52 | for (idlestate = 0; idlestate < idlestates; idlestate++) { |
61 | tmp = sysfs_get_idlestate_name(cpu, idlestate); | 53 | tmp = sysfs_get_idlestate_name(cpu, idlestate); |
62 | if (!tmp) | 54 | if (!tmp) |
63 | continue; | 55 | continue; |
diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c index 87d5605bdda8..6437ef39aeea 100644 --- a/tools/power/cpupower/utils/helpers/amd.c +++ b/tools/power/cpupower/utils/helpers/amd.c | |||
@@ -112,14 +112,12 @@ int decode_pstates(unsigned int cpu, unsigned int cpu_family, | |||
112 | int amd_pci_get_num_boost_states(int *active, int *states) | 112 | int amd_pci_get_num_boost_states(int *active, int *states) |
113 | { | 113 | { |
114 | struct pci_access *pci_acc; | 114 | struct pci_access *pci_acc; |
115 | int vendor_id = 0x1022; | ||
116 | int boost_dev_ids[4] = {0x1204, 0x1604, 0x1704, 0}; | ||
117 | struct pci_dev *device; | 115 | struct pci_dev *device; |
118 | uint8_t val = 0; | 116 | uint8_t val = 0; |
119 | 117 | ||
120 | *active = *states = 0; | 118 | *active = *states = 0; |
121 | 119 | ||
122 | device = pci_acc_init(&pci_acc, vendor_id, boost_dev_ids); | 120 | device = pci_slot_func_init(&pci_acc, 0x18, 4); |
123 | 121 | ||
124 | if (device == NULL) | 122 | if (device == NULL) |
125 | return -ENODEV; | 123 | return -ENODEV; |
diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h index 2747e738efb0..2eb584cf2f55 100644 --- a/tools/power/cpupower/utils/helpers/helpers.h +++ b/tools/power/cpupower/utils/helpers/helpers.h | |||
@@ -66,8 +66,8 @@ enum cpupower_cpu_vendor {X86_VENDOR_UNKNOWN = 0, X86_VENDOR_INTEL, | |||
66 | #define CPUPOWER_CAP_AMD_CBP 0x00000004 | 66 | #define CPUPOWER_CAP_AMD_CBP 0x00000004 |
67 | #define CPUPOWER_CAP_PERF_BIAS 0x00000008 | 67 | #define CPUPOWER_CAP_PERF_BIAS 0x00000008 |
68 | #define CPUPOWER_CAP_HAS_TURBO_RATIO 0x00000010 | 68 | #define CPUPOWER_CAP_HAS_TURBO_RATIO 0x00000010 |
69 | #define CPUPOWER_CAP_IS_SNB 0x00000011 | 69 | #define CPUPOWER_CAP_IS_SNB 0x00000020 |
70 | #define CPUPOWER_CAP_INTEL_IDA 0x00000012 | 70 | #define CPUPOWER_CAP_INTEL_IDA 0x00000040 |
71 | 71 | ||
72 | #define MAX_HW_PSTATES 10 | 72 | #define MAX_HW_PSTATES 10 |
73 | 73 | ||
@@ -132,8 +132,11 @@ extern unsigned long long msr_intel_get_turbo_ratio(unsigned int cpu); | |||
132 | 132 | ||
133 | /* PCI stuff ****************************/ | 133 | /* PCI stuff ****************************/ |
134 | extern int amd_pci_get_num_boost_states(int *active, int *states); | 134 | extern int amd_pci_get_num_boost_states(int *active, int *states); |
135 | extern struct pci_dev *pci_acc_init(struct pci_access **pacc, int vendor_id, | 135 | extern struct pci_dev *pci_acc_init(struct pci_access **pacc, int domain, |
136 | int *dev_ids); | 136 | int bus, int slot, int func, int vendor, |
137 | int dev); | ||
138 | extern struct pci_dev *pci_slot_func_init(struct pci_access **pacc, | ||
139 | int slot, int func); | ||
137 | 140 | ||
138 | /* PCI stuff ****************************/ | 141 | /* PCI stuff ****************************/ |
139 | 142 | ||
diff --git a/tools/power/cpupower/utils/helpers/pci.c b/tools/power/cpupower/utils/helpers/pci.c index cd2eb6fe41c4..9690798e6446 100644 --- a/tools/power/cpupower/utils/helpers/pci.c +++ b/tools/power/cpupower/utils/helpers/pci.c | |||
@@ -10,19 +10,24 @@ | |||
10 | * **pacc : if a valid pci_dev is returned | 10 | * **pacc : if a valid pci_dev is returned |
11 | * *pacc must be passed to pci_acc_cleanup to free it | 11 | * *pacc must be passed to pci_acc_cleanup to free it |
12 | * | 12 | * |
13 | * vendor_id : the pci vendor id matching the pci device to access | 13 | * domain: domain |
14 | * dev_ids : device ids matching the pci device to access | 14 | * bus: bus |
15 | * slot: slot | ||
16 | * func: func | ||
17 | * vendor: vendor | ||
18 | * device: device | ||
19 | * Pass -1 for one of the six above to match any | ||
15 | * | 20 | * |
16 | * Returns : | 21 | * Returns : |
17 | * struct pci_dev which can be used with pci_{read,write}_* functions | 22 | * struct pci_dev which can be used with pci_{read,write}_* functions |
18 | * to access the PCI config space of matching pci devices | 23 | * to access the PCI config space of matching pci devices |
19 | */ | 24 | */ |
20 | struct pci_dev *pci_acc_init(struct pci_access **pacc, int vendor_id, | 25 | struct pci_dev *pci_acc_init(struct pci_access **pacc, int domain, int bus, |
21 | int *dev_ids) | 26 | int slot, int func, int vendor, int dev) |
22 | { | 27 | { |
23 | struct pci_filter filter_nb_link = { -1, -1, -1, -1, vendor_id, 0}; | 28 | struct pci_filter filter_nb_link = { domain, bus, slot, func, |
29 | vendor, dev }; | ||
24 | struct pci_dev *device; | 30 | struct pci_dev *device; |
25 | unsigned int i; | ||
26 | 31 | ||
27 | *pacc = pci_alloc(); | 32 | *pacc = pci_alloc(); |
28 | if (*pacc == NULL) | 33 | if (*pacc == NULL) |
@@ -31,14 +36,20 @@ struct pci_dev *pci_acc_init(struct pci_access **pacc, int vendor_id, | |||
31 | pci_init(*pacc); | 36 | pci_init(*pacc); |
32 | pci_scan_bus(*pacc); | 37 | pci_scan_bus(*pacc); |
33 | 38 | ||
34 | for (i = 0; dev_ids[i] != 0; i++) { | 39 | for (device = (*pacc)->devices; device; device = device->next) { |
35 | filter_nb_link.device = dev_ids[i]; | 40 | if (pci_filter_match(&filter_nb_link, device)) |
36 | for (device = (*pacc)->devices; device; device = device->next) { | 41 | return device; |
37 | if (pci_filter_match(&filter_nb_link, device)) | ||
38 | return device; | ||
39 | } | ||
40 | } | 42 | } |
41 | pci_cleanup(*pacc); | 43 | pci_cleanup(*pacc); |
42 | return NULL; | 44 | return NULL; |
43 | } | 45 | } |
46 | |||
47 | /* Typically one wants to get a specific slot(device)/func of the root domain | ||
48 | and bus */ | ||
49 | struct pci_dev *pci_slot_func_init(struct pci_access **pacc, int slot, | ||
50 | int func) | ||
51 | { | ||
52 | return pci_acc_init(pacc, 0, 0, slot, func, -1, -1); | ||
53 | } | ||
54 | |||
44 | #endif /* defined(__i386__) || defined(__x86_64__) */ | 55 | #endif /* defined(__i386__) || defined(__x86_64__) */ |
diff --git a/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c b/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c index 202e555988be..2116df9ad832 100644 --- a/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c +++ b/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c | |||
@@ -20,8 +20,6 @@ | |||
20 | #include "idle_monitor/cpupower-monitor.h" | 20 | #include "idle_monitor/cpupower-monitor.h" |
21 | #include "helpers/helpers.h" | 21 | #include "helpers/helpers.h" |
22 | 22 | ||
23 | /******** PCI parts could go into own file and get shared ***************/ | ||
24 | |||
25 | #define PCI_NON_PC0_OFFSET 0xb0 | 23 | #define PCI_NON_PC0_OFFSET 0xb0 |
26 | #define PCI_PC1_OFFSET 0xb4 | 24 | #define PCI_PC1_OFFSET 0xb4 |
27 | #define PCI_PC6_OFFSET 0xb8 | 25 | #define PCI_PC6_OFFSET 0xb8 |
@@ -82,10 +80,7 @@ static cstate_t amd_fam14h_cstates[AMD_FAM14H_STATE_NUM] = { | |||
82 | }; | 80 | }; |
83 | 81 | ||
84 | static struct pci_access *pci_acc; | 82 | static struct pci_access *pci_acc; |
85 | static int pci_vendor_id = 0x1022; | ||
86 | static int pci_dev_ids[2] = {0x1716, 0}; | ||
87 | static struct pci_dev *amd_fam14h_pci_dev; | 83 | static struct pci_dev *amd_fam14h_pci_dev; |
88 | |||
89 | static int nbp1_entered; | 84 | static int nbp1_entered; |
90 | 85 | ||
91 | struct timespec start_time; | 86 | struct timespec start_time; |
@@ -286,13 +281,13 @@ struct cpuidle_monitor *amd_fam14h_register(void) | |||
286 | if (cpupower_cpu_info.vendor != X86_VENDOR_AMD) | 281 | if (cpupower_cpu_info.vendor != X86_VENDOR_AMD) |
287 | return NULL; | 282 | return NULL; |
288 | 283 | ||
289 | if (cpupower_cpu_info.family == 0x14) { | 284 | if (cpupower_cpu_info.family == 0x14) |
290 | if (cpu_count <= 0 || cpu_count > 2) { | 285 | strncpy(amd_fam14h_monitor.name, "Fam_14h", |
291 | fprintf(stderr, "AMD fam14h: Invalid cpu count: %d\n", | 286 | MONITOR_NAME_LEN - 1); |
292 | cpu_count); | 287 | else if (cpupower_cpu_info.family == 0x12) |
293 | return NULL; | 288 | strncpy(amd_fam14h_monitor.name, "Fam_12h", |
294 | } | 289 | MONITOR_NAME_LEN - 1); |
295 | } else | 290 | else |
296 | return NULL; | 291 | return NULL; |
297 | 292 | ||
298 | /* We do not alloc for nbp1 machine wide counter */ | 293 | /* We do not alloc for nbp1 machine wide counter */ |
@@ -303,7 +298,9 @@ struct cpuidle_monitor *amd_fam14h_register(void) | |||
303 | sizeof(unsigned long long)); | 298 | sizeof(unsigned long long)); |
304 | } | 299 | } |
305 | 300 | ||
306 | amd_fam14h_pci_dev = pci_acc_init(&pci_acc, pci_vendor_id, pci_dev_ids); | 301 | /* We need PCI device: Slot 18, Func 6, compare with BKDG |
302 | for fam 12h/14h */ | ||
303 | amd_fam14h_pci_dev = pci_slot_func_init(&pci_acc, 0x18, 6); | ||
307 | if (amd_fam14h_pci_dev == NULL || pci_acc == NULL) | 304 | if (amd_fam14h_pci_dev == NULL || pci_acc == NULL) |
308 | return NULL; | 305 | return NULL; |
309 | 306 | ||
@@ -325,7 +322,7 @@ static void amd_fam14h_unregister(void) | |||
325 | } | 322 | } |
326 | 323 | ||
327 | struct cpuidle_monitor amd_fam14h_monitor = { | 324 | struct cpuidle_monitor amd_fam14h_monitor = { |
328 | .name = "Ontario", | 325 | .name = "", |
329 | .hw_states = amd_fam14h_cstates, | 326 | .hw_states = amd_fam14h_cstates, |
330 | .hw_states_num = AMD_FAM14H_STATE_NUM, | 327 | .hw_states_num = AMD_FAM14H_STATE_NUM, |
331 | .start = amd_fam14h_start, | 328 | .start = amd_fam14h_start, |