From nobody Sun Oct 5 21:48:09 2025 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 516C67082F; Wed, 30 Jul 2025 03:23:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753845800; cv=none; b=RM/5QJysnA55bM2SvLrKtMHQYOcGjFG2Tza5fi9OokTha4FCVvv2NOfH/VdtUrNQJbJtjtEcjoFWEO+R0i+M7BwCKNv5Zssg7v3wRNxlOxx6ecIQxMHW0susy8LspFPNgLPdL7QOT5vhnFQoG+K0CuXaUDMi7pJbyi6HgjSosQw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753845800; c=relaxed/simple; bh=tzCNHp0ESR+PV5haOei97I13pxR2/0b/4S413xF/154=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UoLJ6VgWKaCCPDVeZkdzhf3xTrLFX4LKOqXqD22WkuU9dUGkBMu2wdTnDOnKuUmIyUC1xtfUuWIA180DtCD1RMForitEn+eKGvlFduIiKxlHAu4tOPNkLEYQXRq9BaylyoBp2n32XEpDNPCfHeOeQvoQD5c3lHZYn85EGC5k1ew= 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.190 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.163]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4bsHVs3W9fzphCC; Wed, 30 Jul 2025 11:19:01 +0800 (CST) Received: from kwepemk500012.china.huawei.com (unknown [7.202.194.97]) by mail.maildlp.com (Postfix) with ESMTPS id A555B18005F; Wed, 30 Jul 2025 11:23:14 +0800 (CST) Received: from localhost.localdomain (10.50.165.33) by kwepemk500012.china.huawei.com (7.202.194.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 30 Jul 2025 11:23:14 +0800 From: Bowen Yu To: , CC: , , , , , , , Subject: [PATCH 2/2] cpufreq: CPPC: Fix error handling in cppc_scale_freq_workfn() Date: Wed, 30 Jul 2025 11:23:12 +0800 Message-ID: <20250730032312.167062-3-yubowen8@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20250730032312.167062-1-yubowen8@huawei.com> References: <20250730032312.167062-1-yubowen8@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: kwepems200002.china.huawei.com (7.221.188.68) To kwepemk500012.china.huawei.com (7.202.194.97) Content-Type: text/plain; charset="utf-8" From: Jie Zhan Perf counters could be 0 if the cpu is in a low-power idle state. Just try it again next time and update the frequency scale when the cpu is active and perf counters successfully return. Also, remove the FIE source on an actual failure. Signed-off-by: Jie Zhan --- drivers/cpufreq/cppc_cpufreq.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 904006027df2..e95844d3d366 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -78,12 +78,23 @@ static void cppc_scale_freq_workfn(struct kthread_work = *work) struct cppc_cpudata *cpu_data; unsigned long local_freq_scale; u64 perf; + int ret; =20 cppc_fi =3D container_of(work, struct cppc_freq_invariance, work); cpu_data =3D cppc_fi->cpu_data; =20 - if (cppc_get_perf_ctrs(cppc_fi->cpu, &fb_ctrs)) { + ret =3D cppc_get_perf_ctrs(cppc_fi->cpu, &fb_ctrs); + /* + * Perf counters could be 0 if the cpu is in a low-power idle state. + * Just try it again next time. + */ + if (ret =3D=3D -EFAULT) + return; + + if (ret) { pr_warn("%s: failed to read perf counters\n", __func__); + topology_clear_scale_freq_source(SCALE_FREQ_SOURCE_CPPC, + cpu_data->shared_cpu_map); return; } =20 --=20 2.33.0