Received: by 2002:ab2:855:0:b0:1ef:b27b:cc29 with SMTP id 21csp1722399lqy; Fri, 29 Mar 2024 06:50:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVknPeggFQw/Dxwi8nTIk6My22wMMjBD5uO6m1isFpBH/vjD1WOJCjN2NAipOys/0roqP5f8AvOcru9nnLJZq8L/+Rs3y3VD49Jpr3LiA== X-Google-Smtp-Source: AGHT+IG4euEEOAsoHBGyV6hQCwAo9GZNLZMZ5JsDKREZpHAH09hdCZkPqd6k1+Q34eg4qvbD3B7+ X-Received: by 2002:a17:906:4698:b0:a4e:dff:23c4 with SMTP id a24-20020a170906469800b00a4e0dff23c4mr1836287ejr.47.1711720229571; Fri, 29 Mar 2024 06:50:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711720229; cv=pass; d=google.com; s=arc-20160816; b=jMNab8JXLMb0HvyXktFULsHKU7qRufFrKF53ik3KbtDTawOm8Zdjb/6jCI2SMjApdi x3Y1n/cIQ0ZYZOgoS5covvlIVlxVVhbdrVQ3Gc1KQFs8yZCsS334fPlW2CoKHXpTyCT/ CxVm3mJNliHepQ5KXKdQcIp7mFHTYDPYifNQcXshGky0TJN6URPJmBV0pXqucFCmdhB3 5O6S7544bHSjIiyZ+AirMv9V8riqiFTcdIBW6HGTcusOC/7jYe3kqEmQHtqSk5bYkSXp xi1/MhVVln/YExcrGGdqSej9Wu0wdYKGY0v/+MeSjN/lXWGVCD/syI8Xqa5CAwClA6bR SgPQ== 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=60gINvF8CFpxxqMj+MjqxozmhS89GujvzIH6dNUrwW0=; fh=yqyvFScLAUxSCfmRRCtR/ImIvoZBh01yAoTjk9txMyA=; b=D2saebaypLti3PTE7EWOhw3T3bdbsEtLY0oFX5QeX6QRtej3EGwrwWCj5hoXklpy3T lUhmnbLOnRN2Y5EeZnrUBdoMhE4CELluYG15mGkzuu3NCUVuCmdNkKNM78vFJdTb99SN aW+edRTTw5X3CJvTZScMh4vYYjRPEnOGFmeeJS7ztdADa9yT3No5SxHOa2nES4Q72IVE uofWUB5ZM0escWygz3+/3ocHrPpM1fAlMWSZGQiUb2wq/zzrZgc2611ayXaowNbJXYjr HWJGK32Rbk/khmKjqgA5Bmmx8k3ZJNDjGT/iqjcMw/HdebRrc88JcAhxCQQc+BRNm8FV a72A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UdYoRZtG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124783-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124783-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id mf20-20020a170906cb9400b00a4753c8b031si1760422ejb.492.2024.03.29.06.50.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 06:50:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124783-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UdYoRZtG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124783-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124783-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 595831F241CB for ; Fri, 29 Mar 2024 13:50:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60CEB187E77; Fri, 29 Mar 2024 12:42:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UdYoRZtG" 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 82194187870; Fri, 29 Mar 2024 12:42:15 +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=1711716135; cv=none; b=Iv6w6CE3guloG7CYMn7tj+NQ3mwljd2wof3+X0EuOCks9hqyscKcRakOVsecw/vNB4GXTnoso2nSMru5+A3vy6BTEySoalPDVLsIAapvOTGQWK+6b7TeRxbQVJgwSgAHmrv96I/ydL6iR3PPlYueupIw7pBdsJhH3ClSif76fns= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711716135; c=relaxed/simple; bh=6tnYUOP215gYhaLsw+XIjv4f/5EIBDD3XJwwci8tAVQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pZ6raYDQBPNFo5sOtZckOUdsAo5JKaPRakb3iI47GOiGepOtKXze8S9gSndkEHvdKOLxRrJDfnmSgrUnYzPNSwY389dhZkZLSNf9ThpAojGENLbvX2FONHBfv4gUA/Q/l/kwr1smDYBBTdcOzE833t4qKtjNfgsGi2X3AsDBzho= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UdYoRZtG; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F3CEC43394; Fri, 29 Mar 2024 12:42:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711716135; bh=6tnYUOP215gYhaLsw+XIjv4f/5EIBDD3XJwwci8tAVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UdYoRZtGWZyARY2Og416YkBhDkvp4Wobh14KbNvJ1aUN5NaY9OimtzlOh9HkBT+zz /rZWZSiGCxyoFRn6OUIqMZ99YuQ9c584AAX+71z9pIt8CbFE0sT02OSD4M0vbI/HF2 qiie3MSfRPb3ffAyHodtrLc5jR5br+LCrdLwDIuyRQh5SGVhijDlVpZzQkabJqbeJG ik589rPGBPY8fF50XAzvaoBSio+6gpQkE1t9FK4cKaJFXsuQbGsKCqK98yIkP5uVzZ m8RZHzpRFOgVuOaJpTRxY4x9NzEuXWbIrd2qLHDEj0V5EDpJPlF1WlZpAAbw3S0Xue G19CL6kBfQzEg== 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.8 73/98] cpufreq: Don't unregister cpufreq cooling on CPU hotplug Date: Fri, 29 Mar 2024 08:37:44 -0400 Message-ID: <20240329123919.3087149-73-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329123919.3087149-1-sashal@kernel.org> References: <20240329123919.3087149-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.8.2 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 44db4f59c4cc6..4133c606dacb9 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