Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp630556imu; Wed, 9 Jan 2019 03:51:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN6qjU+jBrBEdOihN6JpmimLWud7rbMtFOAI+jV+RiPJdr7u62s8TYYQL8iBYOw+A0+ejoJr X-Received: by 2002:a62:37c3:: with SMTP id e186mr5765106pfa.251.1547034673287; Wed, 09 Jan 2019 03:51:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547034673; cv=none; d=google.com; s=arc-20160816; b=XrNg1IIqZO6D32kI5nHiDLoLw7t0lqHwT2qfFI4FxppcbFvVaevBIK/AFJOhltA+Sk CSF3pNlRGqIOkqbceEERXsDqjATlEpDVIKvjm9blN99BeX0h8/P3KSzqFbRrvav9bjvz N4SwicFLfj+Tyk3WWRIuK1wbTg0M5fF3Bi1HR0+NJF/32Fb0hMCC2NDiuUYL+mReS8tO tqrnM0zvCZ1Ox8fr01rIEbZ5TcpW7RGqIgRU+7ktEwc8Z4E94SDi8oLOGmjDErxXBz/d 5MKEF5pwjACD9YUZOmIn4I0JGt0/37g2dHP9taEwzeg/3nZadi1Q0I23/f0wo49NtGaX kJLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=dUWGm/4sPfFN1UJt6UEtJ/PK1+2pHD5Y0JKS7yOTNDA=; b=ALgPlA9RLxSZ8L6R9d/iEuFhJp8z/km9gCE1ag8cnTnIcW+xtvQknrN5zGZ/frfOR0 CSOAHiWmbm05LOF9xwqnHD6T0YhnURgWcpAmT4M5AsXAFEAhZtypyTu9rZZYzUMndqbX T0JWLyOCUfOrlY59c/sNcjcr6NN61WVfAcbyt8JOEIqdtUOzZGwCipStmY8meo4EMhYy LbQLVY7PZ5As7XmB8vQt61zXg1L1bqDUgJqVh+V4Vt58YBMtPQ8XZodFj2JgFY8lNGgi GK1hhej3V+U3eEbKTL7DsQPFLJQaOfovOwDRA8IXRzpqXyyuP07den8bwxI1kw9q8oE7 WSDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UvEgHCGU; 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; 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 v3si3371728pga.556.2019.01.09.03.50.57; Wed, 09 Jan 2019 03:51:13 -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; dkim=pass header.i=@linaro.org header.s=google header.b=UvEgHCGU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730602AbfAIL2M (ORCPT + 99 others); Wed, 9 Jan 2019 06:28:12 -0500 Received: from mail-it1-f195.google.com ([209.85.166.195]:36630 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730392AbfAIL2M (ORCPT ); Wed, 9 Jan 2019 06:28:12 -0500 Received: by mail-it1-f195.google.com with SMTP id c9so10502550itj.1 for ; Wed, 09 Jan 2019 03:28:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=dUWGm/4sPfFN1UJt6UEtJ/PK1+2pHD5Y0JKS7yOTNDA=; b=UvEgHCGUwfarWCc7/zBI+UiEkSkzynG6Vpcd0ZY5TEpy090k6LeW/wX2I/sF7fS7VX deN1/pJCZWssjtAQIt98U/fQR7jPsorbb9pFYBvya2qFc0ZfIPBlpDkoo5EVOpGYM3g+ 8GxtP+75TzebzPX8BtdIzr/2F0pS0Ce1/MWfc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=dUWGm/4sPfFN1UJt6UEtJ/PK1+2pHD5Y0JKS7yOTNDA=; b=jHV6A3VF9hOLrp+E8/VUn9jzUPDcGeelfSAiEcJKRKB0tV3oWlPthe+vuAurxYTWWC yCV8eYRdsGLV4qEdrcOowwc6olW8owlpktl5G1Ud8QfOMKYR1b6V1qGumBuf0AQyGIhK fFvzECH8BUlhKQTg33OBCCo9LVOoZS3Hi3YRv9aGpvZ2JOvHDQx10h48RXLTwB/wQVNG xu6/Tzet5bwraMH/ELwN+jWWjftaWjwdzfqFONwfX+C0fd7LkUc3IxTf/HrF7EUVyrpr NvVBhPO1uS4qTj5pljVOPJudHhqYvqY2KG34OM3i4yKk7LuoDbti+YVhkMw9vlnwT1vk vXRg== X-Gm-Message-State: AJcUukcyqa6j5J+utmCKxdrRYQ3+C/gKlAsMP1OgxTywZs0E53D5fAN+ spywi1JOjD6yMOhk1vgnu7/WjLIqQ5MBNa7MAS3ZZA== X-Received: by 2002:a24:a20e:: with SMTP id j14mr3921367itf.14.1547033289883; Wed, 09 Jan 2019 03:28:09 -0800 (PST) MIME-Version: 1.0 References: <20190107233833.GI5544@atomide.com> <20190108155354.GL5544@atomide.com> <20190108213743.GN5544@atomide.com> <20190109014218.GA8363@linaro.org> <20190109111703.GA28605@lenoch> In-Reply-To: <20190109111703.GA28605@lenoch> From: Vincent Guittot Date: Wed, 9 Jan 2019 12:27:57 +0100 Message-ID: Subject: Re: Regression in v5.0-rc1 with autosuspend hrtimers To: Ladislav Michl Cc: Tony Lindgren , "Rafael J. Wysocki" , Ulf Hansson , "open list:THERMAL" , linux-kernel , LAK , linux-omap@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 9 Jan 2019 at 12:17, Ladislav Michl wrote: > > On Wed, Jan 09, 2019 at 02:42:18AM +0100, Vincent Guittot wrote: > > Le Tuesday 08 Jan 2019 =C3=A0 13:37:43 (-0800), Tony Lindgren a =C3=A9c= rit : > > > * 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 =3D READ_ONCE(dev->power.last_busy); > > > > - expires =3D last_busy + autosuspend_delay * NSEC_PER_MSEC; > > + expires =3D last_busy + (u64)(autosuspend_delay) * NSEC_PER_MSEC; > > if (expires <=3D now) > > expires =3D 0; /* Already expired. */ > > Hmm, comment above function states it returns "the expiration time in jif= fies > (adjusted to be nonzero)", so there's probably more to fix... The comment is wrong and should be updated as commit 8234f6734c5d has moved on hrtimer and expires is now in raw ns unit > > 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 =3D 0; > - u64 now =3D ktime_to_ns(ktime_get()); > + ktime_t expires; > > if (!dev->power.use_autosuspend) > - goto out; > + return 0; > > autosuspend_delay =3D READ_ONCE(dev->power.autosuspend_delay); > if (autosuspend_delay < 0) > - goto out; > - > - last_busy =3D READ_ONCE(dev->power.last_busy); > + return 0; > > - expires =3D last_busy + autosuspend_delay * NSEC_PER_MSEC; > - if (expires <=3D now) > - expires =3D 0; /* Already expired. */ > + expires =3D ktime_add_ns(ms_to_ktime(autosuspend_delay), > + READ_ONCE(dev->power.last_busy)); > + if (expires <=3D ktime_get()) > + return 0; /* Already expired. */ > > - out: > return expires; > } > EXPORT_SYMBOL_GPL(pm_runtime_autosuspend_expiration); > > Regards, > ladis