Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp49384lqz; Fri, 29 Mar 2024 08:12:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVXLgOTyxTYu8aLVL2autykhNO2n4YdTJJiJ0OZ8tNX79Cc+dtz7mfDeu310hGQ2k7nGA/4QAcess29LFAviuJeNshs0LbE1hJxyHB8rg== X-Google-Smtp-Source: AGHT+IETtClTvP7nRG/3igm63L7riMJJWdC+fBJr8poUxzRuzd9jC6sntgegkl8CAd21gjL/7pJN X-Received: by 2002:a17:902:c20b:b0:1e0:b25b:c421 with SMTP id 11-20020a170902c20b00b001e0b25bc421mr2435921pll.65.1711725133047; Fri, 29 Mar 2024 08:12:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711725133; cv=pass; d=google.com; s=arc-20160816; b=sT2MnkQ+DvYd4D7277/WJcJnWGUUiBkuW8NIeGjAUd9WXEhnT3XNX8ESEgFWM8KaRm xjOxIAeWclZ8BlaJ4oq5neUBu24f18H/+UHJTsiKbXgX4uTvLJj03j02mVQbBfGpwwCC vb8AzeiNFUafODRcIHr+pBp/+8v9WO7v/PNQKX7MGHF7WxunW6gtCYFMkHoo6CgsafAY zvuPOQWaq6/QuQ+Y++llfGY8mgjBbj0Wmd+8R2W383vo6hRRJG+Qxc2D+XzzboLmsjwt X/DhB6zei9oaiRTIQ1ZrPiJ6riZf4k7P/dGo2OY4D1V6QfPJx5B4G2UHJcEarNApakX9 Yn0g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=gJLWs107XEAPo5KSHwnY9P8/SgnGVjdtNb/2DwK4w8Y=; fh=yqyvFScLAUxSCfmRRCtR/ImIvoZBh01yAoTjk9txMyA=; b=tvjWk7i9XJ82EuYu22dsvWvkdOZVcdtKdVxVecURVU4ObfUVT8EjW3GlcHyb3oZ/Gs EwdkOOLK7gbgwFz5bhvOMLRN3+SJXnB4KQkc29zo1l/mxuoe7wB2w/H0T7LD+gvxcPbo doGZX+ocWKnR863AVKPYFwspz37LwV+mHXExXBJwKOZNIL3UKgPP8rE0TBdv+6TPXGfA nTx408j3ohBL5RRGzwczi1rO2MFdeUr5J5pPHuy4id1T5zol7EfP8WURX9yenXKGC8iG S+p6jHNL24dKjZkyiz1s2UOa4OmR2KimmR7hJoW6WGy/Qa4cwkLI4PYFW5g64frxzQ6g UzRw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B2nd6oJ2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124918-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124918-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b5-20020a170902a9c500b001e0d5b7e4d9si3613389plr.644.2024.03.29.08.12.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 08:12:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124918-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B2nd6oJ2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124918-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124918-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D2C9DB215B4 for ; Fri, 29 Mar 2024 14:26:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD7A43165F2; Fri, 29 Mar 2024 12:47:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="B2nd6oJ2" 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 D9FE83165D4; Fri, 29 Mar 2024 12:47:08 +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=1711716429; cv=none; b=r/tk2MLHotDuLCrzitLHm4Pffkn06WLGeG66XAori8PpzlYcGMZJVN4kHnYL2M2PvbwYomGyARqNqk+1gx4QJVs04CUvSyAEqL2T5BqZMvizagXCAuDNlvV5YKKEbgkak7C0Sddt4kk++WWXlCZPv1k6akv5lbtomHZ+aFHHh2o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711716429; c=relaxed/simple; bh=atto/ogA6M8ZBYdQ2P1WfmZG6v0P4C0Cd59ErmHOJ+E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M779HHUrD2y8mogsPflPpDW0gBYe0ZQ1AcwHbhdAtLWWfhwuYOYry8lRitujo+bhhJMzVgy4SgStBmkDfGoaTwlF3XI7T8VQ18tvxD3kiesBUCwDL6SYM63atlPcs1LNo6r+iTKVyKHTIMUgC08OeqbFQLAKqm4HHPZEkWLnH5w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=B2nd6oJ2; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9CEFC433B2; Fri, 29 Mar 2024 12:47:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711716428; bh=atto/ogA6M8ZBYdQ2P1WfmZG6v0P4C0Cd59ErmHOJ+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B2nd6oJ2E5pOcNvKfeqS88uT+umVj7WpAIDEzLzTYQfU+zEWbcd2h2wEJtj0x8QLr I+oVrXHna5ffPd5C52S6uITYrV/d4zm2EQj1tqEMXUovpOmaeIro/HIdHeS7An//Nc aVMUZvUpw266maLQvu6J+aqoYStMKGNk08DPChDzpyxId8zHowPRIm7UuzXO6IlBax bHycxjxaPr1X4xLTPCet0bH+gEUd+hI6WY8fTjIf4j/Sdy0QNAtJqXGuHB8LZpE5AV hqIZsuVGkeX48loTMPfajw3XKlYb6zqxlAyE/wIV38ye6Vyhu5Ych4m/kMQt873Y4t NS6kZf9hQwEkw== 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.1 34/52] cpufreq: Don't unregister cpufreq cooling on CPU hotplug Date: Fri, 29 Mar 2024 08:45:28 -0400 Message-ID: <20240329124605.3091273-34-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329124605.3091273-1-sashal@kernel.org> References: <20240329124605.3091273-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.1.83 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 c8912756fc06d..91efa23e0e8f3 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1525,7 +1525,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"); @@ -1609,11 +1610,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); @@ -1674,6 +1670,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