Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2636348ybk; Mon, 18 May 2020 04:19:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtukh/E7ENxov8FlcTZK1NtnVpKsVKt3Xir1wvByJgGs1NpFm7yCo92xRUkOwidBEY6Np7 X-Received: by 2002:a50:f40e:: with SMTP id r14mr12367882edm.241.1589800755614; Mon, 18 May 2020 04:19:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589800755; cv=none; d=google.com; s=arc-20160816; b=lMNwEtoWFWk3TpKfhxUFGBvM6P9PaMTX6LGCN52g78mE9qgq8NuCWVuIE9QmFl1E13 PDawqO2C1AY9g+gddS1m0DoB+2UAUWFoP/noQwCJTfElwWyS+7Ls26YElq6K445IPO1I tzeGGAG4px3MkxYa0FHv1q5neLDfNKVTNt49C/g7h27o3794Bq1m9FojxABcSW1Mc6Xo 8WO8Jw0g4xEDWcPNFmND50yEI1gprbHv3EUpJgjbbkHTRpuZ40n5hOlPOw4WLBZSFEtD uCx2qR+fAZughCexFYXObGPjDG1Tn3nNxthpV7JJ1IXX8lZjLL3o7pIdYg5MosjvZQ93 mA9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=xIPLeWfzuIiw+O1I+1psfswOSkbFeXLFcX0dH9PjiPk=; b=ShtUatqWc4YKuBlo92t4QMqVvELi7xn5CYZlxvFTMjMUl6EcJGOhG6M1XuNhKPBJnr wX1XPdrLyFb31xh5uYyvewgsJdSWGU+xbWTdSk1X3f2JZkvvBFO2FD4bTSBKq5QuZQ8t 8q81Rlo+JNE7G764X7JNwpHAfMafCCKaF+tN5ty9Dy0pmUBPwFR5LqLv1K/E4ARAeDhj OCfWHY8dPUN/DTCWK773mW2xFOcfDavnfXlr4wyizWnx8E8pGZDx08mfQnKtA1lWIdp5 UUGMEGU6IE1z1sdv6NJjDhm93zvi+kACGrhydA9lSNvEQRfK+4ZvI4WPBtDP5Xt1Dfyk M2aw== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gw9si6068711ejb.476.2020.05.18.04.18.51; Mon, 18 May 2020 04:19:15 -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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727941AbgERLOm (ORCPT + 99 others); Mon, 18 May 2020 07:14:42 -0400 Received: from mail-oo1-f66.google.com ([209.85.161.66]:33199 "EHLO mail-oo1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727840AbgERLOg (ORCPT ); Mon, 18 May 2020 07:14:36 -0400 Received: by mail-oo1-f66.google.com with SMTP id q6so1948442oot.0; Mon, 18 May 2020 04:14:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xIPLeWfzuIiw+O1I+1psfswOSkbFeXLFcX0dH9PjiPk=; b=VKXy+kZFmQZOVGV4ja7GB9lC/o6XQ25NP4HKhhIIRpMukzO0GmDm2lBq6DOH/3RTgy JluM3WKFVRm1HpxTIgrCPDXhWFxBmXJDEIvSwIdOV2it/71ZnxyWPJuxYlBSTzSP1Mil q9p/Pjzp8oXnxSrryoJGkPEDuRLBQnRAv0ygAue/veGcKVCNdt0UfWRTyQeFEJK7AWxh CPlDYza+zNa14g5K7yLkfZaXM3dAm+sNfWhIpkCBQlh0tBQV0JjGw+dvNPvVFNXNlC0w tPwad7bwXdjJjPDsg46N/2Uq9fCJn495l0BPx3ZILD8oS0dsX32NlXzkCZg6vjDnbKgF HepA== X-Gm-Message-State: AOAM531d4L/CAUOOh6/9VWFn2iVGFSoheT8rp3tlvbZw/01RTn9wrld5 NP7JA9XJ/YQINI3haYxEuYfHahjsrju06PlbW0w= X-Received: by 2002:a4a:a286:: with SMTP id h6mr12497264ool.38.1589800474994; Mon, 18 May 2020 04:14:34 -0700 (PDT) MIME-Version: 1.0 References: <4502272.pByIgeXik9@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Mon, 18 May 2020 13:14:23 +0200 Message-ID: Subject: Re: [PATCH[RFT]] ACPI: EC: s2idle: Avoid flushing EC work when EC GPE is inactive To: Chris Chiu Cc: "Rafael J. Wysocki" , Linux ACPI , Linux PM , LKML , "Rafael J. Wysocki" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 18, 2020 at 1:11 PM Chris Chiu wrote: > > On Mon, May 18, 2020 at 4:59 PM Rafael J. Wysocki wrote: > > > > On Thu, May 14, 2020 at 12:10 PM Rafael J. Wysocki wrote: > > > > > > 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/). > > > > Hi Chris, > > > > Since I haven't heard back from you and the problem at hand is a > > regression on the machine where it happens, I'm going to push this > > patch for merging. > > > > If it causes the key press wakeup issue to reappear on your machine, > > I'm afraid that we'll need to quirk it in the EC driver. > > > > Thanks! > > Hi Rafael, > My laptop works w/o problem waking up from a keystroke with this patch > on top of https://patchwork.kernel.org/patch/11538065/). Great, thanks for the confirmation! > > > --- > > > 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; > > > > > > > > > > > >