Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1024638ybb; Wed, 8 Apr 2020 14:55:10 -0700 (PDT) X-Google-Smtp-Source: APiQypJV43Q70EpMUPWKjkQ/t3rYSR/CRck08HgKOp51FK2rbBHMjPae4m66CNAllXQao+1xWYr5 X-Received: by 2002:a9d:68c5:: with SMTP id i5mr1662112oto.266.1586382909866; Wed, 08 Apr 2020 14:55:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586382909; cv=none; d=google.com; s=arc-20160816; b=A9LfC0UXW7f/DMCNJ7DAd21G3EpuYKTlcfDNVhCZ1It95whWqBQBioxqODhsgfqBls YvRpYReE7LUBQlxPgTvrXT/MByfw7cLxI4WdZX6TTMb+SPGt25xTl09kvcc9M8OjGQSD 52U5fNaCBrz00d0T23ceozlmxkJWM6A1ywGuPZLFA/jqSZfF6dnyggslClrh5aNZiJC7 i8bECVZIfdN0q51kO5gPR/Ub9VeAgej+2IFTzwa+/JUylCrwpEgiPCilK6XIDzVzZNlh BTPchxMiXbsLJaPIcjHZqNIMUrGTxaSLM9E0Rf7WpXYbGEmif6N683/hIJLbgMNaPnkf OSQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:in-reply-to :subject:cc:to:from:user-agent:references; bh=btaHeHiZRcO/Rot1joPmoYdYIbJ3YO7JUWRPMZK6Sjs=; b=JAUZNiBLZe40DYUbyHJknPhdjDG0mH6FeeXGYRX9Ps/dXEPws0p1xqc6DHVZh22fAE wuVNRc1+vTHq5XC4tVelpxmukNWzd9ZaQCQJfwA6ZNztAw9SRmt8SZgd+9IFGLKuQ2XM OO4HrlTCT+geKwwz0k0hTY+cvZ+0TtI0HeC/MGyuGb9Co6c/gPijfvIBf4ETPymVVnrk 0HdrTJx/Y5i/db3KNZ+3UPP4FkNa5pGVmrKQ6KrVafZoOXKMp63/8mzSfgz1KK2/uQdi UibUkNBfwTarQyMMNP/QhEhddbnorsKKi/RG70tUSaPyWbCGDnN8ixYEPK+6yavqTtBe RJ3w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s4si3065840oom.84.2020.04.08.14.54.57; Wed, 08 Apr 2020 14:55:09 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730658AbgDHSXU (ORCPT + 99 others); Wed, 8 Apr 2020 14:23:20 -0400 Received: from foss.arm.com ([217.140.110.172]:41994 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729672AbgDHSXU (ORCPT ); Wed, 8 Apr 2020 14:23:20 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 30FAE1FB; Wed, 8 Apr 2020 11:23:19 -0700 (PDT) Received: from e113632-lin (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3EC083F73D; Wed, 8 Apr 2020 11:23:14 -0700 (PDT) References: <20200408113505.2528103-1-jiaxun.yang@flygoat.com> <20200408113505.2528103-4-jiaxun.yang@flygoat.com> User-agent: mu4e 0.9.17; emacs 26.3 From: Valentin Schneider To: Jiaxun Yang Cc: linux-mips@vger.kernel.org, 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" , Thomas Gleixner , Jason Cooper , Marc Zyngier , Paul Burton , Allison Randal , Enrico Weigelt , Kate Stewart , Vladimir Kondratiev , Paul Cercueil , Zhou Yanjie , =?utf-8?B?5ZGo55Cw5p2wIChaaG91IFlhbmpp?= =?utf-8?B?ZSk=?= , YunQiang Su , Arnd Bergmann , Serge Semin , Matt Redfearn , Steve Winslow , Alexios Zavras , Richard Fontana , afzal mohammed , Peter Xu , Mike Rapoport , Oleksij Rempel , Kamal Dasu , linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, oprofile-list@lists.sf.net, Dietmar Eggemann Subject: Re: [PATCH 03/12] arch_topology: Make it avilable for MIPS In-reply-to: <20200408113505.2528103-4-jiaxun.yang@flygoat.com> Date: Wed, 08 Apr 2020 19:23:04 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (+ Dietmar) On 08/04/20 12:34, Jiaxun Yang wrote: > @@ -275,7 +224,64 @@ 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) && !defined(CONFIG_ARM) > +#if defined(CONFIG_COMMON_CLK) > +bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu) We actually use this for arm: arch/arm/kernel/topology.o: In function `init_cpu_topology': topology.c:(.init.text+0xc8): undefined reference to `topology_parse_cpu_capacity' So that doesn't work. TBH I'd be quite happy to see the ifdef(ARCH) go away entirely; it's shame that arm is using some of those names already. I think some of that is due to the CPU efficiency faff, if we can't get rid of it / align those then perhaps the next best thing is to make some of those definitions __weak. > +{ > + 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; > +} > +#else > +bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu) > +{ > + return false; > +} > +#endif /* CONFIG_COMMON_CLK */ > /* > * This function returns the logic cpu number of the node. > * There are basically three kinds of return values: