Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2709395pxv; Sun, 11 Jul 2021 23:25:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwrSjfxpv5dXj/yR02CiwJ2VVUzVCfdrmm62u0kdk3RpVkgVx0JRYG4jaKIH6Rexay0chz X-Received: by 2002:aa7:d2ca:: with SMTP id k10mr18291964edr.379.1626071149250; Sun, 11 Jul 2021 23:25:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626071149; cv=none; d=google.com; s=arc-20160816; b=sgeD/5ztmg6tx287ZPBdFM41WKHSp+x68X8kTKEQvWPrT+b9AQRGw+D0T1Adho3/62 NbN8geQ5mC0rZxd4aHLb/wg4dCgNNNl92YSwploqIR9nPFLy2N+MqWOE6j4+Dzcut1Td x24y0031x3Dzl00XIlvlE8jD3cBIxLiQTgqAW9U/M0v0nbn6CM+VM2pyrSPTjB2Q8Yiv X0gEIQ4ZSlF/i4lwkXdixzaHvFXu6OQ7MekWUA2oClz9goilYo0iVEywSdOfKbqRcwOY KxjOhCsuZeR8HNyib1A3FsxwQ38GbFF3CJv2jPH6XXq+bGDZWXtY9ybOH7U/lvVv1UTI SZTA== 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=QQkDEMQqvJ9BfoiAhqRl5SvXPfxXW1CGuB3RQ22ucj4=; b=SkwjBqKWw/FXLbdOhlOhQwFuqgpE8+qkXv3/GvfHg0/Inuc58uuZqDLrxUobWLUxDv 5yFNzSQV0K582QPzVIlAPkRFqxbTfOVxvdIZcn8leBt496FjaU/N+skzPt9Bzpmb5IjB x0PGukkRkAh+R/CHYOiZp1WSxUppl5jz08DGE6nwzwcCL+NY7twm3rCkClifCp4RakBS rzrcstbdCb+NTJMaj8JpC1uA6VwjOsP2COfrsj0MnrKAz/07Zd/L4Gi3Jms+BDaof+TV oW1GfVgrfpJL8RZGneB1chRCQvG3b6zbiL96tTpxdms//9XmOckQDQzLTNulATEPIZ1T wf+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Hhu4alhd; 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 cw13si15709089ejc.195.2021.07.11.23.25.26; Sun, 11 Jul 2021 23:25:49 -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=Hhu4alhd; 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 S234652AbhGLG1N (ORCPT + 99 others); Mon, 12 Jul 2021 02:27:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:39364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235162AbhGLGYe (ORCPT ); Mon, 12 Jul 2021 02:24:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4D511611CB; Mon, 12 Jul 2021 06:21:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626070882; bh=702o+TxfHomejioSJ9Obb5zgsMMe/60vVcgmbLw42WE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hhu4alhdSABKfPHG7sXbpPuCO+MF4+3tGFd+HuZHYQF476ADOMX9n55EiRVM70yO+ X5qI1FUnv8QkAHa6DBU1DCfo5xv9560g7xuGqt9gEra469t86yjrjGlebCJ9fYN3GJ KioG77omcfsGZQws3n5HfpgH4UH2yHNA0tF6Pw2Q= 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.4 181/348] cpufreq: Make cpufreq_online() call driver->offline() on errors Date: Mon, 12 Jul 2021 08:09:25 +0200 Message-Id: <20210712060724.927674237@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060659.886176320@linuxfoundation.org> References: <20210712060659.886176320@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 194a6587a1de..c4e928375c40 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1361,9 +1361,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); @@ -1507,6 +1512,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