Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1354931lqp; Mon, 15 Apr 2024 04:13:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXoBH5uj9AZgkKeltCiPdLwc1fqc2N5Uf/S5gWrsgMy+ZIXKhfwxU3MYT45TeuFGByw3fgBiO2OZBpMMi++TTbqqwjgPaPKFwWgAJGXiA== X-Google-Smtp-Source: AGHT+IHuG3uvGv+G+IryAHZh/GV8GhrAJ8JNOjAPrqMzQK980FfvujZVWmHgkMEwzMwIaqaRNdRy X-Received: by 2002:a50:9556:0:b0:568:a655:49c6 with SMTP id v22-20020a509556000000b00568a65549c6mr7613840eda.8.1713179634001; Mon, 15 Apr 2024 04:13:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713179633; cv=pass; d=google.com; s=arc-20160816; b=ZAQA6FLoyULWwrjGTwouWk9G8X9PXRyOtZVJip1kU4+RNwbbfg8HRsPDQ3rrxxFwP4 W771A0coPLAxgJTLlioB1R/F8vO7rnvX6sDQsnBFZpcueraDSAoE1zfd/h/ar8zWWGmL cuAmvWXTp6cldKVaul+n1c3TwSzBdREhEl7bFxKVJI7sOJCAHOO55KG4TQjZ4itDzh8c aQoptiYe09nrOtz+kQ4fgJvWao9fMrNx0+Klhze+oVYGfXPAYkSl3qQvtoTE9CEsAbHx vjXIukG1vQ3L92yLLsuYFaP8ZmRAcs5pptKgeYsm02aVqyLkupDiSaSPQabsSll1U6A0 v/MQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date; bh=nEk/wkKhmDHcH6W5ZeJ4gV+wKwYG5yUriMBxjx38BHE=; fh=4Z17oT/oiPjOdZCNrsdgXoPa6+QMB+qkBOunD7ptTrU=; b=fhnfE+wrAMsZC84hV5xuSBO2Nd8BTjT2S2NFyeIuYY1chFR5Xtk/emLENm2Yy86JRk +cqvBceiHIi/YmEDOtatVg2OrYkN/GhjNdGvugr7+2HB//ePJRFUlmPwTbDy3gzrofGc cyvXzi+Gef4mEDBw0N0K5et5KfAKsGFlFMIIrU4NF90NZVXw2uIK6A/+iwXVN6KgwieU nYtW8qqzEFZ2POnd4FneavL1/ZrbHZLsVesKkfC44G/tYBt3yM3W47j/Pl9vafkvIobL TRnMOeuP/wB1JhTrv9RZQ7Gz0FlpoXe7QgqVqjhBt7vFKbedjd8Odmo8jVKy39NRFXaJ FOWw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-144942-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144942-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 21-20020a508e55000000b005700f5e070esi2437098edx.312.2024.04.15.04.13.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 04:13:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-144942-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-144942-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144942-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C24BE1F2416E for ; Mon, 15 Apr 2024 10:52:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 876725D494; Mon, 15 Apr 2024 10:52:13 +0000 (UTC) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 425735D465; Mon, 15 Apr 2024 10:52:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713178332; cv=none; b=hWXmGqKUPJg4P1v9eXnZCaXlH+LW1pKU3AuaaZkgiqmaWNooIPKfK+LD/5FwWVALhboFgLQuG7B6xSi9YegZBmk4yzpMYV0In+mfsqYeUPFhvOJBCweaqIFJxJv3TMxHK4tkajbGAJFvR01oLmIK9OvZEZxDAPrO2Lv/WQfxwcY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713178332; c=relaxed/simple; bh=YjzZLPQbXgfdGlGbGlYWn308Tq/4T7rk/4RnIScxBMU=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jGVkxz3RPwwHmqkvL0Q/eG0QovHsDcAozyYNfEJacMGdsQqfdoyr0yPlPbZLDisJOvd10k0JFo6WjwNKmayFeU1/xKx0rUD554kOfD/tUj7bkO6ZsVhXYFY6i9c+aon5l7Fkv1QvqD0aojmMD3DFLEQdI++r6FKIP6JfbdShxrY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4VJ3lL5dzRz6K919; Mon, 15 Apr 2024 18:47:10 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 5943D140A08; Mon, 15 Apr 2024 18:52:05 +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_256_GCM_SHA384) id 15.1.2507.35; Mon, 15 Apr 2024 11:52:04 +0100 Date: Mon, 15 Apr 2024 11:52:03 +0100 From: Jonathan Cameron To: "Rafael J. Wysocki" CC: , , , , , , , , Russell King , Miguel Luis , James Morse , Salil Mehta , "Jean-Philippe Brucker" , Catalin Marinas , Will Deacon , , , Subject: Re: [PATCH v5 03/18] ACPI: processor: Register deferred CPUs from acpi_processor_get_info() Message-ID: <20240415115203.0000011b@Huawei.com> In-Reply-To: References: <20240412143719.11398-1-Jonathan.Cameron@huawei.com> <20240412143719.11398-4-Jonathan.Cameron@huawei.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: lhrpeml100002.china.huawei.com (7.191.160.241) To lhrpeml500005.china.huawei.com (7.191.163.240) On Fri, 12 Apr 2024 20:30:40 +0200 "Rafael J. Wysocki" wrote: > On Fri, Apr 12, 2024 at 4:38=E2=80=AFPM Jonathan Cameron > wrote: > > > > From: James Morse > > > > The arm64 specific arch_register_cpu() call may defer CPU registration > > until the ACPI interpreter is available and the _STA method can > > be evaluated. > > > > If this occurs, then a second attempt is made in > > acpi_processor_get_info(). Note that the arm64 specific call has > > not yet been added so for now this will never be successfully > > called. > > > > Systems can still be booted with 'acpi=3Doff', or not include an > > ACPI description at all as in these cases arch_register_cpu() > > will not have deferred registration when first called. > > > > This moves the CPU register logic back to a subsys_initcall(), > > while the memory nodes will have been registered earlier. > > Note this is where the call was prior to the cleanup series so > > there should be no side effects of moving it back again for this > > specific case. > > > > [PATCH 00/21] Initial cleanups for vCPU HP. > > https://lore.kernel.org/all/ZVyz%2FVe5pPu8AWoA@shell.armlinux.org.uk/ > > > > e.g. 5b95f94c3b9f ("x86/topology: Switch over to GENERIC_CPU_DEVICES") > > > > Signed-off-by: James Morse > > Reviewed-by: Gavin Shan > > Tested-by: Miguel Luis > > Tested-by: Vishnu Pajjuri > > Tested-by: Jianyong Wu > > Signed-off-by: Russell King (Oracle) > > Co-developed-by: Jonathan Cameron > > Signed-off-by: Joanthan Cameron > > --- > > v5: Update commit message to make it clear this is moving the > > init back to where it was until very recently. > > > > No longer change the condition in the earlier registration point > > as that will be handled by the arm64 registration routine > > deferring until called again here. > > --- > > drivers/acpi/acpi_processor.c | 12 ++++++++++++ > > 1 file changed, 12 insertions(+) > > > > diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processo= r.c > > index 93e029403d05..c78398cdd060 100644 > > --- a/drivers/acpi/acpi_processor.c > > +++ b/drivers/acpi/acpi_processor.c > > @@ -317,6 +317,18 @@ static int acpi_processor_get_info(struct acpi_dev= ice *device) > > > > c =3D &per_cpu(cpu_devices, pr->id); > > ACPI_COMPANION_SET(&c->dev, device); > > + /* > > + * Register CPUs that are present. get_cpu_device() is used to = skip > > + * duplicate CPU descriptions from firmware. > > + */ > > + if (!invalid_logical_cpuid(pr->id) && cpu_present(pr->id) && > > + !get_cpu_device(pr->id)) { > > + int ret =3D arch_register_cpu(pr->id); > > + > > + if (ret) > > + return ret; > > + } > > + > > /* > > * Extra Processor objects may be enumerated on MP systems with > > * less than the max # of CPUs. They should be ignored _iff > > -- =20 >=20 > I am still unsure why there need to be two paths calling > arch_register_cpu() in acpi_processor_get_info(). I replied further down the thread, but the key point was to maintain the strong distinction between 'what' was done in a real hotplug path vs one where onlining was all. We can relax that but it goes contrary to the careful dance that was needed to get any agreement to the ARM architecture aspects of this. >=20 > Just below the comment partially pulled into the patch context above, > there is this code: >=20 > if (invalid_logical_cpuid(pr->id) || !cpu_present(pr->id)) { > int ret =3D acpi_processor_hotadd_init(pr); >=20 > if (ret) > return ret; > } >=20 > For the sake of the argument, fold acpi_processor_hotadd_init() into > it and drop the redundant _STA check from it: If we combine these, the _STA check is necessary because we will call this path for delayed onlining of ARM64 CPUs (if the earlier registration code call or arch_register_cpu() returned -EPROBE defer). That's the only way we know that a given CPU is online capable but firmware is saying we can't bring it online yet (it may be be vHP later). >=20 > if (invalid_logical_cpuid(pr->id) || !cpu_present(pr->id)) { > if (invalid_phys_cpuid(pr->phys_id)) > return -ENODEV; >=20 > cpu_maps_update_begin(); > cpus_write_lock(); >=20 > ret =3D acpi_map_cpu(pr->handle, pr->phys_id, pr->acpi_id, &pr->id= ); I read that call as acpi_map_cpu_for_physical_cpu_hotplug() but we could make it equivalent of. acpi_map_cpu_for_whatever_cpu_hotplug() (I'm not proposing those names though ;) in which case it is fine to just stub it out on ARM64. > if (ret) { > cpus_write_unlock(); > cpu_maps_update_done(); > return ret; > } > ret =3D arch_register_cpu(pr->id); > if (ret) { > acpi_unmap_cpu(pr->id); >=20 > cpus_write_unlock(); > cpu_maps_update_done(); > return ret; > } > pr_info("CPU%d has been hot-added\n", pr->id); > pr->flags.need_hotplug_init =3D 1; This one needs more careful handling because we are calling this for non hotplug cases on arm64 in which case we end up setting this for initially online CPUs - thus if we offline and online them again via sysfs /sys/bus/cpu/device/cpuX/online it goes through the hotplug path and should not. So I need a way to detect if we are hotplugging the cpu or not. Is there a standard way to do this? I haven't figured out how to use flags in drivers to communicate this state. >=20 > cpus_write_unlock(); > cpu_maps_update_done(); > } >=20 > so I'm not sure why this cannot be combined with the new code. >=20 > Say acpi_map_cpu) / acpi_unmap_cpu() are turned into arch calls. > What's the difference then? The locking, which should be fine if I'm > not mistaken and need_hotplug_init that needs to be set if this code > runs after the processor driver has loaded AFAICS. That's the bit that I'm currently finding a challenge. Is there a clean way to detect that? Jonathan