From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F4078C433ED for ; Mon, 12 Apr 2021 12:40:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC09F61027 for ; Mon, 12 Apr 2021 12:40:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241178AbhDLMks (ORCPT ); Mon, 12 Apr 2021 08:40:48 -0400 Received: from foss.arm.com ([217.140.110.172]:49574 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238587AbhDLMkl (ORCPT ); Mon, 12 Apr 2021 08:40:41 -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 9587C31B; Mon, 12 Apr 2021 05:40:23 -0700 (PDT) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 52F0A3F793; Mon, 12 Apr 2021 05:40:21 -0700 (PDT) Subject: Re: [PATCH 1/1] arm: topology: parse the topology from the dt To: Ruifeng Zhang , Valentin Schneider Cc: linux@armlinux.org.uk, sudeep.holla@arm.com, Greg KH , "Rafael J. Wysocki" , a.p.zijlstra@chello.nl, mingo@kernel.org, ruifeng.zhang1@unisoc.com, nianfu.bai@unisoc.com, linux-arm-kernel@lists.infradead.org, Linux Kernel Mailing List References: <20210412070819.23493-1-ruifeng.zhang0110@gmail.com> <87y2dnn3gw.mognet@arm.com> From: Dietmar Eggemann Message-ID: <121d5639-b827-937f-1cf0-e6c256e306db@arm.com> Date: Mon, 12 Apr 2021 14:40:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/04/2021 14:20, Ruifeng Zhang wrote: > Valentin Schneider 于2021年4月12日周一 下午7:32写道: >> >> >> Hi, >> >> On 12/04/21 15:08, Ruifeng Zhang wrote: >>> From: Ruifeng Zhang >>> >>> The arm topology still parse from the MPIDR, but it is incomplete. When >>> the armv8.3 cpu runs in aarch32 mode, it will parse out the wrong topology. >>> >>> armv7 (A7) mpidr is: >>> [11:8] [7:2] [1:0] >>> cluster reserved cpu >>> >>> armv8.3 (A55) mpidr is: >>> [23:16] [15:8] [7:0] >>> cluster cpu thread >>> >>> For compatibility to keep the function of get capacity from default >>> cputype, renamed arm parse_dt_topology to get_cputype_capacity and delete >>> related logic of parse from dt. >>> Arm using the same parse_dt_topology function as arm64. >>> >>> The arm device boot step is to look for the default cputype and get cpu >>> capacity firstly. Then parse the topology and capacity from dt to replace >>> default values. >>> >> >> I'm afraid I don't get it. >> >> CONFIG_COMPAT lets you run 32-bit stuff at EL0, but the kernel is still >> arm64. So if you take your armv8.3 system, the topology parsed by the >> kernel will be the same regardless of CONFIG_COMPAT. >> >> Could you elaborate on what problem you are trying to fix here? > > There is a armv8.3 cpu which should work normally both on aarch64 and aarch32. > The MPIDR has been written to the chip register in armv8.3 format. > For example, > core0: 0000000080000000 > core1: 0000000080000100 > core2: 0000000080000200 > ... > > Its cpu topology can be parsed normally on aarch64 mode (both > userspace and kernel work on arm64). > > The problem is when it working on aarch32 mode (both userspace and > kernel work on arm 32-bit), the cpu topology > will parse error because of the format is different between armv7 and armv8.3. > The arm 32-bit driver, arch/arm/kernel/topology will parse the MPIDR > and store to the topology with armv7, > and the result is all cpu core_id is 0, the bit[1:0] of armv7 MPIDR format. > > In addition, I think arm should also allow customers to configure cpu > topologies via DT. This patch ruins the CPU capacity detection based on capacity-dmips-mhz (Documentation/devicetree/bindings/arm/cpu-capacity.txt) on my TC2 [L B B L L] (armv7). tip/sched/core with *mainline* multi_v7_defconfig: root@linaro-nano:~# cat /sys/devices/system/cpu/cpu*/cpu_capacity 516 1024 1024 516 516 your patch with mainline multi_v7_defconfig: root@linaro-nano:~# cat /sys/devices/system/cpu/cpu*/cpu_capacity 1024 1024 1024 1024 1024 There are 2 capacity detection mechanism in arch/arm/kernel/topology.c: (1) cpu_efficiency (only for armv7 a15 and a7) based, relies on clock-frequency dt property (2) capacity-dmips-mhz dt property based I currently don't see how this different MPIDR layout leads to you code changes.