From patchwork Wed Mar 18 16:25:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 6041701 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0DFCC9F318 for ; Wed, 18 Mar 2015 16:25:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1C9AC203E3 for ; Wed, 18 Mar 2015 16:25:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2B64C203F1 for ; Wed, 18 Mar 2015 16:25:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755960AbbCRQZy (ORCPT ); Wed, 18 Mar 2015 12:25:54 -0400 Received: from laurent.telenet-ops.be ([195.130.137.89]:38705 "EHLO laurent.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755299AbbCRQZx (ORCPT ); Wed, 18 Mar 2015 12:25:53 -0400 Received: from ayla.of.borg ([84.193.93.87]) by laurent.telenet-ops.be with bizsmtp id 54Rr1q0181t5w8s014RrTC; Wed, 18 Mar 2015 17:25:52 +0100 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1YYGn1-0007UG-Is; Wed, 18 Mar 2015 17:25:51 +0100 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1YYGn3-0005eg-2C; Wed, 18 Mar 2015 17:25:53 +0100 From: Geert Uytterhoeven To: "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson Cc: linux-pm@vger.kernel.org, linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] PM / Domains: Skip latency measurements if timekeeping is suspended Date: Wed, 18 Mar 2015 17:25:46 +0100 Message-Id: <1426695946-21705-1-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The PM Domain code uses ktime_get() to perform various latency measurements. However, if ktime_get() is called while timekeeping is suspended, the following warning is printed: WARNING: CPU: 0 PID: 1340 at kernel/time/timekeeping.c:576 ktime_get+0x30/0xf4() This happens when resuming the PM Domain that contains the clock events source. Chain of operations is: timekeeping_resume() { clockevents_resume() sh_cmt_clock_event_resume() pm_genpd_syscore_poweron() pm_genpd_sync_poweron() genpd_power_on() ktime_get(), but timekeeping_suspended == 1 ... timekeeping_suspended = 0; } Skip all latency measurements if timekeeping is suspended to fix this. Signed-off-by: Geert Uytterhoeven --- I'm not sure if this is needed for all latency measurements. So far I only encountered it while powering-on a clock domain during resume from s2ram. --- drivers/base/power/domain.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 45937f88e77c8889..ab2398cfcebb7732 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -18,6 +18,7 @@ #include #include #include +#include #define GENPD_DEV_CALLBACK(genpd, type, callback, dev) \ ({ \ @@ -33,16 +34,24 @@ #define GENPD_DEV_TIMED_CALLBACK(genpd, type, callback, dev, field, name) \ ({ \ - ktime_t __start = ktime_get(); \ - type __retval = GENPD_DEV_CALLBACK(genpd, type, callback, dev); \ - s64 __elapsed = ktime_to_ns(ktime_sub(ktime_get(), __start)); \ - struct gpd_timing_data *__td = &dev_gpd_data(dev)->td; \ - if (!__retval && __elapsed > __td->field) { \ - __td->field = __elapsed; \ - dev_dbg(dev, name " latency exceeded, new value %lld ns\n", \ - __elapsed); \ - genpd->max_off_time_changed = true; \ - __td->constraint_changed = true; \ + type __retval; \ + if (unlikely(timekeeping_suspended)) { \ + dev_dbg(dev, "Skipping %s timings\n", #callback); \ + __retval = GENPD_DEV_CALLBACK(genpd, type, callback, dev); \ + } else { \ + ktime_t __start = ktime_get(); \ + type __ret = GENPD_DEV_CALLBACK(genpd, type, callback, dev); \ + s64 __elapsed = ktime_to_ns(ktime_sub(ktime_get(), __start)); \ + struct gpd_timing_data *__td = &dev_gpd_data(dev)->td; \ + if (!__ret && __elapsed > __td->field) { \ + __td->field = __elapsed; \ + dev_dbg(dev, \ + name " latency exceeded, new value %lld ns\n", \ + __elapsed); \ + genpd->max_off_time_changed = true; \ + __td->constraint_changed = true; \ + } \ + __retval = __ret; \ } \ __retval; \ }) @@ -161,6 +170,11 @@ static int genpd_power_on(struct generic_pm_domain *genpd) if (!genpd->power_on) return 0; + if (unlikely(timekeeping_suspended)) { + pr_debug("%s: Skipping %s timings\n", genpd->name, "power_on"); + return genpd->power_on(genpd); + } + time_start = ktime_get(); ret = genpd->power_on(genpd); if (ret) @@ -188,6 +202,11 @@ static int genpd_power_off(struct generic_pm_domain *genpd) if (!genpd->power_off) return 0; + if (unlikely(timekeeping_suspended)) { + pr_debug("%s: Skipping %s timings\n", genpd->name, "power_off"); + return genpd->power_off(genpd); + } + time_start = ktime_get(); ret = genpd->power_off(genpd); if (ret == -EBUSY)