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_ */