Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp205975ybj; Fri, 8 May 2020 09:48:10 -0700 (PDT) X-Google-Smtp-Source: APiQypK49M4SCdXQsQgvQwb0fw7W4sT4i/9yqRvd7WFUlDUSozIIBOfgVJzNZZeWKOnN1XbPjWj0 X-Received: by 2002:a05:6402:688:: with SMTP id f8mr2867000edy.233.1588956490298; Fri, 08 May 2020 09:48:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588956490; cv=none; d=google.com; s=arc-20160816; b=YuZa39FhwACxJXMpxPuYC/fIEpEP/w7gKtEpPhtsfLoGtUzdX/Yn0Z49jikKPls4if RBwh0gceevy5N2yjUBRZ9tCNEhzHdhBsLDST0zF1wpkI/VtAeHGNpPqedv7cp/LWnUC8 BIXRCGUVX2iVRPiM0plY6BbOol8Ly894VDJlQeTzwgEUtm4sN5Vd4VTcPWOPIRhhRpq6 wem7dAF48VhnLUemaYCHojNg3aRfrBXL5EtslPbBUKTUDpLtMSj2tOQ7ddhUjZ3AFrao VZMzGnTbGStAK6/PaZVnJ1KVb7c2sdSuc/sAZlxG+3l/jviaeRK0WKQ72B0arjxpqSnd fe4A== 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 :message-id:date:subject:cc:to:from; bh=anYwdBmDHIL6Ja26v9MajUqUVx38cPok+je5asNDo3s=; b=WHFFdP4ZKuy5PsWNh2gdtvX/uoVXrX/vgUxp10yGftu6INfCDgRTFofpEplaFfJONM /XRwMKNQ61+ZZKfCg/KPXEa9fomBHWMLMmiN0kOKAOYx3wbtezRB13d+ZsFM6HEnJCh1 ZxfcxXXDHMarVo3yh3x1B7VR3qB6YD3gQyeu9Qs8wZDweaafw1XsFawrHACk6VFFZla6 vkfHZZlID+wlzZQuL7Jf7YMs8895cvn1z2YLPHLdHbJ2k9hb+xEFITA5k8RxRSDME6wt Ih2S/ugXrIDtAjgH+UPP3otl0KDK8aKV5NA3J4qnX1/PEeZBxhuErjo4Zg9XpoO1e8bx /kYQ== 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 dn6si1308609edb.514.2020.05.08.09.47.45; Fri, 08 May 2020 09:48:10 -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 S1726906AbgEHQqW (ORCPT + 99 others); Fri, 8 May 2020 12:46:22 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:47884 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726750AbgEHQqV (ORCPT ); Fri, 8 May 2020 12:46:21 -0400 Received: from 89-64-85-173.dynamic.chello.pl (89.64.85.173) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.415) id b97d93fcd990997d; Fri, 8 May 2020 18:46:18 +0200 From: "Rafael J. Wysocki" To: Linux ACPI Cc: Linux PM , Zhang Rui , LKML , Chris Chiu Subject: [PATCH] ACPI: EC: s2idle: Avoid premature returns from acpi_s2idle_wake() Date: Fri, 08 May 2020 18:46:17 +0200 Message-ID: <1604462.Hd3yvOQCVk@kreacher> 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 From: Rafael J. Wysocki If the EC GPE status is not set after checking all of the other GPEs, acpi_s2idle_wake() returns 'false', to indicate that the SCI event that has just triggered is not a system wakeup one, but it does that without canceling the pending wakeup and re-arming the SCI for system wakeup which is a mistake, because it may cause valid subsequent wakeup events to be missed. Fix that by moving all of the GPE checking logic from acpi_s2idle_wake() to acpi_ec_dispatch_gpe() and making the latter return 'true' only if a non-EC GPE has triggered and 'false' otherwise, which will cause acpi_s2idle_wake() to cancel the pending SCI wakeup and re-arm the SCI for system wakeup regardless of the EC GPE status. Fixes: d5406284ff80 ("ACPI: PM: s2idle: Refine active GPEs check") Reported-by: Chris Chiu Signed-off-by: Rafael J. Wysocki --- drivers/acpi/ec.c | 24 ++++++++++++++++-------- drivers/acpi/internal.h | 1 - drivers/acpi/sleep.c | 14 ++------------ 3 files changed, 18 insertions(+), 21 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,31 @@ 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 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; + + if (ec_no_wakeup) return false; + /* + * 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