Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3912826rwi; Sat, 22 Oct 2022 02:05:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6HNAKdNfI8vxppLLjQRUwUd2CMuBhdm1dLBuxpkwi98hEJMTfc+isTag4MhumaFPHfVuIm X-Received: by 2002:a17:90b:4c52:b0:20d:489b:5607 with SMTP id np18-20020a17090b4c5200b0020d489b5607mr26764521pjb.40.1666429511599; Sat, 22 Oct 2022 02:05:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666429511; cv=none; d=google.com; s=arc-20160816; b=h3ATjQ2xS+UdeAwA81qxakhGalGAKZePKhUUeFyDCUyRVwZYLhgLKOopT8FlMDCJeH rnPxyO88aYGGx3H+flM5JKE/TeUTD8TN+Mxe+AO+YTyOovCoq1ucVSFdUokQEDtTlH4D Ph54fKFxyO8IcrTa9KliiZAXDKUT3QcEU4bq3wG5kgjkl3cyt12YouINeNvyiG4XaCoB 16pzchuT5+1XS7/epdBfJ8AounAqpkS4X+ozfKix3TV00Xw9VdpmaVMyhQQRkqq80sIb yAbp9NKK00m19LoAuFe4PDpGPQzvc8s40X4RtQNdqyfVAw9WSaiSRviIvs1hv8JDQuUJ lonA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dxzoifxGbZvVhUEGOgVwMXE1xNwMPdeSxSQR2oxXbuA=; b=HBrm+n7CZkQQ9/LdfqGpDvErf5pDVwaPngW0zQZJXGfqiDmMDI/gM28VDnD4ru0TXF L9YIRLpp+NMtk/Kk2USb8VNOI13Cz9czzbG5vBUnXWRFWAq3XyAjHGgq1d2++uKCFu7G 0Awk/TR9HSUsKLwd47K0bkIxpnuVQTODbqtoC1/YiN9BF3CEaaQiNpTTy3SYpF0RjnNE 7Vuwc871S9at32Xw6aQdZ1Rm8nFJcbM9H8Yl6xJxaWE2qAZ7uZaiSFIBqG7XEWfVvbh5 0SasxU755ci4GrLV6/ToW3ma8Kgvh9ctxZDnZze2Cr8Uc+al2yA1oQIhEwfLwDjtjjGt vYdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="IVWkqib/"; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ls15-20020a17090b350f00b001eccaceca72si10977986pjb.1.2022.10.22.02.04.57; Sat, 22 Oct 2022 02:05:11 -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=@linuxfoundation.org header.s=korg header.b="IVWkqib/"; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231137AbiJVHjq (ORCPT + 99 others); Sat, 22 Oct 2022 03:39:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230473AbiJVHjB (ORCPT ); Sat, 22 Oct 2022 03:39:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79A3429C4AA; Sat, 22 Oct 2022 00:36:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A9B3C60AE6; Sat, 22 Oct 2022 07:36:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A71CC433C1; Sat, 22 Oct 2022 07:36:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424168; bh=ZgtsA7uhgYQY0cLa9bVr9Xj0WekQOGNPc4X55m/AVGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IVWkqib/ml8RMGgRTaZ1XzDf+6r28GXfUoFXe8X2Q2YuHeqo1oKlJrPaA5uxEmDjU thXgeZ45W1pYB5hJQa+oK83E+yFt9cqPK9fJ6/FSCzwF89ggnnFJg9tVhQOR8kjkvE 1S/tkXtpmK70+DMQDpaR0H2vRrf0PwYWo9s8G+dU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sudeep Holla , Catalin Marinas , Atish Patra , Conor Dooley Subject: [PATCH 5.19 049/717] arm64: topology: move store_cpu_topology() to shared code Date: Sat, 22 Oct 2022 09:18:48 +0200 Message-Id: <20221022072423.804804782@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 From: Conor Dooley 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 Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/topology.c | 40 ---------------------------------------- drivers/base/arch_topology.c | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 40 deletions(-) --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -22,46 +22,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) { --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -791,4 +791,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