From: Hans de Goede Subject: Re: [PATCH] ACPI / device_sysfs: Leave modalias empty for devices which are not present Date: Mon, 30 Oct 2017 14:14:21 +0100 Message-ID: References: <20171015192449.16035-1-hdegoede@redhat.com> <2550330b-38ff-28b1-6294-d55462c03cca@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Return-path: Received: from mx1.redhat.com ([209.132.183.28]:42760 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751378AbdJ3NOb (ORCPT ); Mon, 30 Oct 2017 09:14:31 -0400 In-Reply-To: <2550330b-38ff-28b1-6294-d55462c03cca@redhat.com> Content-Language: en-US Sender: linux-acpi-owner@vger.kernel.org List-Id: linux-acpi@vger.kernel.org To: "Rafael J. Wysocki" Cc: "Rafael J . Wysocki" , Len Brown , ACPI Devel Maling List Hi, On 16-10-17 13:44, Hans de Goede wrote: > Hi, > > On 16-10-17 01:47, Rafael J. Wysocki wrote: >> On Sun, Oct 15, 2017 at 9:24 PM, Hans de Goede wrote: >>> Most Bay and Cherry Trail devices use a generic DSDT with all possible >>> peripheral devices present in the DSDT, with their _STA returning 0x00 or >>> 0x0f based on AML variables which describe what is actually present on >>> the board. >>> >>> Since ACPI device objects with a 0x00 status (not present) still get an >>> entry under /sys/bus/acpi/devices, and those entry had an acpi:PNPID >>> modalias, userspace would end up loading modules for non present hardware. >>> >>> This commit fixes this by leaving the modalias empty for non present >>> devices. This results in 10 modules less being loaded with a generic >>> distro kernel config on my Cherry Trail test-device (a GPD pocket). >> >> Well, what about hotplug? >> >> On some systems _STA may change from 0 to nonzero for some devices, so >> what's going to happen to the modalias then? > > A good question. I would expect a change uevent to be generated in > this case and when the device has become present in this new uvent the > modalias will no longer be empty and the module will get loaded, so > the module will not get loaded until the actual hotplug. > > The actual generation of this uevent should be done by the various > subsystems based on ACPI_RECONFIG_DEVICE_ADD messages, at which point > adev->status is already updated and then when the subsys calls > acpi_device_uevent_modalias() for the new uevent it will return a > non-empty modalias. Rafael, how do you want to move forward with this patch ? Regards, Hans > > >> >>> Signed-off-by: Hans de Goede >>> --- >>>   drivers/acpi/device_sysfs.c | 4 ++++ >>>   1 file changed, 4 insertions(+) >>> >>> diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c >>> index 24418932612e..a041689e5701 100644 >>> --- a/drivers/acpi/device_sysfs.c >>> +++ b/drivers/acpi/device_sysfs.c >>> @@ -146,6 +146,10 @@ static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias, >>>          int count; >>>          struct acpi_hardware_id *id; >>> >>> +       /* Avoid unnecessarily loading modules for non present devices. */ >>> +       if (!acpi_device_is_present(acpi_dev)) >>> +               return 0; >>> + >>>          /* >>>           * Since we skip ACPI_DT_NAMESPACE_HID from the modalias below, 0 should >>>           * be returned if ACPI_DT_NAMESPACE_HID is the only ACPI/PNP ID in the >>> --