From patchwork Sat Oct 22 07:18:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7172 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1088517wrr; Sat, 22 Oct 2022 00:40:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5QlTdOsE9gtM3i1m3bWNFAV1OJyx+JCWNHtESHPt5Q3C93Ey/UkjjEA+ROEDDcY9X6nYju X-Received: by 2002:a05:6a00:2906:b0:52a:bc7f:f801 with SMTP id cg6-20020a056a00290600b0052abc7ff801mr23692507pfb.49.1666424416583; Sat, 22 Oct 2022 00:40:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424416; cv=none; d=google.com; s=arc-20160816; b=HLEJFXUenZHsyO+pffdioswFJnfwHDNVFfPeWPsR+Y/Uu3DSBR1yVhsNfqoPG+FIUl Dj+kaCDkFcyZ6LC85XMcThCnspcU4j2NNlteDPlptqOi9TWjkcYLb1F89GgDQAuyztxx 6mj0FlOK30II2Mjd6mhKzoOlAoAWev8Wruj+NfpjRFJqZ4N0bbbZYXYm2V3KumCUq3D6 j3OQBH3o+8lHdJK1/zMzMuGecwWUXb73I23/mNDEMltLxxNJA8IbLQtF0qNa3WoEYjbm uoNis5eAOR6FL9rLy50tKfg5aoIUhRWT0MStg4duSt7WnFuEqwnQOk9IUKHZWcfLK46L X9ew== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y12-20020a1709027c8c00b001769e71398csi25111244pll.340.2022.10.22.00.40.04; Sat, 22 Oct 2022 00:40:16 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747372648707798663?= X-GMAIL-MSGID: =?utf-8?q?1747372648707798663?= 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