Skip to content

Commit b444e1a

Browse files
committed
Merge branches 'pm-opp' and 'pm-tools'
* pm-opp: PM / OPP: Update performance state when freq == old_freq OPP: Fix handling of multiple power domains * pm-tools: tools/power/cpupower: Display boost frequency separately
3 parents 75f3e23 + faef080 + 2c0bf86 commit b444e1a

File tree

5 files changed

+65
-30
lines changed

5 files changed

+65
-30
lines changed

drivers/opp/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
760760
old_freq, freq);
761761

762762
/* Scaling up? Configure required OPPs before frequency */
763-
if (freq > old_freq) {
763+
if (freq >= old_freq) {
764764
ret = _set_required_opps(dev, opp_table, opp);
765765
if (ret)
766766
goto put_opp;

drivers/opp/of.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static void _opp_table_alloc_required_tables(struct opp_table *opp_table,
173173
struct opp_table **required_opp_tables;
174174
struct device **genpd_virt_devs = NULL;
175175
struct device_node *required_np, *np;
176-
int count, i;
176+
int count, count_pd, i;
177177

178178
/* Traversing the first OPP node is all we need */
179179
np = of_get_next_available_child(opp_np, NULL);
@@ -186,7 +186,19 @@ static void _opp_table_alloc_required_tables(struct opp_table *opp_table,
186186
if (!count)
187187
goto put_np;
188188

189-
if (count > 1) {
189+
/*
190+
* Check the number of power-domains to know if we need to deal
191+
* with virtual devices. In some cases we have devices with multiple
192+
* power domains but with only one of them being scalable, hence
193+
* 'count' could be 1, but we still have to deal with multiple genpds
194+
* and virtual devices.
195+
*/
196+
count_pd = of_count_phandle_with_args(dev->of_node, "power-domains",
197+
"#power-domain-cells");
198+
if (!count_pd)
199+
goto put_np;
200+
201+
if (count_pd > 1) {
190202
genpd_virt_devs = kcalloc(count, sizeof(*genpd_virt_devs),
191203
GFP_KERNEL);
192204
if (!genpd_virt_devs)

tools/power/cpupower/lib/cpufreq.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,17 +333,20 @@ void cpufreq_put_available_governors(struct cpufreq_available_governors *any)
333333
}
334334

335335

336-
struct cpufreq_available_frequencies
337-
*cpufreq_get_available_frequencies(unsigned int cpu)
336+
struct cpufreq_frequencies
337+
*cpufreq_get_frequencies(const char *type, unsigned int cpu)
338338
{
339-
struct cpufreq_available_frequencies *first = NULL;
340-
struct cpufreq_available_frequencies *current = NULL;
339+
struct cpufreq_frequencies *first = NULL;
340+
struct cpufreq_frequencies *current = NULL;
341341
char one_value[SYSFS_PATH_MAX];
342342
char linebuf[MAX_LINE_LEN];
343+
char fname[MAX_LINE_LEN];
343344
unsigned int pos, i;
344345
unsigned int len;
345346

346-
len = sysfs_cpufreq_read_file(cpu, "scaling_available_frequencies",
347+
snprintf(fname, MAX_LINE_LEN, "scaling_%s_frequencies", type);
348+
349+
len = sysfs_cpufreq_read_file(cpu, fname,
347350
linebuf, sizeof(linebuf));
348351
if (len == 0)
349352
return NULL;
@@ -389,9 +392,9 @@ struct cpufreq_available_frequencies
389392
return NULL;
390393
}
391394

392-
void cpufreq_put_available_frequencies(struct cpufreq_available_frequencies
393-
*any) {
394-
struct cpufreq_available_frequencies *tmp, *next;
395+
void cpufreq_put_frequencies(struct cpufreq_frequencies *any)
396+
{
397+
struct cpufreq_frequencies *tmp, *next;
395398

396399
if (!any)
397400
return;

tools/power/cpupower/lib/cpufreq.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ struct cpufreq_available_governors {
2828
struct cpufreq_available_governors *first;
2929
};
3030

31-
struct cpufreq_available_frequencies {
31+
struct cpufreq_frequencies {
3232
unsigned long frequency;
33-
struct cpufreq_available_frequencies *next;
34-
struct cpufreq_available_frequencies *first;
33+
struct cpufreq_frequencies *next;
34+
struct cpufreq_frequencies *first;
3535
};
3636

3737

@@ -129,14 +129,14 @@ void cpufreq_put_available_governors(
129129
*
130130
* Only present on _some_ ->target() cpufreq drivers. For information purposes
131131
* only. Please free allocated memory by calling
132-
* cpufreq_put_available_frequencies after use.
132+
* cpufreq_put_frequencies after use.
133133
*/
134134

135-
struct cpufreq_available_frequencies
136-
*cpufreq_get_available_frequencies(unsigned int cpu);
135+
struct cpufreq_frequencies
136+
*cpufreq_get_frequencies(const char *type, unsigned int cpu);
137137

138-
void cpufreq_put_available_frequencies(
139-
struct cpufreq_available_frequencies *first);
138+
void cpufreq_put_frequencies(
139+
struct cpufreq_frequencies *first);
140140

141141

142142
/* determine affected CPUs

tools/power/cpupower/utils/cpufreq-info.c

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,19 +161,12 @@ static void print_duration(unsigned long duration)
161161
return;
162162
}
163163

164-
/* --boost / -b */
165-
166-
static int get_boost_mode(unsigned int cpu)
164+
static int get_boost_mode_x86(unsigned int cpu)
167165
{
168166
int support, active, b_states = 0, ret, pstate_no, i;
169167
/* ToDo: Make this more global */
170168
unsigned long pstates[MAX_HW_PSTATES] = {0,};
171169

172-
if (cpupower_cpu_info.vendor != X86_VENDOR_AMD &&
173-
cpupower_cpu_info.vendor != X86_VENDOR_HYGON &&
174-
cpupower_cpu_info.vendor != X86_VENDOR_INTEL)
175-
return 0;
176-
177170
ret = cpufreq_has_boost_support(cpu, &support, &active, &b_states);
178171
if (ret) {
179172
printf(_("Error while evaluating Boost Capabilities"
@@ -248,6 +241,33 @@ static int get_boost_mode(unsigned int cpu)
248241
return 0;
249242
}
250243

244+
/* --boost / -b */
245+
246+
static int get_boost_mode(unsigned int cpu)
247+
{
248+
struct cpufreq_frequencies *freqs;
249+
250+
if (cpupower_cpu_info.vendor == X86_VENDOR_AMD ||
251+
cpupower_cpu_info.vendor == X86_VENDOR_HYGON ||
252+
cpupower_cpu_info.vendor == X86_VENDOR_INTEL)
253+
return get_boost_mode_x86(cpu);
254+
255+
freqs = cpufreq_get_frequencies("boost", cpu);
256+
if (freqs) {
257+
printf(_(" boost frequency steps: "));
258+
while (freqs->next) {
259+
print_speed(freqs->frequency);
260+
printf(", ");
261+
freqs = freqs->next;
262+
}
263+
print_speed(freqs->frequency);
264+
printf("\n");
265+
cpufreq_put_frequencies(freqs);
266+
}
267+
268+
return 0;
269+
}
270+
251271
/* --freq / -f */
252272

253273
static int get_freq_kernel(unsigned int cpu, unsigned int human)
@@ -456,15 +476,15 @@ static int get_latency(unsigned int cpu, unsigned int human)
456476

457477
static void debug_output_one(unsigned int cpu)
458478
{
459-
struct cpufreq_available_frequencies *freqs;
479+
struct cpufreq_frequencies *freqs;
460480

461481
get_driver(cpu);
462482
get_related_cpus(cpu);
463483
get_affected_cpus(cpu);
464484
get_latency(cpu, 1);
465485
get_hardware_limits(cpu, 1);
466486

467-
freqs = cpufreq_get_available_frequencies(cpu);
487+
freqs = cpufreq_get_frequencies("available", cpu);
468488
if (freqs) {
469489
printf(_(" available frequency steps: "));
470490
while (freqs->next) {
@@ -474,7 +494,7 @@ static void debug_output_one(unsigned int cpu)
474494
}
475495
print_speed(freqs->frequency);
476496
printf("\n");
477-
cpufreq_put_available_frequencies(freqs);
497+
cpufreq_put_frequencies(freqs);
478498
}
479499

480500
get_available_governors(cpu);

0 commit comments

Comments
 (0)