Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2827093pxv; Mon, 12 Jul 2021 02:55:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNni+yDtCMO1Cs4mlvP6Tqnc6+95i9JFwMYk0jwXRdAfZjc5OIfzQtV6q8+zFeemtWgNYI X-Received: by 2002:a05:6602:1544:: with SMTP id h4mr18569506iow.76.1626083751636; Mon, 12 Jul 2021 02:55:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626083751; cv=none; d=google.com; s=arc-20160816; b=P8XCVRjtHBkFQbi4MFJBcKS1nJbbaMg9fOiexNFlgQ89up2nTLoour0UdgBWZwvUYP gA2IBwWxM8B/oTD7vRsRYB5/z8HwUO3Hi9QEUJQhQ3fZmWwGYUpAnf9cYvrk6WzNSh2/ HTJXkiVD7zpSdgxNslpcDsYy3vnWOVubCX2QNjhCEO5H2No2N09zV6f09YdO+z0vFB2b Us+UrLKTT9SboDDExO0TC2yFLqj+YJA8dL2Erht9cFvctGjCutvx8n9Wr1Dab8FcMlWX LZ4Dmx14LISKZZ4rGKTefi2Hftg7SNXLbOX+2TJjriI4wkMIUyYauXJK+IjL/qnW5bPK 6L7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+MYmlWy2TIjFZ8B5sQwq0tenwXUDRHJJX3LNHZLi3iA=; b=RBJurpeLK7MNRvNhaTLpuR708+BPXiJnUJFfbt+yKuZom7xLRrP/U9G6ojwnXKS9nU YEdenhU8IB+F1NLOsXSpJNKKK5GQfNicuWzs7Fp08llFwO2DDOx6ekqJh+qqecBXrbK3 /6MCzfU1dVMFEF5JgWGAmlEZx6Y5hB4dsq/2ZXcPgZMl8cOZF7Fo2MI0nTjQEMR8elqu g4LlQfJC5jlglImcI+hORJhgoJa5qOyGGQlYWOYq5IKXkhT0Oqe0QQ8nVO3sh/AXdfiO +uhGF9P8sMzcD9GIvvhTEmOQoHxgjvjVpv58laaK1WveYl9ULzHm559xxms40Nsbco+r JsbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bamjTuWv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w13si16572186jar.0.2021.07.12.02.55.40; Mon, 12 Jul 2021 02:55:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bamjTuWv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239540AbhGLG6X (ORCPT + 99 others); Mon, 12 Jul 2021 02:58:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:36804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236149AbhGLGmi (ORCPT ); Mon, 12 Jul 2021 02:42:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 51668610E5; Mon, 12 Jul 2021 06:39:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071948; bh=bX0vvbNRP0Tct8NSoWZg+tEOYZPdUGxvgH5JjqQzHXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bamjTuWvONod8h6HR0DAzK11JyVACw3wc8PtnZqq1+eiksmnavkyQcAesxQroj3FR wAtPiQCPUkpOeMUZZdsVCtmW0k4BjhYZXLtT15n9UeNeAGMATokN8eBhx8fgUI8LLL iIvSIX8mppRtaJRtJ22LtbNBLcLvjnAA7p2Occpc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Rafael J. Wysocki" , Viresh Kumar , Sasha Levin Subject: [PATCH 5.10 287/593] cpufreq: Make cpufreq_online() call driver->offline() on errors Date: Mon, 12 Jul 2021 08:07:27 +0200 Message-Id: <20210712060915.890759400@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki [ Upstream commit 3b7180573c250eb6e2a7eec54ae91f27472332ea ] In the CPU removal path the ->offline() callback provided by the driver is always invoked before ->exit(), but in the cpufreq_online() error path it is not, so ->exit() is expected to somehow know the context in which it has been called and act accordingly. That is less than straightforward, so make cpufreq_online() invoke the driver's ->offline() callback, if present, on errors before ->exit() too. This only potentially affects intel_pstate. Fixes: 91a12e91dc39 ("cpufreq: Allow light-weight tear down and bring up of CPUs") Signed-off-by: Rafael J. Wysocki Acked-by: Viresh Kumar Signed-off-by: Sasha Levin --- drivers/cpufreq/cpufreq.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 1e7e3f2ff09f..ebee0ad559fa 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1368,9 +1368,14 @@ static int cpufreq_online(unsigned int cpu) goto out_free_policy; } + /* + * The initialization has succeeded and the policy is online. + * If there is a problem with its frequency table, take it + * offline and drop it. + */ ret = cpufreq_table_validate_and_sort(policy); if (ret) - goto out_exit_policy; + goto out_offline_policy; /* related_cpus should at least include policy->cpus. */ cpumask_copy(policy->related_cpus, policy->cpus); @@ -1513,6 +1518,10 @@ out_destroy_policy: up_write(&policy->rwsem); +out_offline_policy: + if (cpufreq_driver->offline) + cpufreq_driver->offline(policy); + out_exit_policy: if (cpufreq_driver->exit) cpufreq_driver->exit(policy); -- 2.30.2