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;