Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1544587rdd; Thu, 11 Jan 2024 02:20:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IEYW7geIiQ58sfGqOQA1Kzv/AN8E6j4iiqcmHSK0cRvxcoh2g3wDhlD/ZLA5Sris/pPMT/G X-Received: by 2002:a92:d287:0:b0:360:6e4e:e849 with SMTP id p7-20020a92d287000000b003606e4ee849mr1048109ilp.37.1704968443328; Thu, 11 Jan 2024 02:20:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704968443; cv=none; d=google.com; s=arc-20160816; b=UBj5x1OVsmTKFsxvfC/6hzYn/byCyobVsavOfdhlZ5lUo5nfOFNirA4h26sR8qDg0a hVzN6LXYDT0pgiOJcoJ0fDaY+2eEJwA22G8BpQsrXSGmeedD+tTjYTGd0AJ5T6jDOgkA zM+lDJMQuNGBaSxsvZPV0YSqQSAqOv8YZ4duSb4EFeIT8yZBxxngC3gECu/7WgetjgtD Pjoc+r9RN54te1b2stC0EuM5AKH8XitWlhQ5lmTdSUU9awc7GGoQO2qLQBF5NlAouvHx qYB/c0lFjFNk+4mcQqaOEfa7kOo1kCUnWbKCfiHcK1ZxqABuRJmNSMXhvkHyFLR8akBb WiXA== 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=ypzPq9WlvCQO45JUKeJWoXXDGTr/CervaNt1RUEStjc=; fh=knw1PiZW9grOh/iP8gH1OdZe6pWSD+MVIpthKwzYg+w=; b=FR95cuKwKFZlcKtWRfllz94h7wRnuSh10hKMinz3qLzj45q5bZUCSA9l4rLoFsUdPw 6xIuEXN1QOWMR6RyKSrHA2mLiIJiPSOuihleCKyyI6KEoKh2oY9AVjOW+ISjp0Bq9J76 LVQllAISEQ1hNHoEevy5Ex3qpnCuOSRCaBw88Xy+7HM8S6jaji0rVpfJffYGQ//GdnT9 lMtJiyRQf2rPHLnsVvMhdhjGQ0zA6OdHwlktBAUuJaibXMokDKn75xiEelPY9PxS5uEg U8eUv4xuOUFc/G9iLYZDPpcfyNEPekuXJ4k1VBBOiyyRt4Lw7NXOimn2UeTK/PhTmjsC KS8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-23378-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23378-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t22-20020a634616000000b005cdc2cc9a16si759071pga.804.2024.01.11.02.20.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 02:20:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23378-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-23378-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23378-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B0737286255 for ; Thu, 11 Jan 2024 10:20:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BB6B014AB5; Thu, 11 Jan 2024 10:20:02 +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 50C801426C; Thu, 11 Jan 2024 10:19:59 +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.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4T9gZf0gDvz6K8Kq; Thu, 11 Jan 2024 18:17:14 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 3C7501400CD; Thu, 11 Jan 2024 18:19:51 +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; Thu, 11 Jan 2024 10:19:50 +0000 Date: Thu, 11 Jan 2024 10:19:49 +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: <20240111101949.000075dc@Huawei.com> In-Reply-To: <20240102143925.00004361@Huawei.com> References: <20231215161539.00000940@Huawei.com> <5760569.DvuYhMxLoT@kreacher> <20240102143925.00004361@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 Tue, 2 Jan 2024 14:39:25 +0000 Jonathan Cameron wrote: > On Fri, 15 Dec 2023 20:47:31 +0100 > "Rafael J. Wysocki" wrote: >=20 > > On Friday, December 15, 2023 5:15:39 PM CET Jonathan Cameron wrote: =20 > > > 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= _PROCESSOR || > > > > > > > device->status.enabled; > > > > > > > else > > > > > > > return device->status.functional; > > > > > > > > > > > > > > so we only check device->status.enabled for processor-type de= vices? =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 co= de 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). =20 >=20 > Hi Rafael, >=20 > 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 whe= ther > there is anything missing >=20 > Thanks for putting this together. This is rather embarrassing... I span this up on a QEMU instance with some prints to find out we need the !acpi_device_is_processor() restriction. On my 'random' test setup it fails on one device. ACPI0017 - which I happen to know rather well. It's the weird pseudo device that lets a CXL aware OS know there is a CEDT table to probe. Whilst I really don't like that hack (it is all about making software distribution of out of tree modules easier rather than something fundamental), I'm the CXL QEMU maintainer :( Will fix that, but it shows there is at least one broken firmware out there. On plus side, Rafael's code seems to work as expected and lets that buggy firwmare carry on working :) So lets pretend the bug in qemu is a deliberate test case! Jonathan p.s. My test setup blows up later for an unrelated reason with latest kernel, so I'll be off debugging that for a while :( >=20 > Jonathan >=20 > >=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 *handl= er, > > const char *hotplug_profile_name); > > void acpi_scan_hotplug_enabled(struct acpi_hotplug_profile *hotplug, b= ool 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 *de= v); > > 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 *i= dstr, > > 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 >=20 >=20 > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel