Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp460725iob; Wed, 11 May 2022 19:21:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1saMqxOh4VCznWgXgrdQTU+uk5JpyTKexFkbyIFNj5craXB5JCus2VCLi95yZuNP6wYKD X-Received: by 2002:aa7:d9c8:0:b0:428:364c:df2f with SMTP id v8-20020aa7d9c8000000b00428364cdf2fmr32509844eds.327.1652322072261; Wed, 11 May 2022 19:21:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652322072; cv=none; d=google.com; s=arc-20160816; b=g/nmFPUMXHhi8SzgD9CkiNPQ12OfnTu7K76rC6pupD/aAQhDvRRTRZU2bTLxhuvVu2 ykHaWx6SkPCHOrIv29KxS31meoGN9XBEYFbLd5fVffsDifJnjCerz3kJbIx7cjnu+PjN zeQzXsSLm9n4toyU8pAxYE3L+AJy/nmc36CQ1cbZAGob7xmvgNaBCl30+A0OMq8iMMxD LIpZyXlZzAXcnafC0+YOldby6kfi2ohKtwpG7/hLf8hgBpaveUVGROa+NWnlw7oPfVKT 0fncOATnk+OphGA83zBpPAbjtVcBmfTOiRJIGVKXHusIcUjetmaggRL93woYOVA1dWPO FKxw== 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=jP1IfejAYw7N1XCd9xrFM55RS2n0WFi6IiEGuNwZiwk=; b=OiP6Y071PuquS/re3DZ7XpUedOqLlSThbF9glP50TnmKPqJSQgQsxjFhAJfsIIz98i 7vFAJl+v8tZrnIntVMsReEk4xWC+IzrY+CYdmQ0Z9hEEULez/yof61y0ZYnD1w/9U2hq TwiNs8Ph3rehZQm4wIvbZJmFuNfawKHCwI9X9DbQlrmf+bgSPW0AIXoChVukGLolB5Ix XKSwdkqZ3QhvQnyJ8pVz15lNSJSjXji/QEbAUFcXCectfKuecQO2YcG7M5oT2YSu6lcv ioE2o2qGp/cCzRqb9FsPMfDczHXSrJhbEWGI6/SLrvhvHSvRe1chCZh1yeZVmp+MVihF C8IQ== 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 gb6-20020a170907960600b006e88b6bf99dsi5082966ejc.80.2022.05.11.19.20.46; Wed, 11 May 2022 19:21:12 -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 S1343995AbiEKPwD (ORCPT + 99 others); Wed, 11 May 2022 11:52:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343979AbiEKPwA (ORCPT ); Wed, 11 May 2022 11:52:00 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF87D63BF3; Wed, 11 May 2022 08:51:58 -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.0.0) id 5f9c539cb460ba1c; Wed, 11 May 2022 17:51:57 +0200 Received: from kreacher.localnet (unknown [213.134.181.161]) (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 4C20866C3E6; Wed, 11 May 2022 17:51:56 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Viresh Kumar Subject: [PATCH v1 2/3] cpufreq: Split cpufreq_offline() Date: Wed, 11 May 2022 17:50:09 +0200 Message-ID: <2258373.ElGaqSPkdT@kreacher> In-Reply-To: <5585781.DvuYhMxLoT@kreacher> References: <5585781.DvuYhMxLoT@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.181.161 X-CLIENT-HOSTNAME: 213.134.181.161 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedrgeehgdeludcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepvddufedrudefgedrudekuddrudeiudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvudefrddufeegrddukedurdduiedupdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeefpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepvhhirhgvshhhrdhkuhhmrghrsehlihhnrghrohdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=3 Fuz1=3 Fuz2=3 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 From: Rafael J. Wysocki Split the "core" part running under the policy rwsem out of cpufreq_offline() to allow the locking in cpufreq_remove_dev() to be rearranged more easily. As a side-effect this eliminates the unlock label that's not needed any more. No expected functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/cpufreq.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) Index: linux-pm/drivers/cpufreq/cpufreq.c =================================================================== --- linux-pm.orig/drivers/cpufreq/cpufreq.c +++ linux-pm/drivers/cpufreq/cpufreq.c @@ -1576,21 +1576,10 @@ static int cpufreq_add_dev(struct device return 0; } -static int cpufreq_offline(unsigned int cpu) +static void __cpufreq_offline(unsigned int cpu, struct cpufreq_policy *policy) { - struct cpufreq_policy *policy; int ret; - pr_debug("%s: unregistering CPU %u\n", __func__, cpu); - - policy = cpufreq_cpu_get_raw(cpu); - if (!policy) { - pr_debug("%s: No cpu_data found\n", __func__); - return 0; - } - - down_write(&policy->rwsem); - if (has_target()) cpufreq_stop_governor(policy); @@ -1608,7 +1597,7 @@ static int cpufreq_offline(unsigned int pr_err("%s: Failed to start governor\n", __func__); } - goto unlock; + return; } if (has_target()) @@ -1635,8 +1624,24 @@ static int cpufreq_offline(unsigned int cpufreq_driver->exit(policy); policy->freq_table = NULL; } +} + +static int cpufreq_offline(unsigned int cpu) +{ + struct cpufreq_policy *policy; + + pr_debug("%s: unregistering CPU %u\n", __func__, cpu); + + policy = cpufreq_cpu_get_raw(cpu); + if (!policy) { + pr_debug("%s: No cpu_data found\n", __func__); + return 0; + } + + down_write(&policy->rwsem); + + __cpufreq_offline(cpu, policy); -unlock: up_write(&policy->rwsem); return 0; }