Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1961915rda; Tue, 24 Oct 2023 08:19:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGPPCl91d+axXKZ1lJV9uj1XxtoPXDytJpojlDCR6VClVyx2o+AVcv5s79vUvDLCESPhtDL X-Received: by 2002:a17:90b:608:b0:27d:44ce:cf7a with SMTP id gb8-20020a17090b060800b0027d44cecf7amr10864826pjb.5.1698160778786; Tue, 24 Oct 2023 08:19:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698160778; cv=none; d=google.com; s=arc-20160816; b=UG4clBZvhxYedXhz+KKXukHZ22Vm8SyOCq5yE+m9lk+VW6wSnjukfiDdCPd9s8G9Hw v5m7dWhpgwCBZwxZ1eWEka/v/+23NMG4OAMiwfGHexOVFTTbxo1IOqMwax/4WlZu3sJB iabt+tFN9wTJq5luNj1dq3+DwbevgqJusMzw6WRPxeTZjIbvj1JqAVSHvLu10NljcVo1 Q5vbw+hvrFTlPzLfOmTTdGagpOqDiem4vc9TqloI13SP4i6fNF/uMwACr8+zVaB0sl7x C5niqaumC/c8XB2YiB/y2t3NM8MVpdti2f81OiMEx12wISFOhoB/vipdoMN9K40dpQF+ reWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:sender:message-id:content-transfer-encoding :content-disposition:mime-version:subject:cc:to:from:references :in-reply-to:dkim-signature; bh=CjScRbjimPWolEjPv1iNmcYG5tuVKE74LVx0kYeqVqg=; fh=n/hNKOBwq2yLiZtHUXdrVYIb15Q112aXmz8Dk56reME=; b=cHAVW9Kkba/atXBnQsrnt1Anp/r0w88s2zoYRrrq+Wjtta1RWnA5939pIf67xsxsQ4 ZbwZjSezN/yCmhQD1YGSd4w7jPQcvQJezZEmJuZQqmQaQeo6NOAm0p1hArC2jDFc4WIM iF/0UYNWvjUa3jxTPPOXa4/4sE07XLxbDyzycAhDbjYKoKbFJ2iFBZkzr7GoT0ycKAzv levu6skLdj201q+6oldOWs6fsp+/qlQn9nEkL9TZrlsjpBzSYj4vDnJE6g7htd2Vypag kFblmPD3D8ccaf2k+s3HA7VLs0Sug0MPznpsk8fDcUhV1S+zVsOERu8I+T3obUGY2yom tAOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=vWxJVtsg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id c12-20020a17090a8d0c00b002748c1bbd79si11344916pjo.6.2023.10.24.08.19.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 08:19:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=vWxJVtsg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 054B48028A60; Tue, 24 Oct 2023 08:19:34 -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 S1343640AbjJXPTT (ORCPT + 99 others); Tue, 24 Oct 2023 11:19:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234736AbjJXPS0 (ORCPT ); Tue, 24 Oct 2023 11:18:26 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9BA4199A; Tue, 24 Oct 2023 08:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=CjScRbjimPWolEjPv1iNmcYG5tuVKE74LVx0kYeqVqg=; b=vWxJVtsg7WAxV+31eW086kiVVz +Nfq4GNnO/goU36WX82JXeCpyz1NRsTtPu+wCbSUfXCIxDEs8V2oWVRggK16YBGzFFxeQ+OnMmZJx SKduHKqxOYaitZ5qSYpjaCC0mvbjdemJ7HST9R8ycAJWqs8qXQ/6cjIBtkPQnUeXcUewNThjp+aOB 3aqMMgcdALK6mkVwT0lgVBdBJKtVLR6yPuBhyST5VM/0eclmOmMma1u7G/bGi/oWtm9qAcpwTa/tA rxS9YGk4y0z9idXXB4mRIJ5H2iWjMlEX9mJu2motC/v1mbTTHrodN2WdAL7T9Y+SC/cMdxPfwyp5P 9dxgHRjw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:34774 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qvJ9o-0004Pd-3B; Tue, 24 Oct 2023 16:17:25 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qvJ9q-00AqQI-F8; Tue, 24 Oct 2023 16:17:26 +0100 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse , Huacai Chen , WANG Xuerui Subject: [PATCH 15/39] LoongArch: Switch over to GENERIC_CPU_DEVICES MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" Message-Id: Sender: Russell King Date: Tue, 24 Oct 2023 16:17:26 +0100 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, 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 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]); Tue, 24 Oct 2023 08:19:34 -0700 (PDT) From: James Morse 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. This allows topology_init() to be removed. 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. This is a subtle change. Originally: - on boot, topology_init() would have marked present CPUs that io_master() is true for as hotplug-incapable. - if a CPU is hotplugged that is an io_master(), it can later be hot-unplugged. The new behaviour is that any CPU that io_master() is true for will now always be marked as hotplug-incapable, thus even if it was hotplugged, it can no longer be hot-unplugged. This patch also has the effect of moving the registration of CPUs from subsys to driver core initialisation, prior to any initcalls running. Signed-off-by: James Morse Signed-off-by: Russell King (Oracle) --- Changes since RFC v2: * Explain the change in behaviour in the patch description (highlighted by Jonathan Cameron - thanks.) Add note about initialisation order change. --- arch/loongarch/Kconfig | 1 + arch/loongarch/kernel/topology.c | 29 ++--------------------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index 2bddd202470e..5bed51adc68c 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -72,6 +72,7 @@ config LOONGARCH select GENERIC_CLOCKEVENTS select GENERIC_CMOS_UPDATE select GENERIC_CPU_AUTOPROBE + select GENERIC_CPU_DEVICES select GENERIC_ENTRY select GENERIC_GETTIMEOFDAY select GENERIC_IOREMAP if !ARCH_IOREMAP diff --git a/arch/loongarch/kernel/topology.c b/arch/loongarch/kernel/topology.c index 3fd166006698..bf58351beac1 100644 --- a/arch/loongarch/kernel/topology.c +++ b/arch/loongarch/kernel/topology.c @@ -10,20 +10,13 @@ #include -static DEFINE_PER_CPU(struct cpu, cpu_devices); - #ifdef CONFIG_HOTPLUG_CPU int arch_register_cpu(int cpu) { - int ret; struct cpu *c = &per_cpu(cpu_devices, cpu); - c->hotpluggable = 1; - ret = register_cpu(c, cpu); - if (ret < 0) - pr_warn("register_cpu %d failed (%d)\n", cpu, ret); - - return ret; + c->hotpluggable = !io_master(cpu); + return register_cpu(c, cpu); } EXPORT_SYMBOL(arch_register_cpu); @@ -36,21 +29,3 @@ void arch_unregister_cpu(int cpu) } EXPORT_SYMBOL(arch_unregister_cpu); #endif - -static int __init topology_init(void) -{ - int i, ret; - - for_each_present_cpu(i) { - struct cpu *c = &per_cpu(cpu_devices, i); - - c->hotpluggable = !io_master(i); - ret = register_cpu(c, i); - if (ret < 0) - pr_warn("topology_init: register_cpu %d failed (%d)\n", i, ret); - } - - return 0; -} - -subsys_initcall(topology_init); -- 2.30.2