From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D2D9C31E5E for ; Wed, 19 Jun 2019 08:29:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D0BC9208CB for ; Wed, 19 Jun 2019 08:29:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560932957; bh=rg4hI+ag4/cZb2Bs+5Y7ss/W19aLgHV4NYGX814EmwU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=QpLn6906YmjWaXC6V/sEXm5ouOQRmyyT31BwRYAbQlslUIwih757u6XeGiC2HRzxX CRn+UL5MJ3+DOu3lNPFMQcI3aAMO8CuzPFXQrWFpVoFWxKdvizf6Qkz3zltNFBZmZm E3q66gf5DsnUmED9f2NcpDgIFnEQybzbde5wUJbA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731266AbfFSI3R convert rfc822-to-8bit (ORCPT ); Wed, 19 Jun 2019 04:29:17 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:45975 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731135AbfFSI3R (ORCPT ); Wed, 19 Jun 2019 04:29:17 -0400 Received: by mail-ot1-f68.google.com with SMTP id x21so18393307otq.12 for ; Wed, 19 Jun 2019 01:29:16 -0700 (PDT) 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=+E4sNn+Rhs3o0koNZdxkGFMzE9jFySnGtPnlKM7L4RM=; b=bRUIxX7sZwKjfu3dhczJOt/PQyzuVfYx1Lo6U3lP4Q6RSaFJjQlxUgZMoWh4I12sIi LjrekcIQjSOdeLaex/zL9wY4iRt2LSwgqJEbso6GpAb6I2U7vP28mADhW7FujEY3GrHh JAec/ddtdSnb+o/BIOw8LGIdUgSV9pQpdELjkvqW2sB6/X2pAstteHStyrM1G7BCmakt ZM5X0XVebLMXN1BTF4z/72q452M+qi3Qk3g8V59JKDOzWz8eXNCC6W1cDeD87TrMSAF6 o83g6/7OF+p+LFVObb78oBz7dlB5kBvr+GHG5ywBPAOgFGwPrFKDBkE15d8IT00QgDgg mNZg== X-Gm-Message-State: APjAAAUDBn45aAt1Nl/AjtwNoa95vWWP4QS96cMZIh+03L/Kyh8tbE41 ErXJeYuf5UWH+LdHnqoCohiX1E5hv+cpGEk2+MhBbCMY X-Google-Smtp-Source: APXvYqxHMEtSLSk6HKv0bes8Uwo13JYyvc0ls02pv6B0jmI/NOrGRw5h9ZBWBAkOJQJx57oAxLDNuhCqMnWN9Wm5+4I= X-Received: by 2002:a9d:5d15:: with SMTP id b21mr894891oti.262.1560932956131; Wed, 19 Jun 2019 01:29:16 -0700 (PDT) MIME-Version: 1.0 References: <20190526202750.4614-1-shaunak.saha@intel.com> <2151762.asltZFE8WJ@kreacher> <593AE8A18AD46543B92D8EF146E2AA9408C326BA@ORSMSX107.amr.corp.intel.com> In-Reply-To: <593AE8A18AD46543B92D8EF146E2AA9408C326BA@ORSMSX107.amr.corp.intel.com> From: "Rafael J. Wysocki" Date: Wed, 19 Jun 2019 10:29:03 +0200 Message-ID: Subject: Re: drivers/acpi: Change the lpit function call flow To: "Saha, Shaunak" Cc: "Rafael J. Wysocki" , Mario Limonciello , ACPI Devel Maling List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Wed, Jun 19, 2019 at 7:33 AM Saha, Shaunak wrote: > > Hi Rafael, > > Thanks for your review comments. Agreed that this patch needs to be fixed. I am working on it. > 1.First off, aborting system suspend because S0ix constraints are not met is a non-starter. The kernel really cannot refuse to suspend the system for that reason (and diagnostics can be done after resume anyway). > > For this as the LPIT specs says "_DSM function may be invoked when the OS state has reached sufficient criteria > for processor idle state entry matching Entry Trigger defined in LPIT" then to check that entry trigger from before calling the sleep function would be better approach. Will report an error if that is not met and still go to suspend. Is that a proper way to handle this? please suggest. > > 2. Second, according to my knowledge, it is not a bug to invoke the ACPI_LPS0_ENTRY _DSM when the constraints are not met. Do you actually know about any platforms where that may cause real problems to occur? > > Actually in the present platform i m working we are seeing the failure to go to suspend whenever this _DSM methods are called. But as you correctly mentioned i found that the bug was not because this function was called early but it's happening because in our case ec seems to be bit noisy and that's why it's coming out of suspend too early. Something is going wrong in the ec polling function it seems in this case. > > 3. Finally, it is too late to invoke that _DSM from acpi_s2idle_sync(), because that is called after leaving S0ix and resuming some devices. > > Agreed. I think moving the call of DSM from s2idle_enter is better if we decide to move it a later stage As I have just tested on one of my systems, moving the invocation of the ACPI_LPS0_ENTRY _DSM to a later stage causes problems to happen (spurious wakeups generated by the EC), so this generally doesn't work. I thus don't see a reason to change the code in the area at hand. > ________________________________________ > From: Rafael J. Wysocki [rafael@kernel.org] > Sent: Tuesday, June 18, 2019 1:44 AM > To: Mario Limonciello > Cc: Saha, Shaunak; ACPI Devel Maling List > Subject: Re: drivers/acpi: Change the lpit function call flow > > On Thu, Jun 13, 2019 at 11:37 PM Rafael J. Wysocki wrote: > > > > On Sunday, May 26, 2019 10:27:50 PM CEST Shaunak Saha wrote: > > > In the present implementation sleep function was getting called in > > > acpi_s2idle_prepare and as all the devices may not have suspended > > > at that stage e.g. if we are telling ec about the S0ix then calling early > > > can cause ec reply wrongly interpreted as spurious wake events. > > > Here we call it at much later stage in acpi_s2idle_sync. As per the > > > specification the entry _DSM function may be invoked when the OS state has > > > reached sufficient criteria for processor idle state entry matching > > > Entry Trigger defined in LPIT to be interpreted as a request for the > > > platform to enter a Low Power S0 Idle (LPI) state. Here we are checking if > > > the we reached the minimum D-State defined in the constraint function of > > > the LPIT _DSM method before calling the sleep entry function. Also not > > > checking for constraint in acpi_s2idle_wake anymore and also changed the > > > acpi info loglevel to debug in lpi_check_constraint. > > > > This patch does three different things, two of which are questionable and > > one is done incorrectly. > > > > First off, aborting system suspend because S0ix constraints are not met is > > a non-starter. The kernel really cannot refuse to suspend the system for > > that reason (and diagnostics can be done after resume anyway). > > > > Second, according to my knowledge, it is not a bug to invoke the > > ACPI_LPS0_ENTRY _DSM when the constraints are not met. Do you > > actually know about any platforms where that may cause real problems > > to occur? > > > > Finally, it is too late to invoke that _DSM from acpi_s2idle_sync(), because > > that is called after leaving S0ix and resuming some devices. > > > > I can believe the claim that invoking the ACPI_LPS0_ENTRY _DSM in > > acpi_s2idle_prepare() may be too early and it may confuse the EC, say, > > but I'm not sure why the ACPI_LPS0_SCREEN_OFF _DSM would be > > affected by that too. > > > > So overall, the patch below may actually work, > > On my Dell XPS13 9360 it clearly makes things worse by causing the EC > to generate spurious wakeup events all the time, so I'm afraid that > this like of reasoning is misguided overall. > > > but not the $subject one > > (if evaluating the ACPI_LPS0_ENTRY _DSM when the constraints are not > > met is *really* problematic, it may be necessary to add the check > > for that on top of it). > > > > --- > > drivers/acpi/sleep.c | 13 +++++++++---- > > include/linux/suspend.h | 1 + > > kernel/power/suspend.c | 8 ++++++-- > > 3 files changed, 16 insertions(+), 6 deletions(-) > > > > Index: linux-pm/drivers/acpi/sleep.c > > =================================================================== > > --- linux-pm.orig/drivers/acpi/sleep.c > > +++ linux-pm/drivers/acpi/sleep.c > > @@ -967,8 +967,6 @@ static int acpi_s2idle_prepare(void) > > { > > if (lps0_device_handle) { > > acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_OFF); > > - acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY); > > - > > acpi_ec_set_gpe_wake_mask(ACPI_GPE_ENABLE); > > } > > > > @@ -983,6 +981,12 @@ static int acpi_s2idle_prepare(void) > > return 0; > > } > > > > +static void acpi_s2idle_sleep(void) > > +{ > > + if (lps0_device_handle) > > + acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY); > > +} > > + > > static void acpi_s2idle_wake(void) > > { > > if (!lps0_device_handle) > > @@ -1007,6 +1011,8 @@ static void acpi_s2idle_wake(void) > > */ > > acpi_ec_dispatch_gpe(); > > } > > + > > + acpi_sleep_run_lps0_dsm(ACPI_LPS0_EXIT); > > } > > > > static void acpi_s2idle_sync(void) > > @@ -1034,8 +1040,6 @@ static void acpi_s2idle_restore(void) > > > > if (lps0_device_handle) { > > acpi_ec_set_gpe_wake_mask(ACPI_GPE_DISABLE); > > - > > - acpi_sleep_run_lps0_dsm(ACPI_LPS0_EXIT); > > acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_ON); > > } > > } > > @@ -1049,6 +1053,7 @@ static void acpi_s2idle_end(void) > > static const struct platform_s2idle_ops acpi_s2idle_ops = { > > .begin = acpi_s2idle_begin, > > .prepare = acpi_s2idle_prepare, > > + .sleep = acpi_s2idle_sleep, > > .wake = acpi_s2idle_wake, > > .sync = acpi_s2idle_sync, > > .restore = acpi_s2idle_restore, > > Index: linux-pm/include/linux/suspend.h > > =================================================================== > > --- linux-pm.orig/include/linux/suspend.h > > +++ linux-pm/include/linux/suspend.h > > @@ -190,6 +190,7 @@ struct platform_suspend_ops { > > struct platform_s2idle_ops { > > int (*begin)(void); > > int (*prepare)(void); > > + void (*sleep)(void); > > void (*wake)(void); > > void (*sync)(void); > > void (*restore)(void); > > Index: linux-pm/kernel/power/suspend.c > > =================================================================== > > --- linux-pm.orig/kernel/power/suspend.c > > +++ linux-pm/kernel/power/suspend.c > > @@ -136,10 +136,14 @@ static void s2idle_loop(void) > > * so prevent them from terminating the loop right away. > > */ > > error = dpm_noirq_suspend_devices(PMSG_SUSPEND); > > - if (!error) > > + if (!error) { > > + if (s2idle_ops && s2idle_ops->sleep) > > + s2idle_ops->sleep(); > > + > > s2idle_enter(); > > - else if (error == -EBUSY && pm_wakeup_pending()) > > + } else if (error == -EBUSY && pm_wakeup_pending()) { > > error = 0; > > + } > > > > if (!error && s2idle_ops && s2idle_ops->wake) > > s2idle_ops->wake(); > > > > > >