Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp630474imu; Wed, 9 Jan 2019 03:51:09 -0800 (PST) X-Google-Smtp-Source: ALg8bN4U+4vXT0RioSa3MB/tAUXM0SWY+eSjihdPeP7528nAUf+xSqkIYq9PnUPwuZNTqogpvTWQ X-Received: by 2002:a65:55ca:: with SMTP id k10mr5061529pgs.448.1547034669375; Wed, 09 Jan 2019 03:51:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547034669; cv=none; d=google.com; s=arc-20160816; b=LsmXvfJR5/dOFa8vdUWj/243jRqQSh84HTvoPsHCw8uwr/NBW8TRMJDcuopKI50FQ7 iOxCJisI3/PZIxgDaXmXcwNTfDafNLsXDR3fHZZF69GtZ+TC0BPdmjk2L39bC+zBUzgV eQEv2yV3SrPEoIykt13wjquVZkj1nFPqCX5Q91F6IjQFGfVmBiKU2QwsctvuxyLynyn5 P8pW767BJLntMqSlNeQ2UND8HekLHONQNM1DLyFTCJlz++b8DpK413ZO0n9hyZNUAstE 697OIZYHOnkdiwDEVOKAP/tawyThS51sgjrUrhBk89f/QLef33pv1Da57nsiPEulPVYL gpxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=fwalqQP0EtHKCg5jERkb/5Rc9dt+DwOqndtUoce1eyI=; b=EdMKAXKoseNN+K6+OPWDlob98m99+ectbc28OikAiJ7+gl3ikuztwpQeIcFa/uIczw Z/3p5PbaFi6NeNllWWijvm/QT1eyNk0OYd/FY3j0ywir9uFlpWAaJibkMi6I2Aam7MZl oLsOHegnPkSR6kWyjTbypP8GVhHvFQaclNI0TW/vGwSLtp9luFBvTay//AohIEWXTV5F WkJALL1+RRRy73F4yS1cuSo6NVrueRIAKIcS87wuuvkKc1g87nXi0sibYIACEISWzvsv rNl/V0zGu6He964SPPZC7dLV9aF+hrpHLAKIBj2y914jspV+hnWqmMu/o1kSxa7rtqTk G0Gw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l22si68450770pgo.411.2019.01.09.03.50.53; Wed, 09 Jan 2019 03:51:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730809AbfAILRI (ORCPT + 99 others); Wed, 9 Jan 2019 06:17:08 -0500 Received: from eddie.linux-mips.org ([148.251.95.138]:52482 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730111AbfAILRI (ORCPT ); Wed, 9 Jan 2019 06:17:08 -0500 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23993832AbfAILRFLEeRV (ORCPT + 2 others); Wed, 9 Jan 2019 12:17:05 +0100 Date: Wed, 9 Jan 2019 12:17:03 +0100 From: Ladislav Michl To: Vincent Guittot Cc: Tony Lindgren , "Rafael J. Wysocki" , Ulf Hansson , "open list:THERMAL" , linux-kernel , LAK , linux-omap@vger.kernel.org Subject: Re: Regression in v5.0-rc1 with autosuspend hrtimers Message-ID: <20190109111703.GA28605@lenoch> References: <20190107233833.GI5544@atomide.com> <20190108155354.GL5544@atomide.com> <20190108213743.GN5544@atomide.com> <20190109014218.GA8363@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190109014218.GA8363@linaro.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 09, 2019 at 02:42:18AM +0100, Vincent Guittot wrote: > Le Tuesday 08 Jan 2019 à 13:37:43 (-0800), Tony Lindgren a écrit : > > * Vincent Guittot [190108 16:42]: > > > On Tue, 8 Jan 2019 at 16:53, Tony Lindgren wrote: > > > > Hmm so could it be that we now rely on timers that that may > > > > not be capable of waking up the system from idle states with > > > > hrtimer? > > > > > > With nohz and hrtimer enabled, timer relies on hrtimer to generate > > > the tick so you should use the same interrupt. > > > > OK yeah looks like that part is working just fine. > > > > Adding some printks and debugging over ssh, looks like > > omap8250_runtime_resume() gets called just fine based on a wakeirq, > > but then omap8250_runtime_suspend() runs immediately instead of > > waiting for the three second timeout. > > > > Lowering the autosuspend_delay_ms to 2100 ms makes things work again. > > Anything higher than 2200 ms seems to somehow time out immediately > > now :) > > This is quite close to the max ns of an int on arm 32bits > > Could you try the patch below ? > > --- > drivers/base/power/runtime.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c > index 7062469..44c5c76 100644 > --- a/drivers/base/power/runtime.c > +++ b/drivers/base/power/runtime.c > @@ -141,7 +141,7 @@ u64 pm_runtime_autosuspend_expiration(struct device *dev) > > last_busy = READ_ONCE(dev->power.last_busy); > > - expires = last_busy + autosuspend_delay * NSEC_PER_MSEC; > + expires = last_busy + (u64)(autosuspend_delay) * NSEC_PER_MSEC; > if (expires <= now) > expires = 0; /* Already expired. */ Hmm, comment above function states it returns "the expiration time in jiffies (adjusted to be nonzero)", so there's probably more to fix... You can also consider change like this (still does not return jiffies): diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 70624695b6d5..c72eaf21a61c 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -129,23 +129,20 @@ static void pm_runtime_cancel_pending(struct device *dev) u64 pm_runtime_autosuspend_expiration(struct device *dev) { int autosuspend_delay; - u64 last_busy, expires = 0; - u64 now = ktime_to_ns(ktime_get()); + ktime_t expires; if (!dev->power.use_autosuspend) - goto out; + return 0; autosuspend_delay = READ_ONCE(dev->power.autosuspend_delay); if (autosuspend_delay < 0) - goto out; - - last_busy = READ_ONCE(dev->power.last_busy); + return 0; - expires = last_busy + autosuspend_delay * NSEC_PER_MSEC; - if (expires <= now) - expires = 0; /* Already expired. */ + expires = ktime_add_ns(ms_to_ktime(autosuspend_delay), + READ_ONCE(dev->power.last_busy)); + if (expires <= ktime_get()) + return 0; /* Already expired. */ - out: return expires; } EXPORT_SYMBOL_GPL(pm_runtime_autosuspend_expiration); Regards, ladis