Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6456548rwb; Mon, 5 Dec 2022 12:37:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf7koMOnkwNTRcn3x/6WFefzqudeCuvl4ybwsWq+LolGgcfSZCEjv/3BDzFc8LQAQW5ie/c5 X-Received: by 2002:a05:6a00:44cd:b0:576:d5e9:513a with SMTP id cv13-20020a056a0044cd00b00576d5e9513amr8455193pfb.62.1670272670811; Mon, 05 Dec 2022 12:37:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670272670; cv=none; d=google.com; s=arc-20160816; b=mBlYWZaqatgn/CIqwtyr9X8WP8+amteTBejErYSA9RMsJ7DYYN9fMg0TY5Gf58nJVK Jb+8vOY693lzswlEyRKcznRIHPrBmEQ5YS8pyjiCJUivtQMecLq2raDNedWK38hRrTWx AdXOduyxpAhq8NBvyFiwO91yel1M7pd1QMlpbIqxJrWPA+NE9xC8aBlEeUVLLvWcpzxP 7d5gxjvLCSnp4O4H9md0uZu+jk9USu+9P01dqtSd6oYXU7hO6SJSHuP1+Am4PaiLHz2V dW3dC68wGkM4b3WUPqoaoPv4rjU7ah4HZXlx6dYpEmsXrioFegNEc/lNXIkGe0kIn8Hf D6jQ== 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=SR6dUtA+EryeyATRFpolUd4Zcg1Lx2QKFCn3kWuye08=; b=oJWvmCRaQ1ORW7Eq5XuinttdIKzSJohIBkgoCFsC+8Gl9qXoa/tuh/Ev+bdYSi0M1H luJJQWzHNfemP0+Sc97y0Rx0C/9T2Fo5hfa7CofjSObGTIymmMgOW5ZPb1DsXfGYa1Hk kjlFMUy6h6mdhg/ZeIBjE6jcAO5k+2pcoMak9aYYORveYrzEiacD7VJBz82mYCoSY0uF 0n/myzLgUkWK5XO4djiZjNWg++0JRAC8HDjdC5jaUnMHUxIiCUye4gttHCdNLVK3RE3p WIiYCOTNb+hWfBGY3SDOOSlYPI+jshTWWeSqaeu2CJx6YDdF+SuBWaL8IAAEpd3wT/zg uW/g== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ix17-20020a170902f81100b00174b83659fasi14362403plb.502.2022.12.05.12.37.40; Mon, 05 Dec 2022 12:37:50 -0800 (PST) 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 S233425AbiLETI0 (ORCPT + 80 others); Mon, 5 Dec 2022 14:08:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232300AbiLETIR (ORCPT ); Mon, 5 Dec 2022 14:08:17 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 478B5DF36; Mon, 5 Dec 2022 11:08:16 -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.1.0) id 9a9b99851343d4ad; Mon, 5 Dec 2022 20:08:14 +0100 Received: from kreacher.localnet (unknown [213.134.188.181]) (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 01BE02801EA0; Mon, 5 Dec 2022 20:08:13 +0100 (CET) Authentication-Results: v370.home.net.pl; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: v370.home.net.pl; spf=fail smtp.mailfrom=rjwysocki.net From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Linux PM , Zhang Rui , Srinivas Pandruvada Subject: [PATCH v1 4/5] ACPI: processor: perflib: Rearrange acpi_processor_notify_smm() Date: Mon, 05 Dec 2022 20:07:08 +0100 Message-ID: <2206087.iZASKD2KPV@kreacher> In-Reply-To: <1836012.tdWV9SEqCh@kreacher> References: <1836012.tdWV9SEqCh@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.188.181 X-CLIENT-HOSTNAME: 213.134.188.181 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrudeggdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppedvudefrddufeegrddukeekrddukedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekkedrudekuddphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohephedprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehruhhirdiihhgrnhhgsehinhhtvghlrdgtohhmpdhrtghpthht ohepshhrihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomh 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 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 From: Rafael J. Wysocki Rearrange the code in acpi_processor_notify_smm() to consolidate error handling in it and improve the comments in there while at it. No expected functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/processor_perflib.c | 52 ++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 27 deletions(-) Index: linux-pm/drivers/acpi/processor_perflib.c =================================================================== --- linux-pm.orig/drivers/acpi/processor_perflib.c +++ linux-pm/drivers/acpi/processor_perflib.c @@ -453,7 +453,7 @@ int acpi_processor_pstate_control(void) int acpi_processor_notify_smm(struct module *calling_module) { static int is_done; - int result; + int result = 0; if (!acpi_processor_cpufreq_init) return -EBUSY; @@ -461,40 +461,38 @@ int acpi_processor_notify_smm(struct mod if (!try_module_get(calling_module)) return -EINVAL; - /* is_done is set to negative if an error occurred, - * and to postitive if _no_ error occurred, but SMM - * was already notified. This avoids double notification - * which might lead to unexpected results... + /* + * is_done is set to negative if an error occurs and to 1 if no error + * occurrs, but SMM has been notified already. This avoids repeated + * notification which might lead to unexpected results. */ - if (is_done > 0) { - module_put(calling_module); - return 0; - } else if (is_done < 0) { - module_put(calling_module); - return is_done; - } + if (is_done != 0) { + if (is_done < 0) + result = is_done; - is_done = -EIO; + goto out_put; + } result = acpi_processor_pstate_control(); - if (!result) { - pr_debug("No SMI port or pstate_control\n"); - module_put(calling_module); - return 0; - } - if (result < 0) { - module_put(calling_module); - return result; + if (result <= 0) { + if (!result) + pr_debug("No SMI port or pstate_control\n"); + + is_done = -EIO; + goto out_put; } - /* Success. If there's no _PPC, we need to fear nothing, so - * we can allow the cpufreq driver to be rmmod'ed. */ is_done = 1; + /* + * Success. If there _PPC, unloading the cpufreq driver would be risky, + * so disallow it in that case. + */ + if (acpi_processor_ppc_in_use) + return 0; - if (!acpi_processor_ppc_in_use) - module_put(calling_module); - - return 0; +out_put: + module_put(calling_module); + return result; } EXPORT_SYMBOL(acpi_processor_notify_smm);