From patchwork Thu Sep 12 07:20:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Zhan X-Patchwork-Id: 13801551 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 553A1EE6457 for ; Thu, 12 Sep 2024 07:27:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=n5ch4ibqXd88ODHWFEXDMF4j13qQoGuVQwN1WQfkQZA=; b=dmqGnCg3ckfKYFPyNEfX79wm2f IOeKfGnDaAKmk1wK5OmIy/9TsFuoR1/zqaMN2xD0bSnI6Z3JXYGf4/yjQi8nMIKXOb5wTSnNZItyL Hp5v0QFWlLGm0wbWxBtepVX/C1f4gTdH1/lsjaUYlohFihlOXxBHmoyLocZP0TSt5wxJnPspqRqUf j/ISNg4MZWokiPDkHtjQSRDcCTHcipsZm0/wzczKq5Ak+PiaNfcgiqgZQCPdAt01TnE2SVhgLuANM cAKB1FRrHu9zmAesgc+zTcn+AHtM252/hyTQ2+Ss97kEaGYEw0tPQhwVzheHAGRAVDOvLiP4yu8mW zYNskipA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1soeEM-0000000CABo-1L5C; Thu, 12 Sep 2024 07:27:06 +0000 Received: from szxga07-in.huawei.com ([45.249.212.35]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1soeDI-0000000CA4x-2utq for linux-arm-kernel@lists.infradead.org; Thu, 12 Sep 2024 07:26:02 +0000 Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4X489H3y8dz1SB9w; Thu, 12 Sep 2024 15:25:23 +0800 (CST) Received: from dggpeml500019.china.huawei.com (unknown [7.185.36.137]) by mail.maildlp.com (Postfix) with ESMTPS id 9385E1401F4; Thu, 12 Sep 2024 15:25:54 +0800 (CST) Received: from localhost.localdomain (10.90.30.45) by dggpeml500019.china.huawei.com (7.185.36.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 12 Sep 2024 15:25:54 +0800 From: Jie Zhan To: , , , , CC: , , , , , , , , , , , Subject: [PATCH v2 2/3] cppc_cpufreq: Return latest desired perf if feedback counters don't change Date: Thu, 12 Sep 2024 15:20:00 +0800 Message-ID: <20240912072001.433980-3-zhanjie9@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240912072001.433980-1-zhanjie9@hisilicon.com> References: <20240912072001.433980-1-zhanjie9@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.90.30.45] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpeml500019.china.huawei.com (7.185.36.137) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240912_002601_032660_22A36389 X-CRM114-Status: GOOD ( 10.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The existing cppc_perf_from_fbctrs() returns a cached desired perf if the delta of feedback counters is 0. Some platforms may update the real frequency back to the desired perf reg. Try getting the latest desired perf first; if failed, return the cached desired perf. Signed-off-by: Jie Zhan Reviewed-by: Zeng Heng --- drivers/cpufreq/cppc_cpufreq.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 6aa3af56924b..c8fe0f1fc22b 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -715,7 +715,8 @@ static int cppc_perf_from_fbctrs(struct cppc_cpudata *cpu_data, struct cppc_perf_fb_ctrs *fb_ctrs_t1) { u64 delta_reference, delta_delivered; - u64 reference_perf; + u64 reference_perf, desired_perf; + int cpu, ret; reference_perf = fb_ctrs_t0->reference_perf; @@ -725,8 +726,14 @@ static int cppc_perf_from_fbctrs(struct cppc_cpudata *cpu_data, fb_ctrs_t0->delivered); /* Check to avoid divide-by zero and invalid delivered_perf */ - if (!delta_reference || !delta_delivered) - return cpu_data->perf_ctrls.desired_perf; + if (!delta_reference || !delta_delivered) { + cpu = cpumask_first(cpu_data->shared_cpu_map); + ret = cppc_get_desired_perf(cpu, &desired_perf); + if (ret) + return cpu_data->perf_ctrls.desired_perf; + + return desired_perf; + } return (reference_perf * delta_delivered) / delta_reference; }