Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3842909rdb; Thu, 14 Sep 2023 04:37:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEfYzQeHTT48mjKlxuxOQFLHWj3KhWG5JLmQOby/Gx+X2cE0p2tczZg+nwHJ+yfeUTo3DqF X-Received: by 2002:a05:6870:220d:b0:1d0:f0a9:b3f2 with SMTP id i13-20020a056870220d00b001d0f0a9b3f2mr5199337oaf.48.1694691467605; Thu, 14 Sep 2023 04:37:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694691467; cv=none; d=google.com; s=arc-20160816; b=PmQsqGUP7zhqtQ+TMDztd2SDB9yfv1ImE2U9I63DSy25Va4g+OwqH/KjwnzIULPFoj y8v6fun/9UKQW5YnGzkYLCEtSdbHBHkrx+86t1S+9y8DmvXm/U3nSdaAqNB2Mf5vH/kQ lC6gEFpKInNQvOCaHMchy3m/YNW94Cd6aAUEA0Q1+arqDYLccLJWHwbNDHt5s2KEf8vQ ytX9E64dSOympWKWFNHz3okOP9I34ye5E7CiH5i7ujfQQfNh4UuSwqsfVrlvmsb/eZXf ZVO6mbYYGzpzoCanMd4K2ql6diR3WpNheQu7ybEH1ohUdvcJsOn70kd5YCSNn7qlcooj 19mA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=TiHQ03SFcOgdjEvdFvF5FU3FwIqtPT5YRbGpddft+jM=; fh=oO43h3w0Gnh1/uzgjBLTRg+oe1Gv6aFHPIod5z8aS5s=; b=g/3PViP55+/zmOHDJbiFgtcK7wSqN+JAZVwGort/DgUS55XeL0KnYxbcfbnUpyK3Wa oK8SImoatg1XtLJTgb+JAJ8mpuRLxDKcgvN1Eavu/6KQMHqmSNS5eHkRNTxTrzRM/tSI /ZgHcQtCz+OnqglyXUkjZrVI2rBIszj8thGU324633NaPKYsSf14kWxrmsSEwlg0/yFI VRkcI/oXzNaT6XlXzt4uSO/qsYKm3KGhd99VQ+ren/76+wsgkRNn5pUUJhlyqQSDnjVw miukI3vR9w9UvZIQO9/Tvo9s7H6289tg+GgZmNBkQ9YqpQSGnFnj+aSPm8+fKStWgE0j 0RUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id m15-20020a633f0f000000b00573f9a427cesi1318962pga.47.2023.09.14.04.37.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 04:37:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D925C82F27ED; Thu, 14 Sep 2023 04:27:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238119AbjINL12 (ORCPT + 99 others); Thu, 14 Sep 2023 07:27:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237872AbjINL1X (ORCPT ); Thu, 14 Sep 2023 07:27:23 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD7661FC9; Thu, 14 Sep 2023 04:27:18 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4RmZkL5jfYz6HJbR; Thu, 14 Sep 2023 19:25:30 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 14 Sep 2023 12:27:16 +0100 Date: Thu, 14 Sep 2023 12:27:15 +0100 From: Jonathan Cameron To: James Morse CC: , , , , , , , , , Salil Mehta , Russell King , Jean-Philippe Brucker , , Subject: Re: [RFC PATCH v2 06/35] arm64: setup: Switch over to GENERIC_CPU_DEVICES using arch_register_cpu() Message-ID: <20230914122715.000076be@Huawei.com> In-Reply-To: <20230913163823.7880-7-james.morse@arm.com> References: <20230913163823.7880-1-james.morse@arm.com> <20230913163823.7880-7-james.morse@arm.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml100004.china.huawei.com (7.191.162.219) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected 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 (snail.vger.email [0.0.0.0]); Thu, 14 Sep 2023 04:27:28 -0700 (PDT) On Wed, 13 Sep 2023 16:37:54 +0000 James Morse wrote: > To allow ACPI's _STA value to hide CPUs that are present, but not > available to online right now due to VMM or firmware policy, the > register_cpu() call needs to be made by the ACPI machinery when ACPI > is in use. This allows it to hide CPUs that are unavailable from sysfs. > > Switching to GENERIC_CPU_DEVICES is an intermediate step to allow all > five ACPI architectures to be modified at once. > > Switch over to GENERIC_CPU_DEVICES, and provide an arch_register_cpu() > that populates the hotpluggable flag. arch_register_cpu() is also the > interface the ACPI machinery expects. > > The struct cpu in struct cpuinfo_arm64 is never used directly, remove > it to use the one GENERIC_CPU_DEVICES provides. > > This changes the CPUs visible in sysfs from possible to present, but > on arm64 smp_prepare_cpus() ensures these are the same. > > Signed-off-by: James Morse After this the earlier question about ordering of cpu_dev_init() and node_dev_init() is relevant. Why won't node_dev_init() call get_cpu_devce() which queries per_cpu(cpu_sys_devices) and get NULL as we haven't yet filled that in? Or does it do so but that doesn't matter as well create the relevant links later? I've not had enough coffee yet today so might be missing the obvious! Jonathan > --- > arch/arm64/Kconfig | 1 + > arch/arm64/include/asm/cpu.h | 1 - > arch/arm64/kernel/setup.c | 13 ++++--------- > 3 files changed, 5 insertions(+), 10 deletions(-) > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > index b10515c0200b..7b3990abf87a 100644 > --- a/arch/arm64/Kconfig > +++ b/arch/arm64/Kconfig > @@ -132,6 +132,7 @@ config ARM64 > select GENERIC_ARCH_TOPOLOGY > select GENERIC_CLOCKEVENTS_BROADCAST > select GENERIC_CPU_AUTOPROBE > + select GENERIC_CPU_DEVICES > select GENERIC_CPU_VULNERABILITIES > select GENERIC_EARLY_IOREMAP > select GENERIC_IDLE_POLL_SETUP > diff --git a/arch/arm64/include/asm/cpu.h b/arch/arm64/include/asm/cpu.h > index e749838b9c5d..887bd0d992bb 100644 > --- a/arch/arm64/include/asm/cpu.h > +++ b/arch/arm64/include/asm/cpu.h > @@ -38,7 +38,6 @@ struct cpuinfo_32bit { > }; > > struct cpuinfo_arm64 { > - struct cpu cpu; > struct kobject kobj; > u64 reg_ctr; > u64 reg_cntfrq; > diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c > index 417a8a86b2db..165bd2c0dd5a 100644 > --- a/arch/arm64/kernel/setup.c > +++ b/arch/arm64/kernel/setup.c > @@ -402,19 +402,14 @@ static inline bool cpu_can_disable(unsigned int cpu) > return false; > } > > -static int __init topology_init(void) > +int arch_register_cpu(int num) > { > - int i; > + struct cpu *cpu = &per_cpu(cpu_devices, num); > > - for_each_possible_cpu(i) { > - struct cpu *cpu = &per_cpu(cpu_data.cpu, i); > - cpu->hotpluggable = cpu_can_disable(i); > - register_cpu(cpu, i); > - } > + cpu->hotpluggable = cpu_can_disable(num); > > - return 0; > + return register_cpu(cpu, num); > } > -subsys_initcall(topology_init); > > static void dump_kernel_offset(void) > {