From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20106157E69; Fri, 29 Mar 2024 12:31:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711715479; cv=none; b=ZSVjhgHxwiLTL2z1MJ65ZRKwLTPyBL6VfGbdK8DDVHNx7BCzF85i0cd2XCJ8eRVG2zFQ9C4F7xDymeueGL4P3fD6NKgL4NmksZZikVbRhXooqUDgBnTHa6uguh+yBrELrmfwi4sj2UNRO8PJ7kZZVn5G89LtWXojWGICSUQWQM4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711715479; c=relaxed/simple; bh=nReDHNhW6WLr/jmKSHD2nNWb0shuFQM76WKvSHe1xJ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cvvsLrFA8/hK77usVfL88nohW2AyTmhBCYjEB1mG7IUDYYaWHNUQ2ws6IVXyeSIYmqJsMVmTV15mHvrZL2nCDZb5NQF3SX1KZk4tL8fApGmBGonClQIaaxryBoTtrKCU+H5wIfJzSZUow7e+bf3DzgzaT6SKI7NzJjyRpleAp3s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iaJHzkXZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iaJHzkXZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D283DC43399; Fri, 29 Mar 2024 12:31:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711715478; bh=nReDHNhW6WLr/jmKSHD2nNWb0shuFQM76WKvSHe1xJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iaJHzkXZ1N3JYwA/5FK7H+xeTwHpko7nFNau68/jOvvKGV43TF+8cbRprXbajXdbt jM9LZ+NQLdXQTuF41XD9BKnNQrJC0HvG7O7rbeSaV+nX49+Ye7ERPBybqb6Sw88qzn swcrwDvU24xAi7SZndgGHG57xSp5TSLrN+nUUogcCd4nzwiPj0RX26piUcMA5+695X 0Q6+YzgaGSouxqyODZCdqE7ObbuNFbmmCZ8ruRq3DsgWh+MP1R/fe1c/cmD1JvUYEk VhAeN0wFP2/4vz5d/oN0On+OR44c0gIQAEj5BvKn64TY9UVFtVxOg1mkDaUG9tNCGV M/UK+HbrmeWfQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Viresh Kumar , Manaf Meethalavalappu Pallikunhi , Roman Stratiienko , Dhruva Gole , "Rafael J . Wysocki" , Sasha Levin , rafael@kernel.org, linux-pm@vger.kernel.org Subject: [PATCH AUTOSEL 6.6 39/52] cpufreq: Don't unregister cpufreq cooling on CPU hotplug Date: Fri, 29 Mar 2024 08:29:09 -0400 Message-ID: <20240329122956.3083859-39-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329122956.3083859-1-sashal@kernel.org> References: <20240329122956.3083859-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.23 Content-Transfer-Encoding: 8bit From: Viresh Kumar [ Upstream commit c4d61a529db788d2e52654f5b02c8d1de4952c5b ] Offlining a CPU and bringing it back online is a common operation and it happens frequently during system suspend/resume, where the non-boot CPUs are hotplugged out during suspend and brought back at resume. The cpufreq core already tries to make this path as fast as possible as the changes are only temporary in nature and full cleanup of resources isn't required in this case. For example the drivers can implement online()/offline() callbacks to avoid a lot of tear down of resources. On similar lines, there is no need to unregister the cpufreq cooling device during suspend / resume, but only while the policy is getting removed. Moreover, unregistering the cpufreq cooling device is resulting in an unwanted outcome, where the system suspend is eventually aborted in the process. Currently, during system suspend the cpufreq core unregisters the cooling device, which in turn removes a kobject using device_del() and that generates a notification to the userspace via uevent broadcast. This causes system suspend to abort in some setups. This was also earlier reported (indirectly) by Roman [1]. Maybe there is another way around to fixing that problem properly, but this change makes sense anyways. Move the registering and unregistering of the cooling device to policy creation and removal times onlyy. Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218521 Reported-by: Manaf Meethalavalappu Pallikunhi Reported-by: Roman Stratiienko Link: https://patchwork.kernel.org/project/linux-pm/patch/20220710164026.541466-1-r.stratiienko@gmail.com/ [1] Tested-by: Manaf Meethalavalappu Pallikunhi Signed-off-by: Viresh Kumar Reviewed-by: Dhruva Gole Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/cpufreq/cpufreq.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 60ed89000e82d..332b7a88ecfc4 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1571,7 +1571,8 @@ static int cpufreq_online(unsigned int cpu) if (cpufreq_driver->ready) cpufreq_driver->ready(policy); - if (cpufreq_thermal_control_enabled(cpufreq_driver)) + /* Register cpufreq cooling only for a new policy */ + if (new_policy && cpufreq_thermal_control_enabled(cpufreq_driver)) policy->cdev = of_cpufreq_cooling_register(policy); pr_debug("initialization complete\n"); @@ -1655,11 +1656,6 @@ static void __cpufreq_offline(unsigned int cpu, struct cpufreq_policy *policy) else policy->last_policy = policy->policy; - if (cpufreq_thermal_control_enabled(cpufreq_driver)) { - cpufreq_cooling_unregister(policy->cdev); - policy->cdev = NULL; - } - if (has_target()) cpufreq_exit_governor(policy); @@ -1720,6 +1716,15 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) return; } + /* + * Unregister cpufreq cooling once all the CPUs of the policy are + * removed. + */ + if (cpufreq_thermal_control_enabled(cpufreq_driver)) { + cpufreq_cooling_unregister(policy->cdev); + policy->cdev = NULL; + } + /* We did light-weight exit earlier, do full tear down now */ if (cpufreq_driver->offline) cpufreq_driver->exit(policy); -- 2.43.0