Re: [PATCH 3/3] pmdomain: core: Extend statistics for domain idle states with s2idle data
From: Dhruva Gole <hidden>
Date: 2026-01-27 13:54:42
Also in:
linux-pm, lkml
On Jan 19, 2026 at 15:31:15 +0100, Ulf Hansson wrote:
To allow user space to monitor the selection of the domain idle state during s2idle for a CPU PM domain, let's extend the debugfs support in genpd with this information. Suggested-by: Dhruva Gole <redacted> Signed-off-by: Ulf Hansson <redacted> --- drivers/pmdomain/core.c | 13 ++++++++++--- include/linux/pm_domain.h | 1 + 2 files changed, 11 insertions(+), 3 deletions(-)
This will be quite helpful, thanks alot Ulf! Reviewed-by: Dhruva Gole <redacted>
quoted hunk ↗ jump to hunk
diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index bf512ff0857d..bb04cb7ccdcd 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c@@ -1438,6 +1438,13 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock, return; } else { genpd->states[genpd->state_idx].usage++; + + /* + * The ->system_power_down_ok() callback is currently used only + * for s2idle. Use it to know when to update the usage counter. + */ + if (genpd->gov && genpd->gov->system_power_down_ok) + genpd->states[genpd->state_idx].usage_s2idle++; } genpd->status = GENPD_STATE_OFF;@@ -3772,7 +3779,7 @@ static int idle_states_show(struct seq_file *s, void *data) if (ret) return -ERESTARTSYS; - seq_puts(s, "State Time(ms) Usage Rejected Above Below\n"); + seq_puts(s, "State Time(ms) Usage Rejected Above Below S2idle\n"); for (i = 0; i < genpd->state_count; i++) { struct genpd_power_state *state = &genpd->states[i];@@ -3790,9 +3797,9 @@ static int idle_states_show(struct seq_file *s, void *data) snprintf(state_name, ARRAY_SIZE(state_name), "S%-5d", i); do_div(idle_time, NSEC_PER_MSEC); - seq_printf(s, "%-6s %-14llu %-10llu %-10llu %-10llu %llu\n", + seq_printf(s, "%-6s %-14llu %-10llu %-10llu %-10llu %-10llu %llu\n", state_name, idle_time, state->usage, state->rejected, - state->above, state->below); + state->above, state->below, state->usage_s2idle); } genpd_unlock(genpd);diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 93ba0143ca47..f6f6d494f728 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h@@ -183,6 +183,7 @@ struct genpd_power_state { u64 rejected; u64 above; u64 below; + u64 usage_s2idle; struct fwnode_handle *fwnode; u64 idle_time; void *data;-- 2.43.0
-- Best regards, Dhruva Gole Texas Instruments Incorporated