Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp946888ybj; Thu, 7 May 2020 11:08:18 -0700 (PDT) X-Google-Smtp-Source: APiQypLfCadberOSr+j2cLURYdbz+Hrtw4YINiZl2/P6Fk/2skCz7mpx+262F7vyxskUZrvIa0uf X-Received: by 2002:a17:906:938c:: with SMTP id l12mr11679040ejx.338.1588874898671; Thu, 07 May 2020 11:08:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588874898; cv=none; d=google.com; s=arc-20160816; b=E9mZgEi4ARw5dJFoxHOR73HwIU8mAFWY/DjNOU7Xr7nHPLk+Tp0Hx0rO6lwotjDrP3 KTowpskimQl7AYNiI9KZcgHrI4bsXkuRjTlnGZAIczSJVGjGeyA2VqLUeHTta1Ou1Alz 0Iusi2ljDPUZKigwyu0CJo9ZBfvR/hhhxkcPCvboM1m4F11+oWQmm6EV6gc8rE2dufFf GFJCTt2mXVStDxARwggzYKcqiAFjsNDgv4Q0mUmi6JQeJZEj4Pl9kavfmlUQRHpiUHWE ZkFPMau+56oJA0MR4fi48DhEYlO2/MFainXS0cwBYeCERJFY7o2/lojwLgjD0QP5DQtU MOFg== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=RtyA1fFE4nlYTrERP2cwZ8Pk7eaCe4jxnm8mCa8UjRM=; b=eajfl3q9Vi829/s4GyTG3EkyrZIAQVi0TUcJA3jb8EYWRk8O/kQ5texvLL4ryANDBa YwKv0ob2J5JN9ZcQR1r2fJZISEzGbzIbtZSicufB8EYak4ULj0CmfPkAr1AOMO/ReuxI t/CCrK5eOLfiZU7TkhaUyXbDh4KVpCHzo/DwWkdTwrjr4AJ4hV6Ms2RWHKVSuqF8Nd8K z3cGQKte3v8pAgk0Q5SabgJR2hmTGCjgLkzMCowR7ToGum7/ZXOIFJeLqdB/kMgx+4cg fWnEGoRph3JaAw4At0+txeExHOpKWL61rz+8nEkZ8eJEUmXoSFtfNfWOeQiqs0utempy C/zA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q13si3555521eds.115.2020.05.07.11.07.54; Thu, 07 May 2020 11:08:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728378AbgEGSFW (ORCPT + 99 others); Thu, 7 May 2020 14:05:22 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:51330 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728373AbgEGSFV (ORCPT ); Thu, 7 May 2020 14:05:21 -0400 Received: from 89-64-84-94.dynamic.chello.pl (89.64.84.94) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.415) id eede8e33c27c587e; Thu, 7 May 2020 20:05:18 +0200 From: "Rafael J. Wysocki" To: Chris Chiu Cc: "Rafael J. Wysocki" , Seth Forshee , Len Brown , ACPI Devel Maling List , Linux Kernel , Linux Upstreaming Team Subject: Re: System fails to exit s2idle by a keystroke on my laptop Date: Thu, 07 May 2020 20:05:11 +0200 Message-ID: <5029155.caIQduTdCh@kreacher> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday, May 7, 2020 5:38:11 AM CEST Chris Chiu wrote: > On Wed, May 6, 2020 at 6:19 PM Rafael J. Wysocki wrote: > > > > On Wed, May 6, 2020 at 11:32 AM Rafael J. Wysocki wrote: > > > > > > > > > Thanks for the report, the issue evidently is EC-related. > > > > > > > @@ -1024,7 +1024,7 @@ static bool acpi_s2idle_wake(void) > > > > * regarded as a spurious one. > > > > */ > > > > if (!acpi_ec_dispatch_gpe()) > > > > - return false; > > > > + return true; > > > > > > Have you tried commenting out simply removing the if () check and the > > > following return statement? > > > > Scratch that. > > > > Instead, please try doing > > > > acpi_ec_dispatch_gpe() > > > > instead of the if () and the following return statement. > > Yes. I verified with the modification you suggested on my laptop. It's > working OK. > I can wake from a keystroke w/o problem. > > @ -1024,8 +1024,7 @@ static bool acpi_s2idle_wake(void) > * If the EC GPE status bit has not been set, the wakeup is > * regarded as a spurious one. > */ > - if (!acpi_ec_dispatch_gpe()) > - return false; > + acpi_ec_dispatch_gpe(); > > /* > * Cancel the wakeup and process all pending events in case > OK, great, thanks for the confirmation! Does the appended patch work for you then? It should be functionally equivalent to the above change if I didn't mess it up. --- drivers/acpi/ec.c | 23 ++++++++++++++--------- drivers/acpi/internal.h | 1 - drivers/acpi/sleep.c | 14 ++------------ 3 files changed, 16 insertions(+), 22 deletions(-) Index: linux-pm/drivers/acpi/sleep.c =================================================================== --- linux-pm.orig/drivers/acpi/sleep.c +++ linux-pm/drivers/acpi/sleep.c @@ -1013,21 +1013,11 @@ static bool acpi_s2idle_wake(void) if (acpi_check_wakeup_handlers()) return true; - /* - * If the status bit is set for any enabled GPE other than the - * EC one, the wakeup is regarded as a genuine one. - */ - if (acpi_ec_other_gpes_active()) + /* Check non-EC GPE wakeups and dispatch the EC GPE. */ + if (acpi_ec_dispatch_gpe()) return true; /* - * If the EC GPE status bit has not been set, the wakeup is - * regarded as a spurious one. - */ - if (!acpi_ec_dispatch_gpe()) - return false; - - /* * Cancel the wakeup and process all pending events in case * there are any wakeup ones in there. * Index: linux-pm/drivers/acpi/ec.c =================================================================== --- linux-pm.orig/drivers/acpi/ec.c +++ linux-pm/drivers/acpi/ec.c @@ -1994,23 +1994,28 @@ void acpi_ec_set_gpe_wake_mask(u8 action acpi_set_gpe_wake_mask(NULL, first_ec->gpe, action); } -bool acpi_ec_other_gpes_active(void) -{ - return acpi_any_gpe_status_set(first_ec ? first_ec->gpe : U32_MAX); -} - bool acpi_ec_dispatch_gpe(void) { u32 ret; if (!first_ec) - return false; + return acpi_any_gpe_status_set(U32_MAX); + /* + * Report wakeup if the status bit is set for any enabled GPE other + * than the EC one. + */ + if (acpi_any_gpe_status_set(first_ec->gpe)) + return true; + + /* + * Dispatch the EC GPE in-band, but do not report wakeup in any case + * to allow the caller to process events properly after that. + */ ret = acpi_dispatch_gpe(NULL, first_ec->gpe); - if (ret == ACPI_INTERRUPT_HANDLED) { + if (ret == ACPI_INTERRUPT_HANDLED) pm_pr_dbg("EC GPE dispatched\n"); - return true; - } + return false; } #endif /* CONFIG_PM_SLEEP */ Index: linux-pm/drivers/acpi/internal.h =================================================================== --- linux-pm.orig/drivers/acpi/internal.h +++ linux-pm/drivers/acpi/internal.h @@ -202,7 +202,6 @@ void acpi_ec_remove_query_handler(struct #ifdef CONFIG_PM_SLEEP void acpi_ec_flush_work(void); -bool acpi_ec_other_gpes_active(void); bool acpi_ec_dispatch_gpe(void); #endif