Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6583887rdb; Tue, 2 Jan 2024 06:46:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IEAKWstro52NK46rL5GgF0pwXBMcRetk1xjAUeBrNMwBchyd11Kbg4a6ti0Ja4B+LW79aUO X-Received: by 2002:a05:6a21:a5a0:b0:197:6146:b496 with SMTP id gd32-20020a056a21a5a000b001976146b496mr99899pzc.45.1704206760117; Tue, 02 Jan 2024 06:46:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704206760; cv=none; d=google.com; s=arc-20160816; b=z/SMSj3GxFFZOEqbG0RbsXGNJYoKxFOutKwL6AvVA/DGFwHqt26bQgMhlegDUNqznN XOXl2bL10Fh0pXFe3bSQnk5DF00et4mDdfwDOKSz1Uof4FFyXuomC1eqY7dWdo9xPmMa M1ZBrQxPQwvS5f4oLlA0zFsCFcayCJf1N+OUDXv6B9bG/bTxt3A2h6e7HtPaAFUAAUb/ jVGNY3n9PBZs7+UTsM2vXp2Lmee7PCS3wP/GmBjmPMNckWxdDL3alXKA+oyzg+NJaz6Y SpXdV3540NwKgt0t9R41pWvu56F3B2GmtJhx0ebSt8aKpfpdsy5jaCaLlELAKKrsmAdD Hkig== ARC-Message-Signature: i=1; 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=5u39JlM0tCp2A1kRI1bfejiOkS3Z5L9j5XYxb0i49/I=; fh=knw1PiZW9grOh/iP8gH1OdZe6pWSD+MVIpthKwzYg+w=; b=D5pYGBuviY/oOxJdvqVILrTJFIshc4wcYoS/8Gv5pMv//IdzlI88rns5ZzwutBQ575 7kPNwwxjQ112z9/zkb1fSwns9tk3f1LF93XiUmIM8zGgWGcatSCskNa2S1iSc4DyMrYG d1Ut23BZA1Yr+GKWtahCmbv7xODsTPO18s8UAvVhRqkeCJOkkBs8w9YnFli/oUzjfrC6 6q09J2iMNvTTMXL/+qlK1vqngYS2bOK/sUBz5ak0J7OfTqr3FHq8181YHTPnaMOGj2GG sg9TEG105V9mbgtNsI5B43dDrX711ojlpGDlIEIGbgtqqK1dswChBy8BCM6g8ZVZv4wK mPJQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-14502-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14502-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d1-20020aa78e41000000b006d9b2420e50si14574131pfr.358.2024.01.02.06.45.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 06:46:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14502-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-14502-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14502-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A34E4B22320 for ; Tue, 2 Jan 2024 14:44:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E0B214A92; Tue, 2 Jan 2024 14:39:39 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org 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 B4C9614267; Tue, 2 Jan 2024 14:39:35 +0000 (UTC) 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.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4T4Fn71b29z6JB5q; Tue, 2 Jan 2024 22:37:31 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id CBC821400DB; Tue, 2 Jan 2024 22:39:27 +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.35; Tue, 2 Jan 2024 14:39:27 +0000 Date: Tue, 2 Jan 2024 14:39:25 +0000 From: Jonathan Cameron To: "Rafael J. Wysocki" CC: "Russell King (Oracle)" , "Rafael J. Wysocki" , , , , , , , , , , , , , , , Salil Mehta , Jean-Philippe Brucker , , , James Morse Subject: Re: [PATCH RFC v3 01/21] ACPI: Only enumerate enabled (or functional) devices Message-ID: <20240102143925.00004361@Huawei.com> In-Reply-To: <5760569.DvuYhMxLoT@kreacher> References: <20231215161539.00000940@Huawei.com> <5760569.DvuYhMxLoT@kreacher> 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: lhrpeml500001.china.huawei.com (7.191.163.213) To lhrpeml500005.china.huawei.com (7.191.163.240) On Fri, 15 Dec 2023 20:47:31 +0100 "Rafael J. Wysocki" wrote: > On Friday, December 15, 2023 5:15:39 PM CET Jonathan Cameron wrote: > > On Fri, 15 Dec 2023 15:31:55 +0000 > > "Russell King (Oracle)" wrote: > > =20 > > > On Thu, Dec 14, 2023 at 07:37:10PM +0100, Rafael J. Wysocki wrote: =20 > > > > On Thu, Dec 14, 2023 at 7:16=E2=80=AFPM Rafael J. Wysocki wrote: =20 > > > > > > > > > > On Thu, Dec 14, 2023 at 7:10=E2=80=AFPM Russell King (Oracle) > > > > > wrote: =20 > > > > > > I guess we need something like: > > > > > > > > > > > > if (device->status.present) > > > > > > return device->device_type !=3D ACPI_BUS_TYPE_P= ROCESSOR || > > > > > > device->status.enabled; > > > > > > else > > > > > > return device->status.functional; > > > > > > > > > > > > so we only check device->status.enabled for processor-type devi= ces? =20 > > > > > > > > > > Yes, something like this. =20 > > > >=20 > > > > However, that is not sufficient, because there are > > > > ACPI_BUS_TYPE_DEVICE devices representing processors. > > > >=20 > > > > I'm not sure about a clean way to do it ATM. =20 > > >=20 > > > Ok, how about: > > >=20 > > > static bool acpi_dev_is_processor(const struct acpi_device *device) > > > { > > > struct acpi_hardware_id *hwid; > > >=20 > > > if (device->device_type =3D=3D ACPI_BUS_TYPE_PROCESSOR) > > > return true; > > >=20 > > > if (device->device_type !=3D ACPI_BUS_TYPE_DEVICE) > > > return false; > > >=20 > > > list_for_each_entry(hwid, &device->pnp.ids, list) > > > if (!strcmp(ACPI_PROCESSOR_OBJECT_HID, hwid->id) || > > > !strcmp(ACPI_PROCESSOR_DEVICE_HID, hwid->id)) > > > return true; > > >=20 > > > return false; > > > } > > >=20 > > > and then: > > >=20 > > > if (device->status.present) > > > return !acpi_dev_is_processor(device) || device->status.enabled; > > > else > > > return device->status.functional; > > >=20 > > > ? > > > =20 > > Changing it to CPU only for now makes sense to me and I think this code= snippet should do the > > job. Nice and simple. =20 >=20 > Well, except that it does checks that are done elsewhere slightly > differently, which from the maintenance POV is not nice. >=20 > Maybe something like the appended patch (untested). Hi Rafael, As far as I can see that's functionally equivalent, so looks good to me. I'm not set up to test this today though, so will defer to Russell on wheth= er there is anything missing Thanks for putting this together. Jonathan >=20 > --- > drivers/acpi/acpi_processor.c | 11 +++++++++++ > drivers/acpi/internal.h | 3 +++ > drivers/acpi/scan.c | 24 +++++++++++++++++++++++- > 3 files changed, 37 insertions(+), 1 deletion(-) >=20 > Index: linux-pm/drivers/acpi/acpi_processor.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- linux-pm.orig/drivers/acpi/acpi_processor.c > +++ linux-pm/drivers/acpi/acpi_processor.c > @@ -644,6 +644,17 @@ static struct acpi_scan_handler processo > }, > }; > =20 > +bool acpi_device_is_processor(const struct acpi_device *adev) > +{ > + if (adev->device_type =3D=3D ACPI_BUS_TYPE_PROCESSOR) > + return true; > + > + if (adev->device_type !=3D ACPI_BUS_TYPE_DEVICE) > + return false; > + > + return acpi_scan_check_handler(adev, &processor_handler); > +} > + > static int acpi_processor_container_attach(struct acpi_device *dev, > const struct acpi_device_id *id) > { > Index: linux-pm/drivers/acpi/internal.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- linux-pm.orig/drivers/acpi/internal.h > +++ linux-pm/drivers/acpi/internal.h > @@ -62,6 +62,8 @@ void acpi_sysfs_add_hotplug_profile(stru > int acpi_scan_add_handler_with_hotplug(struct acpi_scan_handler *handler, > const char *hotplug_profile_name); > void acpi_scan_hotplug_enabled(struct acpi_hotplug_profile *hotplug, boo= l val); > +bool acpi_scan_check_handler(const struct acpi_device *adev, > + struct acpi_scan_handler *handler); > =20 > #ifdef CONFIG_DEBUG_FS > extern struct dentry *acpi_debugfs_dir; > @@ -133,6 +135,7 @@ int acpi_bus_register_early_device(int t > const struct acpi_device *acpi_companion_match(const struct device *dev); > int __acpi_device_uevent_modalias(const struct acpi_device *adev, > struct kobj_uevent_env *env); > +bool acpi_device_is_processor(const struct acpi_device *adev); > =20 > /* ---------------------------------------------------------------------= ----- > Power Resource > Index: linux-pm/drivers/acpi/scan.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- linux-pm.orig/drivers/acpi/scan.c > +++ linux-pm/drivers/acpi/scan.c > @@ -1938,6 +1938,19 @@ static bool acpi_scan_handler_matching(s > return false; > } > =20 > +bool acpi_scan_check_handler(const struct acpi_device *adev, > + struct acpi_scan_handler *handler) > +{ > + struct acpi_hardware_id *hwid; > + > + list_for_each_entry(hwid, &adev->pnp.ids, list) { > + if (acpi_scan_handler_matching(handler, hwid->id, NULL)) > + return true; > + } > + > + return false; > +} > + > static struct acpi_scan_handler *acpi_scan_match_handler(const char *ids= tr, > const struct acpi_device_id **matchid) > { > @@ -2410,7 +2423,16 @@ bool acpi_dev_ready_for_enumeration(cons > if (device->flags.honor_deps && device->dep_unmet) > return false; > =20 > - return acpi_device_is_present(device); > + if (device->status.functional) > + return true; > + > + if (!device->status.present) > + return false; > + > + if (device->status.enabled) > + return true; /* Fast path. */ > + > + return !acpi_device_is_processor(device); > } > EXPORT_SYMBOL_GPL(acpi_dev_ready_for_enumeration); > =20 >=20 >=20 >=20