From patchwork Thu Jul 7 22:04:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 12910291 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 23905C43334 for ; Thu, 7 Jul 2022 22:06:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MAYWzwBDenP0l2sRLyFjn8CbfSu5BFpuJB+XfAAJDZ8=; b=Eev8T2p2IOJRYs ILN7f16afpJ1oTA983jXlPDAdwQfUc4/0IBq0ftNIMQw0YgUKn75wP5WXo29j9SUiuMUQS3dmg+l7 gWfDuxkF9aV103PwbE2hYtGp2v8I+uGjrYC8ExjWt5vMTaNS8XRehiG+TGJZZ0Pg4OgJVVscaylrU /przMsURn9dv8epLmvu+6e+AarBamfrKHNeqGtZqcfCVLR0tc72C4m2gcSBeuZvJIK29gZxPVeTaA J+rSFEYUwctsJxZ8wcCfWiJam44mEnOIO8xLVCbbLGAfxrzSCsz0tyAt6WiyWyzkH947wMzsSD7vv iTzrLFVtwD+UKRYN6hEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9Zcb-000Rt7-RX; Thu, 07 Jul 2022 22:05:18 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9ZcK-000Rgr-O3 for linux-arm-kernel@lists.infradead.org; Thu, 07 Jul 2022 22:05:04 +0000 Received: by mail-wr1-x42c.google.com with SMTP id b26so28164164wrc.2 for ; Thu, 07 Jul 2022 15:04:59 -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=7E7EjtLMLS23T2bsvt4SNELdhBh6QzAyNMiy3mGJiIQ=; b=IpDj5afJY9kCBQK/vOv90bAyHCUlUto7onzuO/nC3gDHXS58GwaZXLBMRi1NpV8ze2 7b17aX7eg5pNGdN+ljCBcQEc7Flzi0KrNPzi/DSS83gxm/xyJ6d8Y10aQ11y5TH8tSm7 qxtNVNxZoHIHsKaon5dlXSvMpW9bZI5FVCtqvHtnlP/HB2Wrg8hCLpJp20X1soauPaZK P6wZGFi3ZwZviCg8NdSlenWNPuXDtvx6V91JHpVX/vU12PqONkh1XKjIVuPe/Qsc7Scw 3xn/BvmyMLVj2asQTVoDw2k2nLgR7SK989r2ZPBZIJK8ddDzmN3y0lb0xRMqXv3YSmq0 gvJw== 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=7E7EjtLMLS23T2bsvt4SNELdhBh6QzAyNMiy3mGJiIQ=; b=gryWTa8dCtFoJz/WGTcLVKUKHNfOGpm6zzM4qs7PBEIBJLhJrnggKUXpFkf5eSvLHb /XRpfMRmg+WfO3GTG+7UjPVDXS6tPuKwA2cYJqdaM5e7CAEtfz4nQVbkfozlgrclPnzn J6nEhWn2z0FoXGD02d5OTEzhN+crPLAab2cFBf5oMYRkzZxcd4W0E/z6bwD8JRHoBLKM 8cvsTd0ha/5UjWiU5BXONfFo77Ojj67VLpj7BbB9FWtxKhlFIKIaKQjCX5yxNivZgW9R LJ61RmdaJ3sM/WKhc0HvgCq0H+hOtcMuNGhL6HebDOcsgUrJtJOlkHZqgIdB1rSZgR9p beXw== X-Gm-Message-State: AJIora9flSzklrvE21b+oUxubFyoNsrZEyjRfNtS89EyjmoQfQTF8k1k ao+wZTFE0tUjPzVfGtD8QgMvDg== X-Google-Smtp-Source: AGRyM1vvwbxzDYSubtFunJO4nqpmeLLb8LTkGF5ahzlCzgxU+DSPa3gNVAuFvhOqaznOY1rAHaAZfA== X-Received: by 2002:a5d:5c05:0:b0:21d:83b4:d339 with SMTP id cc5-20020a5d5c05000000b0021d83b4d339mr40615wrb.611.1657231497860; Thu, 07 Jul 2022 15:04:57 -0700 (PDT) Received: from henark71.. ([51.37.234.167]) by smtp.gmail.com with ESMTPSA id bn24-20020a056000061800b0020fe35aec4bsm38625743wrb.70.2022.07.07.15.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 15:04:57 -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 , Changbin Du , 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: [RFC 1/4] riscv: arch-topology: fix default topology reporting Date: Thu, 7 Jul 2022 23:04:34 +0100 Message-Id: <20220707220436.4105443-2-mail@conchuod.ie> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220707220436.4105443-1-mail@conchuod.ie> References: <20220707220436.4105443-1-mail@conchuod.ie> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220707_150500_858224_8F3A67E6 X-CRM114-Status: GOOD ( 23.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Conor Dooley RISC-V has no sane defaults to fall back on where there is no cpu-map in the devicetree. Without sane defaults, the package, core and thread IDs are all set to -1. This causes user-visible inaccuracies for tools like hwloc/lstopo which rely on the sysfs cpu topology files to detect a system's topology. Add sane defaults in ~the exact same way as ARM64. CC: stable@vger.kernel.org Fixes: 03f11f03dbfe ("RISC-V: Parse cpu topology during boot.") Reported-by: Brice Goglin Link: https://github.com/open-mpi/hwloc/issues/536 Signed-off-by: Conor Dooley --- Sudeep suggested that this be backported rather than the changes to the devicetrees adding cpu-map since that property is optional. That patchset is still valid in it's own right. Changes since v1: - removed the GENERIC_ARCH_TOPOLOGY dependancy on SMP - removed a duplicate call to update_siblings_masks() --- arch/riscv/Kconfig | 2 +- arch/riscv/include/asm/topology.h | 13 +++++++++++++ arch/riscv/kernel/Makefile | 1 + arch/riscv/kernel/smpboot.c | 5 ++++- arch/riscv/kernel/topology.c | 32 +++++++++++++++++++++++++++++++ 5 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 arch/riscv/include/asm/topology.h create mode 100644 arch/riscv/kernel/topology.c diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 2af0701b7518..4b6c2fdbb57c 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -52,7 +52,7 @@ config RISCV select COMMON_CLK select CPU_PM if CPU_IDLE select EDAC_SUPPORT - select GENERIC_ARCH_TOPOLOGY if SMP + select GENERIC_ARCH_TOPOLOGY select GENERIC_ATOMIC64 if !64BIT select GENERIC_CLOCKEVENTS_BROADCAST if SMP select GENERIC_EARLY_IOREMAP diff --git a/arch/riscv/include/asm/topology.h b/arch/riscv/include/asm/topology.h new file mode 100644 index 000000000000..36bc6ecda898 --- /dev/null +++ b/arch/riscv/include/asm/topology.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2022 Microchip Technology Inc. and its subsidiaries + */ + +#ifndef _ASM_RISCV_TOPOLOGY_H +#define _ASM_RISCV_TOPOLOGY_H + +#include + +void store_cpu_topology(unsigned int cpuid); + +#endif /* _ASM_RISCV_TOPOLOGY_H */ diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile index c71d6591d539..9518882ba6f9 100644 --- a/arch/riscv/kernel/Makefile +++ b/arch/riscv/kernel/Makefile @@ -50,6 +50,7 @@ obj-y += riscv_ksyms.o obj-y += stacktrace.o obj-y += cacheinfo.o obj-y += patch.o +obj-y += topology.o obj-y += probes/ obj-$(CONFIG_MMU) += vdso.o vdso/ diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index f1e4948a4b52..a8239b4b61f3 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "head.h" @@ -40,6 +41,8 @@ static DECLARE_COMPLETION(cpu_running); void __init smp_prepare_boot_cpu(void) { init_cpu_topology(); + + store_cpu_topology(smp_processor_id()); } void __init smp_prepare_cpus(unsigned int max_cpus) @@ -161,9 +164,9 @@ asmlinkage __visible void smp_callin(void) mmgrab(mm); current->active_mm = mm; + store_cpu_topology(curr_cpuid); notify_cpu_starting(curr_cpuid); numa_add_cpu(curr_cpuid); - update_siblings_masks(curr_cpuid); set_cpu_online(curr_cpuid, 1); /* diff --git a/arch/riscv/kernel/topology.c b/arch/riscv/kernel/topology.c new file mode 100644 index 000000000000..db72862bd5b5 --- /dev/null +++ b/arch/riscv/kernel/topology.c @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2022 Microchip Technology Inc. and its subsidiaries + * + * Based on the arm64 version, which was in turn based on arm32, which was + * ultimately based on sh's. + * The arm64 version was listed as: + * Copyright (C) 2011,2013,2014 Linaro Limited. + */ + +#include +#include +#include + +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); +} From patchwork Thu Jul 7 22:04:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 12910292 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 69FAFC433EF for ; Thu, 7 Jul 2022 22:06:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vESfBGbO2jxJQgSSPBmQkQPMP+hYWo1RJrVxsAnZTTM=; b=2Gocm5HhiOZIo2 aGsh25eYylPm4NBfWX7/ooB6ehX0vlow5kt4LFKRZGZrK46vmk+/bBYhhT+dLE69eioXhDgH/SJX9 5vBw/5odV53oZslYQu8dxhQnw2hsSvUhjy5IdRAxPjcnEyFQfILcZBiwsjYUfJhDAOWOOUYACWn2E vMA8k+phtnPxerQfodGtwlHkgNWc4OpQ3Jd+bKNtXtNIzOwiayBvf6CJ68pqnpHi7cji9sTTtctnT kPQhQj84BM0bJn2EXjdNQzYGHoSzWvIEYXsaxT7WtPK3rJKF8xQ2eTunDCSi9QJqkzDMIGB+UVfKz qFpUq9+R//aP4s2q096A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9Zcl-000Rwy-4e; Thu, 07 Jul 2022 22:05:27 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9ZcM-000RhY-GA for linux-arm-kernel@lists.infradead.org; Thu, 07 Jul 2022 22:05:04 +0000 Received: by mail-wm1-x332.google.com with SMTP id j7so11441084wmp.2 for ; Thu, 07 Jul 2022 15:05:00 -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=B5wkC6bSg20bpLD4uQZm3lcPPl+j3uqj6NVt2WW5Mcg=; b=JoYnHtdqAYiT+36KpL4vd68z4rhaJnSSsg1xfE6U/TWcp9nowym0LLc5feUvF6cUvt FBUAoeUMgHU+d8gc/nAa9KYVpHAA6oc64AfaDNZLuPUl+oOt6hoTTzlVpA6g244CjRAC 0b7eCJwc2WiueTqO7ly4o/mFQwqCHi5xTKI0OY3HTbmapB9RyS7H0ypUMkLfcxwySOUe H+bi7Sss1x8a7j145shtX+T2pXLMx4rZ8NewuiYN+dGyOs7RUfZXeqIbqn3mW9bBWIJK HbNIlILXJ2QlL38ltMXCL5N/aO9naJdqKNA0TMzNgFvBYDziN+CR6FNoB0EVmWiS/LoY hNjQ== 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=B5wkC6bSg20bpLD4uQZm3lcPPl+j3uqj6NVt2WW5Mcg=; b=KscUzdfTTPXZdeJpxdJrdh7Ryc4TrJ6hXU1LORedEsRjRXW09DYH2mI1Aqs69pM8EX Cnqx+DNy1XeOT00Wuk1zGZlBY4cHjBWBoOo5uSJKwflnH//N0biKpCjrY1Y9f8iH4mG9 C9XZ6+eN3d5KZGw08Nyqo1wtWaLx6qtyMM2O6/99nUGdlE9dtRU0uDiJIkq3mQ4uTldq 8nd/HopPni/VMy4bbTvkixMnBrcswC/mT7uaMjtii3SPe07ImGWfmyvy8EC0WfRtdAha mX6Ky4LepCKwxX47exyRZVE5R6NwmNezFOzZgRY8uxoWL4RaY6hL7kVp6M1whp3zC5D6 ZiJA== X-Gm-Message-State: AJIora/AsJPUlqVDP/9Y1J/T1pXq6us3iYfCa7Z7tUYvWy0fhX+k42D2 dgsYEbAIL9nSHi54cp3kh31vJA== X-Google-Smtp-Source: AGRyM1tnnzsxvhPG5IKs+YBZgLkAEtXKFH5kbjSLNkMp91lah456WA9wRpXL5hKIPbb8QYLBQN/YLA== X-Received: by 2002:a05:600c:22d8:b0:3a0:4092:caff with SMTP id 24-20020a05600c22d800b003a04092caffmr7025020wmg.59.1657231499789; Thu, 07 Jul 2022 15:04:59 -0700 (PDT) Received: from henark71.. ([51.37.234.167]) by smtp.gmail.com with ESMTPSA id bn24-20020a056000061800b0020fe35aec4bsm38625743wrb.70.2022.07.07.15.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 15:04:59 -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 , Changbin Du , 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: [RFC 2/4] arch-topology: add a default implementation of store_cpu_topology() Date: Thu, 7 Jul 2022 23:04:35 +0100 Message-Id: <20220707220436.4105443-3-mail@conchuod.ie> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220707220436.4105443-1-mail@conchuod.ie> References: <20220707220436.4105443-1-mail@conchuod.ie> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220707_150502_652115_15166F92 X-CRM114-Status: GOOD ( 13.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Conor Dooley RISC-V & arm64 both use an almost identical method of filling in default vales for arch topology. Create a weakly defined default implementation with the intent of migrating both archs to use it. Signed-off-by: Conor Dooley --- drivers/base/arch_topology.c | 19 +++++++++++++++++++ include/linux/arch_topology.h | 1 + 2 files changed, 20 insertions(+) diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 441e14ac33a4..07e84c6ac5c2 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -765,6 +765,25 @@ void update_siblings_masks(unsigned int cpuid) } } +void __weak 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); +} + static void clear_cpu_topology(int cpu) { struct cpu_topology *cpu_topo = &cpu_topology[cpu]; diff --git a/include/linux/arch_topology.h b/include/linux/arch_topology.h index a07b510e7dc5..fee306b8a541 100644 --- a/include/linux/arch_topology.h +++ b/include/linux/arch_topology.h @@ -92,6 +92,7 @@ void update_siblings_masks(unsigned int cpu); void remove_cpu_topology(unsigned int cpuid); void reset_cpu_topology(void); int parse_acpi_topology(void); + #endif #endif /* _LINUX_ARCH_TOPOLOGY_H_ */ From patchwork Thu Jul 7 22:04:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 12910294 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D3A79C433EF for ; Thu, 7 Jul 2022 22:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FpNPovGXtNWR4ElT0zrMWKe7W8CYlg8aTF73E3stEnA=; b=G1w3Lh6U+KK8Wf Mz8TOoLVqPDdXm+SkEu736v9CBmrzLx2n0cjC3WefzMZwIimfEXTE0eJVQhF1WYlqSq7UCWIFq0J1 1RUidi1pyMQZ1iJyCqtFdgbibMTmeaOzDs3QmtcWfbk0nB9C9lt+dLxcircieqzfAyYeD3XV9ccmY u1ckABRUQkPhCphcssvbFsvbqKvp8l/boMksK71jF0fqeZ5XDQXzitaYeNlqeH6htPy/MGyPxZCyJ D91ebU24WjDAyl6D26ZdYLcmSA2SjD6r4SBFxcUVFjbboQLmCHw/uXdn1WApiYseupHMcvDANYR9j fss7cCMTU4KeaehBOlHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9Zdc-000SVb-8x; Thu, 07 Jul 2022 22:06:20 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9ZcR-000RjJ-4A for linux-arm-kernel@lists.infradead.org; Thu, 07 Jul 2022 22:05:10 +0000 Received: by mail-wr1-x430.google.com with SMTP id n10so2833484wrc.4 for ; Thu, 07 Jul 2022 15:05:02 -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=hjZHB/xWJ3nWli7ZfNwXsxb5s5FyrkVe3kCR2sto3MY=; b=YAksl8QG4Ad+/zsLgP3rFBKEVMf4C2+ycllCQpHkGjWiGmXMrv44Fa5DhcIcWd6OL0 nSTFK6m5aqU3OdaAoJJlvx90zXqFH5x1SntHlfXOfmFM2szSOaT/cE4rNrCxUdQ0k/sb /MXyrA28CE+ypPlAWUYiPH/jh+0UZxSU6DqiijerAqCzqowZEABCeK7WJpCw83jCWrPN HOA9Wt1xlePu2vJNvPB59XhOaCfAaoCWjXki4pgl5sLkfmlFKReDiNi3ADDzQ/feC8+5 CEFG1S2hd5Dk7O/gc4h/Ij2d+6Dp0wuaAqLn9hrf7s2FMU0JpxwUaKqg4II8nREXih3L 4U8A== 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=hjZHB/xWJ3nWli7ZfNwXsxb5s5FyrkVe3kCR2sto3MY=; b=Ln9pUHKJDKFpzoCu/lMujqdb5uktn+oeixxbIt/MZUBXzP/inYzLZJj9BVPDi6iPkG bU0LKVzsXsTCh4qF6OkQecNXagxn63E4zGmskSCXMbZUaV1Xjw0nwBhVIq25onJY47G3 cYArbbhamgbdHlRfbK30mFlDJGbJkjU2g30lzPiXmoDBJ4KuSrAg83b2GZw9dQiN0FRS x5KcdCCnkarg2UwIqBqYsrZgg+uQlILrYgk6cPf4IuRGbVJ0hNSZdJ9DUnA0IRz9v93p r8sjYME47LlDs09r1hEqU8MQuk/WITbysXVv0zlhdZ8Twls3NXMCcyRMerRX4vPCsjuu tzWw== X-Gm-Message-State: AJIora8bXvGvU2okIpqKIoTUDnccHhduct5BIFqRNZijsn/ZX8dZN5xh B+ckSDRa9CjcZt47Ho2bCC6b/g== X-Google-Smtp-Source: AGRyM1ucM2HayA4Nu/4tlRlCtdGGmAk0G8SNuvQDYgL/iSBK+mKdFbxIG/Vfscu+gH+wgAlYNt1K1g== X-Received: by 2002:adf:d206:0:b0:21d:6434:a158 with SMTP id j6-20020adfd206000000b0021d6434a158mr66682wrh.37.1657231501756; Thu, 07 Jul 2022 15:05:01 -0700 (PDT) Received: from henark71.. ([51.37.234.167]) by smtp.gmail.com with ESMTPSA id bn24-20020a056000061800b0020fe35aec4bsm38625743wrb.70.2022.07.07.15.04.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 15:05:01 -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 , Changbin Du , 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: [RFC 3/4] riscv: arch-topology: move riscv to the generic store_cpu_topology() Date: Thu, 7 Jul 2022 23:04:36 +0100 Message-Id: <20220707220436.4105443-4-mail@conchuod.ie> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220707220436.4105443-1-mail@conchuod.ie> References: <20220707220436.4105443-1-mail@conchuod.ie> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220707_150507_239194_E5C1AD8E X-CRM114-Status: GOOD ( 15.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Conor Dooley The default implementation of store_cpu_topology() is exactly that used by RISC-V so revert the portions of aaaabbbbccccdddd ("riscv: arch-topology: fix default topology reporting") which add the arch specific version. Signed-off-by: Conor Dooley --- arch/riscv/include/asm/topology.h | 13 ------------- arch/riscv/kernel/Makefile | 1 - arch/riscv/kernel/smpboot.c | 1 - arch/riscv/kernel/topology.c | 32 ------------------------------- 4 files changed, 47 deletions(-) delete mode 100644 arch/riscv/include/asm/topology.h delete mode 100644 arch/riscv/kernel/topology.c diff --git a/arch/riscv/include/asm/topology.h b/arch/riscv/include/asm/topology.h deleted file mode 100644 index 36bc6ecda898..000000000000 --- a/arch/riscv/include/asm/topology.h +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2022 Microchip Technology Inc. and its subsidiaries - */ - -#ifndef _ASM_RISCV_TOPOLOGY_H -#define _ASM_RISCV_TOPOLOGY_H - -#include - -void store_cpu_topology(unsigned int cpuid); - -#endif /* _ASM_RISCV_TOPOLOGY_H */ diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile index 9518882ba6f9..c71d6591d539 100644 --- a/arch/riscv/kernel/Makefile +++ b/arch/riscv/kernel/Makefile @@ -50,7 +50,6 @@ obj-y += riscv_ksyms.o obj-y += stacktrace.o obj-y += cacheinfo.o obj-y += patch.o -obj-y += topology.o obj-y += probes/ obj-$(CONFIG_MMU) += vdso.o vdso/ diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index a8239b4b61f3..a1c861f84fe2 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -32,7 +32,6 @@ #include #include #include -#include #include "head.h" diff --git a/arch/riscv/kernel/topology.c b/arch/riscv/kernel/topology.c deleted file mode 100644 index db72862bd5b5..000000000000 --- a/arch/riscv/kernel/topology.c +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2022 Microchip Technology Inc. and its subsidiaries - * - * Based on the arm64 version, which was in turn based on arm32, which was - * ultimately based on sh's. - * The arm64 version was listed as: - * Copyright (C) 2011,2013,2014 Linaro Limited. - */ - -#include -#include -#include - -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); -} From patchwork Thu Jul 7 22:04:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 12910293 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5298AC433EF for ; Thu, 7 Jul 2022 22:06:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=O+5+UkgYgwAaQHweDYxO9ln5aTe3hc+C2mcoPfsL9iQ=; b=GWIEDNJAUThWoy t1MoMfTepNId5Ie8auWrR+P0Aji57gdKy+HQ3eI9BT2KkOEuUywxX9R7G1tNia6K6lg/DEQc8KMu8 mxyKt2tnBMqK3IyRLiV2lP6Zzb+0SQzD6lcCYxA7wLf2+5dgElSoHPYNhbK7O0so+kqGMO2QOH2jU u/6cmJM9KzjVcg1WKGlQAdpxzgZ52tKrorvMgJ/wlmlcFelAbNaRxli3WLF02hK099NvHJ2eGAFju eNIE0mQz1Vrk924FjTSW3ewF7eALR2i9Nd26ankbqqYirkI4ZHbgbpKVSvAXeTcmqsg3DjyGc35a5 gGXneNwYqLpfJ9NxCNEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9Zd2-000S72-VJ; Thu, 07 Jul 2022 22:05:45 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9ZcQ-000Rl8-W6 for linux-arm-kernel@lists.infradead.org; Thu, 07 Jul 2022 22:05:08 +0000 Received: by mail-wm1-x32d.google.com with SMTP id o16-20020a05600c379000b003a02eaea815so161703wmr.0 for ; Thu, 07 Jul 2022 15:05:04 -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=bzkzOE355hqIqljAM5HpDyXsSE0Xgb88DMeaRs7oG5A=; b=CFw2+uM+g57y3O9S+BDDURXZpzm9TZdcD9w6aL1Q9BBp/mVgPJmSASYxpP46ODI+6+ PgecRsuYskGLfb7pWQW18Rujt/ybeSrNqS2YyYXjL3PGfbJRSv6K1lZvtZs0Ew1awjCa tVi1UlnKshb0eP3bQ2It6U0uotgqO1ULv83499xyeDvhineaEnJgXRPaQ5XOSDgJfCNW EYUOjSmyeNrhenndSIkT/LnOYLFrW9I93HhO6uvHc07xdx91/7VKhz/YRjw17AIp5dCS c/EM+eOKzdPqPxP39Ifo1M7TWu6prFO7raXxXu/h7XuyKFrTAY4/OjwkNGwG2Mu9aQ1G gADA== 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=bzkzOE355hqIqljAM5HpDyXsSE0Xgb88DMeaRs7oG5A=; b=Be0PcDB9L4+Q7qYsYk4wCm+WAO9SjhquskT+RHFdilt1rl+Sj1x81b2p1CElxkAGr8 +zpQCHyM9kcnnxHVBQaR/uBSBSkZgxAH40mQ/nygyFWycAsvJUKBMc8MGx+HFRNXpjW9 /lYAlWZb4ci6gnKZZgjlOzgIbYaa+r9k/aeFJMloX7HpumD9w9EBNeRBRTaI71r/73f+ QByY4dRCd8wCo1S5CSci7mKV5iozgp5+GwJiHdPbl9SEUc2IgbHvejTGE//vbQqmgDmB GH/IOrqQddjB5ZhEwdmhPXriFVPwyRYQHpIAZuIlp/95g/Rqg2QajiWaJW2DPH2xI9N/ TJSg== X-Gm-Message-State: AJIora8/kNc8jQm5KVu+0jp7FCNbqXUPVR6QfHsO9qjJ/2KsVzfhs/Rz LdSsTtNQPcQdsdTF1hdcf6Dh+Q== X-Google-Smtp-Source: AGRyM1tLaiEFk5UPNSD3yHAf3ofk6myCgCJqlLCWLDoubSbnhyUqfAR/rUMStUtSYmUvTHShFmNKCw== X-Received: by 2002:a05:600c:601d:b0:3a1:a02e:872a with SMTP id az29-20020a05600c601d00b003a1a02e872amr14268wmb.3.1657231503662; Thu, 07 Jul 2022 15:05:03 -0700 (PDT) Received: from henark71.. ([51.37.234.167]) by smtp.gmail.com with ESMTPSA id bn24-20020a056000061800b0020fe35aec4bsm38625743wrb.70.2022.07.07.15.05.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 15:05:02 -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 , Changbin Du , 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: [RFC 4/4] arm64: arch-topology move arm64 to the generic store_cpu_topology() Date: Thu, 7 Jul 2022 23:04:37 +0100 Message-Id: <20220707220436.4105443-5-mail@conchuod.ie> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220707220436.4105443-1-mail@conchuod.ie> References: <20220707220436.4105443-1-mail@conchuod.ie> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220707_150507_089540_19CBD281 X-CRM114-Status: GOOD ( 19.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Conor Dooley The default implementation of store_cpu_topology() was derived from the arm64 implementation, but with the mpidr bits removed. Extract the mpidr bits from the arch implementation to the callsites & use the generic version. Signed-off-by: Conor Dooley --- arch/arm64/kernel/smp.c | 16 +++++++++++++-- arch/arm64/kernel/topology.c | 40 ------------------------------------ 2 files changed, 14 insertions(+), 42 deletions(-) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 62ed361a4376..9e8acaa4c2f7 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -234,7 +234,12 @@ asmlinkage notrace void secondary_start_kernel(void) * Log the CPU info before it is marked online and might get read. */ cpuinfo_store_cpu(); - store_cpu_topology(cpu); + + /* + * Uniprocessor systems can rely on default topology values + */ + if (!(mpidr & MPIDR_UP_BITMASK)) + store_cpu_topology(cpu); /* * Enable GIC and timers. @@ -719,6 +724,7 @@ void __init smp_init_cpus(void) void __init smp_prepare_cpus(unsigned int max_cpus) { const struct cpu_operations *ops; + u64 mpidr; int err; unsigned int cpu; unsigned int this_cpu; @@ -726,7 +732,13 @@ void __init smp_prepare_cpus(unsigned int max_cpus) init_cpu_topology(); this_cpu = smp_processor_id(); - store_cpu_topology(this_cpu); + mpidr = read_cpuid_mpidr(); + + /* + * Uniprocessor systems can rely on default topology values + */ + if (!(mpidr & MPIDR_UP_BITMASK)) + store_cpu_topology(this_cpu); numa_store_cpu_info(this_cpu); numa_add_cpu(this_cpu); 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) {