Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp7298952ybc; Thu, 28 Nov 2019 14:53:12 -0800 (PST) X-Google-Smtp-Source: APXvYqwqkMiWJi/8dGqVltYQED2Y1ExV9ZvlD6N4dFY0TK4mmMKjLb2SWhHdXNbHc35gwA0pbY2X X-Received: by 2002:a17:906:2359:: with SMTP id m25mr8116181eja.22.1574981592259; Thu, 28 Nov 2019 14:53:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574981592; cv=none; d=google.com; s=arc-20160816; b=xJTn9tWZWkFRTjfTgd0nfCsmgqKPyGhK8fnC0AeXSDIm997BhYA7NiCJYcQUdgJ9Mo NuoeDoBeUTyyIRgEQy43lqwh1ky6tpPmJf49ajM044miWZ/uyLrhpk8+DwxlmIXy+7AR gZqzYZDtrEXLOnrMyukSQ2kMtT4+CyzkockB6AsOWHG9f5AKtjweglykyC560cRf3396 v8ar3OrOFaIdE2GB/EkVSz1FAob4W9T994SonAlGnY8wfVnnCFbwROu3Nv9WZ6W0DOfp lds7R5tm4vogzOtN2aXiK259Eoj+PHfL5K5pokYRrO6iwQccOdgyRrDx0umGLYq2Udii jVVA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=El/5v6fSWOM0+N83pvGb7nB1rluGvbuQssLS0zxuPmo=; b=WgfegdgwFZ6NeikVSn0MH5qfcJtkStHAq4PUqHkj0JVPPqZVyeHhxkM3/SDjwThDVv B2//R3UjezayalCZxtpqST4BvSL1qdpcS8Xk4ZrqQpHfdI/P1cqtl6LTtJya9uwkWIkT IAZPDtK5NFAEBfZ4fBNx+v3CpXJVNuqbpEKrbMIaczwhV0Xmzm1OyQTDeM8JNdzD70QN kVeFzaUKq2tWFU2s1I+edXlPIltQdWRJNRgDbqxs+r5Wj6xs7vLnOSoHdJItDJP+DpQI W3jsiAsVmTVANoNODvNZMEn6cUIg1RzEJOwEJY0OWUq8FQIgSWHzW9+Ev8Yl7W3NRM37 TV3A== ARC-Authentication-Results: i=1; mx.google.com; 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 a7si14046474edt.181.2019.11.28.14.52.48; Thu, 28 Nov 2019 14:53:12 -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; 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 S1726692AbfK1WvC (ORCPT + 99 others); Thu, 28 Nov 2019 17:51:02 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:42200 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726610AbfK1WvB (ORCPT ); Thu, 28 Nov 2019 17:51:01 -0500 Received: from 79.184.255.242.ipv4.supernova.orange.pl (79.184.255.242) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.320) id 361cf6a5a72f8264; Thu, 28 Nov 2019 23:50:59 +0100 From: "Rafael J. Wysocki" To: Linux ACPI Cc: "Kenneth R. Crudup" , Linux PM , LKML Subject: [PATCH 2/2] ACPI: PM: s2idle: Rework ACPI events synchronization Date: Thu, 28 Nov 2019 23:50:40 +0100 Message-ID: <6942598.FjHfHmHd9f@kreacher> In-Reply-To: <2787005.CsmIKtZlk9@kreacher> References: <2787005.CsmIKtZlk9@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 Note that the EC GPE processing need not be synchronized in acpi_s2idle_wake() after invoking acpi_ec_dispatch_gpe(), because that function checks the GPE status and dispatches its handler if need be and the SCI action handler is not going to run anyway at that point. Moreover, it is better to drain all of the pending ACPI events before restoring the working-state configuration of GPEs in acpi_s2idle_restore(), because those events are likely to be related to system wakeup, in which case they will not be relevant going forward. Rework the code to take these observations into account. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/sleep.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) Index: linux-pm/drivers/acpi/sleep.c =================================================================== --- linux-pm.orig/drivers/acpi/sleep.c +++ linux-pm/drivers/acpi/sleep.c @@ -977,6 +977,16 @@ static int acpi_s2idle_prepare_late(void return 0; } +static void acpi_s2idle_sync(void) +{ + /* + * The EC driver uses the system workqueue and an additional special + * one, so those need to be flushed too. + */ + acpi_ec_flush_work(); + acpi_os_wait_events_complete(); /* synchronize Notify handling */ +} + static void acpi_s2idle_wake(void) { /* @@ -1001,13 +1011,8 @@ static void acpi_s2idle_wake(void) * should be missed by canceling the wakeup here. */ pm_system_cancel_wakeup(); - /* - * The EC driver uses the system workqueue and an additional - * special one, so those need to be flushed too. - */ - acpi_os_wait_events_complete(); /* synchronize EC GPE processing */ - acpi_ec_flush_work(); - acpi_os_wait_events_complete(); /* synchronize Notify handling */ + + acpi_s2idle_sync(); rearm_wake_irq(acpi_sci_irq); } @@ -1024,6 +1029,13 @@ static void acpi_s2idle_restore_early(vo static void acpi_s2idle_restore(void) { + /* + * Drain pending events before restoring the working-state configuration + * of GPEs. + */ + acpi_os_wait_events_complete(); /* synchronize GPE processing */ + acpi_s2idle_sync(); + s2idle_wakeup = false; acpi_enable_all_runtime_gpes();