[PATCH 2/3] pmdomain: core: Show latency/residency for domain idle states in debugfs

Ulf Hansson posted 3 patches 3 weeks ago
[PATCH 2/3] pmdomain: core: Show latency/residency for domain idle states in debugfs
Posted by Ulf Hansson 3 weeks ago
Similar to how cpuidle provides the values for latency and residency for
CPU's idle states through sysfs, let's make the corresponding data for PM
domain's idle states available for user space, via genpd's debugfs support.

Suggested-by: Dhruva Gole <d-gole@ti.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/pmdomain/core.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
index 919dff2081d6..bf512ff0857d 100644
--- a/drivers/pmdomain/core.c
+++ b/drivers/pmdomain/core.c
@@ -3809,15 +3809,24 @@ static int idle_states_desc_show(struct seq_file *s, void *data)
 	if (ret)
 		return -ERESTARTSYS;
 
-	seq_puts(s, "State  Name\n");
+	seq_puts(s, "State  Latency(us)  Residency(us)  Name\n");
 
 	for (i = 0; i < genpd->state_count; i++) {
 		struct genpd_power_state *state = &genpd->states[i];
+		u64 latency, residency;
 		char state_name[7];
 
+		latency = state->power_off_latency_ns +
+			state->power_on_latency_ns;
+		do_div(latency, NSEC_PER_USEC);
+
+		residency = state->residency_ns;
+		do_div(residency, NSEC_PER_USEC);
+
 		snprintf(state_name, ARRAY_SIZE(state_name), "S%-5d", i);
-		seq_printf(s, "%-6s %s\n",
-			   state_name, state->name ?: "N/A");
+		seq_printf(s, "%-6s %-12llu %-14llu %s\n",
+			   state_name, latency, residency,
+			   state->name ?: "N/A");
 	}
 
 	genpd_unlock(genpd);
-- 
2.43.0
Re: [PATCH 2/3] pmdomain: core: Show latency/residency for domain idle states in debugfs
Posted by Dhruva Gole 1 week, 6 days ago
On Jan 19, 2026 at 15:31:14 +0100, Ulf Hansson wrote:
> Similar to how cpuidle provides the values for latency and residency for
> CPU's idle states through sysfs, let's make the corresponding data for PM
> domain's idle states available for user space, via genpd's debugfs support.
> 
> Suggested-by: Dhruva Gole <d-gole@ti.com>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
>  drivers/pmdomain/core.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
> index 919dff2081d6..bf512ff0857d 100644
> --- a/drivers/pmdomain/core.c
> +++ b/drivers/pmdomain/core.c
> @@ -3809,15 +3809,24 @@ static int idle_states_desc_show(struct seq_file *s, void *data)
>  	if (ret)
>  		return -ERESTARTSYS;
>  
> -	seq_puts(s, "State  Name\n");
> +	seq_puts(s, "State  Latency(us)  Residency(us)  Name\n");
>  
>  	for (i = 0; i < genpd->state_count; i++) {
>  		struct genpd_power_state *state = &genpd->states[i];
> +		u64 latency, residency;
>  		char state_name[7];
>  
> +		latency = state->power_off_latency_ns +
> +			state->power_on_latency_ns;
> +		do_div(latency, NSEC_PER_USEC);
> +
> +		residency = state->residency_ns;
> +		do_div(residency, NSEC_PER_USEC);
> +
>  		snprintf(state_name, ARRAY_SIZE(state_name), "S%-5d", i);
> -		seq_printf(s, "%-6s %s\n",
> -			   state_name, state->name ?: "N/A");
> +		seq_printf(s, "%-6s %-12llu %-14llu %s\n",
> +			   state_name, latency, residency,
> +			   state->name ?: "N/A");

Much needed indeed, thanks!!

Reviewed-by: Dhruva Gole <d-gole@ti.com>

-- 
Best regards,
Dhruva Gole
Texas Instruments Incorporated