From patchwork Fri Jun 23 16:32:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 106275 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp296983qgd; Fri, 23 Jun 2017 09:32:31 -0700 (PDT) X-Received: by 10.84.132.73 with SMTP id 67mr9891809ple.53.1498235551635; Fri, 23 Jun 2017 09:32:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498235551; cv=none; d=google.com; s=arc-20160816; b=Wx9xMmfxhuiXHZ3VYL8ZYAxdAiAuS+3Cu5GMwFvVBD4gMFPLB9fZgzw7rpfDMlV1mK R5xohGsMpst2PCBABfqpeLwfVCsFXHkhDjF2ZDgkM7TPcYoOqmM57/h8JgFQdDVwDUCj Q/u+4wibKa54J4WNwXcMyc//xEFZ7coqEAcG+MQQ6E1WXV4mzf1dkAwjB2KsaN+r+jAG fzVKXPmPXH5xG9uDUHQK1jaikSjMGm5X5kumiTB4dIjRiYN+GxfOQU63Tp9bnqH5BQa7 lW9DK+3j3Ph+fq16qtlpIidgy3XkESS+fn2WI2sxd3fU1QeDmJZNjqw9sayJB7BYAT3L 5D2g== 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=z9p39rabsXDkusSVPrHLdNDHcW65FBN1ZaJdskjDCVk=; b=nCMseskndRYRePDxY99+W8JQp1fQtWhZ5rQQgtSHjL73Ikp2+BcBNUZVdcpWkvVSls Os1RGrdUC6r6pzzO9iFtcvX+EZ0Oeu0S9oaU7zjhSJAnnvKxFcKxFvpn6baDa2ZrfCLE 5VVkdK9K4fDVNMgX3kX4U3znzEWaoG+2oXWcpgSx63WSHkKEb7fyoMebuxlK7kL0o/bB jO1fC1pIKKAcX+WJ4AyhY331xloTwBKQcSFvatmJZqzk2XsDPiBGSL58RyIvg5WbF9Nu N+nC+S6VHv5bc9A7JRJtnoCpRf/2YbBgrPoV0y8LYHXAyFi7IHWLxRFyjS6ETe3ebQ3N GP/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=fQED9y3k; 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 n26si3619926pfj.420.2017.06.23.09.32.31; Fri, 23 Jun 2017 09:32:31 -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=fQED9y3k; 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 S1754414AbdFWQc3 (ORCPT + 14 others); Fri, 23 Jun 2017 12:32:29 -0400 Received: from mail-qk0-f175.google.com ([209.85.220.175]:35029 "EHLO mail-qk0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753893AbdFWQc2 (ORCPT ); Fri, 23 Jun 2017 12:32:28 -0400 Received: by mail-qk0-f175.google.com with SMTP id 16so39761359qkg.2 for ; Fri, 23 Jun 2017 09:32:28 -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=z9p39rabsXDkusSVPrHLdNDHcW65FBN1ZaJdskjDCVk=; b=fQED9y3kXqJqAUBbnAETTCNoLpd6+1aJaj3duLFAkzcD6qPlleSngjMLj1o2WWpXfq GjvbCiwxmSjKxdQvMSFijW5MAixWFi/Sk0HTD1nh+dI+3pHtwrckGuRhQ9zRciK6yFlq xyIS0OUmJW06IOQ+UA5kxI4CzdDkMWP3I+tPk= 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=z9p39rabsXDkusSVPrHLdNDHcW65FBN1ZaJdskjDCVk=; b=D/8rrW1FskCdp9CySrHsj7bVtTSqjIoTW4WbZM534ZHNt4Tj26cnbpT01s7GRI3+LL Cn9ylqjLLSfebVx5mWMrRNwZQ/PI2MmOUtx2J8+k78iny9TXvjt/lXJiHqMWNzn4cuHT ADMcZrgOH/TcAvaBzBUNVo46W+9OUDux8tMgDjHlkwK3/gPDjuHZVQ7ITf+L7JZkQKmD RJw4g9+85ZUDhSkhbUnuI0h7BP6SAoyRXNw8A+yfyxeFfoh07lnQ3j3TqfhWsFBuiuYT g4sIimSTC4zKUFQljaFK/hVtxKfUJMfvxNiM6OKsnNtt58S3/OjNUID7F+dNGlHmi6yF D26A== X-Gm-Message-State: AKS2vOwnx8ElY/5ObXs7xHS9FUbbDiZoakfcIDmzjcvcm3f3q2RuUD08 SDV1SIariGh3EryQbX+mNQ== X-Received: by 10.55.99.76 with SMTP id x73mr9659638qkb.219.1498235547600; Fri, 23 Jun 2017 09:32:27 -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 c26sm1620720qte.63.2017.06.23.09.32.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 23 Jun 2017 09:32:26 -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 V3 1/2] PM / Domains: Add time accounting to various genpd states. Date: Fri, 23 Jun 2017 12:32:22 -0400 Message-Id: <1498235543-30064-2-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1498235543-30064-1-git-send-email-thara.gopinath@linaro.org> References: <1498235543-30064-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 | 32 ++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 3 +++ 2 files changed, 35 insertions(+) -- 2.1.4 Acked-by: Ulf Hansson diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index da49a83..40768cc 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -207,6 +207,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; @@ -359,6 +387,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); @@ -411,6 +440,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: @@ -1486,6 +1517,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 Fri Jun 23 16:32:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 106276 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp297028qgd; Fri, 23 Jun 2017 09:32:37 -0700 (PDT) X-Received: by 10.98.25.8 with SMTP id 8mr6438267pfz.80.1498235557416; Fri, 23 Jun 2017 09:32:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498235557; cv=none; d=google.com; s=arc-20160816; b=EDrTM6Ig8i1A4hojIDPs+MCh/HvkofFC4CHRKsdIuD/il++ZWi47OhozNYe3xBjjeU WeczrvM+uOIfe/T5bVRSjhuQv3894fH9UavBO9GUJlH+i26OUMu8PmzYHGaHdJvj09BB LBT7OdIkUTwyxTxk9LlDEeOTnSgIDQEIB/53WKuFBLBGBhbTjwLxgOvTX/nkIaa81qD2 7JW649Jurbh3zqp1k6w2MRVA+YWNV8uN/vTplOfLWW2bfGO4wukZ2f3ta6ROTYAr010s kzlZMEiq5VnxOPwZOzPNopcUYahY7vCgSc/jkoQ4fcRDJszHnansFQYS0f1ivsPkxxMh ao4g== 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=AdnY34mpY8er1ocVWEoLrGMA73GitJ8mdqcLYo47oxM=; b=DGFPNq7kzQyeg3M5jyEZegNm43138iZoO/PXIOM4jsmrlEAx1mwiXqURADgmSSHa0Y ikNMbizXmA91DKbNMQArMC4aBgLNhpPG/h7528fM2cQ5VLHLbQCw9oxGIo4L8Vchq1ke DasTCYzmy4cpNiPANw7yqkeBdi2ReIAkiJcCOQQc+P4N/jC9qXYF9cGBDRmKONYVeutb FHs/CjvIQdghmSIZpEe/PrzESarPg6PIWrz82c2mLuoEXeTIC1Kdn5oSVVgb2XEEw06R OPtQnaJYrlACmtJJiotwLvCtZrUKIbuLhpN8AaqbJipBKiI84muZvRd5ZPmJig2q+6AW cHAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=hxTdhGn+; 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 n26si3619926pfj.420.2017.06.23.09.32.37; Fri, 23 Jun 2017 09:32:37 -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=hxTdhGn+; 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 S1754453AbdFWQcg (ORCPT + 14 others); Fri, 23 Jun 2017 12:32:36 -0400 Received: from mail-qk0-f176.google.com ([209.85.220.176]:32916 "EHLO mail-qk0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754437AbdFWQcf (ORCPT ); Fri, 23 Jun 2017 12:32:35 -0400 Received: by mail-qk0-f176.google.com with SMTP id r62so39717294qkf.0 for ; Fri, 23 Jun 2017 09:32:30 -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=AdnY34mpY8er1ocVWEoLrGMA73GitJ8mdqcLYo47oxM=; b=hxTdhGn+KR34dQyWTqCEvU9HfCva3pDIPEg38SG00mNunva/8qFV3Ugo4y9gFenIj7 1SVSlgrzti5k74oJa11fuX/4zhOFsxr/osl0fD+SKjzwEc5dd18hwN7tnOvqNnUNTY9g fTzmnrLKiQ3EFcFyku26EAjFWAbeQUMmMHbl0= 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=AdnY34mpY8er1ocVWEoLrGMA73GitJ8mdqcLYo47oxM=; b=ON/DzaWBnQBM+cIAhLiK0aT4yJ7XF7vTvNu7Ajl63We4/iV8WDKscrTNInF5mRvyDH 86YqyD1uFiBzrcPH63N/srmXxa5+GIcL8lTtd1HU1MJF+Ino3usBr8UQW6G5hOOdkjeK 93K2iA0GjjT9WUaVJYwqXZqtAEWzzTu4vtB1c20PCQelgfCFZ21jY4qEMnzB9uwcJNbN EfBZSvOFgGISSC7YkWxOcyMJP6oNpnVGWOowrJVqGqRb/axnMbKXkMtMPyzjJG9BbNYb bmkE+Jhy6IuwQ3qKKN3T/HmIgTneOZZ9485NxuW6zUDmY53PqAOKwTwfcGK9Eig5F9Sn agfA== X-Gm-Message-State: AKS2vOzmGMPZIig9fYUlZmWjCO+yOTJ5K1amZLcpLDmtDrb/gUG+Kmxa u9/Nfn2qk8G83Oyb X-Received: by 10.55.124.194 with SMTP id x185mr9430445qkc.215.1498235549519; Fri, 23 Jun 2017 09:32:29 -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 c26sm1620720qte.63.2017.06.23.09.32.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 23 Jun 2017 09:32:28 -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 V3 2/2] PM / Domains: Extend generic power domain debugfs. Date: Fri, 23 Jun 2017 12:32:23 -0400 Message-Id: <1498235543-30064-3-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1498235543-30064-1-git-send-email-thara.gopinath@linaro.org> References: <1498235543-30064-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 | 205 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 197 insertions(+), 8 deletions(-) -- 2.1.4 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 40768cc..a10f789 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2328,21 +2328,191 @@ 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_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 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; + 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 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; + 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 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); @@ -2354,6 +2524,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);