From patchwork Sun Sep 29 18:19:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 13815189 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 90532CF6495 for ; Sun, 29 Sep 2024 18:21:37 +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-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=tjhrCE9cr+vE0yyMgSItpRNWvRrreI3rBxOLJ2Uo9A0=; b=sE93yUAWKawmxb9svCp3421TlW K+CdHfWmCAKPinZkNQ47zDlaInBrOAt58IJyHhncH+BCxIoSAbYB+AvN+Wcog7mJUMsFO7ooAPTdn l4Kg4Q5R7r3ThZFG4CL8XLv93x4Nt11uZwfEsz5/Xp4EgOVAttsjrw8tAwF7GbmpEsGRFXcQgZbTa y0xaXuUcsqt1ntaKPgcZy2yfkw0tQ03gsJwm23HCk5KhUFxy4YYsrVXET1/Q5jL/OjvhyZfwquBgz hSM/2lNPg0JNT+8Ee+TK/YjP4ToJGc3WI1ymkhGTZxcDTmmVo23GsgVqGv5Bj2WbItPAw/OFFsZ/x 29409nqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1suyXr-0000000FA5m-2457; Sun, 29 Sep 2024 18:21:23 +0000 Received: from leonov.paulk.fr ([185.233.101.22]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1suyWe-0000000FA1L-10Mk for linux-arm-kernel@lists.infradead.org; Sun, 29 Sep 2024 18:20:10 +0000 Received: from laika.paulk.fr (12.234.24.109.rev.sfr.net [109.24.234.12]) by leonov.paulk.fr (Postfix) with ESMTPS id E78651F0004D for ; Sun, 29 Sep 2024 18:19:50 +0000 (UTC) Received: by laika.paulk.fr (Postfix, from userid 65534) id 7CA53A6089B; Sun, 29 Sep 2024 18:19:49 +0000 (UTC) Received: from localhost.localdomain (unknown [192.168.1.64]) by laika.paulk.fr (Postfix) with ESMTP id E147EA60899; Sun, 29 Sep 2024 18:19:46 +0000 (UTC) From: Paul Kocialkowski To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Russell King , Ingo Molnar , Arnd Bergmann , Maxime Ripard , Paul Kocialkowski Subject: [PATCH] ARM: topology: Allow missing CPU clock-frequency device-tree property Date: Sun, 29 Sep 2024 20:19:36 +0200 Message-ID: <20240929181936.644910-1-paulk@sys-base.io> X-Mailer: git-send-email 2.46.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240929_112008_823323_7FB1237F X-CRM114-Status: GOOD ( 19.03 ) 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 From: Paul Kocialkowski When no capacity-dmips-mhz property is provided, the ARM topology code implements a fallback mechanism that uses the clock-frequency device-tree property as an indication of the maximum frequency achievable by the CPU. When the property is missing, the fallback mechanism gives up and prints out a nasty error message that has been haunting generations of ARMv7 Linux users. This is uncalled for since the property is optional (and now deprecated too). Allow the fallback mechanism to continue by assuming the same nominal frequency for all CPU cores, while still benefiting from the static coefficient provided by the compatible-driven table entries. This is similar to what is done in the common arch topology code when it fails to find a clock to get the frequency from. The ranging mechanism (using the middle capacity) is unaffected by the use of a unit frequency and still returns values in the requested range. Also add a comment to clarify what is going on. Signed-off-by: Paul Kocialkowski --- arch/arm/kernel/topology.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c index 2336ee2aa44a..0eb743c65166 100644 --- a/arch/arm/kernel/topology.c +++ b/arch/arm/kernel/topology.c @@ -119,13 +119,23 @@ static void __init parse_dt_topology(void) if (cpu_eff->compatible == NULL) continue; + /* + * Use the legacy clock-frequency property (representing the + * maximum achievable clock frequency) as an efficiency + * coefficient (divided by 2^20, roughly 1 MHz) to the table + * value. If no such property is available, use the table value + * directly and assume all CPUs are running at the same + * nominal frequency. + * + * It is assumed that clock-frequency is either provided for all + * CPUs or for none of them. + */ rate = of_get_property(cn, "clock-frequency", &len); - if (!rate || len != 4) { - pr_err("%pOF missing clock-frequency property\n", cn); - continue; - } - - capacity = ((be32_to_cpup(rate)) >> 20) * cpu_eff->efficiency; + if (rate && len == 4) + capacity = ((be32_to_cpup(rate)) >> 20) * + cpu_eff->efficiency; + else + capacity = cpu_eff->efficiency; /* Save min capacity of the system */ if (capacity < min_capacity)