From nobody Thu Oct 9 00:38:25 2025 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (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 21662253B58; Mon, 23 Jun 2025 13:34:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750685654; cv=none; b=RfHYkNFrc9mX8BCgmLxH1uLt09OqUgri5PgG67/KRAGXnP1q8TYEsFJh7BNZS7ilcVUhTHkgxjPlpR8SWUfaVHLylsmOh+JlS0lM9ff8O3xmV+39r7oY5UZhvgf6jDyALbDM29vij7KSFuXbiBDc1ysfDHra/QiLv4uob2vG8MA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750685654; c=relaxed/simple; bh=AxUz7IYwHHxE4JE7pm9jcypXdfWucVTWW86pgzSsZtw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CiPqvI9HNfnVJFUeIZG/caBB/3vpaUUBFUTdLyBMb+r/xb1yDh3VSsd4osr3ZiqroooakfSdDwAwjGOZ0SwkApZ7/Kc+hw7xBtKSWBCHr9UgjsWlhFr/lCPWTJUX9hRXzJMuOCLd3UpXarfbT2xrfvWqqKqucdpchZlqPgvERJk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4bQppQ3ZRSz10XKG; Mon, 23 Jun 2025 21:29:34 +0800 (CST) Received: from kwepemh100008.china.huawei.com (unknown [7.202.181.93]) by mail.maildlp.com (Postfix) with ESMTPS id 006641402DB; Mon, 23 Jun 2025 21:34:11 +0800 (CST) Received: from localhost.localdomain (10.50.165.33) by kwepemh100008.china.huawei.com (7.202.181.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 23 Jun 2025 21:34:10 +0800 From: Lifeng Zheng To: , , CC: , , , , , , , Subject: [PATCH 7/7] cpufreq: Exit governor when failed to start old governor Date: Mon, 23 Jun 2025 21:34:02 +0800 Message-ID: <20250623133402.3120230-8-zhenglifeng1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20250623133402.3120230-1-zhenglifeng1@huawei.com> References: <20250623133402.3120230-1-zhenglifeng1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemh100008.china.huawei.com (7.202.181.93) Content-Type: text/plain; charset="utf-8" Detect the result of starting old governor in cpufreq_set_policy(). If it fails, exit the governor and clear policy->governor. Signed-off-by: Lifeng Zheng --- drivers/cpufreq/cpufreq.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 7b82ffb50283..2b431845a8a3 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2715,10 +2715,12 @@ static int cpufreq_set_policy(struct cpufreq_policy= *policy, pr_debug("starting governor %s failed\n", policy->governor->name); if (old_gov) { policy->governor =3D old_gov; - if (cpufreq_init_governor(policy)) + if (cpufreq_init_governor(policy)) { policy->governor =3D NULL; - else - cpufreq_start_governor(policy); + } else if (cpufreq_start_governor(policy)) { + cpufreq_exit_governor(policy); + policy->governor =3D NULL; + } } =20 return ret; --=20 2.33.0