Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3369776rdb; Wed, 13 Sep 2023 09:55:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPueLBheeqhdBQ6sWUhjeHrltL9D3KoxI2Rui+vZjRdSlvdOGuo+LVl2Y/oHZTPRu+YPVH X-Received: by 2002:a05:6a21:a5a2:b0:138:68b9:138e with SMTP id gd34-20020a056a21a5a200b0013868b9138emr10005538pzc.8.1694624133703; Wed, 13 Sep 2023 09:55:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694624133; cv=none; d=google.com; s=arc-20160816; b=uuX6PbVB9loqU3kyb+2D6KZUFYkCtknf+4V6QGTuk2L/fx4YB4eBqY3hw4tdRh177Y bCKyrbWn5iN1xOxdhz2uZ+oNxl38wW7WpyMy9mz+o28nCmAaXC18VV+2/swjmkpnJl5m cZvJJVlY9dzdhZCoD2ei3tCvZLAJ//KihJKvW2l1pTjW6MXilWE0yxcp5r+/xfCI5XDz PCydAYdxUjz3v+xz41xfYrn6wwn+N9YE9NTyx6Zjz5dZ+aQDJc1T13IamSRtY83dK7bI 6gqWDJVpffaS7ME440lhEdwgE6cXX2+ZDI1el/Dnct9P2fQiMiqVgI7GBU/hZLT0vo0M eM7A== 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; bh=9ek+nplbfDwxpAsQ1Ja4J48DdQa+1sowmJSgspWq1QE=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=UVtOh+cNr1qKa2vfnQV9zHI/bztx9nvw68kcn5GfbO7W51ibf+33KR7Vjw43nSAp8U g2DGXXRtj0+mumMXqF2m5dq7FKFHJMloKKAMfNSlhdRlqwgYEH7YhmUbCW6rFF8Tu/x5 AEkbXyoAbVkgGiaU0/j1qTkiVfCKT03LU7JHuFC1KFNhgr1gPMbQ4GUHO4xC7RDXKrWV tRwyXlVQfB8BSyc8//aJYsGyjG0ricEWPFuT4AFbYWUwoH5blM81SBkGj9VxpsKTvyZq 0tzFUJmC7sZSSFy5DhgnVbs9EJYrDhLIXj4ybvK5wYYCOdcjA/6PG+hJoJ3lHdyX5UeA c9kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id n11-20020a63e04b000000b0056546b5fef4si10458122pgj.232.2023.09.13.09.55.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:55:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0C84E8043EDC; Wed, 13 Sep 2023 09:39:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231129AbjIMQjj (ORCPT + 99 others); Wed, 13 Sep 2023 12:39:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230453AbjIMQjR (ORCPT ); Wed, 13 Sep 2023 12:39:17 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 42CD01BDD; Wed, 13 Sep 2023 09:39:09 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 42417FEC; Wed, 13 Sep 2023 09:39:46 -0700 (PDT) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 47AE03F5A1; Wed, 13 Sep 2023 09:39:07 -0700 (PDT) From: James Morse To: linux-pm@vger.kernel.org, loongarch@lists.linux.dev, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, kvmarm@lists.linux.dev Cc: x86@kernel.org, Salil Mehta , Russell King , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com Subject: [RFC PATCH v2 08/35] x86/topology: Switch over to GENERIC_CPU_DEVICES Date: Wed, 13 Sep 2023 16:37:56 +0000 Message-Id: <20230913163823.7880-9-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230913163823.7880-1-james.morse@arm.com> References: <20230913163823.7880-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:39:42 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Now that GENERIC_CPU_DEVICES calls arch_register_cpu(), which can be overridden by the arch code, switch over to this to allow common code to choose when the register_cpu() call is made. x86's struct cpus come from struct x86_cpu, which has no other members or users. Remove this and use the version defined by common code. This is an intermediate step to the logic being moved to drivers/acpi, where GENERIC_CPU_DEVICES will do the work when booting with acpi=off. Signed-off-by: James Morse ---- Changes since RFC: * Fixed the second copy of arch_register_cpu() used for non-hotplug --- arch/x86/Kconfig | 1 + arch/x86/include/asm/cpu.h | 4 ---- arch/x86/kernel/topology.c | 25 ++++++------------------- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index a0100a1ab4a0..133ea5f561b5 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -148,6 +148,7 @@ config X86 select GENERIC_CLOCKEVENTS_MIN_ADJUST select GENERIC_CMOS_UPDATE select GENERIC_CPU_AUTOPROBE + select GENERIC_CPU_DEVICES select GENERIC_CPU_VULNERABILITIES select GENERIC_EARLY_IOREMAP select GENERIC_ENTRY diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h index 96dc4665e87d..f349c94510e8 100644 --- a/arch/x86/include/asm/cpu.h +++ b/arch/x86/include/asm/cpu.h @@ -23,10 +23,6 @@ static inline void prefill_possible_map(void) {} #endif /* CONFIG_SMP */ -struct x86_cpu { - struct cpu cpu; -}; - #ifdef CONFIG_HOTPLUG_CPU extern void arch_unregister_cpu(int); extern void soft_restart_cpu(void); diff --git a/arch/x86/kernel/topology.c b/arch/x86/kernel/topology.c index 0bab03130033..ca08a1d138f0 100644 --- a/arch/x86/kernel/topology.c +++ b/arch/x86/kernel/topology.c @@ -35,38 +35,25 @@ #include #include -static DEFINE_PER_CPU(struct x86_cpu, cpu_devices); - #ifdef CONFIG_HOTPLUG_CPU int arch_register_cpu(int cpu) { - struct x86_cpu *xc = per_cpu_ptr(&cpu_devices, cpu); + struct cpu *c = per_cpu_ptr(&cpu_devices, cpu); - xc->cpu.hotpluggable = cpu > 0; - return register_cpu(&xc->cpu, cpu); + c->hotpluggable = cpu > 0; + return register_cpu(c, cpu); } EXPORT_SYMBOL(arch_register_cpu); void arch_unregister_cpu(int num) { - unregister_cpu(&per_cpu(cpu_devices, num).cpu); + unregister_cpu(&per_cpu(cpu_devices, num)); } EXPORT_SYMBOL(arch_unregister_cpu); #else /* CONFIG_HOTPLUG_CPU */ -int __init arch_register_cpu(int num) +int arch_register_cpu(int num) { - return register_cpu(&per_cpu(cpu_devices, num).cpu, num); + return register_cpu(&per_cpu(cpu_devices, num), num); } #endif /* CONFIG_HOTPLUG_CPU */ - -static int __init topology_init(void) -{ - int i; - - for_each_present_cpu(i) - arch_register_cpu(i); - - return 0; -} -subsys_initcall(topology_init); -- 2.39.2