diff options
3 files changed, 44 insertions, 15 deletions
diff --git a/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c b/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c index 5b3205f16217..5b8c4956ff9a 100644 --- a/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c +++ b/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c | |||
@@ -126,6 +126,20 @@ void fix_up_intel_idle_driver_name(char *tmp, int num) | |||
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
129 | #ifdef __powerpc__ | ||
130 | void map_power_idle_state_name(char *tmp) | ||
131 | { | ||
132 | if (!strncmp(tmp, "stop0_lite", CSTATE_NAME_LEN)) | ||
133 | strcpy(tmp, "stop0L"); | ||
134 | else if (!strncmp(tmp, "stop1_lite", CSTATE_NAME_LEN)) | ||
135 | strcpy(tmp, "stop1L"); | ||
136 | else if (!strncmp(tmp, "stop2_lite", CSTATE_NAME_LEN)) | ||
137 | strcpy(tmp, "stop2L"); | ||
138 | } | ||
139 | #else | ||
140 | void map_power_idle_state_name(char *tmp) { } | ||
141 | #endif | ||
142 | |||
129 | static struct cpuidle_monitor *cpuidle_register(void) | 143 | static struct cpuidle_monitor *cpuidle_register(void) |
130 | { | 144 | { |
131 | int num; | 145 | int num; |
@@ -145,6 +159,7 @@ static struct cpuidle_monitor *cpuidle_register(void) | |||
145 | if (tmp == NULL) | 159 | if (tmp == NULL) |
146 | continue; | 160 | continue; |
147 | 161 | ||
162 | map_power_idle_state_name(tmp); | ||
148 | fix_up_intel_idle_driver_name(tmp, num); | 163 | fix_up_intel_idle_driver_name(tmp, num); |
149 | strncpy(cpuidle_cstates[num].name, tmp, CSTATE_NAME_LEN - 1); | 164 | strncpy(cpuidle_cstates[num].name, tmp, CSTATE_NAME_LEN - 1); |
150 | free(tmp); | 165 | free(tmp); |
diff --git a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c index 05f953f0f0a0..051da0a7c454 100644 --- a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c +++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c | |||
@@ -70,36 +70,43 @@ void print_n_spaces(int n) | |||
70 | printf(" "); | 70 | printf(" "); |
71 | } | 71 | } |
72 | 72 | ||
73 | /* size of s must be at least n + 1 */ | 73 | /*s is filled with left and right spaces |
74 | *to make its length atleast n+1 | ||
75 | */ | ||
74 | int fill_string_with_spaces(char *s, int n) | 76 | int fill_string_with_spaces(char *s, int n) |
75 | { | 77 | { |
78 | char *temp; | ||
76 | int len = strlen(s); | 79 | int len = strlen(s); |
77 | if (len > n) | 80 | |
81 | if (len >= n) | ||
78 | return -1; | 82 | return -1; |
83 | |||
84 | temp = malloc(sizeof(char) * (n+1)); | ||
79 | for (; len < n; len++) | 85 | for (; len < n; len++) |
80 | s[len] = ' '; | 86 | s[len] = ' '; |
81 | s[len] = '\0'; | 87 | s[len] = '\0'; |
88 | snprintf(temp, n+1, " %s", s); | ||
89 | strcpy(s, temp); | ||
90 | free(temp); | ||
82 | return 0; | 91 | return 0; |
83 | } | 92 | } |
84 | 93 | ||
94 | #define MAX_COL_WIDTH 6 | ||
85 | void print_header(int topology_depth) | 95 | void print_header(int topology_depth) |
86 | { | 96 | { |
87 | int unsigned mon; | 97 | int unsigned mon; |
88 | int state, need_len; | 98 | int state, need_len; |
89 | cstate_t s; | 99 | cstate_t s; |
90 | char buf[128] = ""; | 100 | char buf[128] = ""; |
91 | int percent_width = 4; | ||
92 | 101 | ||
93 | fill_string_with_spaces(buf, topology_depth * 5 - 1); | 102 | fill_string_with_spaces(buf, topology_depth * 5 - 1); |
94 | printf("%s|", buf); | 103 | printf("%s|", buf); |
95 | 104 | ||
96 | for (mon = 0; mon < avail_monitors; mon++) { | 105 | for (mon = 0; mon < avail_monitors; mon++) { |
97 | need_len = monitors[mon]->hw_states_num * (percent_width + 3) | 106 | need_len = monitors[mon]->hw_states_num * (MAX_COL_WIDTH + 1) |
98 | - 1; | 107 | - 1; |
99 | if (mon != 0) { | 108 | if (mon != 0) |
100 | printf("|| "); | 109 | printf("||"); |
101 | need_len--; | ||
102 | } | ||
103 | sprintf(buf, "%s", monitors[mon]->name); | 110 | sprintf(buf, "%s", monitors[mon]->name); |
104 | fill_string_with_spaces(buf, need_len); | 111 | fill_string_with_spaces(buf, need_len); |
105 | printf("%s", buf); | 112 | printf("%s", buf); |
@@ -107,23 +114,21 @@ void print_header(int topology_depth) | |||
107 | printf("\n"); | 114 | printf("\n"); |
108 | 115 | ||
109 | if (topology_depth > 2) | 116 | if (topology_depth > 2) |
110 | printf("PKG |"); | 117 | printf(" PKG|"); |
111 | if (topology_depth > 1) | 118 | if (topology_depth > 1) |
112 | printf("CORE|"); | 119 | printf("CORE|"); |
113 | if (topology_depth > 0) | 120 | if (topology_depth > 0) |
114 | printf("CPU |"); | 121 | printf(" CPU|"); |
115 | 122 | ||
116 | for (mon = 0; mon < avail_monitors; mon++) { | 123 | for (mon = 0; mon < avail_monitors; mon++) { |
117 | if (mon != 0) | 124 | if (mon != 0) |
118 | printf("|| "); | 125 | printf("||"); |
119 | else | ||
120 | printf(" "); | ||
121 | for (state = 0; state < monitors[mon]->hw_states_num; state++) { | 126 | for (state = 0; state < monitors[mon]->hw_states_num; state++) { |
122 | if (state != 0) | 127 | if (state != 0) |
123 | printf(" | "); | 128 | printf("|"); |
124 | s = monitors[mon]->hw_states[state]; | 129 | s = monitors[mon]->hw_states[state]; |
125 | sprintf(buf, "%s", s.name); | 130 | sprintf(buf, "%s", s.name); |
126 | fill_string_with_spaces(buf, percent_width); | 131 | fill_string_with_spaces(buf, MAX_COL_WIDTH); |
127 | printf("%s", buf); | 132 | printf("%s", buf); |
128 | } | 133 | } |
129 | printf(" "); | 134 | printf(" "); |
diff --git a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h index 9e43f3371fbc..2ae50b499e0a 100644 --- a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h +++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h | |||
@@ -15,7 +15,16 @@ | |||
15 | 15 | ||
16 | #define MONITORS_MAX 20 | 16 | #define MONITORS_MAX 20 |
17 | #define MONITOR_NAME_LEN 20 | 17 | #define MONITOR_NAME_LEN 20 |
18 | |||
19 | /* CSTATE_NAME_LEN is limited by header field width defined | ||
20 | * in cpupower-monitor.c. Header field width is defined to be | ||
21 | * sum of percent width and two spaces for padding. | ||
22 | */ | ||
23 | #ifdef __powerpc__ | ||
24 | #define CSTATE_NAME_LEN 7 | ||
25 | #else | ||
18 | #define CSTATE_NAME_LEN 5 | 26 | #define CSTATE_NAME_LEN 5 |
27 | #endif | ||
19 | #define CSTATE_DESC_LEN 60 | 28 | #define CSTATE_DESC_LEN 60 |
20 | 29 | ||
21 | int cpu_count; | 30 | int cpu_count; |