From patchwork Fri Jul 14 17:10:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 107814 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1164359qge; Fri, 14 Jul 2017 10:10:22 -0700 (PDT) X-Received: by 10.99.104.129 with SMTP id d123mr15816297pgc.236.1500052222788; Fri, 14 Jul 2017 10:10:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500052222; cv=none; d=google.com; s=arc-20160816; b=r9FMtxn9d2formuW0uUtFYtif8H11VfQ5X4Lo2DTEDh7f8s/UkpXYmvZ+JIP82jY0d iImQr6n4NhH42gscCWoNvyekzO2a8rwQ4LcRzKYO1ljhzvuz7X/GTo6EEIjVc76O1e/F +12kPAHEtwlODHNrwbla5n2uyCrooIoUjmYbmNW/rlc/dFajLlu96aIbHkisNPx5OuaR ACz7EVRcH8Pr7fKx7z+X3x7H5pnDpW5pzOK0ARVKzsd71e9WCeFsSIVf+FEqn0gq8H2f BU6WbJuj2TCVsV+MiqqQzWSZ9Soegqso+2g4Gk9S2cA0jPQWbU846aOHHqZKHwnvtlmM VDxA== 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=NXK6xvz/2z70cmdVVcaY3rOA89j+6iEtQ+ATCagLU1U=; b=nVGyk9qa/ZvWaVh4OgBkgXbsvkzTMK3jRf/8vl1yBQyBFr5Ld7xuC093XJgUb71wCc UnHisO3ONFzv6Isa+pBX673WEEw8IT8aITwyn2+cotIyxh4HRuYCxAd/rNNoa3mKTOAI D2LJvu9d+sFbYDRvq2JhQaim8r3X+0ly/mVEBWRtRIWCQkuv3D5lKn/PQCTQ8bMJecGv Us1JmGXddPjlIfxbiXoSNUXejS//K/eqRonHhnf2qG/rIF3qYYW7rXQydBK2rFHHWJOX BQsZoHcJyF/DJORrBZkrzqoC3zN77Aybhl6A/McpKTIqb0cwJ23hvzx1CLymcmy2cYZZ QTrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=fVIDl7qv; 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 15si419763plf.80.2017.07.14.10.10.22; Fri, 14 Jul 2017 10:10:22 -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=fVIDl7qv; 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 S1753665AbdGNRKV (ORCPT + 14 others); Fri, 14 Jul 2017 13:10:21 -0400 Received: from mail-qk0-f175.google.com ([209.85.220.175]:36863 "EHLO mail-qk0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753446AbdGNRKV (ORCPT ); Fri, 14 Jul 2017 13:10:21 -0400 Received: by mail-qk0-f175.google.com with SMTP id v17so74497750qka.3 for ; Fri, 14 Jul 2017 10:10:20 -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=NXK6xvz/2z70cmdVVcaY3rOA89j+6iEtQ+ATCagLU1U=; b=fVIDl7qvBnXoFPz4DqsZ4PR8hLe7ltLGb/o3e1u5Ye6f7rzQpSPytESuarX72k0b4o Zq650rUITFsaPHOb3WjMKLFqIhRPYzvuyrl/ZvhJKfbEEumaHD7ZJ4LGohMmnfih6IEs sD1MFXEj1psM/7/T1r7yUUOjq37+lErvx8O1s= 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=NXK6xvz/2z70cmdVVcaY3rOA89j+6iEtQ+ATCagLU1U=; b=r1bBn0u+4xfrvYXtECIwNmVxO174YHtPjA8kb4Y0lX+qbiYOuX08z4de2KNRHacc9Q i5uIlBorAx1J31YuyakWA+8T/a9fq73igBGf3IGjgVniY+p+npG7Jvvj5nB5iwbn8Hdr wcM0tnX8DnTNbmzJ9rxHnoP9gOAp6O/Mz6FMAceN6P82kV6XNs03mG0cUcQ832bYfFC1 DAfcv+Dch/q+yu30qCgEa+R32TCw9HmdLcE6CuTV1bUGCJhmqq6dfS04Af8BgZxGH9Pi guok+YWLhLDtZtZoACMe492cFgZjX+bgyvSlXgpMricF25y8hNoIzO4JjRMnqfs/Bnpe f+2Q== X-Gm-Message-State: AIVw110l2DDFbSr9/LAf5K9GWdoEfq0PKG6g7+pRciYGoDTzyUTFssYW yS5qJDGEWlHA2Cp6 X-Received: by 10.55.33.194 with SMTP id f63mr12011123qki.112.1500052220167; Fri, 14 Jul 2017 10:10:20 -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 c18sm7546799qtd.62.2017.07.14.10.10.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Jul 2017 10:10:19 -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 V4 1/2] PM / Domains: Add time accounting to various genpd states. Date: Fri, 14 Jul 2017 13:10:15 -0400 Message-Id: <1500052216-22252-2-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1500052216-22252-1-git-send-email-thara.gopinath@linaro.org> References: <1500052216-22252-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 Acked-by: Ulf Hansson --- drivers/base/power/domain.c | 32 ++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 3 +++ 2 files changed, 35 insertions(+) -- 2.1.4 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 3b8210e..640ffc5 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -209,6 +209,34 @@ 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 is active, it means we are just + * out of off and so update the idle time and vice + * versa. + */ + if (genpd->status == GPD_STATE_ACTIVE) { + int state_idx = genpd->state_idx; + + genpd->states[state_idx].idle_time = + ktime_add(genpd->states[state_idx].idle_time, delta); + } else { + genpd->on_time = ktime_add(genpd->on_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; @@ -361,6 +389,7 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, } genpd->status = GPD_STATE_POWER_OFF; + genpd_update_accounting(genpd); list_for_each_entry(link, &genpd->slave_links, slave_node) { genpd_sd_counter_dec(link->master); @@ -413,6 +442,8 @@ static int genpd_power_on(struct generic_pm_domain *genpd, unsigned int depth) goto err; genpd->status = GPD_STATE_ACTIVE; + genpd_update_accounting(genpd); + return 0; err: @@ -1540,6 +1571,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 41004d9..84f423d 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 Fri Jul 14 17:10:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 107815 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1164391qge; Fri, 14 Jul 2017 10:10:24 -0700 (PDT) X-Received: by 10.99.49.142 with SMTP id x136mr3227582pgx.102.1500052224572; Fri, 14 Jul 2017 10:10:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500052224; cv=none; d=google.com; s=arc-20160816; b=HrgYb8sBkWFzEM8w4r2Ijgx3+FCCUOM96czAqUCXs/BM49c6bMRjC2xk8tLPijn0QX 3x1B8F0Ix2fljB8/NkaMWL7eh6xbahLsW8egnZW1axQAwvHjhoQhsZNpKbPOeOZ+ezmF YLOiYVOhxN37Kb2Fp3ppjtxSiKCp7a0egnAZ6EGThuJFIw5SX3X6gXQf+DtmwduA9zJ/ Lc4HlP5URP3fW2Hc+vLa+ZWDDj/nBkTyszIiEM2CIc+cviYQ2REXxDXLtMhLXfJVjjYx GYBDKCT0utJnoDnld95MgW/paf6Ce2wshbw/JEbXxjFqa+w2U0gSWDV53+X2WX0ESevR jumA== 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=aK2EnQUxEEgNBJfoAzGZEDFDHhjcoKDIgVvtntpwEdQ=; b=kTfehCiXM7ELnQT+XFAEemxsNxWLREyfxz2Xby/mheQy74LN6sUutavRuzEtqC3f2j 8eGqkbbk0d+AItDudJCo3ctwkKkPBgV5zOJgvp2PkT9W/G2wHIXEZKz7ooMj00d/vhGj /t9BwVnWe1vtnxNR0lW/fVE+2y4d/jCHM50oi5vrb1ZFb2CQ+JWkQhNN+RBVPqKteBlv 6OPldwnb0Eq2QcS5xcX9EYwvBt6HaWqnnRKeax/vFhwAXMMwRPBtwlBhtAcJpyDetrvD cCpfayDk7WydGN0mCrgJnTV7LLdRZjDG6/uXp6OfgXKs4Z7McnGHhOFCPrHPhyU81agY Hjdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=DMVmbb54; 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 15si419763plf.80.2017.07.14.10.10.24; Fri, 14 Jul 2017 10:10:24 -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=DMVmbb54; 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 S1753844AbdGNRKX (ORCPT + 14 others); Fri, 14 Jul 2017 13:10:23 -0400 Received: from mail-qk0-f172.google.com ([209.85.220.172]:33683 "EHLO mail-qk0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753716AbdGNRKW (ORCPT ); Fri, 14 Jul 2017 13:10:22 -0400 Received: by mail-qk0-f172.google.com with SMTP id a66so66566822qkb.0 for ; Fri, 14 Jul 2017 10:10:22 -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=aK2EnQUxEEgNBJfoAzGZEDFDHhjcoKDIgVvtntpwEdQ=; b=DMVmbb54t2TD1zLrO9lTI/GvmczdpyzOVbPu0gNz42WEOZfJSFOgf8AwArzmRDUMkN iA4gspr8JcyzbpS2gKto0dX9LNPbYlVbu5cHLWxeHJvevjuH+ted9CpXpozlh+M2wQz2 0VgnRnhgnOwjzh4KwDfwe4eGX7vfl9CtFttV8= 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=aK2EnQUxEEgNBJfoAzGZEDFDHhjcoKDIgVvtntpwEdQ=; b=lGtB0ivxV5OL8SHnfjRpmPsQjJm8Qmez0MzeFctxLFlkJkPXRy0KZiO+n5zmHf2Rs8 /TrgW9rrSgXNzosuhuM14xrvY+Qaf1gIPGuHfV3LJa147Hm+qRnVbJKpE/9TxdkbJPuL jyQ/nFkLsfYolUhp6UuPz917POv4PWXQifE8T0rggPQya+Wsf0DQEaUbONodxqnpJ6iz 3/l5cdMWfBfqu9kaizIKTMrIXbXbsEtfA8gT75YjU2qGRBukX65GCbLRZZclGNPVOHnZ 4H0Rnv0PTlllTCodNecHmDGJQVgv59HRCMcfN9eV0ONi5snRvavoz1Tp/Yl8zikft3b6 chzQ== X-Gm-Message-State: AIVw112DT8dBKM6avSErQwd8oH9IKjn5P9H/vyRIA4RRJlSll6pPK4t+ pfNCi4pY3d8UmUr9 X-Received: by 10.55.40.13 with SMTP id o13mr11767310qkh.116.1500052221691; Fri, 14 Jul 2017 10:10:21 -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 c18sm7546799qtd.62.2017.07.14.10.10.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Jul 2017 10:10:20 -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 V4 2/2] PM / Domains: Extend generic power domain debugfs. Date: Fri, 14 Jul 2017 13:10:16 -0400 Message-Id: <1500052216-22252-3-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1500052216-22252-1-git-send-email-thara.gopinath@linaro.org> References: <1500052216-22252-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 Acked-by: Ulf Hansson --- drivers/base/power/domain.c | 205 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 195 insertions(+), 10 deletions(-) -- 2.1.4 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 640ffc5..2e59219 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2359,7 +2359,7 @@ static int pm_genpd_summary_one(struct seq_file *s, return 0; } -static int pm_genpd_summary_show(struct seq_file *s, void *data) +static int genpd_summary_show(struct seq_file *s, void *data) { struct generic_pm_domain *genpd; int ret = 0; @@ -2382,21 +2382,187 @@ 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 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_ONCE(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 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\n", link->slave->name); + + genpd_unlock(genpd); + return ret; +} + +static int genpd_idle_states_show(struct seq_file *s, void *data) +{ + struct generic_pm_domain *genpd = s->private; + unsigned int i; + int 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%-13i %lld\n", i, msecs); + } + + genpd_unlock(genpd); + return ret; +} + +static int 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 genpd_total_idle_time_show(struct seq_file *s, void *data) +{ + struct generic_pm_domain *genpd = s->private; + ktime_t delta = 0, total = 0; + unsigned int i; + int 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 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_genpd_open_function(name) \ +static int genpd_##name##_open(struct inode *inode, struct file *file) \ +{ \ + return single_open(file, genpd_##name##_show, inode->i_private); \ +} + +define_genpd_open_function(summary); +define_genpd_open_function(status); +define_genpd_open_function(sub_domains); +define_genpd_open_function(idle_states); +define_genpd_open_function(active_time); +define_genpd_open_function(total_idle_time); +define_genpd_open_function(devices); + +#define define_genpd_debugfs_fops(name) \ +static const struct file_operations genpd_##name##_fops = { \ + .open = genpd_##name##_open, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = single_release, \ +} + +define_genpd_debugfs_fops(summary); +define_genpd_debugfs_fops(status); +define_genpd_debugfs_fops(sub_domains); +define_genpd_debugfs_fops(idle_states); +define_genpd_debugfs_fops(active_time); +define_genpd_debugfs_fops(total_idle_time); +define_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); @@ -2404,10 +2570,29 @@ static int __init pm_genpd_debug_init(void) return -ENOMEM; d = debugfs_create_file("pm_genpd_summary", S_IRUGO, - pm_genpd_debugfs_dir, NULL, &pm_genpd_summary_fops); + pm_genpd_debugfs_dir, NULL, &genpd_summary_fops); 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, &genpd_status_fops); + debugfs_create_file("sub_domains", 0444, + d, genpd, &genpd_sub_domains_fops); + debugfs_create_file("idle_states", 0444, + d, genpd, &genpd_idle_states_fops); + debugfs_create_file("active_time", 0444, + d, genpd, &genpd_active_time_fops); + debugfs_create_file("total_idle_time", 0444, + d, genpd, &genpd_total_idle_time_fops); + debugfs_create_file("devices", 0444, + d, genpd, &genpd_devices_fops); + } + return 0; } late_initcall(pm_genpd_debug_init);