Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2094182ybb; Sat, 11 Apr 2020 20:28:48 -0700 (PDT) X-Google-Smtp-Source: APiQypJpFDTU6btfgYlIJjIrhS5X0Ns0bQnaCRh6NMf7XKOgdvNuSAjM8IPWm2+CiU+WQUS1ZVhr X-Received: by 2002:a05:620a:252:: with SMTP id q18mr4235401qkn.184.1586662128380; Sat, 11 Apr 2020 20:28:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586662128; cv=none; d=google.com; s=arc-20160816; b=huW0ep1AXOvp0TnB9P1GG0hY1dfhGoI2E0RSm7FB3WaIqXL0hnXEa3WbSfck3PUkxA 7+PyMDfMixYT79VjOEC5ZwUeaurOx+D+kSUsFYeSTXfkjoH9oOVnFuGm5KI6wjBo27dy +1fg9wQXvONrs6GthcVPsdlOshbrpLfm/3VBXLINiCr8PN+2dwbg2KCGGLHxpHkb5Xze 8USbj98l3Cc9pbkNVEe9NM4+dbBm1buig2yokf/bKqGekftBHjD/dlt6SOzip++ZRQny rz+Masq57XMaNb37ROePJIqjx3E2rXCd6YXXYRZtqfEfmKBeISlG/zT0UfmyQ5HUx9/f 9cPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=03RCWIMZOpvkLd76+qalpQLk0WqkvmPl7NOnhIrsfJY=; b=Gsmxh1u8GSvT5Bjdn5KJ8y86/fEvNys1WQo1PR7C9bx6ewervZ7VN6Q2dxhY/IF6Rw kIlNnknlWxT7ebR4af0bSKc81yQrIS70Zb4lybaDisH4ZyCGfMfzfRlXG+q56efaisRL 4EKdz625pv+6N83vceZ8lY5sPoN1bIT84Y0DBy3UWhHXdr+GAdTZuS4WtAMj6RamNA9G KijStevfzzSaxea1lPVzExGz38Rqx87wZ4/D/LK/v8KFPjat6z6gliWb5ofFbmBjuXGJ uci/scl/puHB0HdBOONo4Iegx/QA+QbaOjcGbin4qakzTYgLAo1HfVVMDHsxBWABP6zC AAzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@flygoat.com header.s=vultr header.b=Nq1yaboi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w17si3677750qvf.113.2020.04.11.20.28.34; Sat, 11 Apr 2020 20:28:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@flygoat.com header.s=vultr header.b=Nq1yaboi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726928AbgDLDZX (ORCPT + 99 others); Sat, 11 Apr 2020 23:25:23 -0400 Received: from vultr.net.flygoat.com ([149.28.68.211]:54658 "EHLO vultr.net.flygoat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726633AbgDLDZX (ORCPT ); Sat, 11 Apr 2020 23:25:23 -0400 Received: from localhost.localdomain (unknown [IPv6:2001:da8:20f:4430:250:56ff:fe9a:7470]) by vultr.net.flygoat.com (Postfix) with ESMTPSA id 7C0B620D14; Sun, 12 Apr 2020 03:25:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=flygoat.com; s=vultr; t=1586661923; bh=lW3H17njgy5+F3MBeH473cWUr39gwQNfiozOltaAlZo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nq1yaboi2b8euWQTuffYuLwxu9gm+0wXpG8eAUt872HD3R/G1zamY0v3SrarEoeW+ k0VHnJvkjtoHWMBTefrlzC4SRnwpI/Y0EcyNmhIaapMjN8HJt42EIJq4WmuF7naiY/ s/UBP+yxWVlQSGsamLniRPwr0vnuNKXu1VThSOSx+7vTUXdaDX9vUKK61IYiqs6ow5 n2dbaWXl9T0rWwnoT7vJTa2TIDkqQ5OG7Otu+ZUcB0myOGqO59py/0+nUZC8oTrsC2 JtirU1WhtdHYUioNWoDSOHEKYz5Pv0NYrg6FIXK6NC5f4wpMTwCKN7OyFxEPm24GGe VCx84vG7PUong== From: Jiaxun Yang To: linux-mips@vger.kernel.org Cc: dietmar.eggemann@arm.com, Jiaxun Yang , Thomas Bogendoerfer , Huacai Chen , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Florian Fainelli , Robert Richter , Sudeep Holla , Greg Kroah-Hartman , "Rafael J. Wysocki" , Daniel Lezcano , Thomas Gleixner , Jason Cooper , Marc Zyngier , Paul Burton , Allison Randal , Enrico Weigelt , Kate Stewart , Vladimir Kondratiev , Alexios Zavras , Paul Cercueil , Zhou Yanjie , =?UTF-8?q?=E5=91=A8=E7=90=B0=E6=9D=B0=20=28Zhou=20Yanjie=29?= , YunQiang Su , Arnd Bergmann , Serge Semin , Matt Redfearn , Richard Fontana , Steve Winslow , afzal mohammed , Peter Xu , Kamal Dasu , Oleksij Rempel , Mike Rapoport , linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, oprofile-list@lists.sf.net, linux-pm@vger.kernel.org Subject: [PATCH v2 03/11] arch_topology: Make it avilable for MIPS Date: Sun, 12 Apr 2020 11:20:33 +0800 Message-Id: <20200412032123.3896114-4-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.26.0.rc2 In-Reply-To: <20200412032123.3896114-1-jiaxun.yang@flygoat.com> References: <20200412032123.3896114-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Simply drop unnecessary archtecture limitions and add dummy function for platforms without OF support. As some of the functions are conflicting with Arm's platform implementations, we mark them as weak. Signed-off-by: Jiaxun Yang -- v2: Use weak instead of ifdef to exclude functions for Arm. --- drivers/base/arch_topology.c | 116 ++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 56 deletions(-) diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 4d0a0038b476..13dc4fbf043f 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -143,57 +143,6 @@ void topology_normalize_cpu_scale(void) } } -bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu) -{ - struct clk *cpu_clk; - static bool cap_parsing_failed; - int ret; - u32 cpu_capacity; - - if (cap_parsing_failed) - return false; - - ret = of_property_read_u32(cpu_node, "capacity-dmips-mhz", - &cpu_capacity); - if (!ret) { - if (!raw_capacity) { - raw_capacity = kcalloc(num_possible_cpus(), - sizeof(*raw_capacity), - GFP_KERNEL); - if (!raw_capacity) { - cap_parsing_failed = true; - return false; - } - } - raw_capacity[cpu] = cpu_capacity; - pr_debug("cpu_capacity: %pOF cpu_capacity=%u (raw)\n", - cpu_node, raw_capacity[cpu]); - - /* - * Update freq_factor for calculating early boot cpu capacities. - * For non-clk CPU DVFS mechanism, there's no way to get the - * frequency value now, assuming they are running at the same - * frequency (by keeping the initial freq_factor value). - */ - cpu_clk = of_clk_get(cpu_node, 0); - if (!PTR_ERR_OR_ZERO(cpu_clk)) { - per_cpu(freq_factor, cpu) = - clk_get_rate(cpu_clk) / 1000; - clk_put(cpu_clk); - } - } else { - if (raw_capacity) { - pr_err("cpu_capacity: missing %pOF raw capacity\n", - cpu_node); - pr_err("cpu_capacity: partial information: fallback to 1024 for all CPUs\n"); - } - cap_parsing_failed = true; - free_raw_capacity(); - } - - return !ret; -} - #ifdef CONFIG_CPU_FREQ static cpumask_var_t cpus_to_visit; static void parsing_done_workfn(struct work_struct *work); @@ -275,7 +224,58 @@ static void parsing_done_workfn(struct work_struct *work) core_initcall(free_raw_capacity); #endif -#if defined(CONFIG_ARM64) || defined(CONFIG_RISCV) +#if defined(CONFIG_OF) +bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu) +{ + struct clk *cpu_clk; + static bool cap_parsing_failed; + int ret; + u32 cpu_capacity; + + if (cap_parsing_failed) + return false; + + ret = of_property_read_u32(cpu_node, "capacity-dmips-mhz", + &cpu_capacity); + if (!ret) { + if (!raw_capacity) { + raw_capacity = kcalloc(num_possible_cpus(), + sizeof(*raw_capacity), + GFP_KERNEL); + if (!raw_capacity) { + cap_parsing_failed = true; + return false; + } + } + raw_capacity[cpu] = cpu_capacity; + pr_debug("cpu_capacity: %pOF cpu_capacity=%u (raw)\n", + cpu_node, raw_capacity[cpu]); + + /* + * Update freq_factor for calculating early boot cpu capacities. + * For non-clk CPU DVFS mechanism, there's no way to get the + * frequency value now, assuming they are running at the same + * frequency (by keeping the initial freq_factor value). + */ + cpu_clk = of_clk_get(cpu_node, 0); + if (!PTR_ERR_OR_ZERO(cpu_clk)) { + per_cpu(freq_factor, cpu) = + clk_get_rate(cpu_clk) / 1000; + clk_put(cpu_clk); + } + } else { + if (raw_capacity) { + pr_err("cpu_capacity: missing %pOF raw capacity\n", + cpu_node); + pr_err("cpu_capacity: partial information: fallback to 1024 for all CPUs\n"); + } + cap_parsing_failed = true; + free_raw_capacity(); + } + + return !ret; +} + /* * This function returns the logic cpu number of the node. * There are basically three kinds of return values: @@ -461,7 +461,12 @@ static int __init parse_dt_topology(void) of_node_put(cn); return ret; } -#endif +#else +static int __init parse_dt_topology(void) +{ + return 0; +} +#endif /* CONFIG_OF */ /* * cpu topology table @@ -562,8 +567,8 @@ __weak int __init parse_acpi_topology(void) return 0; } -#if defined(CONFIG_ARM64) || defined(CONFIG_RISCV) -void __init init_cpu_topology(void) + +__weak void __init init_cpu_topology(void) { reset_cpu_topology(); @@ -576,4 +581,3 @@ void __init init_cpu_topology(void) else if (of_have_populated_dt() && parse_dt_topology()) reset_cpu_topology(); } -#endif -- 2.26.0.rc2