Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2849116pxv; Mon, 12 Jul 2021 03:29:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8zwT32egPHZVtwfoJ87YAvWhLjkwDHdREBDPke082L4tu/aOwBidGZYHMyXzchZYGC5dS X-Received: by 2002:a92:874f:: with SMTP id d15mr19970852ilm.294.1626085778273; Mon, 12 Jul 2021 03:29:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626085778; cv=none; d=google.com; s=arc-20160816; b=IoDaZLeccFa7bMNjp7xDotqhpyYgnMTLo0kyaCY/2BYuFAktn09GAFdMM3FkGo/ibZ NpTmWk7vZQYjoEf4lvmkYQiRK0wXQma688EOsusBijbGQmlFvz1uIla9nhoI6hPcxQD2 30AccDG7cXccWdKOoh7aIyaBQRLINfDTCY+Sll8yA6/ejVqQIg0sarFBtiThVHFB/reC Nsv/hciSBS1DL5Q4n4MI2MHHTGaRKmKo1rIWg7g50QNPtZaaTLjGLkMi8ExDSCunKdSH 4o6862jvi1pylhAsZDjBfsYihhZrb/VlJhjlIYVSCwBh/BC0qFGgVHPAb7/GJJ6vlRTA c9tA== 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=H2w8qmlwQu9Ls7cUSzF4c4rRfQXHKoKj1KB3I3d48Vk=; b=xygmuU91/mRWu3dKv9ldvhMjdcW1wXXzc3cImq7QXkQjWCBowwxw5Axukklu6olKrw RRmMDjkfi3l0KerjxQnWereiKfVElvjdD/3X/ocuSHE85bY9mmuZWKYeNERQ/wRocXdK FsuCTAms6KUeSdn26tTmeqW/A8d+pWpGF1kuGkzHskj/zynb7vZz4/D51Wk0dNMbJkSj audcNzLAi6saiIAOSM0AyFuOFys/ARLVovqEz0GJnGfYeaFepgWH6oStyPiDpUiXhQQl DURDm1efSWgSVR0V2yaoI4Y0bg3UT8zoPU9TurU3v1m2thrQpQ7mkko8En/FQj8AEBjo meYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=necXCugz; 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 y18si5344913iow.54.2021.07.12.03.29.26; Mon, 12 Jul 2021 03:29:38 -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=necXCugz; 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 S1349812AbhGLHor (ORCPT + 99 others); Mon, 12 Jul 2021 03:44:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:45838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245337AbhGLHLj (ORCPT ); Mon, 12 Jul 2021 03:11:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DD61D6052B; Mon, 12 Jul 2021 07:08:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626073730; bh=3AiVv/LfwI91vjTakuEn/rOtlxcUxuqn2PImj3a9zB8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=necXCugzKcBblZwbus6wNWAxnrLqqhFI1nxrYN+d8H2+SYvaPRC/x53/w5k726jo2 c9Cp1q3yicvFI/S2y/pX7wSXHXqh6G9FmgmQWzMpNpkdztQyx5I8kA9/kcD0dgTxIu czxw7kwPjIWICb8CzLmIvC7mhTgyvMSCDJ88pi/c= 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.12 339/700] cpufreq: Make cpufreq_online() call driver->offline() on errors Date: Mon, 12 Jul 2021 08:07:02 +0200 Message-Id: <20210712061012.378170982@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@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 1d1b563cea4b..1bc1293deae9 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1370,9 +1370,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); @@ -1518,6 +1523,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