From patchwork Tue Jun 27 14:35:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 113445 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8247405vqr; Tue, 27 Jun 2023 07:38:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ55buQaILsSCfclNBVqtojbLO7VZX9hNady7XqfeP1vF98C6Mfnnxe1475qyWTyx84gIUfQ X-Received: by 2002:a05:6402:2816:b0:51a:41fd:9732 with SMTP id h22-20020a056402281600b0051a41fd9732mr33648275ede.11.1687876703184; Tue, 27 Jun 2023 07:38:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687876703; cv=none; d=google.com; s=arc-20160816; b=RwGyTdYFk+RoOpK2BouN7T25+LU+gAkbWRYk0YvADZVa5+dwXRWzKpaVy6h4uU+urJ RcVTRwm1wYlppyom9KkVL67LLShG55lJeZ+UT3cgn5J0gTrQwwN+St1vr8vDSd8hAouH Te0yNREo4NshYxqu5Fl64Ca9i6+vW0da358EdSgQxdu+VZMmPM7I7yvlV+/fTDVnGGhU QVNyBOBA3XkdFiXUc38TLt62NAOkYROt7sCfZja58KNRNnwHwEeIwYAtzIHcrsCVmlju Eo9khBBw1TT8EyJ6OTxSDY0amNem9Ckt1vbrhJI/3LBdySHr/W/mxI8eUfHZbPohcFiS yJhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=FJ9pEIknvBd2RRhCIbZs/d5YqavKkTA5T+7LPv1qXI4=; fh=j4X1a4OTbyRVi8sadAy6hGfsHtZEueKscdxWQdJHKv0=; b=kc6P0SGTnc4dIXVbKxbfEZY83ZVu832z23OCsaV+iwXEEzx/Zfu6IR3HrgQPTKlSE0 CH8b7N4R4kcQ6p9B12FmManXymwWHD58BN4bpsJM1fWRjFzmnnoxBPzZLrarKOFEqDqe PFntUqVPX5AsOBy7SABQw/bqGsCsa2GpUIDtXqJCQ937NM58Ll8vUk/ms1+TALWHWw/b /DgyH8+mHxlG9TITaxHGPA11Tpzv9yZ0YtkQTngIyROMRn/yvRw7ufzjXInChtHvznVU COPaEMzcGbbVHb/Q1scHDxu80GbLHi9UqJ/vMSXu0F3z6QTigE1ly1gfvEp2Si85jR5r i1AA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f18-20020a50ee92000000b0051d98bd1cb0si2455035edr.93.2023.06.27.07.37.59; Tue, 27 Jun 2023 07:38:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231495AbjF0OgH (ORCPT + 99 others); Tue, 27 Jun 2023 10:36:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231504AbjF0OgD (ORCPT ); Tue, 27 Jun 2023 10:36:03 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47DB330F1; Tue, 27 Jun 2023 07:35:55 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.2.0) id 5fa6a326169e7c8a; Tue, 27 Jun 2023 16:35:52 +0200 Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 6236F660365; Tue, 27 Jun 2023 16:35:52 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI Cc: Jeremy Compostella , LKML , Linux PM , "Rafael J. Wysocki" Subject: [PATCH v1] ACPI: EC: Fix acpi_ec_dispatch_gpe() Date: Tue, 27 Jun 2023 16:35:52 +0200 Message-ID: <12234124.O9o76ZdvQC@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedviedrtddtgdefhecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpeffffffkefgheehffelteeiveeffeevhfelteejvddvieejjeelvdeiheeuveeuffenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeehpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepjhgvrhgvmhihrdgtohhmphhoshhtvghllhgrsehinhhtvghlrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghp thhtoheprhgrfhgrvghlsehkvghrnhgvlhdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769867001653819408?= X-GMAIL-MSGID: =?utf-8?q?1769867001653819408?= From: Rafael J. Wysocki Commit 896e97bf99ec ("ACPI: EC: Clear GPE on interrupt handling only") broke suspend-to-idle at least on Dell XPS13 9360 and 9380. The problem is that acpi_ec_dispatch_gpe() must clear the EC GPE, because the EC GPE handler never runs when the system is in the suspend-to-idle state and if the EC GPE is not cleared by the suspend- to-idle loop, it is never cleared at all which leads to a GPE storm. This causes suspend-to-idle to burn energy instead of saving it which is potentially dangerous (the affected machines heat up rather badly when that happens). Addess this by making acpi_ec_dispatch_gpe() clear the EC GPE as it did before. Fixes: 896e97bf99ec ("ACPI: EC: Clear GPE on interrupt handling only") Tested-by: Rafael J. Wysocki Signed-off-by: Rafael J. Wysocki --- drivers/acpi/ec.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) Index: linux-pm/drivers/acpi/ec.c =================================================================== --- linux-pm.orig/drivers/acpi/ec.c +++ linux-pm/drivers/acpi/ec.c @@ -1267,12 +1267,8 @@ static void acpi_ec_event_handler(struct spin_unlock_irq(&ec->lock); } -static void acpi_ec_handle_interrupt(struct acpi_ec *ec) +static void clear_gpe_and_advance_transaction(struct acpi_ec *ec, bool interrupt) { - unsigned long flags; - - spin_lock_irqsave(&ec->lock, flags); - /* * Clear GPE_STS upfront to allow subsequent hardware GPE_STS 0->1 * changes to always trigger a GPE interrupt. @@ -1289,6 +1285,16 @@ static void acpi_ec_handle_interrupt(str acpi_clear_gpe(NULL, ec->gpe); advance_transaction(ec, true); +} + +static void acpi_ec_handle_interrupt(struct acpi_ec *ec) +{ + unsigned long flags; + + spin_lock_irqsave(&ec->lock, flags); + + clear_gpe_and_advance_transaction(ec, true); + spin_unlock_irqrestore(&ec->lock, flags); } @@ -2083,7 +2089,7 @@ bool acpi_ec_dispatch_gpe(void) if (acpi_ec_gpe_status_set(first_ec)) { pm_pr_dbg("ACPI EC GPE status set\n"); - advance_transaction(first_ec, false); + clear_gpe_and_advance_transaction(first_ec, false); work_in_progress = acpi_ec_work_in_progress(first_ec); }