From patchwork Wed Oct 19 08:22:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4535 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp203798wrs; Wed, 19 Oct 2022 01:44:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4yiJObXgx+N1bQrOef75ldbUQ26L/WXTQyA86DkVy6qk7UFSSjk4wRqOrHWQ3kiE6ussA8 X-Received: by 2002:a63:1112:0:b0:43c:7998:ac15 with SMTP id g18-20020a631112000000b0043c7998ac15mr6489262pgl.51.1666169046233; Wed, 19 Oct 2022 01:44:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666169046; cv=none; d=google.com; s=arc-20160816; b=r+De6yJMvLuTbh2UTQSZ2xfWe8KMuB/yJb6SUjRACanvqglSxT6DdV5q6/YCWeeF99 +xdevnA/dHRYv7PNsyR+Mfpxmc+1Mm/VvObTKIVzrF2GUhGEx+b2oCvjzW1MlETVuBWr 2b3WHAMpNc4ZoRWGVY54wGLQYaE1VENiC+aUTAiqrGcLSy1Oo+jz0329tgxC5I23EXdN NucPIUhjNg/g5oufoqLftEWz3uZ9sQvi8tHQcSHrmGEf0yROheNME1zq6kbq0qQhsNyJ zrxj0so/eVcCSOjNSZiln5zyfN+adw3Op+i4pXpFy6SHlMExx9EuSpO+uBLGGFIGyT12 Joag== 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=uyYr3a8rSMfbxvMeIufQCAxCcGGwezphBh/unxt4dj8=; b=Px3YW37A2eZ4zBnsNIX6E1rVMyW6J68b8dz1LZ5CNJeNkvYYazVFdvKnIEjIA3PzYQ w5QJWNrubrD+Q57Lul2wNEkiFuHccUHPqNDVclleTZ0dm9uQHwZZpZTwJAB6sqhJ1//W 5KLTpmaIpD3eeV0Pt1l5d4ewc1ls/JMrqtjn2AICPlcz6/nlh+JeJDmtzQ0bRylImbRQ trgyKJPhNiYNdkPkYnHNXy2GGf4SXA71dalH+pVcGwFCzgbn3Lby1m8U1LzWd/vgI2bZ YJjUN/nAXOBpcUDmpTK//QIlyX0qITcrzoUFmkxBt5sqKu1xGeG9w+guKTkYvQfkCZaE 1Kyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HVk4jeiP; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k135-20020a633d8d000000b00461916bca4asi18350789pga.627.2022.10.19.01.43.53; Wed, 19 Oct 2022 01:44:06 -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=HVk4jeiP; 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 S231284AbiJSInX (ORCPT + 99 others); Wed, 19 Oct 2022 04:43:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230515AbiJSImk (ORCPT ); Wed, 19 Oct 2022 04:42:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89AC753A63; Wed, 19 Oct 2022 01:39:54 -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 25E09617D6; Wed, 19 Oct 2022 08:39:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 177F5C433D6; Wed, 19 Oct 2022 08:39:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168793; bh=a2KNSKtYiPrIMjccfWprCEzKN1CyLwO/KdoTcBtdja8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HVk4jeiPGnCNn3FM0SCCBxVOdAUFcIBIvSKI297zOb9WgSYHGf9e9Vti3S+SR+jA6 QqFonKqtYd20ngClCeukaCRFNl6OyuLuQ2no8Hy7gqJEOIXSS7WMkKeI81ZAM2nvdd SKt62uvOjXgSlsCVXrU3ARtwg3nwAgAYLz4TpDjw= 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 6.0 055/862] arm64: topology: move store_cpu_topology() to shared code Date: Wed, 19 Oct 2022 10:22:22 +0200 Message-Id: <20221019083252.410045280@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747104873922902684?= X-GMAIL-MSGID: =?utf-8?q?1747104873922902684?= 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 @@ -841,4 +841,23 @@ void __init init_cpu_topology(void) return; } } + +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