ACPI: change the way of enumerating PNPACPI/Platform devices
Subsystems (3)
v5 cover ACPI: change the way of enumerating PNPACPI/Platform devices
Hi, all,
Currently, PNP bus is used as the default bus for for enumerating ACPI devices with _HID/_CID.
For a device that needs to be enumerated to platform bus, we need to add its id string to the platform scan handler white list explicitly.
This becomes a problem as more and more _HID devices need to be enumerated to platform bus nowadays, thus the list is continuously growing.
So, a solution that uses platform bus for _HID enumeration by default is preferred.
In order to do this, this patch set
First (Patch 1~5), changes the way of enumerating PNP devices.
We introduce a white list to create PNP devices instead. The white list contains all the pnp_device_id strings in all the pnp drivers, thus this change is transparent to PNP core and all the PNP drivers.
Second (Patch 6~12), changes the code to enumerate ACPI _HID devices to platform bus by default, unless the device already has a scan handler attached.
The patches of this patch set has been tested on my desktop machine, I can see that there are four PNP devices disappeared from PNP bus /sys/bus/pnp/devices/00:01/id:PNP0200 /sys/bus/pnp/devices/00:02/id:INT0800 /sys/bus/pnp/devices/00:03/id:PNP0103 /sys/bus/pnp/devices/00:0a/id:PNP0c04
and all of these devices have no associated drivers in kernel.
At the same time there are 10 more platform devices created, /sys/bus/platform/devices/INT0800:00
/sys/bus/platform/devices/PNP0103:00 (HPET) /sys/bus/platform/devices/PNP0C04:00 (Numeric data processor?) /sys/bus/platform/devices/PNP0C0B:00 (ACPI fan) /sys/bus/platform/devices/PNP0C0B:01 (ACPI fan) /sys/bus/platform/devices/PNP0C0B:02 (ACPI fan) /sys/bus/platform/devices/PNP0C0B:03 (ACPI fan) /sys/bus/platform/devices/PNP0C0B:04 (ACPI fan) /sys/bus/platform/devices/PNP0C0C:00 (Power Button) /sys/bus/platform/devices/PNP0C14:00 (ACPI wmi)
Clarification:
Although it seems that we are introducing a much bigger white list to replace a small one, the benefit is that
1. without the patch, the acpi_platform scan handler white list is continuously growing.
2. with the patch set, the PNPACPI scan handler white list will become smaller and smaller by
a) remove the ids from the PNPACPI white list, for the devices that are never enumerated via ACPI
b) remove the ids from the PNPACPI whilte list and convert the drivers to platform bus drivers, for the devices that are not PNP devices in nature.
which will be done later.
Known Issue:
PNP bus does not check the device resources when adding a new PNP device, while Platform bus does by invoking insert_resource() in platform_device_add(). This results in failure when creating platform device node for some ACPI device objects in case there is resource conflict.
In my desktop, I can see that
Creating PNP0200:00 (DMA controller) fails because its resource (IO: 0x81 ~ 0x91) conflicts with "0080-008f : dma page reg"
and
Creating PNP0C02:02 fails because its resource (IO: 0x72 ~ 0x7f) conflicts with "0070-0077 : PNP0B00:00" (CMOS RTC).
Known Issue:
Currently, we can't enumerate devices with _CID PNP0C01/PNP0C02 to platform bus because we need them in PNP bus in order to reserve mother board resources.
thanks,
rui
----------------------------------------------------------------
Changes in V5:
1. fix a problem that ACPI tries to enumerate lpss slaves to platform bus
2. rebased on 3.14 kernel
Changes in V4:
1. coding style cleanups, fix checkpatch warnings/errors.
Changes in V3:
1. rename enumerable_id to platform_id according to Rafael' suggestion.
2. drop two patches to handle devices with _CID PNP0C01/PNP0C02 enumeration because the code in drivers/pnp/system.c is still under discussion.
3. make cmos rtc scan handler return 1 so that the device will not be enumerated to platform bus.
Changes in V2:
1.move acpi pnp scan handler from drivers/pnp/pnpacpi/core.c to
drivers/acpi/acpi-pnp.c, because the scan handler needs to be always built in to prevent platform devices from being created for those ACPI devices.
2.remove the __init tag for the acpi pnp scan handler because the scan
handler is still needed after system initialization, for hotplug.
3.introduce enumerable_id flag for devices that can be enumerated to platform
bus.
4.introduce excluded id list for creating platform devices, because some
devices have _HID but they will never be associated with a platform driver.
5.introduce dummy lpss/container/memory_hotplug scan handler to prevent
platform devices from being created for those ACPI device objects.
----------------------------------------------------------------
Zhang Rui (12):
ACPI: introduce .match() callback for ACPI scan handler
PNPACPI: use whilte list for pnpacpi device enumeration
ACPI: remove ids that does not comply with the ACPI PNP id rule
ACPI: remove unsupported serial PNP ids from acpi pnp scan handler id lsit
ACPI: check and enumerate CMOS RTC devices explicitly
ACPI: introduce platform_id flag
ACPI: use platform bus as the default bus for _HID enumeration
ACPI: introduce dummy lpss scan handler
ACPI: introduce acpi platform exclude id list
ACPI: introduce dummy container scan handler
ACPI: introduce dummy memory hotplug scan handler
ACPI: introduce .handle_children flag for acpi scan handler
drivers/acpi/Makefile | 7 +- drivers/acpi/acpi_cmos_rtc.c | 2 +- drivers/acpi/acpi_lpss.c | 71 +++++--- drivers/acpi/acpi_memhotplug.c | 45 +++-- drivers/acpi/acpi_platform.c | 38 ++-- drivers/acpi/acpi_pnp.c | 381 ++++++++++++++++++++++++++++++++++++++++ drivers/acpi/container.c | 21 +++ drivers/acpi/internal.h | 15 +- drivers/acpi/scan.c | 56 +++++- drivers/pnp/pnpacpi/core.c | 28 +-- include/acpi/acpi_bus.h | 8 +- include/linux/acpi.h | 2 + 12 files changed, 564 insertions(+), 110 deletions(-) create mode 100644 drivers/acpi/acpi_pnp.c
PATCH v5 1/12 ACPI: introduce .match() callback for ACPI scan handler
Currently, ACPI scan handler uses strcmp() to match device ids and scan handler ids.
When converting PNPACPI enumeration into a scan handler, which I will do later in this patch set, the current code becomes not flexible enough because ACPI pnp scan handler requires wildcase and case insensitive support.
Thus a per scan handler .match() callback is introduced in this patch, so that specified scan handler can have more flexible matching mechanism by introduce its own .match() callback.
--- drivers/acpi/scan.c | 17 +++++++++++------ include/acpi/acpi_bus.h | 1 + 2 files changed, 12 insertions(+), 6 deletions(-)
drivers/acpi/scan.c +11 -6
@@ -1974,14 +1974,19 @@ static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler,const struct acpi_device_id *devid;for (devid = handler->ids; devid->id[0 ]; devid++) -if (!strcmp ((char *)devid->id, idstr)) { -if (matchid) - *matchid = devid; - -return true; - } +if (handler->match) { +if (handler->match (idstr, (char *)devid->id)) + goto success; + }else +if (!strcmp ((char *)devid->id, idstr)) + goto success;return false; + +success: +if (matchid) + *matchid = devid; +return true; } static struct acpi_scan_handler *acpi_scan_match_handler(char *idstr,
include/acpi/acpi_bus.h +1 -0
@@ -131,6 +131,7 @@ static inline struct acpi_hotplug_profile *to_acpi_hotplug_profile(struct acpi_scan_handler {const struct acpi_device_id *ids;struct list_head list_node; +int (*match)(char *devid,char *handler_id);int (*attach)(struct acpi_device *dev,const struct acpi_device_id *id);void (*detach)(struct acpi_device *dev);void (*bind)(struct device *phys_dev);
Signature · 1 line
1.7.9.5
PATCH v5 2/12 PNPACPI: use whilte list for pnpacpi device enumeration
In reply to Zhang RuiACPI can be used to enumerate PNP devices, but the code does not handle this in a good manner.
Currently, if an ACPI device
1. has _CRS method,
2. has an identifications of
"three capital charactors followed by four hex numbers",
3. is not in the excluded id list,
it is enumerated to PNP bus.
So actually, PNP bus is used as the default bus for enumerating _HID devices.
But, nowadays, more and more _HID devices are needed to be enumerate to platform bus instead. And a white list is used for those devices to avoid overlapping with PNP bus.
The problem is that this list is continuously growing.
So, a solution that uses platform bus as the default bus for _HID enumeration is preferred.
In order to do this, this patch changes the way of enumerating PNP devices. As the first step, we use a white list (scan handler) to create PNP devices instead. This white list contains all the pnp_device_id strings in all the pnp drivers, thus this change is transparent to PNP core and all the PNP drivers.
Note: I just grep all the id strings in all pnp_device_id instances and
copy them to the new white list, with a few changes to the comments only, to follow the format of:
/* driver name, or file name if not a PNP driver */ {"id-string"}, /* optional comments for the id-string */
...
Note: the PNPACPI devices are created in two step,
1. mark the PNPACPI devices by the acpi pnp scan handler.
2. create the PNPACPI devices in PNPACPI code in a fs_initcall() In this case, if PNP/PNPACPI is not set or "pnpacpi=off" kernel option is used, the acpi pnp scan handler is still there, to prevent those PNPACPI devices from being created to platform bus.
TODO: Reduce this PNPACPI white list by
1. remove the ids for the devices that are never enumerated via ACPI
2. remove the ids and convert the drivers to platform bus drivers for the devices that are not PNP devices in nature.
--- drivers/acpi/Makefile | 1 + drivers/acpi/acpi_pnp.c | 367 ++++++++++++++++++++++++++++++++++++++++++++ drivers/acpi/internal.h | 1 + drivers/acpi/scan.c | 1 + drivers/pnp/pnpacpi/core.c | 28 +--- include/linux/acpi.h | 2 + 6 files changed, 376 insertions(+), 24 deletions(-) create mode 100644 drivers/acpi/acpi_pnp.c
drivers/acpi/Makefile +1 -0
@@ -41,6 +41,7 @@ acpi-$(CONFIG_ACPI_DOCK) += dock.o acpi-y += pci_root.o pci_link.o pci_irq.o acpi-$(CONFIG_X86_INTEL_LPSS) += acpi_lpss.o acpi-y += acpi_platform.o +acpi-y += acpi_pnp.o acpi-y += power.o acpi-y += event.o acpi-y += sysfs.o
drivers/acpi/acpi_pnp.c new file +367 -0
367 lines not on this page · raw message
drivers/acpi/internal.h +1 -0
@@ -30,6 +30,7 @@ void acpi_pci_root_init(void);void acpi_pci_link_init (void );void acpi_processor_init (void );void acpi_platform_init (void ); +void acpi_pnp_init (void );int acpi_sysfs_init (void );#ifdef CONFIG_ACPI_CONTAINER void acpi_container_init (void );
drivers/acpi/scan.c +1 -0
@@ -2251,6 +2251,7 @@ int __init acpi_scan_init(void)acpi_cmos_rtc_init ();acpi_container_init ();acpi_memory_hotplug_init (); +acpi_pnp_init ();mutex_lock (&acpi_scan_lock);/*
drivers/pnp/pnpacpi/core.c +4 -24
@@ -30,26 +30,6 @@static int num; -/* We need only to blacklist devices that have already an acpi driver that -* can't use pnp layer. We don't need to blacklist device that are directly -* used by the kernel (PCI root, ...), as it is harmless and there were -* already present in pnpbios. But there is an exception for devices that -* have irqs (PIC, Timer) because we call acpi_register_gsi. -* Finally, only devices that have a CRS method need to be in this list. -*/ -static struct acpi_device_id excluded_id_list[]__initdata = { - {"PNP0C09" ,0 },/* EC */ - {"PNP0C0F" ,0 },/* Link device */ - {"PNP0000" ,0 },/* PIC */ - {"PNP0100" ,0 },/* Timer */ - {"" ,0 }, -}; - -static inline int __init is_exclusive_device (struct acpi_device *dev) -{ -return (!acpi_match_device_ids (dev, excluded_id_list)); -} -/* * Compatible Device IDs */
@@ -258,7 +238,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)if (!pnpid)return 0 ; -if (is_exclusive_device (device) || !device->status.present) +if (!device->status.present)return 0 ; dev =pnp_alloc_dev (&pnpacpi_protocol, num, pnpid);
@@ -318,10 +298,10 @@ static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, {struct acpi_device *device; -if (!acpi_bus_get_device (handle, &device)) -pnpacpi_add_device (device); -else +if (acpi_bus_get_device (handle, &device))return AE_CTRL_DEPTH ; +if (acpi_is_pnp_device (device)) +pnpacpi_add_device (device);return AE_OK ; }
include/linux/acpi.h +2 -0
@@ -184,6 +184,8 @@ extern int ec_transaction(u8 command, u8 *rdata, unsigned rdata_len);extern acpi_handle ec_get_handle (void ); +extern bool acpi_is_pnp_device (struct acpi_device *); +#if defined(CONFIG_ACPI_WMI ) || defined(CONFIG_ACPI_WMI_MODULE )typedef void (*wmi_notify_handler ) (u32 value,void *context);
Signature · 1 line
1.7.9.5
Re: [PATCH V5 02/12] PNPACPI: use whilte list for pnpacpi device enumeration
On Tuesday, April 08, 2014 12:06:49 AM Zhang Rui wrote:
[...]
Quoted 11 lines
drivers/acpi/acpi_pnp.c new file +11
-0+ +static int acpi_pnp_scan_handler_attach (struct acpi_device *adev, +const struct acpi_device_id *id) +{ +return 1 ; +} + +static int acpi_pnp_scan_handler_match (char *devid,char *handlerid) +{ +int i; +
drivers/acpi/acpi_pnp.c line 345
Quoted 10 lines
drivers/acpi/acpi_pnp.c new file +10
-0+if (memcmp (devid, handlerid,3 )) +return 0 ; + +for (i =3 ; i <7 ; i++) { +/* Not a HEX value */ +if (!((devid[i] >='0' && devid[i] <='9' ) || + (devid[i] >'A' && devid[i] <='F' ))) +return 0 ; + + if ((handlerid[i] != 'X') &&
Hmm. What exactly is the above check for?
Quoted 23 lines
drivers/acpi/acpi_pnp.c new file +22
-0+ toupper(devid[i]) != toupper(handlerid[i])) +return 0 ; + } +return 1 ; +} + +static struct acpi_scan_handler acpi_pnp_handler = { + .ids = acpi_pnp_device_ids, + .match = acpi_pnp_scan_handler_match, + .attach = acpi_pnp_scan_handler_attach, +}; + +bool acpi_is_pnp_device (struct acpi_device *device) +{ +return device->handler == &acpi_pnp_handler; +} +EXPORT_SYMBOL_GPL (acpi_is_pnp_device); + +void __init acpi_pnp_init (void ) +{ +acpi_scan_add_handler (&acpi_pnp_handler); +}drivers/acpi/internal.h +0
-0
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH V5 02/12] PNPACPI: use whilte list for pnpacpi device enumeration
Quoted 19 lines · Rafael J. Wysocki
On Tuesday, April 08, 2014 12:06:49 AM Zhang Rui wrote:
[...]
Quoted 15 lines
drivers/acpi/acpi_pnp.c new file +15
-0+ +static int acpi_pnp_scan_handler_attach (struct acpi_device *adev, +const struct acpi_device_id *id) +{ +return 1 ; +} + +static int acpi_pnp_scan_handler_match (char *devid,char *handlerid) +{ +int i; + +if (memcmp (devid, handlerid,3 )) +return 0 ; + +for (i =3 ; i <7 ; i++) {
Quoted 9 lines
drivers/acpi/acpi_pnp.c line 345
Quoted 6 lines
drivers/acpi/acpi_pnp.c new file +6
-0+/* Not a HEX value */ +if (!((devid[i] >='0' && devid[i] <='9' ) || + (devid[i] >'A' && devid[i] <='F' ))) +return 0 ; + + if ((handlerid[i] != 'X') &&Hmm. What exactly is the above check for?
PNP bus supports wildcard in the drivers' id list.
say, drivers/tty/serial/8250/8250_pnp.c
{"WACFXXX"}, /* Wacom tablets */
means the driver wants to try to probe all the PNP devices start with "WACF".
thanks,
rui
Quoted 25 lines
Quoted 23 lines
drivers/acpi/acpi_pnp.c new file +22
-0+ toupper(devid[i]) != toupper(handlerid[i])) +return 0 ; + } +return 1 ; +} + +static struct acpi_scan_handler acpi_pnp_handler = { + .ids = acpi_pnp_device_ids, + .match = acpi_pnp_scan_handler_match, + .attach = acpi_pnp_scan_handler_attach, +}; + +bool acpi_is_pnp_device (struct acpi_device *device) +{ +return device->handler == &acpi_pnp_handler; +} +EXPORT_SYMBOL_GPL (acpi_is_pnp_device); + +void __init acpi_pnp_init (void ) +{ +acpi_scan_add_handler (&acpi_pnp_handler); +}drivers/acpi/internal.h +0
-0
Re: [PATCH V5 02/12] PNPACPI: use whilte list for pnpacpi device enumeration
Quoted 28 lines · Zhang Rui
Quoted 18 lines · Rafael J. Wysocki
On Tuesday, April 08, 2014 12:06:49 AM Zhang Rui wrote:
[...]
Quoted 14 lines
drivers/acpi/acpi_pnp.c new file +14
-0+ +static int acpi_pnp_scan_handler_attach (struct acpi_device *adev, +const struct acpi_device_id *id) +{ +return 1 ; +} + +static int acpi_pnp_scan_handler_match (char *devid,char *handlerid) +{ +int i; + +if (memcmp (devid, handlerid,3 )) +return 0 ; +Quoted 9 lines
drivers/acpi/acpi_pnp.c line 345
Quoted 7 lines
drivers/acpi/acpi_pnp.c new file +7
-0+for (i =3 ; i <7 ; i++) { +/* Not a HEX value */ +if (!((devid[i] >='0' && devid[i] <='9' ) || + (devid[i] >'A' && devid[i] <='F' ))) +return 0 ; + + if ((handlerid[i] != 'X') &&Hmm. What exactly is the above check for?
Quoted 5 lines
PNP bus supports wildcard in the drivers' id list.
say,drivers/tty/serial/8250/8250_pnp.c
{"WACFXXX"}, /* Wacom tablets */
means the driver wants to try to probe all the PNP devices start with "WACF".
I see. Maybe you can add a comment explaining this before that statement, then?
Rafael
Re: [PATCH V5 02/12] PNPACPI: use whilte list for pnpacpi device enumeration
In reply to Zhang Ruis/whilte/white/ in subject line
PATCH v5 3/12 ACPI: remove ids that does not comply with the ACPI PNP id rule
In reply to Zhang RuiThe acpi pnp scan handler id list just copies all the ids from all the struct pnp_device_id instances, but some of them do not comply with the ACPI PNP id rule (3 Alpha Charactors + 4 Hex numbers).
For those ids, the coressponding devices will never be enumerated via ACPI, so it is safe to remove those ids from the PNPACPI white list.
--- drivers/acpi/acpi_pnp.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/acpi/acpi_pnp.c +0 -4
@@ -33,10 +33,6 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = {/* ide */ {"PNP0600"}, /* Generic ESDI/IDE/ATA compatible hard disk controller *//* ns558 */ - {"@P@0001"}, /* ALS 100 */ - {"@P@0020"}, /* ALS 200 */ - {"@P@1001"}, /* ALS 100+ */ - {"@P@2001"}, /* ALS 120 */ {"ASB16fd"}, /* AdLib NSC16 */ {"AZT3001"}, /* AZT1008 */ {"CDC0001"}, /* Opl3-SAx */
Signature · 1 line
1.7.9.5
PATCH v5 4/12 ACPI: remove unsupported serial PNP ids from acpi pnp scan handler id lsit
In reply to Zhang RuiThe "serial" pnp driver supports some unknown PNP modems (PNPCXXX/PNPDXXX) by matching magic strings in the pnp device name or the pnp device card name.
ACPI enumerated PNP device neither supports pnp card, nor supports those magic strings in its device name, which means this mechamism never works for ACPI enumerated PNPCXXX/PNPDXXX devices.
So it is safe to remove those two ids from the ACPI pnp scan handler id list.
--- drivers/acpi/acpi_pnp.c | 2 -- 1 file changed, 2 deletions(-)
drivers/acpi/acpi_pnp.c +0 -2
@@ -300,8 +300,6 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = { {"LTS0001"}, /* LG C1 EXPRESS DUAL (C1-PB11A3) touch screen (actually a FUJ02E6 in disguise) */ {"WCI0003"}, /* Rockwell's (PORALiNK) 33600 INT PNP */ {"WEC1022"}, /* Winbond CIR port, should not be probed. We should keep track of it to prevent the legacy serial driver from probing it */ - {"PNPCXXX"}, /* Unknown PnP modems */ - {"PNPDXXX"}, /* More unknown PnP modems *//* scl200wdt */ {"NSC0800"}, /* National Semiconductor PC87307/PC97307 watchdog component *//* mpu401 */
Signature · 1 line
1.7.9.5
PATCH v5 5/12 ACPI: check and enumerate CMOS RTC devices explicitly
In reply to Zhang RuiFor CMOS RTC devices, the acpi pnp scan handler does not work because there is already a cmos rtc scan handler installed, thus we need to check those devices and enumerate them to PNP bus explicitly. Plus, the cmos rtc scan handler needs to return 1 so that it will not be enumerated to platform bus.
Note: the CMOS RTC device id is not removed from ACPI pnp scan handler
id list, thus, if cmos rtc scan handler is compiled out, the ACPI pnp scan handler will be attached to the CMOS RTC devices instead, to prevent these devices from being created to platform bus.
--- drivers/acpi/acpi_cmos_rtc.c | 2 +- drivers/acpi/acpi_pnp.c | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-)
drivers/acpi/acpi_cmos_rtc.c +1 -1
@@ -68,7 +68,7 @@ static int acpi_install_cmos_rtc_space_handler(struct acpi_device *adev,return -ENODEV ; } -return 0 ; +return 1 ; }static void acpi_remove_cmos_rtc_space_handler (struct acpi_device *adev)
drivers/acpi/acpi_pnp.c +21 -1
@@ -349,9 +349,29 @@ static struct acpi_scan_handler acpi_pnp_handler = { .attach = acpi_pnp_scan_handler_attach, }; +/* +* For CMOS RTC devices, the acpi pnp spcan handler does not work because +* there is already a cmos rtc scan handler installed, thus we need to +* check those devices and enumerate them to PNP bus explicitly. +*/ +static int is_cmos_rtc_device (struct acpi_device *adev) +{ +struct acpi_device_id ids[] = { + {"PNP0B00" }, + {"PNP0B01" }, + {"PNP0B02" }, + {"" }, + }; +return !acpi_match_device_ids (adev, ids); +} +bool acpi_is_pnp_device (struct acpi_device *device) { -return device->handler == &acpi_pnp_handler; +if (device->handler == &acpi_pnp_handler) +return true; +if (is_cmos_rtc_device (device)) +return true; +return false; }EXPORT_SYMBOL_GPL (acpi_is_pnp_device);
Signature · 1 line
1.7.9.5
Re: [PATCH V5 05/12] ACPI: check and enumerate CMOS RTC devices explicitly
Quoted 52 lines · Zhang Rui
For CMOS RTC devices, the acpi pnp scan handler does not work because there is already a cmos rtc scan handler installed, thus we need to check those devices and enumerate them to PNP bus explicitly. Plus, the cmos rtc scan handler needs to return 1 so that it will not be enumerated to platform bus.
Note: the CMOS RTC device id is not removed from ACPI pnp scan handler
id list, thus, if cmos rtc scan handler is compiled out, the ACPI pnp scan handler will be attached to the CMOS RTC devices instead, to prevent these devices from being created to platform bus.Signed-off-by Zhang Rui <[email protected]>--- drivers/acpi/acpi_cmos_rtc.c | 2 +- drivers/acpi/acpi_pnp.c | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-)drivers/acpi/acpi_cmos_rtc.c +1
-1@@ -68,7 +68,7 @@ static int acpi_install_cmos_rtc_space_handler(struct acpi_device *adev,return -ENODEV ; } -return 0 ; +return 1 ; }static void acpi_remove_cmos_rtc_space_handler (struct acpi_device *adev)drivers/acpi/acpi_pnp.c +14
-0@@ -349,9 +349,29 @@ static struct acpi_scan_handler acpi_pnp_handler = { .attach = acpi_pnp_scan_handler_attach, }; +/* +* For CMOS RTC devices, the acpi pnp spcan handler does not work because +* there is already a cmos rtc scan handler installed, thus we need to +* check those devices and enumerate them to PNP bus explicitly. +*/ +static int is_cmos_rtc_device (struct acpi_device *adev) +{ +struct acpi_device_id ids[] = { + {"PNP0B00" }, + {"PNP0B01" }, + {"PNP0B02" }, + {"" }, + }; +return !acpi_match_device_ids (adev, ids);
drivers/acpi/acpi_pnp.c static struct acpi_scan_handler acpi_pnp_handler = { · line 374
Quoted 10 lines
drivers/acpi/acpi_pnp.c +7
-1+} +bool acpi_is_pnp_device (struct acpi_device *device) { -return device->handler == &acpi_pnp_handler; +if (device->handler == &acpi_pnp_handler) +return true; +if (is_cmos_rtc_device (device)) +return true; +return false;
What about doing
return device->handler == &acpi_pnp_handler || is_cmos_rtc_device(device);
instead?
Quoted 4 lines
drivers/acpi/acpi_pnp.c +0
-0}EXPORT_SYMBOL_GPL (acpi_is_pnp_device);
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH V5 05/12] ACPI: check and enumerate CMOS RTC devices explicitly
Quoted 66 lines · Rafael J. Wysocki
Quoted 52 lines · Zhang Rui
For CMOS RTC devices, the acpi pnp scan handler does not work because there is already a cmos rtc scan handler installed, thus we need to check those devices and enumerate them to PNP bus explicitly. Plus, the cmos rtc scan handler needs to return 1 so that it will not be enumerated to platform bus.
Note: the CMOS RTC device id is not removed from ACPI pnp scan handler
id list, thus, if cmos rtc scan handler is compiled out, the ACPI pnp scan handler will be attached to the CMOS RTC devices instead, to prevent these devices from being created to platform bus.Signed-off-by Zhang Rui <[email protected]>--- drivers/acpi/acpi_cmos_rtc.c | 2 +- drivers/acpi/acpi_pnp.c | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-)drivers/acpi/acpi_cmos_rtc.c +1
-1@@ -68,7 +68,7 @@ static int acpi_install_cmos_rtc_space_handler(struct acpi_device *adev,return -ENODEV ; } -return 0 ; +return 1 ; }static void acpi_remove_cmos_rtc_space_handler (struct acpi_device *adev)drivers/acpi/acpi_pnp.c +14
-0@@ -349,9 +349,29 @@ static struct acpi_scan_handler acpi_pnp_handler = { .attach = acpi_pnp_scan_handler_attach, }; +/* +* For CMOS RTC devices, the acpi pnp spcan handler does not work because +* there is already a cmos rtc scan handler installed, thus we need to +* check those devices and enumerate them to PNP bus explicitly. +*/ +static int is_cmos_rtc_device (struct acpi_device *adev) +{ +struct acpi_device_id ids[] = { + {"PNP0B00" }, + {"PNP0B01" }, + {"PNP0B02" }, + {"" }, + }; +return !acpi_match_device_ids (adev, ids);drivers/acpi/acpi_pnp.c static struct acpi_scan_handler acpi_pnp_handler = { · line 374
Quoted 10 lines
drivers/acpi/acpi_pnp.c +7
-1+} +bool acpi_is_pnp_device (struct acpi_device *device) { -return device->handler == &acpi_pnp_handler; +if (device->handler == &acpi_pnp_handler) +return true; +if (is_cmos_rtc_device (device)) +return true; +return false;What about doing
Quoted 6 lines
return device->handler == &acpi_pnp_handler || is_cmos_rtc_device(device);instead?
Quoted 2 lines
drivers/acpi/acpi_pnp.c +0
-0}EXPORT_SYMBOL_GPL (acpi_is_pnp_device);
Moreover, it looks like this patch should be folded into [2/12] to avoid breaking bisection.
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH V5 05/12] ACPI: check and enumerate CMOS RTC devices explicitly
Quoted 67 lines · Rafael J. Wysocki
Quoted 66 lines · Rafael J. Wysocki
Quoted 52 lines · Zhang Rui
For CMOS RTC devices, the acpi pnp scan handler does not work because there is already a cmos rtc scan handler installed, thus we need to check those devices and enumerate them to PNP bus explicitly. Plus, the cmos rtc scan handler needs to return 1 so that it will not be enumerated to platform bus.
Note: the CMOS RTC device id is not removed from ACPI pnp scan handler
id list, thus, if cmos rtc scan handler is compiled out, the ACPI pnp scan handler will be attached to the CMOS RTC devices instead, to prevent these devices from being created to platform bus.Signed-off-by Zhang Rui <[email protected]>--- drivers/acpi/acpi_cmos_rtc.c | 2 +- drivers/acpi/acpi_pnp.c | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-)drivers/acpi/acpi_cmos_rtc.c +1
-1@@ -68,7 +68,7 @@ static int acpi_install_cmos_rtc_space_handler(struct acpi_device *adev,return -ENODEV ; } -return 0 ; +return 1 ; }static void acpi_remove_cmos_rtc_space_handler (struct acpi_device *adev)drivers/acpi/acpi_pnp.c +14
-0@@ -349,9 +349,29 @@ static struct acpi_scan_handler acpi_pnp_handler = { .attach = acpi_pnp_scan_handler_attach, }; +/* +* For CMOS RTC devices, the acpi pnp spcan handler does not work because +* there is already a cmos rtc scan handler installed, thus we need to +* check those devices and enumerate them to PNP bus explicitly. +*/ +static int is_cmos_rtc_device (struct acpi_device *adev) +{ +struct acpi_device_id ids[] = { + {"PNP0B00" }, + {"PNP0B01" }, + {"PNP0B02" }, + {"" }, + }; +return !acpi_match_device_ids (adev, ids);drivers/acpi/acpi_pnp.c static struct acpi_scan_handler acpi_pnp_handler = { · line 374
Quoted 10 lines
drivers/acpi/acpi_pnp.c +7
-1+} +bool acpi_is_pnp_device (struct acpi_device *device) { -return device->handler == &acpi_pnp_handler; +if (device->handler == &acpi_pnp_handler) +return true; +if (is_cmos_rtc_device (device)) +return true; +return false;What about doing
Quoted 4 lines
Quoted 4 lines
return device->handler == &acpi_pnp_handler || is_cmos_rtc_device(device);instead?
okay.
Quoted 6 lines
Quoted 2 lines
drivers/acpi/acpi_pnp.c static struct acpi_scan_handler acpi_pnp_handler = { · line 376
Quoted 2 lines
drivers/acpi/acpi_pnp.c +0
-0}EXPORT_SYMBOL_GPL (acpi_is_pnp_device);Moreover, it looks like this patch should be folded into [2/12] to avoid breaking bisection.
well, I wanted to make the patch clean and cleasr so I preferred to do one thing in one patch and fix the side effect in a later patch as long as it builds okay.
But you're right, will merge them in next version.
thanks,
rui
PATCH v5 6/12 ACPI: introduce platform_id flag
In reply to Zhang RuiOnly certain kind of ACPI device objects can be enumerated to platform bus. These ACPI device objects include
1. ACPI device objects that have _HID control method.
2. some ACPI device objects that have Linux specified HID strings.
In order to distinguish those device objects from the others, a new flag platform_id and a new function acpi_add_platform_id() are introduced in this patch.
Currently, only devices with _HID method have this flag set.
If you want platform devices to be created for device objects without _HID, use acpi_add_platform_id() when adding artificial Linux-specific ID strings to them.
--- drivers/acpi/scan.c | 9 ++++++++- include/acpi/acpi_bus.h | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/acpi/scan.c +8 -1
@@ -1730,6 +1730,13 @@ static void acpi_add_id(struct acpi_device_pnp *pnp, const char *dev_id) pnp->type.hardware_id =1 ; } +static void acpi_add_platform_id (struct acpi_device_pnp *pnp, +const char *dev_id) +{ +acpi_add_id (pnp, dev_id); + pnp->type.platform_id =1 ; +} +/* * Old IBM workstations have a DSDT bug wherein the SMBus object * lacks the SMBUS01 HID and the methods do not have the necessary "_"
@@ -1794,7 +1801,7 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp, }if (info->valid &ACPI_VALID_HID ) -acpi_add_id (pnp, info->hardware_id.string); +acpi_add_platform_id (pnp, info->hardware_id.string);if (info->valid &ACPI_VALID_CID ) { cid_list = &info->compatible_id_list;for (i =0 ; i < cid_list->count; i++)
include/acpi/acpi_bus.h +2 -1
@@ -233,7 +233,8 @@ struct acpi_hardware_id {struct acpi_pnp_type {u32 hardware_id:1 ;u32 bus_address:1 ; -u32 reserved:30 ; +u32 platform_id:1 ; +u32 reserved:29 ; };struct acpi_device_pnp {
Signature · 1 line
1.7.9.5
Re: [PATCH V5 06/12] ACPI: introduce platform_id flag
Quoted 9 lines · Zhang Rui
Only certain kind of ACPI device objects can be enumerated to platform bus. These ACPI device objects include
1. ACPI device objects that have_HIDcontrol method.
2. some ACPI device objects that have Linux specified HID strings.In order to distinguish those device objects from the others, a new flag
platform_idand a new functionacpi_add_platform_id()are introduced in this patch.
Quoted 6 lines
Currently, only devices with
_HIDmethod have this flag set.
If you want platform devices to be created for device objects without_HID, useacpi_add_platform_id()when adding artificial Linux-specific ID strings to them.Signed-off-by Zhang Rui <[email protected]>
It looks like [12/12] should be folded into this one or bisection may be broken for somebody.
Quoted 47 lines
--- drivers/acpi/scan.c | 9 ++++++++- include/acpi/acpi_bus.h | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-)drivers/acpi/scan.c +8
-1@@ -1730,6 +1730,13 @@ static void acpi_add_id(struct acpi_device_pnp *pnp, const char *dev_id) pnp->type.hardware_id =1 ; } +static void acpi_add_platform_id (struct acpi_device_pnp *pnp, +const char *dev_id) +{ +acpi_add_id (pnp, dev_id); + pnp->type.platform_id =1 ; +} +/* * Old IBM workstations have a DSDT bug wherein the SMBus object * lacks the SMBUS01 HID and the methods do not have the necessary "_" @@ -1794,7 +1801,7 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp, }if (info->valid &ACPI_VALID_HID ) -acpi_add_id (pnp, info->hardware_id.string); +acpi_add_platform_id (pnp, info->hardware_id.string);if (info->valid &ACPI_VALID_CID ) { cid_list = &info->compatible_id_list;for (i =0 ; i < cid_list->count; i++)include/acpi/acpi_bus.h +2
-1@@ -233,7 +233,8 @@ struct acpi_hardware_id {struct acpi_pnp_type {u32 hardware_id:1 ;u32 bus_address:1 ; -u32 reserved:30 ; +u32 platform_id:1 ; +u32 reserved:29 ; };struct acpi_device_pnp {
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH V5 06/12] ACPI: introduce platform_id flag
Quoted 15 lines · Rafael J. Wysocki
Quoted 14 lines · Zhang Rui
Only certain kind of ACPI device objects can be enumerated to platform bus. These ACPI device objects include
1. ACPI device objects that have_HIDcontrol method.
2. some ACPI device objects that have Linux specified HID strings.In order to distinguish those device objects from the others, a new flag
platform_idand a new functionacpi_add_platform_id()are introduced in this patch.Currently, only devices with
_HIDmethod have this flag set.
If you want platform devices to be created for device objects without_HID, useacpi_add_platform_id()when adding artificial Linux-specific ID strings to them.
Quoted 5 lines
Quoted 1 line
Signed-off-by Zhang Rui <[email protected]>It looks like [12/12] should be folded into this one or bisection may be broken for somebody.
agreed.
thanks,
rui
Quoted 48 lines
Quoted 47 lines
--- drivers/acpi/scan.c | 9 ++++++++- include/acpi/acpi_bus.h | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-)drivers/acpi/scan.c +8
-1@@ -1730,6 +1730,13 @@ static void acpi_add_id(struct acpi_device_pnp *pnp, const char *dev_id) pnp->type.hardware_id =1 ; } +static void acpi_add_platform_id (struct acpi_device_pnp *pnp, +const char *dev_id) +{ +acpi_add_id (pnp, dev_id); + pnp->type.platform_id =1 ; +} +/* * Old IBM workstations have a DSDT bug wherein the SMBus object * lacks the SMBUS01 HID and the methods do not have the necessary "_" @@ -1794,7 +1801,7 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp, }if (info->valid &ACPI_VALID_HID ) -acpi_add_id (pnp, info->hardware_id.string); +acpi_add_platform_id (pnp, info->hardware_id.string);if (info->valid &ACPI_VALID_CID ) { cid_list = &info->compatible_id_list;for (i =0 ; i < cid_list->count; i++)include/acpi/acpi_bus.h +2
-1@@ -233,7 +233,8 @@ struct acpi_hardware_id {struct acpi_pnp_type {u32 hardware_id:1 ;u32 bus_address:1 ; -u32 reserved:30 ; +u32 platform_id:1 ; +u32 reserved:29 ; };struct acpi_device_pnp {
PATCH v5 7/12 ACPI: use platform bus as the default bus for _HID enumeration
In reply to Zhang RuiBecause of the growing demand for enumerating ACPI devices to platform bus, this patch changes the code to enumerate ACPI devices with _HID to platform bus by default, unless the device already has a scan handler attached.
--- drivers/acpi/acpi_platform.c | 28 ---------------------------- drivers/acpi/scan.c | 5 ++++- 2 files changed, 4 insertions(+), 29 deletions(-)
drivers/acpi/acpi_platform.c +0 -28
@@ -22,24 +22,6 @@ACPI_MODULE_NAME ("platform" ); -/* -* The following ACPI IDs are known to be suitable for representing as -* platform devices. -*/ -static const struct acpi_device_id acpi_platform_device_ids[] = { - - {"PNP0D40" }, - {"ACPI0003" }, - {"VPC2004" }, - {"BCM4752" }, - -/* Intel Smart Sound Technology */ - {"INT33C8" }, - {"80860F28" }, - - { } -}; -/** * acpi_create_platform_device - Create platform device for ACPI device node * @adev: ACPI device node to create a platform device for.
@@ -125,13 +107,3 @@ int acpi_create_platform_device(struct acpi_device *adev,kfree (resources);return 1 ; } - -static struct acpi_scan_handler platform_handler = { - .ids = acpi_platform_device_ids, - .attach = acpi_create_platform_device, -}; - -void __init acpi_platform_init (void ) -{ -acpi_scan_add_handler (&platform_handler); -}
drivers/acpi/scan.c +4 -1
@@ -2094,6 +2094,10 @@ static int acpi_scan_attach_handler(struct acpi_device *device)break ; } } + +if (device->pnp.type.platform_id && !device->handler) +acpi_create_platform_device (device,NULL ); +return ret; }
@@ -2253,7 +2257,6 @@ int __init acpi_scan_init(void)acpi_pci_root_init ();acpi_pci_link_init ();acpi_processor_init (); -acpi_platform_init ();acpi_lpss_init ();acpi_cmos_rtc_init ();acpi_container_init ();
Signature · 1 line
1.7.9.5
PATCH v5 8/12 ACPI: introduce dummy lpss scan handler
In reply to Zhang RuiWhen the lpss scan handler is compiled out, aka, CONFIG_X86_INTEL_LPSS is cleared, those ACPI device objects will be recgonized as regular _HID devices, and a platform device would be created for each of them. This is wrong because the platform drivers for those devices would be loaded, but with broken behavior.
In order to fix this, a dummy lpss scan handler is introduced to prevent those platform devices from being created.
Plus, if lpt_clk_init() fails, we need this dummy scan handler as well.
--- drivers/acpi/Makefile | 2 +- drivers/acpi/acpi_lpss.c | 69 ++++++++++++++++++++++++++++++++-------------- drivers/acpi/internal.h | 4 --- 3 files changed, 50 insertions(+), 25 deletions(-)
drivers/acpi/Makefile +1 -1
@@ -39,7 +39,7 @@ acpi-y += processor_core.o acpi-y += ec.o acpi-$(CONFIG_ACPI_DOCK) += dock.o acpi-y += pci_root.o pci_link.o pci_irq.o -acpi-$(CONFIG_X86_INTEL_LPSS) += acpi_lpss.o +acpi-y += acpi_lpss.o acpi-y += acpi_platform.o acpi-y += acpi_pnp.o acpi-y += power.o
drivers/acpi/acpi_lpss.c +49 -20
105 lines not on this page · raw message
drivers/acpi/internal.h +0 -4
@@ -73,11 +73,7 @@ int acpi_debugfs_init(void);#else static inline void acpi_debugfs_init (void ) {return ; }#endif -#ifdef CONFIG_X86_INTEL_LPSS void acpi_lpss_init (void ); -#else -static inline void acpi_lpss_init (void ) {} -#endif acpi_status acpi_hotplug_schedule (struct acpi_device *adev,u32 src);bool acpi_queue_hotplug_work (struct work_struct *work);
Signature · 1 line
1.7.9.5
Re: [PATCH V5 08/12] ACPI: introduce dummy lpss scan handler
Quoted 11 lines · Zhang Rui
When the lpss scan handler is compiled out, aka,
CONFIG_X86_INTEL_LPSSis cleared, those ACPI device objects will be recgonized as regular_HIDdevices, and a platform device would be created for each of them. This is wrong because the platform drivers for those devices would be loaded, but with broken behavior.In order to fix this, a dummy lpss scan handler is introduced to prevent those platform devices from being created.
Plus, iflpt_clk_init()fails, we need this dummy scan handler as well.Signed-off-by Zhang Rui <[email protected]>
All of the patches adding dummy scan handlers should go before [7/12] I think.
Quoted 148 lines
--- drivers/acpi/Makefile | 2 +- drivers/acpi/acpi_lpss.c | 69 ++++++++++++++++++++++++++++++++-------------- drivers/acpi/internal.h | 4 --- 3 files changed, 50 insertions(+), 25 deletions(-)drivers/acpi/Makefile +1
-1@@ -39,7 +39,7 @@ acpi-y += processor_core.o acpi-y += ec.o acpi-$(CONFIG_ACPI_DOCK) += dock.o acpi-y += pci_root.o pci_link.o pci_irq.o -acpi-$(CONFIG_X86_INTEL_LPSS) += acpi_lpss.o +acpi-y += acpi_lpss.o acpi-y += acpi_platform.o acpi-y += acpi_pnp.o acpi-y += power.odrivers/acpi/acpi_lpss.c +49
-20@@ -24,6 +24,8 @@ACPI_MODULE_NAME ("acpi_lpss" ); +#ifdef CONFIG_X86_INTEL_LPSS +#define LPSS_CLK_SIZE 0x04#define LPSS_LTR_SIZE 0x18@@ -159,40 +161,50 @@ static struct lpss_device_desc byt_i2c_dev_desc = { .shared_clock = &i2c_clock, }; +#define LPSS_PTR (desc) ((unsigned long)&desc) + +#else + +#define LPSS_PTR (desc) 0 + +#endif +static const struct acpi_device_id acpi_lpss_device_ids[] = {/* Generic LPSS devices */ - {"INTL9C60" , (unsigned long )&lpss_dma_desc }, + {"INTL9C60" ,LPSS_PTR (lpss_dma_desc) },/* Lynxpoint LPSS devices */ - {"INT33C0" , (unsigned long )&lpt_dev_desc }, - {"INT33C1" , (unsigned long )&lpt_dev_desc }, - {"INT33C2" , (unsigned long )&lpt_dev_desc }, - {"INT33C3" , (unsigned long )&lpt_dev_desc }, - {"INT33C4" , (unsigned long )&lpt_uart_dev_desc }, - {"INT33C5" , (unsigned long )&lpt_uart_dev_desc }, - {"INT33C6" , (unsigned long )&lpt_sdio_dev_desc }, + {"INT33C0" ,LPSS_PTR (lpt_dev_desc) }, + {"INT33C1" ,LPSS_PTR (lpt_dev_desc) }, + {"INT33C2" ,LPSS_PTR (lpt_dev_desc) }, + {"INT33C3" ,LPSS_PTR (lpt_dev_desc) }, + {"INT33C4" ,LPSS_PTR (lpt_uart_dev_desc) }, + {"INT33C5" ,LPSS_PTR (lpt_uart_dev_desc) }, + {"INT33C6" ,LPSS_PTR (lpt_sdio_dev_desc) }, {"INT33C7" , },/* BayTrail LPSS devices */ - {"80860F09" , (unsigned long )&byt_pwm_dev_desc }, - {"80860F0A" , (unsigned long )&byt_uart_dev_desc }, - {"80860F0E" , (unsigned long )&byt_spi_dev_desc }, - {"80860F14" , (unsigned long )&byt_sdio_dev_desc }, - {"80860F41" , (unsigned long )&byt_i2c_dev_desc }, + {"80860F09" ,LPSS_PTR (byt_pwm_dev_desc) }, + {"80860F0A" ,LPSS_PTR (byt_uart_dev_desc) }, + {"80860F0E" ,LPSS_PTR (byt_spi_dev_desc) }, + {"80860F14" ,LPSS_PTR (byt_sdio_dev_desc) }, + {"80860F41" ,LPSS_PTR (byt_i2c_dev_desc) }, {"INT33B2" , }, - {"INT3430" , (unsigned long )&lpt_dev_desc }, - {"INT3431" , (unsigned long )&lpt_dev_desc }, - {"INT3432" , (unsigned long )&lpt_dev_desc }, - {"INT3433" , (unsigned long )&lpt_dev_desc }, - {"INT3434" , (unsigned long )&lpt_uart_dev_desc }, - {"INT3435" , (unsigned long )&lpt_uart_dev_desc }, - {"INT3436" , (unsigned long )&lpt_sdio_dev_desc }, + {"INT3430" ,LPSS_PTR (lpt_dev_desc) }, + {"INT3431" ,LPSS_PTR (lpt_dev_desc) }, + {"INT3432" ,LPSS_PTR (lpt_dev_desc) }, + {"INT3433" ,LPSS_PTR (lpt_dev_desc) }, + {"INT3434" ,LPSS_PTR (lpt_uart_dev_desc) }, + {"INT3435" ,LPSS_PTR (lpt_uart_dev_desc) }, + {"INT3436" ,LPSS_PTR (lpt_sdio_dev_desc) }, {"INT3437" , }, { } }; +#ifdef CONFIG_X86_INTEL_LPSS +static int is_memory (struct acpi_resource *res,void *not_used) {struct resource r;@@ -511,10 +523,27 @@ static struct acpi_scan_handler lpss_handler = { .unbind = acpi_lpss_unbind, }; +#endif /* CONFIG_X86_INTEL_LPSS */ + +static int acpi_lpss_dummy_attach (struct acpi_device *adev, +const struct acpi_device_id *id) +{ +return 1 ; +} + +static struct acpi_scan_handler lpss_dummy_handler = { + .ids = acpi_lpss_device_ids, + .attach = acpi_lpss_dummy_attach, +}; +void __init acpi_lpss_init (void ) { +#ifdef CONFIG_X86_INTEL_LPSS if (!lpt_clk_init ()) {bus_register_notifier (&platform_bus_type, &acpi_lpss_nb);acpi_scan_add_handler (&lpss_handler); +return ; } +#endif +acpi_scan_add_handler (&lpss_dummy_handler); }drivers/acpi/internal.h +0
-4@@ -73,11 +73,7 @@ int acpi_debugfs_init(void);#else static inline void acpi_debugfs_init (void ) {return ; }#endif -#ifdef CONFIG_X86_INTEL_LPSS void acpi_lpss_init (void ); -#else -static inline void acpi_lpss_init (void ) {} -#endif acpi_status acpi_hotplug_schedule (struct acpi_device *adev,u32 src);bool acpi_queue_hotplug_work (struct work_struct *work);
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH V5 08/12] ACPI: introduce dummy lpss scan handler
Quoted 7 lines · Rafael J. Wysocki
Quoted 6 lines · Zhang Rui
When the lpss scan handler is compiled out, aka,
CONFIG_X86_INTEL_LPSSis cleared, those ACPI device objects will be recgonized as regular_HIDdevices, and a platform device would be created for each of them. This is wrong because the platform drivers for those devices would be loaded, but with broken behavior.
Quoted 8 lines
Quoted 5 lines
In order to fix this, a dummy lpss scan handler is introduced to prevent those platform devices from being created.
Plus, iflpt_clk_init()fails, we need this dummy scan handler as well.Signed-off-by Zhang Rui <[email protected]>All of the patches adding dummy scan handlers should go before [7/12] I think.
agreed, will do it in next version.
thanks,
rui
Quoted 149 lines
Quoted 148 lines
--- drivers/acpi/Makefile | 2 +- drivers/acpi/acpi_lpss.c | 69 ++++++++++++++++++++++++++++++++-------------- drivers/acpi/internal.h | 4 --- 3 files changed, 50 insertions(+), 25 deletions(-)drivers/acpi/Makefile +1
-1@@ -39,7 +39,7 @@ acpi-y += processor_core.o acpi-y += ec.o acpi-$(CONFIG_ACPI_DOCK) += dock.o acpi-y += pci_root.o pci_link.o pci_irq.o -acpi-$(CONFIG_X86_INTEL_LPSS) += acpi_lpss.o +acpi-y += acpi_lpss.o acpi-y += acpi_platform.o acpi-y += acpi_pnp.o acpi-y += power.odrivers/acpi/acpi_lpss.c +49
-20@@ -24,6 +24,8 @@ACPI_MODULE_NAME ("acpi_lpss" ); +#ifdef CONFIG_X86_INTEL_LPSS +#define LPSS_CLK_SIZE 0x04#define LPSS_LTR_SIZE 0x18@@ -159,40 +161,50 @@ static struct lpss_device_desc byt_i2c_dev_desc = { .shared_clock = &i2c_clock, }; +#define LPSS_PTR (desc) ((unsigned long)&desc) + +#else + +#define LPSS_PTR (desc) 0 + +#endif +static const struct acpi_device_id acpi_lpss_device_ids[] = {/* Generic LPSS devices */ - {"INTL9C60" , (unsigned long )&lpss_dma_desc }, + {"INTL9C60" ,LPSS_PTR (lpss_dma_desc) },/* Lynxpoint LPSS devices */ - {"INT33C0" , (unsigned long )&lpt_dev_desc }, - {"INT33C1" , (unsigned long )&lpt_dev_desc }, - {"INT33C2" , (unsigned long )&lpt_dev_desc }, - {"INT33C3" , (unsigned long )&lpt_dev_desc }, - {"INT33C4" , (unsigned long )&lpt_uart_dev_desc }, - {"INT33C5" , (unsigned long )&lpt_uart_dev_desc }, - {"INT33C6" , (unsigned long )&lpt_sdio_dev_desc }, + {"INT33C0" ,LPSS_PTR (lpt_dev_desc) }, + {"INT33C1" ,LPSS_PTR (lpt_dev_desc) }, + {"INT33C2" ,LPSS_PTR (lpt_dev_desc) }, + {"INT33C3" ,LPSS_PTR (lpt_dev_desc) }, + {"INT33C4" ,LPSS_PTR (lpt_uart_dev_desc) }, + {"INT33C5" ,LPSS_PTR (lpt_uart_dev_desc) }, + {"INT33C6" ,LPSS_PTR (lpt_sdio_dev_desc) }, {"INT33C7" , },/* BayTrail LPSS devices */ - {"80860F09" , (unsigned long )&byt_pwm_dev_desc }, - {"80860F0A" , (unsigned long )&byt_uart_dev_desc }, - {"80860F0E" , (unsigned long )&byt_spi_dev_desc }, - {"80860F14" , (unsigned long )&byt_sdio_dev_desc }, - {"80860F41" , (unsigned long )&byt_i2c_dev_desc }, + {"80860F09" ,LPSS_PTR (byt_pwm_dev_desc) }, + {"80860F0A" ,LPSS_PTR (byt_uart_dev_desc) }, + {"80860F0E" ,LPSS_PTR (byt_spi_dev_desc) }, + {"80860F14" ,LPSS_PTR (byt_sdio_dev_desc) }, + {"80860F41" ,LPSS_PTR (byt_i2c_dev_desc) }, {"INT33B2" , }, - {"INT3430" , (unsigned long )&lpt_dev_desc }, - {"INT3431" , (unsigned long )&lpt_dev_desc }, - {"INT3432" , (unsigned long )&lpt_dev_desc }, - {"INT3433" , (unsigned long )&lpt_dev_desc }, - {"INT3434" , (unsigned long )&lpt_uart_dev_desc }, - {"INT3435" , (unsigned long )&lpt_uart_dev_desc }, - {"INT3436" , (unsigned long )&lpt_sdio_dev_desc }, + {"INT3430" ,LPSS_PTR (lpt_dev_desc) }, + {"INT3431" ,LPSS_PTR (lpt_dev_desc) }, + {"INT3432" ,LPSS_PTR (lpt_dev_desc) }, + {"INT3433" ,LPSS_PTR (lpt_dev_desc) }, + {"INT3434" ,LPSS_PTR (lpt_uart_dev_desc) }, + {"INT3435" ,LPSS_PTR (lpt_uart_dev_desc) }, + {"INT3436" ,LPSS_PTR (lpt_sdio_dev_desc) }, {"INT3437" , }, { } }; +#ifdef CONFIG_X86_INTEL_LPSS +static int is_memory (struct acpi_resource *res,void *not_used) {struct resource r;@@ -511,10 +523,27 @@ static struct acpi_scan_handler lpss_handler = { .unbind = acpi_lpss_unbind, }; +#endif /* CONFIG_X86_INTEL_LPSS */ + +static int acpi_lpss_dummy_attach (struct acpi_device *adev, +const struct acpi_device_id *id) +{ +return 1 ; +} + +static struct acpi_scan_handler lpss_dummy_handler = { + .ids = acpi_lpss_device_ids, + .attach = acpi_lpss_dummy_attach, +}; +void __init acpi_lpss_init (void ) { +#ifdef CONFIG_X86_INTEL_LPSS if (!lpt_clk_init ()) {bus_register_notifier (&platform_bus_type, &acpi_lpss_nb);acpi_scan_add_handler (&lpss_handler); +return ; } +#endif +acpi_scan_add_handler (&lpss_dummy_handler); }drivers/acpi/internal.h +0
-4@@ -73,11 +73,7 @@ int acpi_debugfs_init(void);#else static inline void acpi_debugfs_init (void ) {return ; }#endif -#ifdef CONFIG_X86_INTEL_LPSS void acpi_lpss_init (void ); -#else -static inline void acpi_lpss_init (void ) {} -#endif acpi_status acpi_hotplug_schedule (struct acpi_device *adev,u32 src);bool acpi_queue_hotplug_work (struct work_struct *work);
PATCH v5 9/12 ACPI: introduce acpi platform exclude id list
In reply to Zhang RuiFor ACPI PIC (PNP0000) and Timer (PNP0100) device objects, although they have _HID control method, but they should not be enumerated to platform bus, because there will never be any platform drivers for them.
Thus an exclude id list is introduced in this patch to prevent those platform device nodes from being created.
--- drivers/acpi/acpi_platform.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/acpi/acpi_platform.c +14 -0
@@ -22,6 +22,17 @@ACPI_MODULE_NAME ("platform" ); +static const struct acpi_device_id excluded_id_list[] = { + {"PNP0000" ,0 },/* PIC */ + {"PNP0100" ,0 },/* Timer */ + {"" ,0 }, +}; + +static bool is_exclusive_device (struct acpi_device *dev) +{ +return !acpi_match_device_ids (dev, excluded_id_list); +} +/** * acpi_create_platform_device - Create platform device for ACPI device node * @adev: ACPI device node to create a platform device for.
@@ -48,6 +59,9 @@ int acpi_create_platform_device(struct acpi_device *adev,if (adev->physical_node_count)return 0 ; +if (is_exclusive_device (adev)) +return 0 ; +INIT_LIST_HEAD (&resource_list); count =acpi_dev_get_resources (adev, &resource_list,NULL ,NULL );if (count <0 ) {
Signature · 1 line
1.7.9.5
Re: [PATCH V5 09/12] ACPI: introduce acpi platform exclude id list
Quoted 8 lines · Zhang Rui
For ACPI PIC (PNP0000) and Timer (PNP0100) device objects, although they have
_HIDcontrol method, but they should not be enumerated to platform bus, because there will never be any platform drivers for them.Thus an exclude id list is introduced in this patch to prevent those platform device nodes from being created.
Signed-off-by Zhang Rui <[email protected]>
This should go into [6/12] as well.
Quoted 37 lines
--- drivers/acpi/acpi_platform.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)drivers/acpi/acpi_platform.c +14
-0@@ -22,6 +22,17 @@ACPI_MODULE_NAME ("platform" ); +static const struct acpi_device_id excluded_id_list[] = { + {"PNP0000" ,0 },/* PIC */ + {"PNP0100" ,0 },/* Timer */ + {"" ,0 }, +}; + +static bool is_exclusive_device (struct acpi_device *dev) +{ +return !acpi_match_device_ids (dev, excluded_id_list); +} +/** * acpi_create_platform_device - Create platform device for ACPI device node * @adev: ACPI device node to create a platform device for. @@ -48,6 +59,9 @@ int acpi_create_platform_device(struct acpi_device *adev,if (adev->physical_node_count)return 0 ; +if (is_exclusive_device (adev)) +return 0 ; +INIT_LIST_HEAD (&resource_list); count =acpi_dev_get_resources (adev, &resource_list,NULL ,NULL );if (count <0 ) {
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH V5 09/12] ACPI: introduce acpi platform exclude id list
Quoted 5 lines · Rafael J. Wysocki
Quoted 4 lines · Zhang Rui
For ACPI PIC (PNP0000) and Timer (PNP0100) device objects, although they have
_HIDcontrol method, but they should not be enumerated to platform bus, because there will never be any platform drivers for them.
Quoted 7 lines
Quoted 4 lines
Thus an exclude id list is introduced in this patch to prevent those platform device nodes from being created.
Signed-off-by Zhang Rui <[email protected]>This should go into [6/12] as well.
I think it is okay to keep them as separate patches because they do not break bisect. And this patch is just a cleanup, it does not fix a real BUG in patch 6/12.
thanks,
rui
Quoted 38 lines
Quoted 37 lines
--- drivers/acpi/acpi_platform.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)drivers/acpi/acpi_platform.c +14
-0@@ -22,6 +22,17 @@ACPI_MODULE_NAME ("platform" ); +static const struct acpi_device_id excluded_id_list[] = { + {"PNP0000" ,0 },/* PIC */ + {"PNP0100" ,0 },/* Timer */ + {"" ,0 }, +}; + +static bool is_exclusive_device (struct acpi_device *dev) +{ +return !acpi_match_device_ids (dev, excluded_id_list); +} +/** * acpi_create_platform_device - Create platform device for ACPI device node * @adev: ACPI device node to create a platform device for. @@ -48,6 +59,9 @@ int acpi_create_platform_device(struct acpi_device *adev,if (adev->physical_node_count)return 0 ; +if (is_exclusive_device (adev)) +return 0 ; +INIT_LIST_HEAD (&resource_list); count =acpi_dev_get_resources (adev, &resource_list,NULL ,NULL );if (count <0 ) {
Re: [PATCH V5 09/12] ACPI: introduce acpi platform exclude id list
Quoted 9 lines · Zhang Rui
Quoted 8 lines · Rafael J. Wysocki
Quoted 7 lines · Zhang Rui
For ACPI PIC (PNP0000) and Timer (PNP0100) device objects, although they have
_HIDcontrol method, but they should not be enumerated to platform bus, because there will never be any platform drivers for them.Thus an exclude id list is introduced in this patch to prevent those platform device nodes from being created.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Zhang Rui <[email protected]>This should go into [6/12] as well.
I think it is okay to keep them as separate patches because they do not break bisect. And this patch is just a cleanup, it does not fix a real BUG in patch 6/12.
OK
PATCH v5 10/12 ACPI: introduce dummy container scan handler
In reply to Zhang RuiWhen CONFIG_ACPI_CONTAINER is cleared, platform devices would be created for ACPI container objects.
Introduce a dummy container scan handler in this patch to prevent these platform devices from being created.
--- drivers/acpi/Makefile | 2 +- drivers/acpi/container.c | 21 +++++++++++++++++++++ drivers/acpi/internal.h | 4 ---- 3 files changed, 22 insertions(+), 5 deletions(-)
drivers/acpi/Makefile +1 -1
@@ -63,7 +63,7 @@ obj-$(CONFIG_ACPI_FAN) += fan.o obj-$(CONFIG_ACPI_VIDEO) += video.o obj-$(CONFIG_ACPI_PCI_SLOT) += pci_slot.o obj-$(CONFIG_ACPI_PROCESSOR) += processor.o -obj-$(CONFIG_ACPI_CONTAINER) += container.o +obj-y += container.o obj-$(CONFIG_ACPI_THERMAL) += thermal.o obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o obj-$(CONFIG_ACPI_BATTERY) += battery.o
drivers/acpi/container.c +21 -0
@@ -41,6 +41,8 @@ static const struct acpi_device_id container_device_ids[] = { {"", 0}, }; +#ifdef CONFIG_ACPI_CONTAINER + static int acpi_container_offline(struct container_dev *cdev) { struct acpi_device *adev = ACPI_COMPANION(&cdev->dev);
@@ -111,3 +113,22 @@ void __init acpi_container_init(void) {acpi_scan_add_handler_with_hotplug (&container_handler,"container" ); } + +#else + +static inline int container_device_attach (struct acpi_device *adev, +const struct acpi_device_id *not_used) +{ +return 1 ; +} + +static struct acpi_scan_handler container_handler = { + .ids = container_device_ids, + .attach = container_device_attach, +}; + +void __init acpi_container_init (void ) +{ +acpi_scan_add_handler (&container_handler); +} +#endif /* CONFIG_ACPI_CONTAINER */
drivers/acpi/internal.h +0 -4
@@ -32,11 +32,7 @@ void acpi_processor_init(void);void acpi_platform_init (void );void acpi_pnp_init (void );int acpi_sysfs_init (void ); -#ifdef CONFIG_ACPI_CONTAINER void acpi_container_init (void ); -#else -static inline void acpi_container_init (void ) {} -#endif #ifdef CONFIG_ACPI_DOCK void register_dock_dependent_device (struct acpi_device *adev,acpi_handle dshandle);
Signature · 1 line
1.7.9.5
PATCH v5 11/12 ACPI: introduce dummy memory hotplug scan handler
In reply to Zhang RuiIf CONFIG_ACPI_HOTPLUG_MEMORY is cleared, platform devices would be created for ACPI hotplug memory device objects.
Introduce a dummy memory hotplug scan handler in this patch, to prevent those platform devices from being created.
--- drivers/acpi/Makefile | 2 +- drivers/acpi/acpi_memhotplug.c | 45 ++++++++++++++++++++++++++++------------ drivers/acpi/internal.h | 6 +----- 3 files changed, 34 insertions(+), 19 deletions(-)
drivers/acpi/Makefile +1 -1
@@ -65,7 +65,7 @@ obj-$(CONFIG_ACPI_PCI_SLOT) += pci_slot.o obj-$(CONFIG_ACPI_PROCESSOR) += processor.o obj-y += container.o obj-$(CONFIG_ACPI_THERMAL) += thermal.o -obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o +obj-y += acpi_memhotplug.o obj-$(CONFIG_ACPI_BATTERY) += battery.o obj-$(CONFIG_ACPI_SBS) += sbshc.o obj-$(CONFIG_ACPI_SBS) += sbs.o
drivers/acpi/acpi_memhotplug.c +32 -13
66 lines not on this page · raw message
drivers/acpi/internal.h +1 -5
@@ -33,6 +33,7 @@ void acpi_platform_init(void);void acpi_pnp_init (void );int acpi_sysfs_init (void );void acpi_container_init (void ); +void acpi_memory_hotplug_init (void );#ifdef CONFIG_ACPI_DOCK void register_dock_dependent_device (struct acpi_device *adev,acpi_handle dshandle);
@@ -44,11 +45,6 @@ static inline void register_dock_dependent_device(struct acpi_device *adev,static inline int dock_notify (struct acpi_device *adev,u32 event) {return -ENODEV ; }static inline void acpi_dock_add (struct acpi_device *adev) {}#endif -#ifdef CONFIG_ACPI_HOTPLUG_MEMORY -void acpi_memory_hotplug_init (void ); -#else -static inline void acpi_memory_hotplug_init (void ) {} -#endif #ifdef CONFIG_X86 void acpi_cmos_rtc_init (void );#else
Signature · 1 line
1.7.9.5
PATCH v5 12/12 ACPI: introduce .handle_children flag for acpi scan handler
In reply to Zhang RuiFor some devices with scan handler attached, their children devices are enumerated by the scan handler, indirectly.
In this case, we do not want to enumerate the children devices in acpi scan code explicitly.
Thus a new flag .handle_children is introduced in this patch.
For scan handlers with this flag set, we will do default enumeration neither for the attached devices nor for the children of the attached devices.
--- drivers/acpi/acpi_lpss.c | 2 ++ drivers/acpi/scan.c | 28 ++++++++++++++++++++++++++-- include/acpi/acpi_bus.h | 4 +++- 3 files changed, 31 insertions(+), 3 deletions(-)
drivers/acpi/acpi_lpss.c +2 -0
@@ -521,6 +521,7 @@ static struct acpi_scan_handler lpss_handler = { .attach = acpi_lpss_create_device, .bind = acpi_lpss_bind, .unbind = acpi_lpss_unbind, + .handle_children = true, };#endif /* CONFIG_X86_INTEL_LPSS */
@@ -534,6 +535,7 @@ static int acpi_lpss_dummy_attach(struct acpi_device *adev,static struct acpi_scan_handler lpss_dummy_handler = { .ids = acpi_lpss_device_ids, .attach = acpi_lpss_dummy_attach, + .handle_children = true, };void __init acpi_lpss_init (void )
drivers/acpi/scan.c +26 -2
@@ -2073,6 +2073,31 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,return AE_OK ; } +static void acpi_do_default_enumeration (struct acpi_device *device) +{ +/* +* Do not do enumeration for device object that +* its parent doesn't want to +*/ +if (device->parent && device->parent->flags.no_child_enumeration) { + device->flags.no_child_enumeration =1 ; +return ; + } + +/* Do not do enumeration for device object with scan handler attached */ +if (device->handler) { +if (device->handler->handle_children) + device->flags.no_child_enumeration =1 ; +return ; + } + +/* Do not do enumeration for device object w/o platform_id */ +if (!device->pnp.type.platform_id) +return ; + +acpi_create_platform_device (device,NULL ); +} +static int acpi_scan_attach_handler (struct acpi_device *device) {struct acpi_hardware_id *hwid;
@@ -2095,8 +2120,7 @@ static int acpi_scan_attach_handler(struct acpi_device *device) } } -if (device->pnp.type.platform_id && !device->handler) -acpi_create_platform_device (device,NULL ); +acpi_do_default_enumeration (device);return ret; }
include/acpi/acpi_bus.h +3 -1
@@ -137,6 +137,7 @@ struct acpi_scan_handler {void (*bind)(struct device *phys_dev);void (*unbind)(struct device *phys_dev);struct acpi_hotplug_profile hotplug; +bool handle_children; };/*
@@ -207,7 +208,8 @@ struct acpi_device_flags { u32 no_hotplug:1; u32 hotplug_notify:1; u32 is_dock_station:1; - u32 reserved:22; + u32 no_child_enumeration:1; + u32 reserved:21; };/* File System */
Signature · 1 line
1.7.9.5
Re: [PATCH V5 12/12] ACPI: introduce .handle_children flag for acpi scan handler
Quoted 2 lines · Zhang Rui
For some devices with scan handler attached, their children devices are enumerated by the scan handler, indirectly.
This isn't the case really. They are enumerated by bus controller drivers for the buses they are on.
Quoted 7 lines
In this case, we do not want to enumerate the children devices in acpi scan code explicitly.
Thus a new flag .handle_children is introduced in this patch.
For scan handlers with this flag set, we will do default enumeration neither for the attached devices nor for the children of the attached devices.
I'm not sure if that is the right approach. I would prefer that to be handled in a more fine-graind manner, like a flag per device ID or something similar?
Quoted 96 lines
Signed-off-by Zhang Rui <[email protected]>--- drivers/acpi/acpi_lpss.c | 2 ++ drivers/acpi/scan.c | 28 ++++++++++++++++++++++++++-- include/acpi/acpi_bus.h | 4 +++- 3 files changed, 31 insertions(+), 3 deletions(-)drivers/acpi/acpi_lpss.c +2
-0@@ -521,6 +521,7 @@ static struct acpi_scan_handler lpss_handler = { .attach = acpi_lpss_create_device, .bind = acpi_lpss_bind, .unbind = acpi_lpss_unbind, + .handle_children = true, };#endif /* CONFIG_X86_INTEL_LPSS */ @@ -534,6 +535,7 @@ static int acpi_lpss_dummy_attach(struct acpi_device *adev,static struct acpi_scan_handler lpss_dummy_handler = { .ids = acpi_lpss_device_ids, .attach = acpi_lpss_dummy_attach, + .handle_children = true, };void __init acpi_lpss_init (void )drivers/acpi/scan.c +26
-2@@ -2073,6 +2073,31 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,return AE_OK ; } +static void acpi_do_default_enumeration (struct acpi_device *device) +{ +/* +* Do not do enumeration for device object that +* its parent doesn't want to +*/ +if (device->parent && device->parent->flags.no_child_enumeration) { + device->flags.no_child_enumeration =1 ; +return ; + } + +/* Do not do enumeration for device object with scan handler attached */ +if (device->handler) { +if (device->handler->handle_children) + device->flags.no_child_enumeration =1 ; +return ; + } + +/* Do not do enumeration for device object w/o platform_id */ +if (!device->pnp.type.platform_id) +return ; + +acpi_create_platform_device (device,NULL ); +} +static int acpi_scan_attach_handler (struct acpi_device *device) {struct acpi_hardware_id *hwid;@@ -2095,8 +2120,7 @@ static int acpi_scan_attach_handler(struct acpi_device *device) } } -if (device->pnp.type.platform_id && !device->handler) -acpi_create_platform_device (device,NULL ); +acpi_do_default_enumeration (device);return ret; }include/acpi/acpi_bus.h +3
-1@@ -137,6 +137,7 @@ struct acpi_scan_handler {void (*bind)(struct device *phys_dev);void (*unbind)(struct device *phys_dev);struct acpi_hotplug_profile hotplug; +bool handle_children; };/* @@ -207,7 +208,8 @@ struct acpi_device_flags { u32 no_hotplug:1; u32 hotplug_notify:1; u32 is_dock_station:1; - u32 reserved:22; + u32 no_child_enumeration:1; + u32 reserved:21; };/* File System */
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH V5 12/12] ACPI: introduce .handle_children flag for acpi scan handler
Quoted 7 lines · Rafael J. Wysocki
Quoted 2 lines · Zhang Rui
For some devices with scan handler attached, their children devices are enumerated by the scan handler, indirectly.
This isn't the case really. They are enumerated by bus controller drivers for the buses they are on.
that's what I mean by saying "indirectly". :)
Quoted 12 lines
Quoted 7 lines
In this case, we do not want to enumerate the children devices in acpi scan code explicitly.
Thus a new flag .handle_children is introduced in this patch.
For scan handlers with this flag set, we will do default enumeration neither for the attached devices nor for the children of the attached devices.
I'm not sure if that is the right approach. I would prefer that to be handled in a more fine-graind manner, like a flag per device ID or something similar?
hmmm, how about this,
first, keep the device->flags.no_child_enumeration flag introduced in this patch
second, set the flag explicitly, for specified devices, in the scan handler .attach() function.
thanks,
rui
Quoted 97 lines
Quoted 96 lines
Signed-off-by Zhang Rui <[email protected]>--- drivers/acpi/acpi_lpss.c | 2 ++ drivers/acpi/scan.c | 28 ++++++++++++++++++++++++++-- include/acpi/acpi_bus.h | 4 +++- 3 files changed, 31 insertions(+), 3 deletions(-)drivers/acpi/acpi_lpss.c +2
-0@@ -521,6 +521,7 @@ static struct acpi_scan_handler lpss_handler = { .attach = acpi_lpss_create_device, .bind = acpi_lpss_bind, .unbind = acpi_lpss_unbind, + .handle_children = true, };#endif /* CONFIG_X86_INTEL_LPSS */ @@ -534,6 +535,7 @@ static int acpi_lpss_dummy_attach(struct acpi_device *adev,static struct acpi_scan_handler lpss_dummy_handler = { .ids = acpi_lpss_device_ids, .attach = acpi_lpss_dummy_attach, + .handle_children = true, };void __init acpi_lpss_init (void )drivers/acpi/scan.c +26
-2@@ -2073,6 +2073,31 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,return AE_OK ; } +static void acpi_do_default_enumeration (struct acpi_device *device) +{ +/* +* Do not do enumeration for device object that +* its parent doesn't want to +*/ +if (device->parent && device->parent->flags.no_child_enumeration) { + device->flags.no_child_enumeration =1 ; +return ; + } + +/* Do not do enumeration for device object with scan handler attached */ +if (device->handler) { +if (device->handler->handle_children) + device->flags.no_child_enumeration =1 ; +return ; + } + +/* Do not do enumeration for device object w/o platform_id */ +if (!device->pnp.type.platform_id) +return ; + +acpi_create_platform_device (device,NULL ); +} +static int acpi_scan_attach_handler (struct acpi_device *device) {struct acpi_hardware_id *hwid;@@ -2095,8 +2120,7 @@ static int acpi_scan_attach_handler(struct acpi_device *device) } } -if (device->pnp.type.platform_id && !device->handler) -acpi_create_platform_device (device,NULL ); +acpi_do_default_enumeration (device);return ret; }include/acpi/acpi_bus.h +3
-1@@ -137,6 +137,7 @@ struct acpi_scan_handler {void (*bind)(struct device *phys_dev);void (*unbind)(struct device *phys_dev);struct acpi_hotplug_profile hotplug; +bool handle_children; };/* @@ -207,7 +208,8 @@ struct acpi_device_flags { u32 no_hotplug:1; u32 hotplug_notify:1; u32 is_dock_station:1; - u32 reserved:22; + u32 no_child_enumeration:1; + u32 reserved:21; };/* File System */
Re: [PATCH V5 12/12] ACPI: introduce .handle_children flag for acpi scan handler
Quoted 20 lines · Zhang Rui
Quoted 6 lines · Rafael J. Wysocki
Quoted 2 lines · Zhang Rui
For some devices with scan handler attached, their children devices are enumerated by the scan handler, indirectly.
This isn't the case really. They are enumerated by bus controller drivers for the buses they are on.
that's what I mean by saying "indirectly". :)
Quoted 11 lines
Quoted 7 lines
In this case, we do not want to enumerate the children devices in acpi scan code explicitly.
Thus a new flag .handle_children is introduced in this patch.
For scan handlers with this flag set, we will do default enumeration neither for the attached devices nor for the children of the attached devices.
I'm not sure if that is the right approach. I would prefer that to be handled in a more fine-graind manner, like a flag per device ID or something similar?
Quoted 5 lines
hmmm, how about this,
first, keep thedevice->flags.no_child_enumerationflag introduced in this patch
second, set the flag explicitly, for specified devices, in the scan handler .attach() function.
But then it could simply clear the platform_id flag for them, couldn't it?
Rafael