Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1180082ybf; Thu, 27 Feb 2020 06:24:57 -0800 (PST) X-Google-Smtp-Source: APXvYqwldMJo0te5K779wTQidhO7X4CFInjh9DwlKF24n9fawRstCEqHRHkxaj8YgvrgZjBzxdik X-Received: by 2002:a05:6808:315:: with SMTP id i21mr3352791oie.139.1582813497139; Thu, 27 Feb 2020 06:24:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582813497; cv=none; d=google.com; s=arc-20160816; b=ULs2IbR0HtT6lZv7KnsVgQmPKTuHUi+LoSid3Xp6OJC2sWX2VbC7yLqmsAb9LcX4nZ Oq2S5VvGGJi7yUku4agUPAETscFTnJ9Twy2mwcJPdyPHhPoJUloNyEXUzuap9Ma8lTVE ZOF7JAqiesreVzlqAHmIVMaxVOTfWsIF3VCFTWengGbhYk9FS6g/mZgOmJS+x7Hx2hRZ JrFn8mHwyne/SzjVQOq8J+kw+r0STm/ZR6mbZhr+uDNZVrM6Oi8qkmwZ+XyEu7YJqnLI O7B2iovrzQaFKQsKZYNZKTDSFM9QwXoxn6xsklqNJ/8RCGn7MJYrWVQA3qr4bW2fN5m9 oKQw== 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=QXT6u/94jii8Tmj+tSJPtW2MsDkpmcPJSgjqjRb57S8=; b=PCQeZPoAp/YWcUJaOrpDx1glUiGMJpPdywb6Ja46KVMRJgQZT53hTp0hf8n08243SE Ct/+stjNmmXWCwoNfRyx6zaTwdMa4eoOlq4M3wIkNp8IbK2sC0Ta/XPV/TE8dCGZ9BTr sedPIDXFuccXXLdQAFG3Wdo5w0bqu3IpDCTA5wA/DgIkt9y5OIn+ja+EAe0TU3srAQAi cjeJ5Jj0FrFDJU6oZ/j6twV5fZ1A2YCKpXE6K5RkfATqV2oNcDTweY1WasVhZZ1F6/kM BLF4oFij+M0uHqpt1yv4IXodJWTx63lRWHWehPgWMrpS8sex83T+rBcbAgd4UE0pjeMh gsow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cAl7PVS5; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g25si1430089otj.198.2020.02.27.06.24.43; Thu, 27 Feb 2020 06:24:57 -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=@kernel.org header.s=default header.b=cAl7PVS5; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389320AbgB0OPd (ORCPT + 99 others); Thu, 27 Feb 2020 09:15:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:55090 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389312AbgB0OPb (ORCPT ); Thu, 27 Feb 2020 09:15:31 -0500 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 42B1E2469F; Thu, 27 Feb 2020 14:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582812929; bh=0ofxD2pXQYvifZBLcI9btxAKPZ/MMG5dl+RHuuaoxxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cAl7PVS5UAuSq+fl+N5cbm0g70mIkS0tN+LxjWyKNWQ7Q9KjKARILLOyUGl2Ispw1 SLVUJrZV+NEdDtMiMXsnNX0nTQRjqKLvqtfpmRlvCo7OvPNuF5z6+gV45WHlDskkVj wXv9L8jjCclbEn/SlmoJzbC3q/JkSeUaMkEIK+xk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Rafael J. Wysocki" , Linus Torvalds , Chris Wilson Subject: [PATCH 5.5 071/150] ACPI: PM: s2idle: Check fixed wakeup events in acpi_s2idle_wake() Date: Thu, 27 Feb 2020 14:36:48 +0100 Message-Id: <20200227132243.412235414@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227132232.815448360@linuxfoundation.org> References: <20200227132232.815448360@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 63fb9623427fbb44e3782233b6e4714057b76ff2 upstream. Commit fdde0ff8590b ("ACPI: PM: s2idle: Prevent spurious SCIs from waking up the system") overlooked the fact that fixed events can wake up the system too and broke RTC wakeup from suspend-to-idle as a result. Fix this issue by checking the fixed events in acpi_s2idle_wake() in addition to checking wakeup GPEs and break out of the suspend-to-idle loop if the status bits of any enabled fixed events are set then. Fixes: fdde0ff8590b ("ACPI: PM: s2idle: Prevent spurious SCIs from waking up the system") Reported-and-tested-by: Chris Wilson Cc: 5.4+ # 5.4+ Signed-off-by: Rafael J. Wysocki Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/acpica/evevent.c | 45 ++++++++++++++++++++++++++++++++++++++++++ drivers/acpi/sleep.c | 7 ++++++ include/acpi/acpixf.h | 1 3 files changed, 53 insertions(+) --- a/drivers/acpi/acpica/evevent.c +++ b/drivers/acpi/acpica/evevent.c @@ -265,4 +265,49 @@ static u32 acpi_ev_fixed_event_dispatch( handler) (acpi_gbl_fixed_event_handlers[event].context)); } +/******************************************************************************* + * + * FUNCTION: acpi_any_fixed_event_status_set + * + * PARAMETERS: None + * + * RETURN: TRUE or FALSE + * + * DESCRIPTION: Checks the PM status register for active fixed events + * + ******************************************************************************/ + +u32 acpi_any_fixed_event_status_set(void) +{ + acpi_status status; + u32 in_status; + u32 in_enable; + u32 i; + + status = acpi_hw_register_read(ACPI_REGISTER_PM1_ENABLE, &in_enable); + if (ACPI_FAILURE(status)) { + return (FALSE); + } + + status = acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS, &in_status); + if (ACPI_FAILURE(status)) { + return (FALSE); + } + + /* + * Check for all possible Fixed Events and dispatch those that are active + */ + for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { + + /* Both the status and enable bits must be on for this event */ + + if ((in_status & acpi_gbl_fixed_event_info[i].status_bit_mask) && + (in_enable & acpi_gbl_fixed_event_info[i].enable_bit_mask)) { + return (TRUE); + } + } + + return (FALSE); +} + #endif /* !ACPI_REDUCED_HARDWARE */ --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c @@ -1003,6 +1003,13 @@ static bool acpi_s2idle_wake(void) return true; /* + * If the status bit of any enabled fixed event is set, the + * wakeup is regarded as valid. + */ + if (acpi_any_fixed_event_status_set()) + 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. --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h @@ -753,6 +753,7 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_sta ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable_all_runtime_gpes(void)) ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable_all_wakeup_gpes(void)) ACPI_HW_DEPENDENT_RETURN_UINT32(u32 acpi_any_gpe_status_set(void)) +ACPI_HW_DEPENDENT_RETURN_UINT32(u32 acpi_any_fixed_event_status_set(void)) ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_get_gpe_device(u32 gpe_index,