From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796325069; b=t0kjsS38wppgZozc0ZkB8dN4JwztxTYwPerGxR7p2tVRXfTdROhrp812Kb2bdlGDj2oq qPqht3kWJsF/rduc/H1mF4XX3e6+Q+GOdzd6bgH0pBiM54c7qRtuY1WWYa2gtF3xGMzBU OthyLtSiqW9vJjeyzuIohZtZ+P2ikZdp9gHphzwVoWddnsCH9yGheroSZkASbwNyysXp2 IOP0g/U9Rqt4Tr6pEQIL05kxr2RGZvRc4OCl2aIsj37959h/id6oMvUzWk1fQBeTX87Cf A82XQG6dxWErLj63M0xYYUqgfIFFumX/m/r3IvmTVtleebp5V4H/6JHh0gIa52LMdPQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796325069; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=b38q0uwC0leoUFN48QOeaBjDMspXcWplcj4NMwGl68Q=; b=m6meXt91++CBC+VFtjTvUGPU1e6biG3DfpbUOMjWZ5d+1r6WgHOdfV73rWOu1dbZsfG5 YkQ9aiVvxkIchlEiVKOLOi9EPJ/DVXewhecMTRK/LoMWYeAcelDNXJ2Tj82TVVYKuwEaI 9hTGjEXAjKfgAtXwPDeE/ZIojNM3XTBm/bfSI1IS1BYqYcZFWuAsOoDGrHwACVF5ynzmY os8O3P9yMGviSsnFnMagyrNYRQGB8axhXdOLNHq0gg4xYLzmYl69XedO2oLTKnghrsGQi GbDCMOmBCyijzcUlhC7ZfhUVCAXGch7mZHirjZSISoL1aIr7yCh9LGI4PdZlGrceWzg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fEhuErS6; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8988B60A2604 for ; Thu, 3 Dec 2026 19:11:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fEhuErS6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 484461F000C2; Thu, 3 Dec 2026 19:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796325069; bh=b38q0uwC0leoUFN48QOeaBjDMspXcWplcj4NMwGl68Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fEhuErS6frodkgr/hsx0l+o5qphdMVnLSH75cUkM27Z/GSWKixqaIVd2oVb0FFQO8 An6fnU5fYlnE1nkV5Bg62UtAuN6NGh8RSN83++Y5aOJssjbB/kZqsYq/Cvhu5yNU1l wtY4mDpw9SG1u6skwFb97NGrB3pFGjw+E4on/1YE5zmgV5Tp/D1jqLXTGqqeppV2m4 wD49r0BiVdseMYOlIT6AsJBWFrBRddJyi8uEa/m1oSA80dcysXGMCjp7n5GbKiUcAY gu9jaNbVWcEoQ6a156HBxA3Eeexh6WMVG8URIPejXhz/ChVDYUQevIs0ymJXyj1Lov sjGk4uMwEaOvA== From: Sasha Levin To: stable@vger.kernel.org Cc: "Rafael J. Wysocki" , Viresh Kumar , Mario Limonciello , Sudeep Holla , Sasha Levin Subject: [PATCH 6.12.y 1/4] cpufreq: Consolidate some code in cpufreq_online() Date: Thu, 3 Dec 2026 14:11:03 -0500 Message-ID: <20261203191049.594480-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026120246-salami-crudely-9a3f@gregkh> References: <2026120246-salami-crudely-9a3f@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Rafael J. Wysocki" [ Upstream commit 387b51709db546033cf9a940860b6614a5cda5b6 ] Notice that the policy->cpu update in cpufreq_policy_alloc() can be moved to cpufreq_online() and then it can be carried out under the policy rwsem, along with the clearing of policy->governor (unnecessary in the "new policy" code branch, but also not harmful). If this is done, the bottom parts of the "if (policy)" branches become identical and they can be collapsed and moved below the conditional. Modify the code accordingly which makes it somewhat easier to follow. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Acked-by: Viresh Kumar Reviewed-by: Mario Limonciello Acked-by: Sudeep Holla Tested-by: Sudeep Holla Link: https://patch.msgid.link/13741234.uLZWGnKmhe@rjwysocki.net Stable-dep-of: c5bdb8757372 ("cpufreq: Skip inactive policies in cpufreq_driver_target()") Signed-off-by: Sasha Levin --- drivers/cpufreq/cpufreq.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index a0b603d1e52b7..79a2bbda0d944 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1311,7 +1311,6 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) init_waitqueue_head(&policy->transition_wait); INIT_WORK(&policy->update, handle_update); - policy->cpu = cpu; return policy; err_min_qos_notifier: @@ -1399,17 +1398,18 @@ static int cpufreq_online(unsigned int cpu) /* This is the only online CPU for the policy. Start over. */ new_policy = false; - down_write(&policy->rwsem); - policy->cpu = cpu; - policy->governor = NULL; } else { new_policy = true; policy = cpufreq_policy_alloc(cpu); if (!policy) return -ENOMEM; - down_write(&policy->rwsem); } + down_write(&policy->rwsem); + + policy->cpu = cpu; + policy->governor = NULL; + if (!new_policy && cpufreq_driver->online) { /* Recover policy->cpus using related_cpus */ cpumask_copy(policy->cpus, policy->related_cpus); -- 2.53.0