Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1063924rwi; Wed, 19 Oct 2022 06:22:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4e+bZfIwLZkeuYFNdRi2yElvj/IPjGGBGffrObhjbBpSUVNQOMz0ygbHerh305H3LwkPEH X-Received: by 2002:a17:907:1c17:b0:78d:df89:26c6 with SMTP id nc23-20020a1709071c1700b0078ddf8926c6mr7062207ejc.20.1666185737412; Wed, 19 Oct 2022 06:22:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666185737; cv=none; d=google.com; s=arc-20160816; b=tAYx/nv/EsRAd0tWPsdNHVGYLESiVzvklDe/yZWV+tzONVkmqURtgH1I1GHY3YLmZ+ X2uqFfJB6iRsRAmmZmSlt6a5kHW7QCjOReOmvxl4barCn7H/JOOyYxd4v2MagNy6jvux 7tFCDLfhyfpNQxdF7Sjc3IrwDgupY0ILGWKjwuX8WIc4SGYmsfys3a2F5g2/d6M0fpOE amQWrF8R5hREskcp3xVS+rFtVX9NH/8/1bFcW/FL5VIk8DOnmmlwiTeI9FH59UH4OUG7 sGRVnTNkELgVfa59PAmz3Q/7QbFH3Tico7ibDh3PKLLyq1fcUQW1uIADANJk2t0mnEha odNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=XXn3y8KnHeX8Is9alHcywIXVDRZwIr6TjOS2xcB5atg=; b=dTHTS5CUNnonlltlbHhvN8y3jcMuLSSzPvMW6zOl/F9B5PzQjGs0wY2k0P4zIc5F3x +11SL8mwqyyTStmA/YXUSimL9/NqzwrQBZt+LTEnxPGHThWPBiZZhm/QS/Rr1EXnFO8G rYVSQZudiS7s/OCqkZ2Dn9mEo3e33fLT0SOnAvCHtWfuskTZRKrJGxJmiagBK8dxyHIU H4+NLyNUKcZYceRF5xFZLarUqhNV/L3B0l9pTSySfLnxoDo18ZlhfW10EHRHgGcD1C74 b5UvqHJZHs1Nqr3SumfXcwPI6RRTw7YCi4VRYrDKwIjSY4Si08MlU2oi4qGXHN9ShjRR SRMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=hU9cRblH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z19-20020a05640235d300b00457e293e3easi16324498edc.573.2022.10.19.06.21.50; Wed, 19 Oct 2022 06:22:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=hU9cRblH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233014AbiJSNJx (ORCPT + 99 others); Wed, 19 Oct 2022 09:09:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231522AbiJSNJ3 (ORCPT ); Wed, 19 Oct 2022 09:09:29 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAC8022530; Wed, 19 Oct 2022 05:54:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1666184077; x=1697720077; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=EbfoJoZkMkYyZLm3EYzvXahKcHMzK1vKqL4Mx9vLb6w=; b=hU9cRblHfi4VjUS86tUclSLf4I3/cPe0n1DSr2jlA+Vhm9gTJ4nI2R+N yC4oPKd3RytVhBRDmp2PG5IOc1EbBJtNoAQf6/Mbse7DLoKWGUHmqBePg sKV4vqwojONnlMsTnQFkvbARJS3gYkxeeGIgBDIeIyi9p2YXxyZR95ezR 4POGFY3Eiux3+Juvg04gPTd+fNYmH6xuk/uzfekXrErDt1YzjMJuGjUwa yWzQR1D1rxJDkl8hhgy4WpC+axpdvd8e43NKxBRsgiNoT+ynq/mY0tvTM OmRqmQMTN2uad4/KGV0OdjDhGjTfINPgf9uLhIo5JqXpa3rCER7OM7FmJ A==; X-IronPort-AV: E=Sophos;i="5.95,196,1661842800"; d="scan'208";a="179546648" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 19 Oct 2022 05:53:03 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Wed, 19 Oct 2022 05:53:01 -0700 Received: from wendy.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Wed, 19 Oct 2022 05:52:59 -0700 From: Conor Dooley To: CC: , , , , , , , , , , , Atish Patra Subject: [PATCH 5.4 1/2] arm64: topology: move store_cpu_topology() to shared code Date: Wed, 19 Oct 2022 13:52:09 +0100 Message-ID: <20221019125209.2844943-1-conor.dooley@microchip.com> X-Mailer: git-send-email 2.38.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit 456797da792fa7cbf6698febf275fe9b36691f78 upstream. arm64's method of defining a default cpu topology requires only minimal changes to apply to RISC-V also. The current arm64 implementation exits early in a uniprocessor configuration by reading MPIDR & claiming that uniprocessor can rely on the default values. This is appears to be a hangover from prior to '3102bc0e6ac7 ("arm64: topology: Stop using MPIDR for topology information")', because the current code just assigns default values for multiprocessor systems. With the MPIDR references removed, store_cpu_topolgy() can be moved to the common arch_topology code. Reviewed-by: Sudeep Holla Acked-by: Catalin Marinas Reviewed-by: Atish Patra Signed-off-by: Conor Dooley --- arch/arm64/kernel/topology.c | 40 ------------------------------------ drivers/base/arch_topology.c | 19 +++++++++++++++++ 2 files changed, 19 insertions(+), 40 deletions(-) diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index 113903db666c..3d3a673c6704 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -21,46 +21,6 @@ #include #include -void store_cpu_topology(unsigned int cpuid) -{ - struct cpu_topology *cpuid_topo = &cpu_topology[cpuid]; - u64 mpidr; - - if (cpuid_topo->package_id != -1) - goto topology_populated; - - mpidr = read_cpuid_mpidr(); - - /* Uniprocessor systems can rely on default topology values */ - if (mpidr & MPIDR_UP_BITMASK) - return; - - /* - * This would be the place to create cpu topology based on MPIDR. - * - * However, it cannot be trusted to depict the actual topology; some - * pieces of the architecture enforce an artificial cap on Aff0 values - * (e.g. GICv3's ICC_SGI1R_EL1 limits it to 15), leading to an - * artificial cycling of Aff1, Aff2 and Aff3 values. IOW, these end up - * having absolutely no relationship to the actual underlying system - * topology, and cannot be reasonably used as core / package ID. - * - * If the MT bit is set, Aff0 *could* be used to define a thread ID, but - * we still wouldn't be able to obtain a sane core ID. This means we - * need to entirely ignore MPIDR for any topology deduction. - */ - cpuid_topo->thread_id = -1; - cpuid_topo->core_id = cpuid; - cpuid_topo->package_id = cpu_to_node(cpuid); - - pr_debug("CPU%u: cluster %d core %d thread %d mpidr %#016llx\n", - cpuid, cpuid_topo->package_id, cpuid_topo->core_id, - cpuid_topo->thread_id, mpidr); - -topology_populated: - update_siblings_masks(cpuid); -} - #ifdef CONFIG_ACPI static bool __init acpi_cpu_is_threaded(int cpu) { diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 503404f3280e..0dfe20d18b8d 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -538,4 +538,23 @@ void __init init_cpu_topology(void) else if (of_have_populated_dt() && parse_dt_topology()) reset_cpu_topology(); } + +void store_cpu_topology(unsigned int cpuid) +{ + struct cpu_topology *cpuid_topo = &cpu_topology[cpuid]; + + if (cpuid_topo->package_id != -1) + goto topology_populated; + + cpuid_topo->thread_id = -1; + cpuid_topo->core_id = cpuid; + cpuid_topo->package_id = cpu_to_node(cpuid); + + pr_debug("CPU%u: package %d core %d thread %d\n", + cpuid, cpuid_topo->package_id, cpuid_topo->core_id, + cpuid_topo->thread_id); + +topology_populated: + update_siblings_masks(cpuid); +} #endif -- 2.38.0