From nobody Tue Oct 7 15:20:53 2025 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (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 C9229295511; Wed, 9 Jul 2025 10:42:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752057725; cv=none; b=LPj68RwV+VrCEX3keRzi3isb3bsXE56+Hr4RTBA6uloAyJTIqacBnnFw0qPBK8y8fiOJPUuB6xP44vk4AdYD27O3DhR2sHg51Ciu2H2Vb1npR0F+VRUcn31EOeO+kuRB37RnDzI4i5/XgkotYMfrEvwHb80yV7DlDCjVyLREQkQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752057725; c=relaxed/simple; bh=PKdQWN6KyEHuhS8ypGuhRmp7C2lM8Wdia2DqfvuAIqE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QSJDU5rDTjQkb+FZS9PD8jlbKo6tLZj06r07MAZ5NYw/QO+u7hcXON09ieBzFD+ht6PNLbR0phY0CfUp3X52wkMGJuZ3KXdZc2CAtpHUM0oVZfHonKW0z0CK5UxM2C/JHKUYGwXPDzswQ0fw+Dw1sxEteEyV5wHdogxpq+kiBsI= 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.188 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.162.254]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4bcZJN319TztSml; Wed, 9 Jul 2025 18:40:52 +0800 (CST) Received: from kwepemh100008.china.huawei.com (unknown [7.202.181.93]) by mail.maildlp.com (Postfix) with ESMTPS id E8B96180466; Wed, 9 Jul 2025 18:41:58 +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; Wed, 9 Jul 2025 18:41:58 +0800 From: Lifeng Zheng To: , , CC: , , , , , , , Subject: [PATCH v2 4/4] cpufreq: Exit governor when failed to start old governor Date: Wed, 9 Jul 2025 18:41:45 +0800 Message-ID: <20250709104145.2348017-5-zhenglifeng1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20250709104145.2348017-1-zhenglifeng1@huawei.com> References: <20250709104145.2348017-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: kwepems500001.china.huawei.com (7.221.188.70) 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 84f175a55fc5..d24ad67b3f1e 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2711,10 +2711,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