Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1667646ybz; Thu, 16 Apr 2020 13:17:58 -0700 (PDT) X-Google-Smtp-Source: APiQypIUb6mHqb38nstqmLkYywCXEKu7zyIJqUiqjBwtKjziZHirO9Bt5ArlltlAv1OL9BB8O9Uc X-Received: by 2002:a50:da4a:: with SMTP id a10mr31828916edk.158.1587068278426; Thu, 16 Apr 2020 13:17:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587068278; cv=none; d=google.com; s=arc-20160816; b=Uo5WZYW4sDDMi6XK7W5f9X1lrXFB337WNZCdNaCbBWQTXt7MVwL6Hs7AnJnrb+2t5u 05lir7E5Y8uMD6j1Orph/CLfkwQfZ59QntSj5ZnEmRsZaiaFHmA723RmLBrWsGyFTfS9 jtkRFTmj3jzbBZyVlh4E7xra9hpaLh3ceanp3o6ZZnNDy2aRWp7vhnpoSbI3TqT6YELc Rd3//hGwb+/bxI0ij8TzT+ipHZPrgMgMlMpf9Osg0RnPK0BTkjh3rwweV1G5+oGWWhzV G9PUMnlckwrjHsXPq1tbUXHEMePlxzEMnAwX0U0nmxil2kZuT76Xt7UrCxHuUPb3Oigr 8NHw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FvpuLthfpHzTkZsCWmOlXm7fs583ITswBevLKRxLwYw=; b=RTmfCxw1WEapioGcMr7MHIwTJOj0dtNlEpnMVHnQ4UNvwt4iswymeMkzYSorizMGBv O4amL5AgN/ENc1OHUdjDR/Sl5TSUOZ+FgV63C0jvYK5JVLzy32ohJ9E0ex741Hlvis6K yQod2rN3bcO9LbyOcJ+ULgpa8m9DBfCAgtdpRPS1hCsjOwPhiK1VC5Hdke2B4V4UJ4MG RPHHyQN0hvb9mL7hXWgaUOpM8k4uG9DuKdKH1Ss5i+xFg0FALzKQowruW1G2H0qtqGHB 4WmOdhHilcv9CK6Pu56B7vAg0wFmZeGwu0z52V/XOLsB1pcnW96E5i3hPC7dV3++AyTO kaYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=e4l2cl2d; 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 a11si13539105edn.170.2020.04.16.13.17.35; Thu, 16 Apr 2020 13:17:58 -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; dkim=pass header.i=@kernel.org header.s=default header.b=e4l2cl2d; 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 S2437428AbgDPOML (ORCPT + 99 others); Thu, 16 Apr 2020 10:12:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:33868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2898670AbgDPNru (ORCPT ); Thu, 16 Apr 2020 09:47:50 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 63B1C21734; Thu, 16 Apr 2020 13:47:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587044869; bh=apSV7BQeBMHs9uj1fYCfgNfinODkrv0X4X/MdOfXP7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e4l2cl2djCAh6/ZAV0cWM//cNkgg4wpK4bx0saJQHgEWIgXC65noZ7RvkLrmviyR1 RLCpiVS3dvpJnVprycOjps8OaPlU7FKmZrOs4iuiPVTe/ZtVX4aQDrOE+qgiXRCFy7 c4IIiK5hsD2mMaP9IU6DR19HGb8QmKmWZl2LJxkY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Ond=C5=99ej=20Caletka?= , "Rafael J. Wysocki" Subject: [PATCH 5.4 094/232] ACPI: PM: s2idle: Refine active GPEs check Date: Thu, 16 Apr 2020 15:23:08 +0200 Message-Id: <20200416131326.747906266@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200416131316.640996080@linuxfoundation.org> References: <20200416131316.640996080@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki commit d5406284ff803a578ca503373624312770319054 upstream. The check for any active GPEs added by commit fdde0ff8590b ("ACPI: PM: s2idle: Prevent spurious SCIs from waking up the system") turns out to be insufficiently precise to prevent some systems from resuming prematurely due to a spurious EC wakeup, so refine it by first checking if any GPEs other than the EC GPE are active and skipping all of the SCIs coming from the EC that do not produce any genuine wakeup events after processing. Link: https://bugzilla.kernel.org/show_bug.cgi?id=206629 Fixes: fdde0ff8590b ("ACPI: PM: s2idle: Prevent spurious SCIs from waking up the system") Reported-by: Ondřej Caletka Tested-by: Ondřej Caletka Cc: 5.4+ # 5.4+ Signed-off-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/ec.c | 5 +++++ drivers/acpi/internal.h | 1 + drivers/acpi/sleep.c | 19 ++++++++++--------- 3 files changed, 16 insertions(+), 9 deletions(-) --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -1964,6 +1964,11 @@ 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; --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -201,6 +201,7 @@ 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 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c @@ -1014,19 +1014,20 @@ static bool acpi_s2idle_wake(void) return true; /* - * If there are no EC events to process and at least one of the - * other enabled GPEs is active, the wakeup is regarded as a - * genuine one. - * - * Note that the checks below must be carried out in this order - * to avoid returning prematurely due to a change of the EC GPE - * status bit from unset to set between the checks with the - * status bits of all the other GPEs unset. + * 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_any_gpe_status_set(U32_MAX) && !acpi_ec_dispatch_gpe()) + if (acpi_ec_other_gpes_active()) 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. *