Skip to content

Commit c6a113b

Browse files
Lina Iyerrafaeljw
authored andcommitted
PM: domains: enable domain idle state accounting
To enable better debug of PM domains, keep a track of successful and failing attempts to enter each domain idle state. This statistics are exported in debugfs when reading the idle_states node associated with each PM domain. Signed-off-by: Lina Iyer <ilina@codeaurora.org> [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 505a70b commit c6a113b

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

drivers/base/power/domain.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,11 +591,14 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
591591
return -EBUSY;
592592

593593
ret = _genpd_power_off(genpd, true);
594-
if (ret)
594+
if (ret) {
595+
genpd->states[genpd->state_idx].rejected++;
595596
return ret;
597+
}
596598

597599
genpd->status = GENPD_STATE_OFF;
598600
genpd_update_accounting(genpd);
601+
genpd->states[genpd->state_idx].usage++;
599602

600603
list_for_each_entry(link, &genpd->child_links, child_node) {
601604
genpd_sd_counter_dec(link->parent);
@@ -3061,7 +3064,7 @@ static int idle_states_show(struct seq_file *s, void *data)
30613064
if (ret)
30623065
return -ERESTARTSYS;
30633066

3064-
seq_puts(s, "State Time Spent(ms)\n");
3067+
seq_puts(s, "State Time Spent(ms) Usage Rejected\n");
30653068

30663069
for (i = 0; i < genpd->state_count; i++) {
30673070
ktime_t delta = 0;
@@ -3073,7 +3076,8 @@ static int idle_states_show(struct seq_file *s, void *data)
30733076

30743077
msecs = ktime_to_ms(
30753078
ktime_add(genpd->states[i].idle_time, delta));
3076-
seq_printf(s, "S%-13i %lld\n", i, msecs);
3079+
seq_printf(s, "S%-13i %-14lld %-14llu %llu\n", i, msecs,
3080+
genpd->states[i].usage, genpd->states[i].rejected);
30773081
}
30783082

30793083
genpd_unlock(genpd);

include/linux/pm_domain.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ struct genpd_power_state {
8989
s64 power_off_latency_ns;
9090
s64 power_on_latency_ns;
9191
s64 residency_ns;
92+
u64 usage;
93+
u64 rejected;
9294
struct fwnode_handle *fwnode;
9395
ktime_t idle_time;
9496
void *data;

0 commit comments

Comments
 (0)