Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp14125lqz; Fri, 29 Mar 2024 07:12:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWIYscRMckSMZ4j6b2yWyBEe9AP0hwfXU0D0hz2D7SOvthHSESbvTNSATPiQl24el4NIDnlR73LGnhk+WtwhtGUmNYhQ/wUv3e27GdiTQ== X-Google-Smtp-Source: AGHT+IEOgT3VQZRLyoXltLkoX5jRYU/flukk7Abtp/9aCZ4XQ1RpHMeyicIWGiQV8suMGU4vCM1R X-Received: by 2002:a05:6402:348d:b0:568:a420:7d80 with SMTP id v13-20020a056402348d00b00568a4207d80mr2086407edc.27.1711721535640; Fri, 29 Mar 2024 07:12:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711721535; cv=pass; d=google.com; s=arc-20160816; b=G08RdAsVYAmvzswtDmqEO0DjQbZkY9wikIvJ+JcCsTMs1agl6uFWpoctUv/uaqwFG/ 8hOB5BPiB7bsM9ELT7RP52wbIlP0i9F1dK9noEt2Xf31Vh7NU241t4N7YCHSWRKr3cTz V7C3MHIg1DrH9P8YzS+GPtmDVexEKtHdJGpJwJMXUjUv3EBx6CXDHfeC/gxoomuBmdoj yorTYiVWx4IdqHlQl8OS5EBDCqqYvtX7FeMZ0+YxGxMqblvyXE9fIUMQ8Ggw1tCRrk+l OZYr5dsLqy63gjwP5+NHABhM43N8fnb6zX5FXN9JtbVHpkZmPA669PT4dnRunG6HWEBU uJPg== 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=q/YDEbUCUwkQOLjJ4uA4VU+xu34IkNoQhZW0Euf7pMQ=; fh=yqyvFScLAUxSCfmRRCtR/ImIvoZBh01yAoTjk9txMyA=; b=Jtbdm0lF4vIJJWGyQw2QAHilQOmmRzaTpA601ufJOD0WgE8zjlJ9eH7KFJ/NIYySA5 xD16HcHm+qnK/ibUOf/2zkqMguF4Lwu6hhH60SzNYSAZHnat2US5ES5GO9HpkS0aXqjn jzm1xjhaJg6o1BfJctbNNxET4B6Nioh3QcMMU5Q3ihPtbkvLZvcYFW63oIItUXSPGzK0 fLGBbZOWI7ozf/KsMy885LQ6mHGX7+c7E0wn9K4R0BhxzgMNjsrz7P2LXzNQSVfLPprF cbDZylKqE4P/AUd1ULpnQ4GPNPdhEBRzzbw5tVy/SnWa1uxlYHXOIC8br5W2ICBuYGvS HpHw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cohuvwDC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124862-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124862-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ig3-20020a056402458300b0056bf2890a58si1920123edb.691.2024.03.29.07.12.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:12:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124862-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cohuvwDC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124862-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124862-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 619001F25A00 for ; Fri, 29 Mar 2024 14:12:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C674B1C8FBF; Fri, 29 Mar 2024 12:45:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cohuvwDC" 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 E5B201C8FA4; Fri, 29 Mar 2024 12:45:09 +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=1711716310; cv=none; b=DHsFGAfH4VVKifSRuDuibvVmFzprPya5gcQE/RmSLEeVxBLbX4Q/TRZv/9b93plPQy2o7fTpm4DZFVho8efjNP7u9U83Pd/g1mBDCpR5NqF4hsOU1P37BUnfjYkBHd4F/4LoEPrQOSCNUsh8QPYnqPpC/yOSyVtUxaYLcZwpOac= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711716310; c=relaxed/simple; bh=nReDHNhW6WLr/jmKSHD2nNWb0shuFQM76WKvSHe1xJ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XnBfSci4BjrXL7pWi/1SVkWWLyRV0pQKQEZp6FWngrPo+gpcOwTNjxMQSmB5CnY+Bj6lPxZpMFBE7cnuTM2R2iSGL+MtYQLkgTrYPl+HlSFnQSvQ1y1qIpYY3hgb4MA7dFGhxm/B8TPQNGUmBQtksF39u6lt9LVXAz8y1OSPa6Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cohuvwDC; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0F03C433F1; Fri, 29 Mar 2024 12:45:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711716309; bh=nReDHNhW6WLr/jmKSHD2nNWb0shuFQM76WKvSHe1xJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cohuvwDCjch8G17X/KBCEvPHdokJ7KmZCMErts1pEoXCspwNWlf65Fte5KMU2B0oF D/DmY33xbXuJlT0yIyNj2R+nnEFWnHPP6oZP43OT+TpHjUksoMl1VFccDrb3dbkfvo SR1XGnwx4L8TmF/K57CJrkiXtkpqKg80H0iieNmtNlya7HhQFRhDpgFfMX+wMVwnHX gNDMpZSk9CrDpI/QRJQl69TkyA+lBueRwQoctMcZ/F/j8M8tAoIPd0Z1RvfvO2d0DH BcyMKMDJYum/7ou1UCsqS2VDDU6KBnc1aEGljr5eKnO/kd9mOdSvjd+f/ASl0iFNwp F8aHLZUtN2/IA== 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 53/75] cpufreq: Don't unregister cpufreq cooling on CPU hotplug Date: Fri, 29 Mar 2024 08:42:34 -0400 Message-ID: <20240329124330.3089520-53-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329124330.3089520-1-sashal@kernel.org> References: <20240329124330.3089520-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