Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3563693pxb; Fri, 4 Feb 2022 11:09:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmnQksewuZIltnqZp66BDGg0KXfoSZlzRReFnFmR2D6LH6VjWKI/DcRX84QG3NVSlvntbj X-Received: by 2002:a05:6a00:2490:: with SMTP id c16mr4429247pfv.67.1644001784057; Fri, 04 Feb 2022 11:09:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644001784; cv=none; d=google.com; s=arc-20160816; b=Q41HUaEOGri/dkXhp+JCKqj2VMEdgmzwRP2O0cl6QCTcKEaGY/ndRpi2Re0qNf63lt PIJADAnQ1XHnHJjUKmJSrRAa0CJGQLHN4WtAdtopVdOs0xIzijAIWtmh9R9g6waMHupn IYy66PtZ922jgrcdLLHPTrzoPafQXiXIjDbRCHisrnFERuypapcCAaUJD9HscWSQOIGh /lUa5TzxynFwqoQIIZU8CzksS0Ar+ax02Dbfz+yL7IPu2hrl80b3/RMLGVTjkFn12Rne Rn5k/nvRBXEAXphral5RnAKAbUrzvZE6IBFs0GoUCbJRTaVWMgkxZDGZcGEZa3MQHiZ2 ScOA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=6cBVJ0W//3XwTdJreYVRbaWZx3T/5i2MzR/DWwC7KKk=; b=xKXAhjj701HjHc9Lcf/p//uZ0CLt3HGAu0bBd2u4oj12y5UuaxBP13NlEUNsX049hg pn2lhdFHEEoNe2YIV4Ev3VrdQXfxGxjx7o/KLl8DtJS8Ajfowf0h8PdD52ZluGcSu3+S RyW4d8nh29KWjShcMZDkOyS9jOoGq0a1QCzhwwqp4EkbhiFgZ6eonG79c4sazfZoh/cj yVHa5nr6mbHZFPeB2HjnzaHk6pxUfu/J9vcQ/AbCpnw9kqkXlSjkdWrZ+ST7vnsUSJyP GJDNeXz9+ky8odkwpTqG0TeDiRs8+FziPH8fO1MrW5ghvSJSUE3OZv9VNRHbMGIhwvbb inhQ== 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 w191si3042956pgd.109.2022.02.04.11.09.33; Fri, 04 Feb 2022 11:09:44 -0800 (PST) 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 S1377028AbiBDRn0 (ORCPT + 99 others); Fri, 4 Feb 2022 12:43:26 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:42722 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231896AbiBDRn0 (ORCPT ); Fri, 4 Feb 2022 12:43:26 -0500 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 4.0.0) id 2871c7bdf1ff5afe; Fri, 4 Feb 2022 18:43:24 +0100 Received: from kreacher.localnet (unknown [213.134.181.137]) (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 4897866B456; Fri, 4 Feb 2022 18:43:24 +0100 (CET) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML Subject: [PATCH v1 3/3] ACPI: EC: Rearrange code in acpi_ec_submit_event() Date: Fri, 04 Feb 2022 18:43:14 +0100 Message-ID: <7351357.EvYhyI6sBW@kreacher> In-Reply-To: <12956939.uLZWGnKmhe@kreacher> References: <12956939.uLZWGnKmhe@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.181.137 X-CLIENT-HOSTNAME: 213.134.181.137 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvvddrgeelgddutdefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvjeelgffhiedukedtleekkedvudfggefhgfegjefgueekjeelvefggfdvledutdenucfkphepvddufedrudefgedrudekuddrudefjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvudefrddufeegrddukedurddufeejpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopedvpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhg X-DCC--Metrics: v370.home.net.pl 1024; Body=2 Fuz1=2 Fuz2=2 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki Rearange acpi_ec_event_handler() so as to avoid releasing ec->lock and acquiring it again right away in the case when ec_event_clearing is not ACPI_EC_EVT_TIMING_EVENT. This also reduces the number of checks done by acpi_ec_event_handler() in that case. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/ec.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) Index: linux-pm/drivers/acpi/ec.c =================================================================== --- linux-pm.orig/drivers/acpi/ec.c +++ linux-pm/drivers/acpi/ec.c @@ -1238,6 +1238,7 @@ static void acpi_ec_event_handler(struct acpi_ec_submit_query(ec); spin_lock_irq(&ec->lock); + ec->events_to_process--; } @@ -1246,27 +1247,30 @@ static void acpi_ec_event_handler(struct * event handling work again regardless of whether or not the query * queued up above is processed successfully. */ - if (ec_event_clearing == ACPI_EC_EVT_TIMING_EVENT) + if (ec_event_clearing == ACPI_EC_EVT_TIMING_EVENT) { + bool guard_timeout; + acpi_ec_complete_event(ec); - else - acpi_ec_close_event(ec); - spin_unlock_irq(&ec->lock); + ec_dbg_evt("Event stopped"); - ec_dbg_evt("Event stopped"); + spin_unlock_irq(&ec->lock); + + guard_timeout = !!ec_guard(ec); - if (ec_event_clearing == ACPI_EC_EVT_TIMING_EVENT && ec_guard(ec)) { spin_lock_irq(&ec->lock); /* Take care of SCI_EVT unless someone else is doing that. */ - if (!ec->curr) + if (guard_timeout && !ec->curr) advance_transaction(ec, false); + } else { + acpi_ec_close_event(ec); - spin_unlock_irq(&ec->lock); + ec_dbg_evt("Event stopped"); } - spin_lock_irq(&ec->lock); ec->events_in_progress--; + spin_unlock_irq(&ec->lock); }