From patchwork Tue Jun 13 20:27:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 105415 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp589461qgd; Tue, 13 Jun 2017 13:27:49 -0700 (PDT) X-Received: by 10.107.10.84 with SMTP id u81mr2141441ioi.206.1497385669166; Tue, 13 Jun 2017 13:27:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497385669; cv=none; d=google.com; s=arc-20160816; b=FIapKimUAwRmlL2/nH67Rej0Xua4XmY9shvNcOBpf8aoSnwcTUEXPx7RBOHBJuEWte o+Mp9W0E6n/VF2yJ+fBQZBeMy9GT1TreeroR460KuG5MdhNqjrlMGVa4SVlts3C/zyUJ rXy1pHl+a+VFXUntAzpSvNgB6tFIVD9RIwwiVCWlZutFKAEYc2dbZIAavN3MvkxHRvCj vgjYliDnpV7hEM5Z3ujVOKtHFwwNnqIL2D1qOHeh7W+/7noWztkmAO0YWhPFyr5AWLs3 3pwlJsB6Cnk618THl5kG7U/qYHsgLBKcfFSNNZGYBROqAu+GRWdVp+I3p3G0hXMQ8LMz 1ZZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:arc-authentication-results; bh=9ET6GzW97KrSjnSVcAU3AWqEeZJMVV0MVTTov3y5UDE=; b=SnCgSPnj4XkDke7Kie/g1PpWC2yeetCiWKZAsL47vDtu8HXmoyvPpYH+Dafdntxa4o 1xoxyBJxXiHulon2reuPOb0U1I38IDN8PWeXMOVZU7EVmxN8GZmHZJma+0hsdrhPzT2Q in+x2L8KAL325UY9f3tlZTxHj7fH5KT78gfTQbuRMCs9eA/GhyizK0Lu0FGAQx+SedIv J9TF3SWHka47YkDp/MgJx3fRe9vwxjrQEFPE4xhyqnCwlYq0B0sJjL4WeRmp7vgEeZcE uJPWej5lBCO3fShpcueSVva6j1sKFEym5QdjE2YWzaaVa2Craa9ztfaIsQfc+O2UuGmY fzLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=LS0k06Ka; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p141si7743160itp.89.2017.06.13.13.27.48; Tue, 13 Jun 2017 13:27:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=LS0k06Ka; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753837AbdFMU1q (ORCPT + 14 others); Tue, 13 Jun 2017 16:27:46 -0400 Received: from mail-qt0-f170.google.com ([209.85.216.170]:33458 "EHLO mail-qt0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753766AbdFMU1o (ORCPT ); Tue, 13 Jun 2017 16:27:44 -0400 Received: by mail-qt0-f170.google.com with SMTP id u12so188993755qth.0 for ; Tue, 13 Jun 2017 13:27:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=9ET6GzW97KrSjnSVcAU3AWqEeZJMVV0MVTTov3y5UDE=; b=LS0k06KaAUQZcZDJotjrR/FTwpMjiAdxqwOtZ4rgpvmdDGI4z6IpubiVuVUJAO28r6 3FJn51PCb7ldJ+z5/hO1O+TortHtO8qlf4VzG1s1E5fwADiPD/W4pbFJAFXiwIwxcCYl qTG+yDTfsc6B/LeBpYgP/U42wAbdPNOYKjugE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=9ET6GzW97KrSjnSVcAU3AWqEeZJMVV0MVTTov3y5UDE=; b=rIq7RIzbjoUCWHvTkaRjCroH4mqQyBc/Ml4cxsYxd399M/JWU7Neh9MlUTgduIXty0 SztZlk+RokHyrBtxkyOqtwaiTeqmIPhUxw1OVey6Iw5BUmub+HhAZa3ubWYmiuvq5X8i tZK39uv0xBHkuV+RwOlc+Jn9r50M20QuwCyMTAdaU1vcMo24b0Bz3DTQpu67qUR75GYX yb0ySSYaxDddbmtacALpvh9L/sCkhgzYku5IkyNLLK9nYy+uhuVzrtxs1zu6WW6GFq58 KBIfpoL4mTHkv4uBmkC0UhSAH98tMy3D8/8otczxeB+PxcPzcE3Or5mN7OxZJYuGGmdP M35Q== X-Gm-Message-State: AKS2vOz7JaRiIl7rBTMCuLHP4XfAZmkGq53UynZekr4gD+qVdUIypsKj CkVg+TzzJUjyzqB4 X-Received: by 10.200.13.1 with SMTP id q1mr2299470qti.221.1497385664052; Tue, 13 Jun 2017 13:27:44 -0700 (PDT) Received: from Thara-Work-Ubuntu.fios-router.home (pool-71-255-245-167.washdc.fios.verizon.net. [71.255.245.167]) by smtp.googlemail.com with ESMTPSA id z40sm10101515qth.64.2017.06.13.13.27.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Jun 2017 13:27:42 -0700 (PDT) From: Thara Gopinath To: ulf.hansson@linaro.org, khilman@kernel.org, rjw@rjwysocki.net, gregkh@linuxfoundation.org, linux-pm@vger.kernel.org Subject: [PATCH V2 1/2] PM / Domains: Add time accounting to various genpd states. Date: Tue, 13 Jun 2017 16:27:38 -0400 Message-Id: <1497385659-2356-2-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1497385659-2356-1-git-send-email-thara.gopinath@linaro.org> References: <1497385659-2356-1-git-send-email-thara.gopinath@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This patch adds support to calculate the time spent by the generic power domains in on and various idle states. Signed-off-by: Thara Gopinath --- drivers/base/power/domain.c | 26 ++++++++++++++++++++++++++ include/linux/pm_domain.h | 3 +++ 2 files changed, 29 insertions(+) -- 2.1.4 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index da49a83..33b4632 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -207,6 +207,28 @@ static void genpd_sd_counter_inc(struct generic_pm_domain *genpd) smp_mb__after_atomic(); } +#ifdef CONFIG_DEBUG_FS +static void genpd_update_accounting(struct generic_pm_domain *genpd) +{ + ktime_t delta, now; + + now = ktime_get(); + delta = ktime_sub(now, genpd->accounting_time); + + if (genpd->status == GPD_STATE_ACTIVE) { + genpd->on_time = ktime_add(genpd->on_time, delta); + } else { + int state_idx = genpd->state_idx; + + genpd->states[state_idx].idle_time = + ktime_add(genpd->states[state_idx].idle_time, delta); + } + genpd->accounting_time = now; +} +#else +static inline void genpd_update_accounting(struct generic_pm_domain *genpd) {} +#endif + static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed) { unsigned int state_idx = genpd->state_idx; @@ -358,6 +380,7 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, return ret; } + genpd_update_accounting(genpd); genpd->status = GPD_STATE_POWER_OFF; list_for_each_entry(link, &genpd->slave_links, slave_node) { @@ -410,7 +433,9 @@ static int genpd_power_on(struct generic_pm_domain *genpd, unsigned int depth) if (ret) goto err; + genpd_update_accounting(genpd); genpd->status = GPD_STATE_ACTIVE; + return 0; err: @@ -1486,6 +1511,7 @@ int pm_genpd_init(struct generic_pm_domain *genpd, genpd->max_off_time_changed = true; genpd->provider = NULL; genpd->has_provider = false; + genpd->accounting_time = ktime_get(); genpd->domain.ops.runtime_suspend = genpd_runtime_suspend; genpd->domain.ops.runtime_resume = genpd_runtime_resume; genpd->domain.ops.prepare = pm_genpd_prepare; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index b7803a2..9c8b334 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -43,6 +43,7 @@ struct genpd_power_state { s64 power_on_latency_ns; s64 residency_ns; struct fwnode_handle *fwnode; + ktime_t idle_time; }; struct genpd_lock_ops; @@ -78,6 +79,8 @@ struct generic_pm_domain { unsigned int state_count; /* number of states */ unsigned int state_idx; /* state that genpd will go to when off */ void *free; /* Free the state that was allocated for default */ + ktime_t on_time; + ktime_t accounting_time; const struct genpd_lock_ops *lock_ops; union { struct mutex mlock; From patchwork Tue Jun 13 20:27:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 105417 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp589484qgd; Tue, 13 Jun 2017 13:27:54 -0700 (PDT) X-Received: by 10.107.142.136 with SMTP id q130mr2160978iod.225.1497385674324; Tue, 13 Jun 2017 13:27:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497385674; cv=none; d=google.com; s=arc-20160816; b=IhLHHvKGhnYLpCv8WZL8z4o1VYP+Dlffi0urFegAIoLljPsPrzSZ9zH21LSowGqZAb 6isCQiXehRdu1/pX/CClKUv6CJX/xOB56TQC5dLzGAGubJvIvylHwylCiVPAN//UtjdO FOS8x69cFiLpPPrXh7L5aCeb28vZnpxxFFuLidya1/R6usjetPdF0T1RL8fD3BeDm4T1 qHf1pdqFcAMJYb8GWSizaqhfkgrrzMA1vEx7uJ0aSpW/l0EaeolV875sIpl8T7g84sgv muvjrzrBJtMSn8a8ol9PxBah8A+TjsCv0MBvaNcg5KFVSy9GOJJr13YeI7ZTieh6j2Mt CNUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:arc-authentication-results; bh=anZlNqsHhUzndDQC2SSAHbJmGDGOll5vlzeY3iVS6O8=; b=RZMG1++N3cRYqz84kIOmUEkltpewRDDWH/ej3Mvo8mVgnF0lCGRv1IthVTqzlAqYwl OruSCbUncE0hNSIw9B7pwZ91CgLZcmiZURQJpEA5QuVXf2Zdx5inP5BJSsrAvYO8iLjC SG6QQr413lUKMf2+ih64TONkLbBowc6npsX8SYDn1Fn29h6csTz3EEHjD6BL5xE86GKL 43E7xSosRpYRkoJKH6S6syLzt7NY1MRwgfBBI+mTiGU86SrGGN0RrqvcLkDkHHUgfXa+ /ndOzPwyWJeDPoJz/JdTE1l2FyBsu7R0C9fsJOtTs2U6+3ZUYrY1H5Akwi7KGCC4SV6A lvxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=ZXY58A6c; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p141si7743160itp.89.2017.06.13.13.27.54; Tue, 13 Jun 2017 13:27:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=ZXY58A6c; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753853AbdFMU1x (ORCPT + 14 others); Tue, 13 Jun 2017 16:27:53 -0400 Received: from mail-qt0-f178.google.com ([209.85.216.178]:34903 "EHLO mail-qt0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753845AbdFMU1w (ORCPT ); Tue, 13 Jun 2017 16:27:52 -0400 Received: by mail-qt0-f178.google.com with SMTP id w1so187990928qtg.2 for ; Tue, 13 Jun 2017 13:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=anZlNqsHhUzndDQC2SSAHbJmGDGOll5vlzeY3iVS6O8=; b=ZXY58A6c2gJh9IR9/HcuiZxPLMgF8wJWRX20+N0mLnHAcuqQKvsEnmSYEPZV8b9hw2 dWjbg7i9IPCoL+x9uL9jhyA2cmlxmyYURDHeFKOcxCHSdWVaKH2cd7W34SjXiag43xRw 6DyiD5VeYGoFNctSM2EorLf6H5M3NkSynMEzI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=anZlNqsHhUzndDQC2SSAHbJmGDGOll5vlzeY3iVS6O8=; b=if6+Z3Tm7CLAiin8otjPHRV165DFu1ljtG0jjAguV45RWRfg8N3Ja6Nhrh+ClHqoj0 Kgslrl0MfdM8z2FjqD8ngQil7pWRFl0y4Vq7Kd/2PoLMy/uDOdVzYvWDL70wuuGBbXNL IXYlXDbPx9jyDJQ3A00c4ddahs2h8AVgHHghQ3LJfrXM9wwFGvyKOsmyfsc9IQq711Wa /jN2AgY+0WtxdinIiQICXE/zdBfnEvHR3daK/5f8KzOMzU9Q7sCle3S/VCWibTH0ax7k /5xew5eexF877uKaMvV3D0IZVDLtosyF4nn0ufV0kVB0K96XrraFsoDDf/2orGx2S44X wgyg== X-Gm-Message-State: AKS2vOz1q9lziXsGxCD4LmA3NB8O7T8AjguDWsior1ofkHVpmcwvrW7L q1L+vFY5Ztz7J2rP5Bk5zg== X-Received: by 10.55.24.232 with SMTP id 101mr115352qky.203.1497385666292; Tue, 13 Jun 2017 13:27:46 -0700 (PDT) Received: from Thara-Work-Ubuntu.fios-router.home (pool-71-255-245-167.washdc.fios.verizon.net. [71.255.245.167]) by smtp.googlemail.com with ESMTPSA id z40sm10101515qth.64.2017.06.13.13.27.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Jun 2017 13:27:44 -0700 (PDT) From: Thara Gopinath To: ulf.hansson@linaro.org, khilman@kernel.org, rjw@rjwysocki.net, gregkh@linuxfoundation.org, linux-pm@vger.kernel.org Subject: [PATCH V2 2/2] PM / Domains: Extend generic power domain debugfs. Date: Tue, 13 Jun 2017 16:27:39 -0400 Message-Id: <1497385659-2356-3-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1497385659-2356-1-git-send-email-thara.gopinath@linaro.org> References: <1497385659-2356-1-git-send-email-thara.gopinath@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This patch extends the existing generic power domain debugfs. Changes involve the following - Introduce a unique debugfs entry for each generic power domain with the following attributes - current_state - Displays current state of the domain. - devices - Displays the devices associated with this domain. - sub_domains - Displays the sub power domains. - active_time - Displays the time the domain was in active state in ms. - total_idle_time - Displays the time the domain was in any of the idle states in ms. - idle_states - Displays the various idle states and the time spent in each idle state in ms. Signed-off-by: Thara Gopinath --- drivers/base/power/domain.c | 203 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 195 insertions(+), 8 deletions(-) -- 2.1.4 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 33b4632..c1a0cd1 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2322,21 +2322,189 @@ static int pm_genpd_summary_show(struct seq_file *s, void *data) return ret; } -static int pm_genpd_summary_open(struct inode *inode, struct file *file) +static int pm_genpd_status_show(struct seq_file *s, void *data) { - return single_open(file, pm_genpd_summary_show, NULL); + static const char * const status_lookup[] = { + [GPD_STATE_ACTIVE] = "on", + [GPD_STATE_POWER_OFF] = "off" + }; + + struct generic_pm_domain *genpd = s->private; + int ret = 0; + + ret = genpd_lock_interruptible(genpd); + if (ret) + return -ERESTARTSYS; + + if (WARN_ON(genpd->status >= ARRAY_SIZE(status_lookup))) + goto exit; + + if (genpd->status == GPD_STATE_POWER_OFF) + seq_printf(s, "%s-%u\n", status_lookup[genpd->status], + genpd->state_idx); + else + seq_printf(s, "%s\n", status_lookup[genpd->status]); +exit: + genpd_unlock(genpd); + return ret; } -static const struct file_operations pm_genpd_summary_fops = { - .open = pm_genpd_summary_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +static int pm_genpd_sub_domains_show(struct seq_file *s, void *data) +{ + struct generic_pm_domain *genpd = s->private; + struct gpd_link *link; + int ret = 0; + + ret = genpd_lock_interruptible(genpd); + if (ret) + return -ERESTARTSYS; + + list_for_each_entry(link, &genpd->master_links, master_node) { + seq_printf(s, "%s", link->slave->name); + if (!list_is_last(&link->master_node, &genpd->master_links)) + seq_puts(s, ", "); + } + seq_puts(s, "\n"); + + genpd_unlock(genpd); + return ret; +} + +static int pm_genpd_idle_states_show(struct seq_file *s, void *data) +{ + struct generic_pm_domain *genpd = s->private; + int i, ret = 0; + + ret = genpd_lock_interruptible(genpd); + if (ret) + return -ERESTARTSYS; + + seq_puts(s, "State Time Spent(ms)\n"); + + for (i = 0; i < genpd->state_count; i++) { + ktime_t delta = 0; + s64 msecs; + + if ((genpd->status == GPD_STATE_POWER_OFF) && + (genpd->state_idx == i)) + delta = ktime_sub(ktime_get(), genpd->accounting_time); + + msecs = ktime_to_ms( + ktime_add(genpd->states[i].idle_time, delta)); + seq_printf(s, "S%-15i %lld\n", i, msecs); + } + + genpd_unlock(genpd); + return ret; +} + +static int pm_genpd_active_time_show(struct seq_file *s, void *data) +{ + struct generic_pm_domain *genpd = s->private; + ktime_t delta = 0; + int ret = 0; + + ret = genpd_lock_interruptible(genpd); + if (ret) + return -ERESTARTSYS; + + if (genpd->status == GPD_STATE_ACTIVE) + delta = ktime_sub(ktime_get(), genpd->accounting_time); + + seq_printf(s, "%lld ms\n", ktime_to_ms( + ktime_add(genpd->on_time, delta))); + + genpd_unlock(genpd); + return ret; +} + +static int pm_genpd_total_idle_time_show(struct seq_file *s, void *data) +{ + struct generic_pm_domain *genpd = s->private; + ktime_t delta = 0, total = 0; + int i, ret = 0; + + ret = genpd_lock_interruptible(genpd); + if (ret) + return -ERESTARTSYS; + + for (i = 0; i < genpd->state_count; i++) { + + if ((genpd->status == GPD_STATE_POWER_OFF) && + (genpd->state_idx == i)) + delta = ktime_sub(ktime_get(), genpd->accounting_time); + + total = ktime_add(total, genpd->states[i].idle_time); + } + total = ktime_add(total, delta); + + seq_printf(s, "%lld ms\n", ktime_to_ms(total)); + + genpd_unlock(genpd); + return ret; +} + + +static int pm_genpd_devices_show(struct seq_file *s, void *data) +{ + struct generic_pm_domain *genpd = s->private; + struct pm_domain_data *pm_data; + const char *kobj_path; + int ret = 0; + + ret = genpd_lock_interruptible(genpd); + if (ret) + return -ERESTARTSYS; + + list_for_each_entry(pm_data, &genpd->dev_list, list_node) { + kobj_path = kobject_get_path(&pm_data->dev->kobj, + genpd_is_irq_safe(genpd) ? + GFP_ATOMIC : GFP_KERNEL); + if (kobj_path == NULL) + continue; + + seq_printf(s, "%s\n", kobj_path); + kfree(kobj_path); + } + + genpd_unlock(genpd); + return ret; +} + +#define define_pm_genpd_open_function(name) \ +static int pm_genpd_##name##_open(struct inode *inode, struct file *file) \ +{ \ + return single_open(file, pm_genpd_##name##_show, inode->i_private); \ +} + +define_pm_genpd_open_function(summary); +define_pm_genpd_open_function(status); +define_pm_genpd_open_function(sub_domains); +define_pm_genpd_open_function(idle_states); +define_pm_genpd_open_function(active_time); +define_pm_genpd_open_function(total_idle_time); +define_pm_genpd_open_function(devices); + +#define define_pm_genpd_debugfs_fops(name) \ +static const struct file_operations pm_genpd_##name##_fops = { \ + .open = pm_genpd_##name##_open, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = single_release, \ +} + +define_pm_genpd_debugfs_fops(summary); +define_pm_genpd_debugfs_fops(status); +define_pm_genpd_debugfs_fops(sub_domains); +define_pm_genpd_debugfs_fops(idle_states); +define_pm_genpd_debugfs_fops(active_time); +define_pm_genpd_debugfs_fops(total_idle_time); +define_pm_genpd_debugfs_fops(devices); static int __init pm_genpd_debug_init(void) { struct dentry *d; + struct generic_pm_domain *genpd; pm_genpd_debugfs_dir = debugfs_create_dir("pm_genpd", NULL); @@ -2348,6 +2516,25 @@ static int __init pm_genpd_debug_init(void) if (!d) return -ENOMEM; + list_for_each_entry(genpd, &gpd_list, gpd_list_node) { + d = debugfs_create_dir(genpd->name, pm_genpd_debugfs_dir); + if (!d) + return -ENOMEM; + + debugfs_create_file("current_state", 0444, + d, genpd, &pm_genpd_status_fops); + debugfs_create_file("sub_domains", 0444, + d, genpd, &pm_genpd_sub_domains_fops); + debugfs_create_file("idle_states", 0444, + d, genpd, &pm_genpd_idle_states_fops); + debugfs_create_file("active_time", 0444, + d, genpd, &pm_genpd_active_time_fops); + debugfs_create_file("total_idle_time", 0444, + d, genpd, &pm_genpd_total_idle_time_fops); + debugfs_create_file("devices", 0444, + d, genpd, &pm_genpd_devices_fops); + } + return 0; } late_initcall(pm_genpd_debug_init);