From patchwork Wed Nov 29 13:46:51 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: 171363 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp350122vqn; Wed, 29 Nov 2023 05:53:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFNXpyTBKYk3W3XoBKxsLvBx9KD0Imww62q9koCedmULQZuLf/SGPdpHcgDAZSHTj31CDaj X-Received: by 2002:a05:6871:7288:b0:1fa:1933:b4d4 with SMTP id mm8-20020a056871728800b001fa1933b4d4mr19383106oac.17.1701265981545; Wed, 29 Nov 2023 05:53:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701265981; cv=none; d=google.com; s=arc-20160816; b=pxP9N05EphS09aEb6XrPypC93nqHGdULDKcEev+4oqqT2KPx7QjtKtBqLCpiUKf649 Ygmt+nV9Ts15Bw4BV/OcgdG4KUgmSulUQmrHIGgWrE+11N+5NBUDDXkEFcNNou/2TPfu z2Ce0TXl3EuIdYlN0kEdNMUC/27irTUSJAzvKUpBLnRfhmJRAtyriKvIW5eQbnfxLQUC fKFNGj2YTOhAXNTLaIfFgoQ4NCHZGInmXdw2+sy+fxZvnlRuVJvgizmPavCSwtlRTyrJ 9CuNKKIYk02JRV/sOEaY4I0IJrDs03T1me7kyS+hpBIa6czthVWjscUbMCcZWEvkb58R 7SSg== 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=WaWEdL2MGYerhLzhcDsI8zAh22uGWknxos5OTJUydDc=; fh=Xy56yUsN7dnS9aJqFVOKrydaYiEvkn2fuPmAP6j6D88=; b=qJsAuuEyK0BieiKaVZZmNl+onxC3pS6YBmPNa68Jmf+ihQajqlbJ/lkPPb3bCw1dhl mKcqDQ3uEod6RSDqf4WcMXJEpZtud/btJb9nRCYD+T/mctsTXyzZUJ6fhvFZbOSZ10EJ Z+hoqzDjXZXqdFu8dD05C5RnZXrvFrLxDI6wyTsLgFt2mJkjpHo/LY4VsQgJJ2f6D9jX hb8AEYzKJj0Vd9xehzdL/xsEvDVQn88r3L8VV82IH6JqfIuHQLRX2+pA8ve1fP8CZt1P uN4ofyrUFheNg7ymxsPCl+Rxs3R1LuzRe0ItgdX/9ceRJRT3N7ByOiGadO3aC2DKFzRB /fZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id s3-20020a635243000000b005c1b2d93e52si11683694pgl.368.2023.11.29.05.53.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 05:53:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 615EB80ACB52; Wed, 29 Nov 2023 05:53:00 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234480AbjK2Nwu (ORCPT + 99 others); Wed, 29 Nov 2023 08:52:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234437AbjK2Nwq (ORCPT ); Wed, 29 Nov 2023 08:52:46 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C29E5E6; Wed, 29 Nov 2023 05:52:52 -0800 (PST) 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.4.0) id f46ce4111fa3dfca; Wed, 29 Nov 2023 14:52:51 +0100 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 cloudserver094114.home.pl (Postfix) with ESMTPSA id CA71B6684BD; Wed, 29 Nov 2023 14:52:50 +0100 (CET) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Zhang Rui , Srinivas Pandruvada , Michal Wilczynski , Hans de Goede , Andy Shevchenko , Mika Westerberg , Heikki Krogerus , Mario Limonciello Subject: [PATCH v1 1/4] ACPI: OSL: Rework error handling in acpi_os_execute() Date: Wed, 29 Nov 2023 14:46:51 +0100 Message-ID: <8321623.T7Z3S40VBb@kreacher> In-Reply-To: <3281896.aeNJFYEL58@kreacher> References: <3281896.aeNJFYEL58@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: gggruggvucftvghtrhhoucdtuddrgedvkedrudeihedgheehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepuddtpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgt ohhmpdhrtghpthhtohepmhhitghhrghlrdifihhltgiihihnshhkihesihhnthgvlhdrtghomhdprhgtphhtthhopehhuggvghhovgguvgesrhgvughhrghtrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=10 Fuz1=10 Fuz2=10 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 29 Nov 2023 05:53:00 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783906678270064852 X-GMAIL-MSGID: 1783906678270064852 From: Rafael J. Wysocki Reduce the number of checks and goto labels related to error handling in acpi_os_execute() and drop the status local variable, which turns out to be redundant, from it. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Reviewed-by: Andy Shevchenko --- drivers/acpi/osl.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) Index: linux-pm/drivers/acpi/osl.c =================================================================== --- linux-pm.orig/drivers/acpi/osl.c +++ linux-pm/drivers/acpi/osl.c @@ -1060,7 +1060,6 @@ int __init acpi_debugger_init(void) acpi_status acpi_os_execute(acpi_execute_type type, acpi_osd_exec_callback function, void *context) { - acpi_status status = AE_OK; struct acpi_os_dpc *dpc; struct workqueue_struct *queue; int ret; @@ -1073,9 +1072,9 @@ acpi_status acpi_os_execute(acpi_execute ret = acpi_debugger_create_thread(function, context); if (ret) { pr_err("Kernel thread creation failed\n"); - status = AE_ERROR; + return AE_ERROR; } - goto out_thread; + return AE_OK; } /* @@ -1107,12 +1106,9 @@ acpi_status acpi_os_execute(acpi_execute INIT_WORK(&dpc->work, acpi_os_execute_deferred); } else { pr_err("Unsupported os_execute type %d.\n", type); - status = AE_ERROR; + goto err; } - if (ACPI_FAILURE(status)) - goto err_workqueue; - /* * On some machines, a software-initiated SMI causes corruption unless * the SMI runs on CPU 0. An SMI can be initiated by any AML, but @@ -1123,13 +1119,14 @@ acpi_status acpi_os_execute(acpi_execute ret = queue_work_on(0, queue, &dpc->work); if (!ret) { pr_err("Unable to queue work\n"); - status = AE_ERROR; + goto err; } -err_workqueue: - if (ACPI_FAILURE(status)) - kfree(dpc); -out_thread: - return status; + + return AE_OK; + +err: + kfree(dpc); + return AE_ERROR; } EXPORT_SYMBOL(acpi_os_execute); From patchwork Wed Nov 29 13:48:22 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: 171365 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp350247vqn; Wed, 29 Nov 2023 05:53:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IFKuwItyJpZoyIpiGCdzYxyR7j1ZpG90q3srux7TjLU6Pv8KepKroBtnMzmbeM8fQaAm2SM X-Received: by 2002:a17:902:e843:b0:1cf:c404:45dd with SMTP id t3-20020a170902e84300b001cfc40445ddmr12048236plg.57.1701265992709; Wed, 29 Nov 2023 05:53:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701265992; cv=none; d=google.com; s=arc-20160816; b=oi4pniuKTPcRvXoSEFcOaE8tfX1E6kJrLWp3nLqDX872DnuEEWMHUcP4KqP8ogNS4Q IYcMyVJVK543Nl4MOmpDCiAaoKP3Rgt0//BAbTPjffiHNVdZyhrOwS314vTgyJKoNP40 0w0R2bLdLGayJ7xdlXxuWAw4l/pS80ObL6UoDF49RVmlfq7THvQTiEIyXkRATNJwPMzR sr6TcUn8rPNelTe/HWle4TaqRTDrI48/tqwqbftNxWIlaLH1f6FWVxItTguyh11+Al4a LpAsUl+8eqJQSsi/BW1eCczt0pOxzd+tghcmqov8qxj1xigpzOoxWGDdTyweG4ETC+NM 5o1A== 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=9ca4brxODmtmZzocsEeYaHJ9aFPo81Ojhfx+hC0qNAA=; fh=Xy56yUsN7dnS9aJqFVOKrydaYiEvkn2fuPmAP6j6D88=; b=uhKO5K0NzzqfpZNIWUCzjQS5clK2QQpKvsg+DsxVm8l17RqlipMZfZWK+9u3eQBoIg ltm9Y0NdhghoEiQKTePzURMyx4KVfMw6pr770l+B+rrDuL8m6GCIlkH+TzUSX0ZH1QKo VGu2IGTBNAbLG44vfg+H0Z0IUWf9mXUC/0nbnxk1JpkiGCyfs1ybMuI+ljDxhen10ppc ySx1u6H2dcTNzk2LL/J7YWbOUp8Nnc4YkCmFDOSTDaK/UaYjL5A/J7JxelVR/vt5PTbU fkquZ1STdIfxpnPhDe/kNAgcJ9Xmc+EvKW2emOOnBX9/CZs4toFvDFJwvntp4UJVWMif WdyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id n1-20020a170902968100b001d0068a4a3dsi2734053plp.410.2023.11.29.05.53.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 05:53:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 1E50681F3229; Wed, 29 Nov 2023 05:53:06 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234464AbjK2Nws (ORCPT + 99 others); Wed, 29 Nov 2023 08:52:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234426AbjK2Nwq (ORCPT ); Wed, 29 Nov 2023 08:52:46 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09E85CE; Wed, 29 Nov 2023 05:52:51 -0800 (PST) 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.4.0) id 21be0937861611c0; Wed, 29 Nov 2023 14:52:50 +0100 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 cloudserver094114.home.pl (Postfix) with ESMTPSA id 0D2A16685F3; Wed, 29 Nov 2023 14:52:50 +0100 (CET) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Zhang Rui , Srinivas Pandruvada , Michal Wilczynski , Hans de Goede , Andy Shevchenko , Mika Westerberg , Heikki Krogerus , Mario Limonciello Subject: [PATCH v1 2/4] ACPI: OSL: Rearrange workqueue selection in acpi_os_execute() Date: Wed, 29 Nov 2023 14:48:22 +0100 Message-ID: <2267180.iZASKD2KPV@kreacher> In-Reply-To: <3281896.aeNJFYEL58@kreacher> References: <3281896.aeNJFYEL58@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: gggruggvucftvghtrhhoucdtuddrgedvkedrudeihedgheehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepuddtpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgt ohhmpdhrtghpthhtohepmhhitghhrghlrdifihhltgiihihnshhkihesihhnthgvlhdrtghomhdprhgtphhtthhopehhuggvghhovgguvgesrhgvughhrghtrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=10 Fuz1=10 Fuz2=10 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 29 Nov 2023 05:53:06 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783906689105228816 X-GMAIL-MSGID: 1783906689105228816 From: Rafael J. Wysocki Replace the 3-branch if () statement used for selecting the target workqueue in acpi_os_execute() with a switch () one that is more suitable for this purpose and carry out the work item initialization before it to avoid code duplication. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Reviewed-by: Andy Shevchenko --- drivers/acpi/osl.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) Index: linux-pm/drivers/acpi/osl.c =================================================================== --- linux-pm.orig/drivers/acpi/osl.c +++ linux-pm/drivers/acpi/osl.c @@ -1092,19 +1092,21 @@ acpi_status acpi_os_execute(acpi_execute dpc->function = function; dpc->context = context; + INIT_WORK(&dpc->work, acpi_os_execute_deferred); /* * To prevent lockdep from complaining unnecessarily, make sure that * there is a different static lockdep key for each workqueue by using * INIT_WORK() for each of them separately. */ - if (type == OSL_NOTIFY_HANDLER) { + switch (type) { + case OSL_NOTIFY_HANDLER: queue = kacpi_notify_wq; - INIT_WORK(&dpc->work, acpi_os_execute_deferred); - } else if (type == OSL_GPE_HANDLER) { + break; + case OSL_GPE_HANDLER: queue = kacpid_wq; - INIT_WORK(&dpc->work, acpi_os_execute_deferred); - } else { + break; + default: pr_err("Unsupported os_execute type %d.\n", type); goto err; } From patchwork Wed Nov 29 13:50:54 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: 171364 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp350126vqn; Wed, 29 Nov 2023 05:53:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHljArLz3+cFXrEYWUkqen2u+iBCfofIXkkairCWCGB3C7KRQB/Yhgfs/5JdlhgvAGwz9Tb X-Received: by 2002:a05:6a20:42a0:b0:188:973c:ef84 with SMTP id o32-20020a056a2042a000b00188973cef84mr19577387pzj.9.1701265981742; Wed, 29 Nov 2023 05:53:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701265981; cv=none; d=google.com; s=arc-20160816; b=dD4FSjXxbxcjdBwkOuAPBukFtixDF8W3n3xr8h1tTbCXJ00QcJZc25OXKLbK+UKTzy bwLj7emwI/NKaFRlS+xiCleNC4sShHJcp+qhWYqETTwjwyD9iZ1rmlGEzVeiGCSY1ozX OUztQbwI3PsT/WnqJ3Lm4D1noZiGHbcrRaWwdWDOl9m5Ik5v9KfqGcCU730WGusC/EHk uAiNPIRnZsNufdZolXrFwU56GJV18mKmyJsQ9BxIBm72Ef83v4oWCh4RUW1GIJoM94hl Z9L7X7Oy7A0wvWXMxDzBV03wRx+S9deQmsa+Kz+s77EMSI1siFdLTlYUCfIBFU0qijIk xe0w== 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=Sv6MG33KOz/kcwGRqd5TfV2WfLajmI6LcE+aPcWpjH8=; fh=Xy56yUsN7dnS9aJqFVOKrydaYiEvkn2fuPmAP6j6D88=; b=B1scLgEqfzhaojSf3nc/cqVCTLHly1+6QQHNgqsquX5M0GnFHROzilM65lH5ZUibVk OaUZYRo0gRdx6ZgFfbc7dl2P1T74CspfzPb1s4ZLAhGIpGoOrbStiSXSCXaWUH3TC4wz DIBH7g7TtkGH7HAq6J3AxVmJQR868K/OXg42hDbB/nykYEOaUqD/f1ASzDAu2ySrgA7c 4GC9K06WAEhq2eRwRvBjGT3U80D+lY4FqwIBpQm1UEWESq9z0BmQSiUZ/Le+LDim/eh4 yuKtDgpp6V+T2DLjgkyEnimXZOcwiaj2xRYmxlXYITcfToy7HYD8fTBL0nYocGjxaLBC MI3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id io15-20020a17090312cf00b001b9f55d28a2si3386717plb.205.2023.11.29.05.53.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 05:53:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 4117680AD944; Wed, 29 Nov 2023 05:52:56 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234435AbjK2Nwq (ORCPT + 99 others); Wed, 29 Nov 2023 08:52:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234273AbjK2Nwp (ORCPT ); Wed, 29 Nov 2023 08:52:45 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55D88DE; Wed, 29 Nov 2023 05:52:51 -0800 (PST) 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.4.0) id eddb0e37afb314de; Wed, 29 Nov 2023 14:52:49 +0100 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 cloudserver094114.home.pl (Postfix) with ESMTPSA id 4DBF06684BD; Wed, 29 Nov 2023 14:52:49 +0100 (CET) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Zhang Rui , Srinivas Pandruvada , Michal Wilczynski , Hans de Goede , Andy Shevchenko , Mika Westerberg , Heikki Krogerus , Mario Limonciello Subject: [PATCH v1 3/4] ACPI: OSL: Allow Notify () handlers to run on all CPUs Date: Wed, 29 Nov 2023 14:50:54 +0100 Message-ID: <7617703.EvYhyI6sBW@kreacher> In-Reply-To: <3281896.aeNJFYEL58@kreacher> References: <3281896.aeNJFYEL58@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: gggruggvucftvghtrhhoucdtuddrgedvkedrudeihedgheehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepuddtpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgt ohhmpdhrtghpthhtohepmhhitghhrghlrdifihhltgiihihnshhkihesihhnthgvlhdrtghomhdprhgtphhtthhopehhuggvghhovgguvgesrhgvughhrghtrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=10 Fuz1=10 Fuz2=10 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 29 Nov 2023 05:52:56 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783906678281042206 X-GMAIL-MSGID: 1783906678281042206 From: Rafael J. Wysocki Notify () handlers, like GPE handlers, are only allowed to run on CPU0 now out of the concern that they might trigger an SMM trap and that (in some cases) the SMM code running as a result of that might corrupt memory if not run on CPU0. However, Notify () handlers are registered by kernel code and they are not likely to evaluate AML that would trigger an SMM trap. In fact, many of them don't even evaluate any AML at all and even if they do, that AML may as well be evaluated in other code paths. In other words, they are not special from the AML evaluation perspective, so there is no real reason to treat them in any special way. Accordingly, allow Notify () handlers, unlike GPE handlers, to be executed by all CPUs in the system. Also adjust the allocation of the "notify" workqueue to allow multiple handlers to be executed at the same time, because they need not be serialized. Signed-off-by: Rafael J. Wysocki Reviewed-by: Andy Shevchenko --- drivers/acpi/osl.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) Index: linux-pm/drivers/acpi/osl.c =================================================================== --- linux-pm.orig/drivers/acpi/osl.c +++ linux-pm/drivers/acpi/osl.c @@ -1061,7 +1061,6 @@ acpi_status acpi_os_execute(acpi_execute acpi_osd_exec_callback function, void *context) { struct acpi_os_dpc *dpc; - struct workqueue_struct *queue; int ret; ACPI_DEBUG_PRINT((ACPI_DB_EXEC, @@ -1101,24 +1100,22 @@ acpi_status acpi_os_execute(acpi_execute */ switch (type) { case OSL_NOTIFY_HANDLER: - queue = kacpi_notify_wq; + ret = queue_work(kacpi_notify_wq, &dpc->work); break; case OSL_GPE_HANDLER: - queue = kacpid_wq; + /* + * On some machines, a software-initiated SMI causes corruption + * unless the SMI runs on CPU 0. An SMI can be initiated by + * any AML, but typically it's done in GPE-related methods that + * are run via workqueues, so we can avoid the known corruption + * cases by always queueing on CPU 0. + */ + ret = queue_work_on(0, kacpid_wq, &dpc->work); break; default: pr_err("Unsupported os_execute type %d.\n", type); goto err; } - - /* - * On some machines, a software-initiated SMI causes corruption unless - * the SMI runs on CPU 0. An SMI can be initiated by any AML, but - * typically it's done in GPE-related methods that are run via - * workqueues, so we can avoid the known corruption cases by always - * queueing on CPU 0. - */ - ret = queue_work_on(0, queue, &dpc->work); if (!ret) { pr_err("Unable to queue work\n"); goto err; @@ -1668,7 +1665,7 @@ acpi_status __init acpi_os_initialize(vo acpi_status __init acpi_os_initialize1(void) { kacpid_wq = alloc_workqueue("kacpid", 0, 1); - kacpi_notify_wq = alloc_workqueue("kacpi_notify", 0, 1); + kacpi_notify_wq = alloc_workqueue("kacpi_notify", 0, 0); kacpi_hotplug_wq = alloc_ordered_workqueue("kacpi_hotplug", 0); BUG_ON(!kacpid_wq); BUG_ON(!kacpi_notify_wq); From patchwork Wed Nov 29 13:52:22 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: 171362 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp350107vqn; Wed, 29 Nov 2023 05:53:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IEykrWin7KFqykB7ljMRxFcNYL30qj9AKRjAmS0lHfG57Ryk4tSloaApVn0JTInoDEfAj8Q X-Received: by 2002:a05:6a21:78a3:b0:18c:3ea9:b85d with SMTP id bf35-20020a056a2178a300b0018c3ea9b85dmr20098354pzc.11.1701265980509; Wed, 29 Nov 2023 05:53:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701265980; cv=none; d=google.com; s=arc-20160816; b=CBnISP+8RYtAJWpbh4UVCoMUurRPaUR+hZM47JD8jqhhxqhctV1Zp1mtP59SmAgDAA o+9KJqEIVJMclHUv5AGwQoIirFlGXJvEhDxagXi/6Yj33i1vN0VDxgJ9UsS/of8NDcd9 TJ/ES/zcUEAxHF9In0lJLNMW5ABwDW3dCX0YqD3g6i/Yuxtn3Fey2McUCdxydtZ5XLbJ g7vIZsXiS8OXUciypYUCfAxTLH32M/L0zKUGof5Y45rZcZ+30S0vg6stkAeycfjViTs5 uf17rkSDonYpF5tK9uuDICcBMsR8T0zwahqJyOLZF7zrx+rwjTEUEMnoZY22vlc0C4mR xaUw== 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=UERtOHEfB+wcRXPR63aJC4ZE5tHu6aBvT4BEe2asFMo=; fh=Xy56yUsN7dnS9aJqFVOKrydaYiEvkn2fuPmAP6j6D88=; b=gSof+IgXBZuO/W8xSdeQBIknrQVVai/syNtKwHLj1VubvdFyCzO7LucsvIOoHp8wXk u2fhJmh8F2UtRw0YBd942G+gVUVwMB5ivYK8XyRuWom5JWVi/L8NPgk7hOE6FI9LvnmD dO7bbEIn0azDQYlFL1cS1lp0U6ZHgBcWRGP7MZOuv1JKwRKOOPDnA15avEIzGRhdwtzz QehehLLlG/9KpWEyzfvHlaR4FI20j5268PDQRVh2eEVlBUD1GuBvguvM9a2I4y5coFt0 sS8QENQLrVQXJlJQfb7Irhk0ruuk6BFtwqjGVq33/IvOx7ivEuJdPBIdfNwjOeuLXAJt uKpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id p9-20020a63c149000000b005be0ca9ca31si13967583pgi.294.2023.11.29.05.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 05:53:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E094780AEFB0; Wed, 29 Nov 2023 05:52:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234115AbjK2Nwp (ORCPT + 99 others); Wed, 29 Nov 2023 08:52:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233724AbjK2Nwo (ORCPT ); Wed, 29 Nov 2023 08:52:44 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A5D7DD; Wed, 29 Nov 2023 05:52:50 -0800 (PST) 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.4.0) id a0bed9a11a4d3cbd; Wed, 29 Nov 2023 14:52:49 +0100 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 cloudserver094114.home.pl (Postfix) with ESMTPSA id 714456684BD; Wed, 29 Nov 2023 14:52:48 +0100 (CET) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Zhang Rui , Srinivas Pandruvada , Michal Wilczynski , Hans de Goede , Andy Shevchenko , Mika Westerberg , Heikki Krogerus , Mario Limonciello Subject: [PATCH v1 4/4] ACPI: OSL: Use GFP_KERNEL for work item allocations Date: Wed, 29 Nov 2023 14:52:22 +0100 Message-ID: <3552364.iIbC2pHGDl@kreacher> In-Reply-To: <3281896.aeNJFYEL58@kreacher> References: <3281896.aeNJFYEL58@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: gggruggvucftvghtrhhoucdtuddrgedvkedrudeihedgheehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepuddtpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgt ohhmpdhrtghpthhtohepmhhitghhrghlrdifihhltgiihihnshhkihesihhnthgvlhdrtghomhdprhgtphhtthhopehhuggvghhovgguvgesrhgvughhrghtrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=10 Fuz1=10 Fuz2=10 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 29 Nov 2023 05:52:54 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783906677121885406 X-GMAIL-MSGID: 1783906677121885406 From: Rafael J. Wysocki After the recent modification changing the ACPI SCI interrupt handler into a threaded one, the SCI interrupt handler code does not run in interrupt context any more and acpi_os_execute(), that may be invoked by it, need not use GFP_ATOMIC for allocating work items. Make it use GFP_KERNEL instead. Signed-off-by: Rafael J. Wysocki Reviewed-by: Andy Shevchenko --- drivers/acpi/osl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) Index: linux-pm/drivers/acpi/osl.c =================================================================== --- linux-pm.orig/drivers/acpi/osl.c +++ linux-pm/drivers/acpi/osl.c @@ -1084,8 +1084,7 @@ acpi_status acpi_os_execute(acpi_execute * parameters we can't use the approach some kernel code uses of * having a static work_struct. */ - - dpc = kzalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC); + dpc = kzalloc(sizeof(struct acpi_os_dpc), GFP_KERNEL); if (!dpc) return AE_NO_MEMORY;