Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1662528imw; Sat, 9 Jul 2022 09:00:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vc1CZtGtBLDG0zgc4EUDhxsopo2h3N5CzF2yQeE8cLmESphr69ujOJV9zuzT6sfzUAv6uJ X-Received: by 2002:a05:6402:3507:b0:436:446c:4fc1 with SMTP id b7-20020a056402350700b00436446c4fc1mr12354660edd.31.1657382403914; Sat, 09 Jul 2022 09:00:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657382403; cv=none; d=google.com; s=arc-20160816; b=FTdLFnPzIWGT99juFx03v8cFpklP55w9AXM6kvhHNc+WpmN42mhFkGWo0pnetNXMJE uKjomXpZDvct9XB3RDlCQBQicQENKWrm1iwcHzWmAXSTCMBzZLf8nmxMcX/Aj28x5mkq N5Jo6tzJkXkX/TwZsqVj4f+hFPhO63N0+bjVHa5+B5PG4vwiejSr3PGH2ko3RoSya/O1 15I7iKCJaAu+GIqpv6xioQoyicJpKcX+GqBBRK6aEk+PLSmz3ihgKSXjJMrsPmcAbt1G KosmCwpIGKL/2tQj0GfOemFsvz60DusKK+a4xxvIegylnse6oaCUpSGbTA3tuIUkxuo9 S2mQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZvwkXF6SJyNdBT6GaKehBhnkInv+9xYsnjB27F2CrTA=; b=TMoL51DJ+FEG0Oo3JkldxwIji/EvzbCrSyQuMMTi4kgVNGHLxGTRAJKo6wsFmVDl6N XTGeK6/2O9NEKnEI1DYGab3bidbjgGh/H5y3I7luj9k6UfIrJlVbSoRQzklXp8CekRKO qtOc1BC/qlnxIQcvH7QwEkqguzQ+/e5WQgBgvxeGAi1MsxEgV+8t6vxHg1ONEI5N1hiT N51tcskSeczaZ8vZuREODzeYNJTmTw0Joid4m0OFEACYCcXm3iVVI9cmlUV3OCmHa7pW aOlzIgksNM0w2B7IPpY7pXt10OegZO4KFfN5b3cX0LfzEgxhIsNOWWtiCdC/USQF8RJt ZcIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@conchuod.ie header.s=google header.b=cWTxzGaC; 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=conchuod.ie Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s24-20020a1709064d9800b007269e2c6bf2si2477240eju.794.2022.07.09.08.59.39; Sat, 09 Jul 2022 09:00:03 -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=@conchuod.ie header.s=google header.b=cWTxzGaC; 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=conchuod.ie Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229537AbiGIPYo (ORCPT + 99 others); Sat, 9 Jul 2022 11:24:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbiGIPYn (ORCPT ); Sat, 9 Jul 2022 11:24:43 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C44D12D31 for ; Sat, 9 Jul 2022 08:24:42 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id v67-20020a1cac46000000b003a1888b9d36so2703563wme.0 for ; Sat, 09 Jul 2022 08:24:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=conchuod.ie; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZvwkXF6SJyNdBT6GaKehBhnkInv+9xYsnjB27F2CrTA=; b=cWTxzGaC+PmqSgrWtYZ3lV2Ogppapc9JsZQQ4yuI9kyTwToYEt+TaRo1SNL2/8VSKZ NkKVvHZJo1U+XZV4hjmMqe2/kH3kABibGL2WK0pBrfbE0Qtm7IyJoyGvHaJiyWVDsy6a 6PNwjP3lexTIt5Z0I5TzwDPBe0eWxVtWM/umfUSkCmsxjMygGx+Px3h0W5JAxuZtPXKh Vhzb55MiyjYNhJwzKmJ7L4ysB6HgpMMhuwxGWehmJxzC7slj6tEb61vYZAaQDRLzf/7V Hmw8kOMwVVMndg6q5gHq79p1KQBMaJFPhzLOkTfujofWsAZI3myeO3nZDAD1ZrMCsaWe BMNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZvwkXF6SJyNdBT6GaKehBhnkInv+9xYsnjB27F2CrTA=; b=ndTz/Z40k1SfV5v23V/IavkEOXP8eUQ4FMxqNZfTdQXTU6H2znbij61j9vSgQHdFmQ AxRSu3VdDMwVlBnMf+aGdmkruyA0i4JE+k2/g3ZLUul5p3kvcWv1WSh1mJCayO2ZEg2+ NujOCf9D38yTv+fWIVx3dJu4D3QjDZpo9Nj2K4Nmc2TlqmoQ/RpBSN+fIxtdZXhTHJbw hDDvPaubrBYb+D/BBnH6f3iaksvblitlyYY/6aij4L2QpNZw9ZJZk65OEIzJ/VoFoptj TmEeMYT2EHZ1peq+Y3pZ9G2oBNKjjy7jnSzM+b40ndTVnKw80u1bEJ4r65KvBDWM2GBA ip/A== X-Gm-Message-State: AJIora/NVTrWtxrorfTanwAMEzSHFtZOnXApZEKzIzlZ6dttIZ8n3SWG RNCagKoJBC0uKueHfsQwuAli0Q== X-Received: by 2002:a05:600c:1c0e:b0:3a1:9a4b:28ee with SMTP id j14-20020a05600c1c0e00b003a19a4b28eemr5840203wms.203.1657380280658; Sat, 09 Jul 2022 08:24:40 -0700 (PDT) Received: from henark71.. ([51.37.234.167]) by smtp.gmail.com with ESMTPSA id y12-20020a5d620c000000b0021d63fe0f03sm1626730wru.12.2022.07.09.08.24.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jul 2022 08:24:40 -0700 (PDT) From: Conor Dooley To: Paul Walmsley , Palmer Dabbelt , Palmer Dabbelt , Albert Ou , Sudeep Holla , Catalin Marinas , Will Deacon , Greg Kroah-Hartman , "Rafael J . Wysocki" Cc: Daire McNamara , Conor Dooley , Niklas Cassel , Damien Le Moal , Geert Uytterhoeven , Zong Li , Emil Renner Berthing , Jonas Hahnfeld , Guo Ren , Anup Patel , Atish Patra , Heiko Stuebner , Philipp Tomsich , Rob Herring , Marc Zyngier , Viresh Kumar , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Brice Goglin Subject: [PATCH v3 1/2] arm64: topology: move store_cpu_topology() to shared code Date: Sat, 9 Jul 2022 16:23:54 +0100 Message-Id: <20220709152354.2856586-2-mail@conchuod.ie> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220709152354.2856586-1-mail@conchuod.ie> References: <20220709152354.2856586-1-mail@conchuod.ie> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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. CC: stable@vger.kernel.org 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 869ffc4d4484..7889a00f5487 100644 --- 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) { diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 441e14ac33a4..b7633bacbd31 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -845,4 +845,23 @@ void __init init_cpu_topology(void) } } } + +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.37.0