Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1205716ybk; Thu, 14 May 2020 03:11:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRk3vbqKmDJlxsv1MmEQbTyxJKTKRVOhlMV4vlnS0eCCZZuqe4PdYY2VIPEQkqhDSnNLn1 X-Received: by 2002:a17:906:3418:: with SMTP id c24mr3135612ejb.365.1589451114802; Thu, 14 May 2020 03:11:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589451114; cv=none; d=google.com; s=arc-20160816; b=wjHOaLPXlW4CDac2ugPLsPhibv+i30voh+nUoEPf1k5sj4wfII+cEceKjRDDl7hHZ/ uIqB6hbWTXS4RhoZ1OC7MzyI5BJEpcPWMch9k27LhCwgHh9w+iPWlbNo4ApfPZn6f0sB 2a6XagSt4w7WlWlOgfCDTK0oV+JfjS2v/GsHLzylPhQnam21iUvUMSQnomLqxR8PWzBw nuverFnGTUpA6WYaJYbjuuWuNztfqOThs7V8EbYTqyUG+fDqIAR6fuOERV/H4DiaINns MG0he4vEihqxrHAV3J/TQdZGVCPZ0BYVhTa46uyMWKFlR+SVmZ2OnFfi4hodYNnw7g0Q +8dg== 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=peLrLuf3FZnky9oBY6x//m6imyx8gfMHe1B7IHzfsRM=; b=gzimF0C16AJE0BzB/yXOn0KLiyfxpRW5Qzujcljgwzt1iVDLVFUYgYcAs2WhaLRKjs YP39ZtocxEOSR2uIZ+xE7zLa2WBFRV3QJduLlsAe/lTDXMJHMnDiZER1k0IWmYZJuqtu 8NydFMoe0nxi9BvpdTCvQqjcrC5hP502MXCwPtWW30sz6ippcKfWJ68+lwZByDn5qfLG PwY7HOwiCDvCqdqfqudSjidIsboBJlDihT0cxXgzo3nG90ML0DaEiy/NFtpg9XE1yO8V L9ixGXYBf3pv8E18HI48JlgeWtMkzWFEvwHvKVFRUyJuL4Hrd3R2uxslvk4aYkYX/tqZ Glag== 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 qu5si1449237ejb.365.2020.05.14.03.11.30; Thu, 14 May 2020 03:11:54 -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 S1726070AbgENKKF (ORCPT + 99 others); Thu, 14 May 2020 06:10:05 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:52220 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725955AbgENKKF (ORCPT ); Thu, 14 May 2020 06:10:05 -0400 Received: from 89-64-84-17.dynamic.chello.pl (89.64.84.17) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.415) id bfcb0575ef1464d6; Thu, 14 May 2020 12:10:02 +0200 From: "Rafael J. Wysocki" To: Linux ACPI , Chris Chiu Cc: Linux PM , LKML Subject: [PATCH[RFT]] ACPI: EC: s2idle: Avoid flushing EC work when EC GPE is inactive Date: Thu, 14 May 2020 12:10:01 +0200 Message-ID: <4502272.pByIgeXik9@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 Flushing the EC work while suspended to idle when the EC GPE status is not set causes some EC wakeup events (notably power button and lid ones) to be missed after a series of spurious wakeups on the Dell XPS13 9360 in my office. If that happens, the machine cannot be woken up from suspend-to-idle by a power button press or lid status change and it needs to be woken up in some other way (eg. by a key press). Flushing the EC work only after successful dispatching the EC GPE, which means that its status has been set, avoids the issue, so change the code in question accordingly. Signed-off-by: Rafael J. Wysocki --- Hi Chris, Please check if the key press wakeup still works on your system with this patch applied (on top of https://patchwork.kernel.org/patch/11538065/). Thanks! --- drivers/acpi/ec.c | 6 +++++- drivers/acpi/sleep.c | 15 ++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) Index: linux-pm/drivers/acpi/ec.c =================================================================== --- linux-pm.orig/drivers/acpi/ec.c +++ linux-pm/drivers/acpi/ec.c @@ -2020,9 +2020,13 @@ bool acpi_ec_dispatch_gpe(void) * 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"); + /* Flush the event and query workqueues. */ + acpi_ec_flush_work(); + } + return false; } #endif /* CONFIG_PM_SLEEP */ Index: linux-pm/drivers/acpi/sleep.c =================================================================== --- linux-pm.orig/drivers/acpi/sleep.c +++ linux-pm/drivers/acpi/sleep.c @@ -980,13 +980,6 @@ static int acpi_s2idle_prepare_late(void return 0; } -static void acpi_s2idle_sync(void) -{ - /* The EC driver uses special workqueues that need to be flushed. */ - acpi_ec_flush_work(); - acpi_os_wait_events_complete(); /* synchronize Notify handling */ -} - static bool acpi_s2idle_wake(void) { if (!acpi_sci_irq_valid()) @@ -1018,7 +1011,7 @@ static bool acpi_s2idle_wake(void) return true; /* - * Cancel the wakeup and process all pending events in case + * Cancel the SCI wakeup and process all pending events in case * there are any wakeup ones in there. * * Note that if any non-EC GPEs are active at this point, the @@ -1026,8 +1019,7 @@ static bool acpi_s2idle_wake(void) * should be missed by canceling the wakeup here. */ pm_system_cancel_wakeup(); - - acpi_s2idle_sync(); + acpi_os_wait_events_complete(); /* * The SCI is in the "suspended" state now and it cannot produce @@ -1060,7 +1052,8 @@ static void acpi_s2idle_restore(void) * of GPEs. */ acpi_os_wait_events_complete(); /* synchronize GPE processing */ - acpi_s2idle_sync(); + acpi_ec_flush_work(); /* flush the EC driver's workqueues */ + acpi_os_wait_events_complete(); /* synchronize Notify handling */ s2idle_wakeup = false;