Skip to contentSkip to conversation

make /proc/acpi/wakeup more useful

PATCH Applied David Brownell 6 participants 19 messages Apr 4, 2007 – Apr 25, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 make /proc/acpi/wakeup more useful

This updates /proc/acpi/wakeup to be more informative, primarily by showing the sysfs node associated with each wakeup-enabled device. Example:

	Device	S-state	  Status   Sysfs node
	PCI0	  S4	 disabled  no-bus:pci0000:00
	PS2M	  S4	 disabled  pnp:00:05
	PS2K	  S4	 disabled  pnp:00:06
	UAR1	  S4	 disabled  pnp:00:08
	USB1	  S3	 disabled  pci:0000:00:03.0
	USB2	  S3	 disabled  pci:0000:00:03.1
	USB3	  S3	 disabled  
	USB4	  S3	 disabled  pci:0000:00:03.3
	S139	  S4	 disabled  
	LAN	  S4	 disabled  pci:0000:00:04.0
	MDM	  S4	 disabled  
	AUD	  S4	 disabled  pci:0000:00:02.7
	SLPB	  S4	*enabled   

Eventually this file should be removed, but until then it's almost the only way we have to tell how the relevant ACPI tables are broken (and cope). In that example, two devices don't actually exist (USB3, S139), one can't issue wakeup events (PCI0), and two seem harmlessly (?) confused (MDM and AUD are the same PCI device, but it's the _modem_ that does wake-on-ring).

In particular, we need to be sure driver model nodes are properly hooked up before we can get rid of this ACPI-only interface for wakeup events.

drivers/acpi/sleep/proc.c +13 -3
@@ -360,21 +360,31 @@ acpi_system_wakeup_device_seq_show(struc
 {
 	struct list_head *node, *next;
 
-	seq_printf(seq, "Device	Sleep state	Status\n");
+	seq_printf(seq, "Device\tS-state\t  Status   Sysfs node\n");
 
 	spin_lock(&acpi_device_lock);
 	list_for_each_safe(node, next, &acpi_wakeup_device_list) {
 		struct acpi_device *dev =
 		    container_of(node, struct acpi_device, wakeup_list);
+		struct device *ldev;
 
 		if (!dev->wakeup.flags.valid)
 			continue;
 		spin_unlock(&acpi_device_lock);
-		seq_printf(seq, "%4s	%4d		%s%8s\n",
+
+		ldev = acpi_get_physical_device(dev->handle);
+		seq_printf(seq, "%s\t  S%d\t%c%-8s  ",
 			   dev->pnp.bus_id,
 			   (u32) dev->wakeup.sleep_state,
-			   dev->wakeup.flags.run_wake ? "*" : "",
+			   dev->wakeup.flags.run_wake ? '*' : ' ',
 			   dev->wakeup.state.enabled ? "enabled" : "disabled");
+		if (ldev)
+			seq_printf(seq, "%s:%s",
+				ldev->bus ? ldev->bus->name : "no-bus",
+				ldev->bus_id);
+		seq_printf(seq, "\n");
+		put_device(ldev);
+
 		spin_lock(&acpi_device_lock);
 	}
 	spin_unlock(&acpi_device_lock);
#1 lore raw
Quoted 19 lines · David Brownell

This updates /proc/acpi/wakeup to be more informative, primarily by showing
the sysfs node associated with each wakeup-enabled device. Example:

        Device  S-state   Status   Sysfs node
        PCI0      S4     disabled  no-bus:pci0000:00
        PS2M      S4     disabled  pnp:00:05
        PS2K      S4     disabled  pnp:00:06
        UAR1      S4     disabled  pnp:00:08
        USB1      S3     disabled  pci:0000:00:03.0
        USB2      S3     disabled  pci:0000:00:03.1
        USB3      S3     disabled 
        USB4      S3     disabled  pci:0000:00:03.3
        S139      S4     disabled 
        LAN       S4     disabled  pci:0000:00:04.0
        MDM       S4     disabled 
        AUD       S4     disabled  pci:0000:00:02.7
        SLPB      S4    *enabled  
Quoted 10 lines

Eventually this file should be removed, but until then it's almost the only
way we have to tell how the relevant ACPI tables are broken (and cope). In
that example, two devices don't actually exist (USB3, S139), one can't issue
wakeup events (PCI0), and two seem harmlessly (?) confused (MDM and AUD are
the same PCI device, but it's the _modem_ that does wake-on-ring).

Well, ACPI can't find the sysfs node for all the wakeup-enabled devices. In fact, only pci and pnp devices can be found now.
ACPI needs the ability to distinguish all the physical devices, i.e. map ACPI device to physical device nodes in sysfs, which I mentioned before.

Thanks,
Rui

#16 lore raw
In reply to David Brownell
Quoted 2 lines · David Brownell

This updates /proc/acpi/wakeup to be more informative, primarily by showing the sysfs node associated with each wakeup-enabled device. Example:

This looks good.

Quoted 1 line
	S139	  S4	 disabled  

Any idea what this one is? There's the potential for all sorts of weird platform devices to expose wakeup capabilities.

Quoted 5 lines

Eventually this file should be removed, but until then it's almost the only way we have to tell how the relevant ACPI tables are broken (and cope). In that example, two devices don't actually exist (USB3, S139), one can't issue wakeup events (PCI0), and two seem harmlessly (?) confused (MDM and AUD are the same PCI device, but it's the _modem_ that does wake-on-ring).

Could the MDM entry be referring to the modem codec on the ac97 or hda bus?

Signature · 1 line
Matthew Garrett | [email protected]
#17 lore raw
Quoted 5 lines · Matthew Garrett
Quoted 2 lines · David Brownell

This updates /proc/acpi/wakeup to be more informative, primarily by showing the sysfs node associated with each wakeup-enabled device. Example:

This looks good.

Also "good at exposing some puzzling info" ... ;)

Quoted 4 lines
Quoted 1 line
	S139	  S4	 disabled  

Any idea what this one is? There's the potential for all sorts of weird platform devices to expose wakeup capabilities.

My guess is Firewire (IEEE 1394); "F193" on a different system (different chip vendor) *is* Firewire. This BIOS seems to have wrongly copied ACPI tables from a similar system with a fancier southbridge from the same chip vendor. (ISTR the vendor's reference design used the fancier chip.)

Quoted 8 lines
Quoted 5 lines

Eventually this file should be removed, but until then it's almost the only way we have to tell how the relevant ACPI tables are broken (and cope). In that example, two devices don't actually exist (USB3, S139), one can't issue wakeup events (PCI0), and two seem harmlessly (?) confused (MDM and AUD are the same PCI device, but it's the _modem_ that does wake-on-ring).

Could the MDM entry be referring to the modem codec on the ac97 or hda bus?

That's my assumption; yes. Another system lists "AUD0" and "MODM", but
shows neither as a wakeup device. As I said, "confused".

- Dave

#2 lore raw
In reply to Zhang Rui
Quoted 6 lines · Zhang Rui
Quoted 4 lines · David Brownell

In that example, two devices don't actually exist (USB3, S139), one can't issue wakeup events (PCI0), and two seem harmlessly (?) confused (MDM and AUD are the same PCI device, but it's the _modem_ that does wake-on-ring).

Well, ACPI can't find the sysfs node for all the wakeup-enabled devices.

The only example of that type in the example I provided is SLPB, where the sysfs node is ACPI-internal; I'm not sure how one can detect such cases.

Quoted 1 line

In fact, only pci and pnp devices can be found now.

Well, PNP courtesy of a previous patch from me, but remember that I was using that as an example of a ** BOGUS ACPI TABLE ** as summarized above. In my observation, such bogus tables are common. (This particular one was, I believe, copied from a system using a higher end version of the same southbridge ... but which may well have had its own errors.)

Quoted 2 lines

ACPI needs the ability to distinguish all the physical devices, i.e. map ACPI device to physical device nodes in sysfs, which I mentioned before.

For wakeup devices, the main issue I've seen is with button devices. In my limited set of test sytems, everything else is either PCI, PNP, or a bug (listing a non-existent device).

If this patch starts to get deployed, I expect other people will find a few other curiousities ... and likely some things to be fixed.

The /sys/devices/acpi_system:00/ tree is kind of new. I suspect one way it could be more informative is to set up cross-links in sysfs between the ACPI devices and the "real" device nodes ... e.g. on the system I'm using right now .../device:00/PNP0A03:00/device:15/PNP0B00:00 could have a link pointing to /sys/devices/pnp0/00:06 ... and that PNP node in turn could have an "acpi" link pointing back to the ACPI thing.

Such cross-links would let people see those relationships, and observe which links are missing or otherwise strange. Fixing the bugs would seem unlikely until those things become visible.

- Dave

#3 lore raw
Quoted 8 lines · David Brownell
Quoted 6 lines · Zhang Rui
Quoted 4 lines · David Brownell

In that example, two devices don't actually exist (USB3, S139), one can't issue wakeup events (PCI0), and two seem harmlessly (?) confused (MDM and AUD are the same PCI device, but it's the _modem_ that does wake-on-ring).

Well, ACPI can't find the sysfs node for all the wakeup-enabled devices.

Quoted 8 lines

The only example of that type in the example I provided is SLPB, where the sysfs node is ACPI-internal; I'm not sure how one can detect such cases.

Quoted 1 line

In fact, only pci and pnp devices can be found now.

Well, PNP courtesy of a previous patch from me, but remember that I was using that as an example of a ** BOGUS ACPI TABLE ** as summarized above.

Then it's OK. :)

Quoted 7 lines
Quoted 3 lines

ACPI needs the ability to distinguish all the physical devices, i.e. map ACPI device to physical device nodes in sysfs, which I mentioned before.

For wakeup devices, the main issue I've seen is with button devices. In my limited set of test sytems, everything else is either PCI, PNP, or a bug (listing a non-existent device).

There may be other wakeup-enabled devices like legacy serial, PS2 devices described in ACPI name space.

Quoted 10 lines

If this patch starts to get deployed, I expect other people will find a few other curiousities ... and likely some things to be fixed.

The /sys/devices/acpi_system:00/ tree is kind of new. I suspect one way it could be more informative is to set up cross-links in sysfs between the ACPI devices and the "real" device nodes ... e.g. on the system I'm using right now .../device:00/PNP0A03:00/device:15/PNP0B00:00 could have a link pointing to /sys/devices/pnp0/00:06 ... and that PNP node in turn could have an "acpi" link pointing back to the ACPI thing.

Quoted 3 lines

Such cross-links would let people see those relationships, and observe which links are missing or otherwise strange. Fixing the bugs would seem unlikely until those things become visible.

Sounds nice.
The patch below should make sense.

Add cross-links between ACPI device and "real" devices in sysfs.

---
 drivers/acpi/glue.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+)
drivers/acpi/glue.c +14 -0
Index: linux-2.6.21-rc5/drivers/acpi/glue.c
===================================================================
@@ -147,6 +147,7 @@ EXPORT_SYMBOL(acpi_get_physical_device);
 static int acpi_bind_one(struct device *dev, acpi_handle handle)
 {
 	acpi_status status;
+	struct acpi_device *acpi_dev;
 
 	if (dev->archdata.acpi_handle) {
 		printk(KERN_WARNING PREFIX
@@ -161,16 +162,29 @@ static int acpi_bind_one(struct device *
 	}
 	dev->archdata.acpi_handle = handle;
 
+	if (!acpi_bus_get_device(handle, &acpi_dev)) {
+		sysfs_create_link(&dev->kobj, &acpi_dev->dev.kobj, "ACPI_node");
+		sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj, "physical_node");
+	}
+
 	return 0;
 }
 
 static int acpi_unbind_one(struct device *dev)
 {
+	struct acpi_device *acpi_dev;
+
 	if (!dev->archdata.acpi_handle)
 		return 0;
 	if (dev == acpi_get_physical_device(dev->archdata.acpi_handle)) {
 		/* acpi_get_physical_device increase refcnt by one */
 		put_device(dev);
+
+		if (!acpi_bus_get_device(dev->archdata.acpi_handle, &acpi_dev)) {
+			sysfs_remove_link(&dev->kobj, "ACPI_node");
+			sysfs_remove_link(&acpi_dev->dev.kobj, "physical_node");
+		}
+
 		acpi_detach_data(dev->archdata.acpi_handle,
 				 acpi_glue_data_handler);
 		dev->archdata.acpi_handle = NULL;
#4 lore raw
Quoted 8 lines · Zhang Rui
Quoted 4 lines · David Brownell

For wakeup devices, the main issue I've seen is with button devices. In my limited set of test sytems, everything else is either PCI, PNP, or a bug (listing a non-existent device).

There may be other wakeup-enabled devices like legacy serial, PS2 devices described in ACPI name space.

Do you mean they wouldn't be listed in /proc/acpi/wakeup though?

Or just that they wouldn't be listed as PNP devices (like the button devices)? That seems buglike. Not that BIOS bugs are so rare; and I sure wouldn't know which types are common...

Because that example file certainly included UART and PS2 devices, which were listed both as PNP devices and as ACPI devices.

Quoted 10 lines
Quoted 10 lines

If this patch starts to get deployed, I expect other people will find a few other curiousities ... and likely some things to be fixed.

The /sys/devices/acpi_system:00/ tree is kind of new. I suspect one way it could be more informative is to set up cross-links in sysfs between the ACPI devices and the "real" device nodes ... e.g. on the system I'm using right now .../device:00/PNP0A03:00/device:15/PNP0B00:00 could have a link pointing to /sys/devices/pnp0/00:06 ... and that PNP node in turn could have an "acpi" link pointing back to the ACPI thing.

Quoted 6 lines
Quoted 3 lines

Such cross-links would let people see those relationships, and observe which links are missing or otherwise strange. Fixing the bugs would seem unlikely until those things become visible.

Sounds nice.
The patch below should make sense.

Yeah, that's the idea. Let's see if it's any good. :)

I'd just call it "acpi_node" not "ACPI_node" (NO POINT IN SHOUTING), and might not even use the "_node" suffix.

I cc'd Greg, who's our resident (or is that itinerant?) sysfs guru, in case he has comments on this issue.

This applied over the "ACPI driver model flags and platform_enable_wake()" patch with a bit of fuzz, on RC6.

- Dave

Quoted 50 lines

Add cross-links between ACPI device and "real" devices in sysfs.

---
 drivers/acpi/glue.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+)

Index: linux-2.6.21-rc5/drivers/acpi/glue.c
===================================================================

drivers/acpi/glue.c +14 -0
@@ -147,6 +147,7 @@ EXPORT_SYMBOL(acpi_get_physical_device);
 static int acpi_bind_one(struct device *dev, acpi_handle handle)
 {
 	acpi_status status;
+	struct acpi_device *acpi_dev;
 
 	if (dev->archdata.acpi_handle) {
 		printk(KERN_WARNING PREFIX
@@ -161,16 +162,29 @@ static int acpi_bind_one(struct device *
 	}
 	dev->archdata.acpi_handle = handle;
 
+	if (!acpi_bus_get_device(handle, &acpi_dev)) {
+		sysfs_create_link(&dev->kobj, &acpi_dev->dev.kobj, "ACPI_node");
+		sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj, "physical_node");
+	}
+
 	return 0;
 }
 
 static int acpi_unbind_one(struct device *dev)
 {
+	struct acpi_device *acpi_dev;
+
 	if (!dev->archdata.acpi_handle)
 		return 0;
 	if (dev == acpi_get_physical_device(dev->archdata.acpi_handle)) {
 		/* acpi_get_physical_device increase refcnt by one */
 		put_device(dev);
+
+		if (!acpi_bus_get_device(dev->archdata.acpi_handle, &acpi_dev)) {
+			sysfs_remove_link(&dev->kobj, "ACPI_node");
+			sysfs_remove_link(&acpi_dev->dev.kobj, "physical_node");
+		}
+
 		acpi_detach_data(dev->archdata.acpi_handle,
 				 acpi_glue_data_handler);
 		dev->archdata.acpi_handle = NULL;
#5 lore raw
Quoted 14 lines · David Brownell
Quoted 14 lines
Quoted 13 lines

If this patch starts to get deployed, I expect other people will find a few other curiousities ... and likely some things to be fixed.

The /sys/devices/acpi_system:00/ tree is kind of new. I suspect one way it could be more informative is to set up cross-links in sysfs between the ACPI devices and the "real" device nodes ... e.g. on the system I'm using right now .../device:00/PNP0A03:00/device:15/PNP0B00:00 could have a link pointing to /sys/devices/pnp0/00:06 ... and that PNP node in turn could have an "acpi" link pointing back to the ACPI thing.

Such cross-links would let people see those relationships, and observe which links are missing or otherwise strange. Fixing the bugs would seem unlikely until those things become visible.

Quoted 7 lines
Quoted 2 lines

Sounds nice.
The patch below should make sense.

Yeah, that's the idea. Let's see if it's any good. :)

I'd just call it "acpi_node" not "ACPI_node" (NO POINT IN SHOUTING), and might not even use the "_node" suffix.

Yes, please don't shout :)

Quoted 2 lines

I cc'd Greg, who's our resident (or is that itinerant?) sysfs guru, in case he has comments on this issue.

Are you _sure_ you have a 1-to-1 relationship here? No multiple devices pointing to the same acpi node? Or the other way around? If so, you are going to have to change the name to be something more unique.

Or how about "firmware" instead of "acpi" to be able to have the userspace tools work on any type of firmware that provides this, like openfirmware?

thanks,

greg k-h

#6 lore raw
Quoted 3 lines · Greg KH

Are you _sure_ you have a 1-to-1 relationship here? No multiple devices pointing to the same acpi node? Or the other way around? If so, you are going to have to change the name to be something more unique.

I've wondered that too. The short answer: APCI only supports 1-1 here. It will emit warnings if it tries to bind more than one ACPI device to a given "real" device ... but errors the other way are silently ignored.

By adding a warning over this create-links patch, I found that the system in the $SUBJECT patch (and likely every ACPI system) has two different nodes that correspond to one ACPI node:

	/sys/devices/pci0000:00 ... pci root node
	/sys/devices/pnp0/00:00 ... id PNP0a03
	/sys/devices/acpi_system:00/device:00/PNP0A03:00 ... ditto

Arguably that's too many sysfs nodes for one device...

Plus, there's the issue of flakey ACPI tables; in the $SUBJECT patch both MDM and AUD nodes exist in the ACPI namespace, but they could only refer to one PCI device (with MDM as the wakeup source, not AUD as listed in the table). Or maybe that's another case where the ACPI code isn't handling the tables as sensibly as it might...

Quoted 3 lines

Or how about "firmware" instead of "acpi" to be able to have the userspace tools work on any type of firmware that provides this, like openfirmware?

Assuming they all adopt that same "parallel tree" model, that seems like a good idea. The tools will likely need to understand how ACPI and OF differ, but there's no point in reserving more names than we really need. Though it may be that "parallel trees" should go away.

A small glitch in the patch: lines bigger than 80 characters. :)

- Dave

#7 lore raw
Quoted 8 lines · David Brownell
Quoted 3 lines · Greg KH

Are you _sure_ you have a 1-to-1 relationship here? No multiple devices pointing to the same acpi node? Or the other way around? If so, you are going to have to change the name to be something more unique.

I've wondered that too. The short answer: APCI only supports 1-1 here.

Right.

Quoted 4 lines

It will emit warnings if it tries to bind more than one ACPI
device to a given "real" device ... but errors the other way are silently ignored.

My understanding is different.
First, one "real" device can only have one device.archdata.acpi_handle, which means it can only be bound to one ACPI device.
Second, AE_ALREADY_EXISTS will be returned when ACPI tries to bind more than one "real" devices to the same ACPI device.

Quoted 8 lines

By adding a warning over this create-links patch, I found that the system in the $SUBJECT patch (and likely every ACPI system) has two different nodes that correspond to one ACPI node:

	/sys/devices/pci0000:00 ... pci root node
	/sys/devices/pnp0/00:00 ... id PNP0a03
	/sys/devices/acpi_system:00/device:00/PNP0A03:00 ... ditto
Quoted 8 lines

Arguably that's too many sysfs nodes for one device...

Plus, there's the issue of flakey ACPI tables; in the $SUBJECT patch both MDM and AUD nodes exist in the ACPI namespace, but they could only refer to one PCI device (with MDM as the wakeup source, not AUD as listed in the table). Or maybe that's another case where the ACPI code isn't handling the tables as sensibly as it might...

Could you attach this acpidump please? :)

Thanks,
Rui

#8 lore raw
Quoted 16 lines · David Brownell
Quoted 8 lines · Greg KH
Quoted 4 lines

Are you _sure_ you have a 1-to-1 relationship here? No multiple devices pointing to the same acpi node? Or the other way around? If so, you are going to have to change the name to be something more unique.

I've wondered that too. The short answer: APCI only supports 1-1 here.

Right.

Quoted 3 lines

It will emit warnings if it tries to bind more than one ACPI
device to a given "real" device ... but errors the other way are silently ignored.

Quoted 5 lines

My understanding is different.
First, one "real" device can only have one device.archdata.acpi_handle, which means it can only be bound to one ACPI device.
Second, AE_ALREADY_EXISTS will be returned when ACPI tries to bind more than one "real" devices to the same ACPI device.

Exactly. The "first" case emits a warning, the "second" case doesn't; no matter what it is (though I only saw ALREADY_EXISTS).

When I added a warning to that case:

Quoted 9 lines
Quoted 9 lines

By adding a warning over this create-links patch, I found that the system in the $SUBJECT patch (and likely every ACPI system) has two different nodes that correspond to one ACPI node:

	/sys/devices/pci0000:00 ... pci root node
	/sys/devices/pnp0/00:00 ... id PNP0a03
	/sys/devices/acpi_system:00/device:00/PNP0A03:00 ... ditto

Arguably that's too many sysfs nodes for one device...

Presumably you've noticed this same thing (not necessarily pnp0/00:00) on other systems ...

Quoted 7 lines
Quoted 5 lines

Plus, there's the issue of flakey ACPI tables; in the $SUBJECT patch both MDM and AUD nodes exist in the ACPI namespace, but they could only refer to one PCI device (with MDM as the wakeup source, not AUD as listed in the table). Or maybe that's another case where the ACPI code isn't handling the tables as sensibly as it might...

Could you attach this acpidump please? :)

Off-list; yes.

- Dave

#9 lore raw
In reply to David Brownell
Quoted 9 lines · David Brownell

By adding a warning over this create-links patch, I found that the system in the $SUBJECT patch (and likely every ACPI system) has two different nodes that correspond to one ACPI node:

	/sys/devices/pci0000:00 ... pci root node
	/sys/devices/pnp0/00:00 ... id PNP0a03
	/sys/devices/acpi_system:00/device:00/PNP0A03:00 ... ditto

Arguably that's too many sysfs nodes for one device...

On a different system, I found a more interesting issue.

Specifically, pnp0/00:01 and pnp0:00/03 both have ids ... the appended patch goes on top of the previous pnpacpi patch, and should (nyet tested!) fix another place I saw that warning.

- Dave

========= CUT HERE
Handle PNP devices that have the same IDs a bit more sanely ... I suspect that pnp_dev.number should be compared with some acpi_device field to make it hook up to a particular ACPI device, but I'll leave that to someone who knows how that's supposed to work. At least this will connect e.g. multiple PNP nodes to ACPI nodes sharing the same PNP0c02 id.

drivers/pnp/pnpacpi/core.c +1 -0
@@ -243,6 +243,7 @@ static int __init acpi_pnp_match(struct 
 
 	/* true means it matched */
 	return acpi->flags.hardware_id
+		&& !dev->archdata.acpi_handle
 		&& compare_pnp_id(pnp->id, acpi->pnp.hardware_id);
 }
 
#10 lore raw
Quoted 3 lines · David Brownell

... the appended
patch goes on top of the previous pnpacpi patch, and should (nyet tested!) fix another place I saw that warning.

And here's a tested version. Curiouser and curiouser. I think the mapping of ACPI tables to sysfs nodes still needs a bunch of work...

- Dave

========== CUT HERE
Handle PNP devices that have the same IDs a bit more sanely ... this at least arranges multiple one-to-one mappings between PNP nodes and ACPI nodes that all share the same PNP0c02 id. (Maybe mapped to the wrong node though...)

This remains a hack, since it masks failures where PNP0a03 (a PCI root bridge) is handled by ACPI special case code (/sys/devices/pci0000:00 on my systems instead of /sys/devices/pnp0/pnp00:0/pci0000:00!) not pure PNPACPI logic.

I suspect that pnp_dev.number and some acpi_device field need to be compared, (so the right PNP0c02 nodes hook up to each other, PNP0a03 likewise) but I'll leave that to someone who knows how those ACPI table lookups "should" work.

drivers/pnp/pnpacpi/core.c +1 -0
@@ -243,6 +243,7 @@ static int __init acpi_pnp_match(struct 
 
 	/* true means it matched */
 	return acpi->flags.hardware_id
+		&& !acpi_get_physical_device(acpi->handle)
 		&& compare_pnp_id(pnp->id, acpi->pnp.hardware_id);
 }
 
#11 lore raw
In reply to David Brownell

Hi!

Quoted 6 lines
Quoted 3 lines

Are you _sure_ you have a 1-to-1 relationship here? No multiple devices pointing to the same acpi node? Or the other way around? If so, you are going to have to change the name to be something more unique.

I've wondered that too. The short answer: APCI only supports 1-1 here. It will emit warnings if it tries to bind more than one ACPI

...

Quoted 4 lines

Assuming they all adopt that same "parallel tree" model, that seems like a good idea. The tools will likely need to understand how ACPI and OF differ, but there's no point in reserving more names than we really need. Though it may be that "parallel trees" should go away.

If mapping is indeed 1-to-1 in acpi... it would be nice to just merge the trees.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#12 lore raw
Quoted 8 lines · Pavel Machek

Hi!

Quoted 6 lines
Quoted 3 lines

Are you _sure_ you have a 1-to-1 relationship here? No multiple devices pointing to the same acpi node? Or the other way around? If so, you are going to have to change the name to be something more unique.

I've wondered that too. The short answer: APCI only supports 1-1 here. It will emit warnings if it tries to bind more than one ACPI

(Clarifying: the ACPI *code* works that way. I have no idea whether ACPI itself makes such restrictions. And I suspect that ACPI practice will in some cases couple multiple ACPI devices to one PCI device...)

Quoted 8 lines

...

Quoted 4 lines

Assuming they all adopt that same "parallel tree" model, that seems like a good idea. The tools will likely need to understand how ACPI and OF differ, but there's no point in reserving more names than we really need. Though it may be that "parallel trees" should go away.

If mapping is indeed 1-to-1 in acpi... it would be nice to just merge the trees.

Could you elaborate a bit ... what do you mean by "merge"?

One way to merge the trees would be to relocate

	/sys/devices/pci* --> ... this *HAS* a PNP node
	/sys/devices/pnp*/X --> /sys/devices/acpi_system*/.../X

Not having the PCI root be its PNPACPI node seems more buglike to me than anything else. And for other nodes, it seems like maybe there should be a "firmware" subdirectory holding the ACPI state (hid, path, etc) ... creating a minor chicken/egg problem that ACPI would need to sort out. Likely one can just assume PCI and PNP busses exist, so creating nodes on those buses based on ACPI tables would not be a problem. And for ACPI-internal devices, like SLPB and power buttons, the ACPI bus would suffice. But are there other busses?

- Dave

#13 lore raw
Quoted 13 lines · David Brownell
Quoted 8 lines · Pavel Machek

...

Quoted 4 lines

Assuming they all adopt that same "parallel tree" model, that seems like a good idea. The tools will likely need to understand how ACPI and OF differ, but there's no point in reserving more names than we really need. Though it may be that "parallel trees" should go away.

If mapping is indeed 1-to-1 in acpi... it would be nice to just merge the trees.

Could you elaborate a bit ... what do you mean by "merge"?

Quoted 7 lines

One way to merge the trees would be to relocate

	/sys/devices/pci* --> ... this *HAS* a PNP node
	/sys/devices/pnp*/X --> /sys/devices/acpi_system*/.../X

Not having the PCI root be its PNPACPI node seems more buglike to me than anything else. And for other nodes...

Looks like the i8042 serial nodes will be bizarre too:

	/sys/devices/pnp0/00:09
		... touchpad's PNP node
	/sys/devices/acpi_system:00/device:00/PNP0A03:00/device:15/PNP0F13:00
		... its ACPI node
	/sys/devices/platform/i8042/serio4
		... its serio node

That seems like two nodes too many, but without me trying to twist my mind around i8042 issues, I can't quite speculate why struct serio "is-a" device rather than "has-a" device (the PNP node) as would be the case with a more normal driver structure.

But the existence of that device_add() in serio.c sure explains why the PNP node doesn't get associated with the input class device one would expect from knowing that 00:09 is the touchpad.

And hmm, just this morning I saw email from Greg re-affirming that drivers should not device_add(). Converting such legacy drivers is simple though, right? :)

- Dave

#14 lore raw
Quoted 31 lines · David Brownell
Quoted 13 lines · David Brownell
Quoted 8 lines · Pavel Machek

...

Quoted 4 lines

Assuming they all adopt that same "parallel tree" model, that seems like a good idea. The tools will likely need to understand how ACPI and OF differ, but there's no point in reserving more names than we really need. Though it may be that "parallel trees" should go away.

If mapping is indeed 1-to-1 in acpi... it would be nice to just merge the trees.

Could you elaborate a bit ... what do you mean by "merge"?

Quoted 7 lines

One way to merge the trees would be to relocate

	/sys/devices/pci* --> ... this *HAS* a PNP node
	/sys/devices/pnp*/X --> /sys/devices/acpi_system*/.../X

Not having the PCI root be its PNPACPI node seems more buglike to me than anything else. And for other nodes...

Looks like the i8042 serial nodes will be bizarre too:

	/sys/devices/pnp0/00:09
		... touchpad's PNP node
	/sys/devices/acpi_system:00/device:00/PNP0A03:00/device:15/PNP0F13:00
		... its ACPI node
	/sys/devices/platform/i8042/serio4
		... its serio node
Quoted 8 lines

That seems like two nodes too many, but without me trying to twist my mind around i8042 issues, I can't quite speculate why struct serio "is-a" device rather than "has-a" device (the PNP node) as would be the case with a more normal driver structure.

But the existence of that device_add() in serio.c sure explains why the PNP node doesn't get associated with the input class device one would expect from knowing that 00:09 is the touchpad.

Ick, how can we fix this up?

Quoted 3 lines

And hmm, just this morning I saw email from Greg re-affirming that drivers should not device_add(). Converting such legacy drivers is simple though, right? :)

Heh, yeah right, they can remain platform drivers :)

thanks,

greg k-h

#15 lore raw
Quoted 16 lines · Greg KH
Quoted 14 lines · David Brownell

Looks like the i8042 serial nodes will be bizarre too:

	/sys/devices/pnp0/00:09
		... touchpad's PNP node
	/sys/devices/acpi_system:00/device:00/PNP0A03:00/device:15/PNP0F13:00
		... its ACPI node
	/sys/devices/platform/i8042/serio4
		... its serio node

That seems like two nodes too many, but without me trying to twist my mind around i8042 issues, I can't quite speculate why struct serio "is-a" device rather than "has-a" device (the PNP node) as would be the case with a more normal driver structure.

Quoted 5 lines
Quoted 3 lines

But the existence of that device_add() in serio.c sure explains why the PNP node doesn't get associated with the input class device one would expect from knowing that 00:09 is the touchpad.

Ick, how can we fix this up?

You're asking the wrong penguin for that answer ... :)

But I'd suggest that someone who knows ACPI -- and PNPACPI --- work on merging those ACPI and PNP nodes. (Same thing would need doing with ACPI and PCI ...)

That ACPI subtree is quite new, at least in terms of being public. So I'd think its details must be very flexible right now.

Quoted 5 lines
Quoted 3 lines

And hmm, just this morning I saw email from Greg re-affirming that drivers should not device_add(). Converting such legacy drivers is simple though, right? :)

Heh, yeah right, they can remain platform drivers :)

Most platform drivers aren't legacy drivers. Just the x86 ones! And a lot of those wouldn't be headaches if PNPACPI were used better...

In this case, making the i8042 stuff use PNP more naturally would seem like the most natural way to resolve the problem for all but pre-ACPI legacy x86 hardware. Now that ACPI implies PNPACPI by default, various corner cases have vanished.

That said, I know less about i8042 wierdness -- and I know there's a lot of it! -- than about ACPI, so I'll stay out of that. Beyond pointing out these curious little corner cases I've uncovered while trying to make sure wakeup annotations get assigned to the right sysfs device nodes. :)

- Dave

Quoted 5 lines

thanks,

greg k-h

reviewer Applied
#18 lore raw
In reply to David Brownell

Applied,
and thanks for turning over the rocks in sysfs to see what wiggled out:-)

thanks,
-Len

Quoted 72 lines · David Brownell

This updates /proc/acpi/wakeup to be more informative, primarily by showing the sysfs node associated with each wakeup-enabled device. Example:

	Device	S-state	  Status   Sysfs node
	PCI0	  S4	 disabled  no-bus:pci0000:00
	PS2M	  S4	 disabled  pnp:00:05
	PS2K	  S4	 disabled  pnp:00:06
	UAR1	  S4	 disabled  pnp:00:08
	USB1	  S3	 disabled  pci:0000:00:03.0
	USB2	  S3	 disabled  pci:0000:00:03.1
	USB3	  S3	 disabled  
	USB4	  S3	 disabled  pci:0000:00:03.3
	S139	  S4	 disabled  
	LAN	  S4	 disabled  pci:0000:00:04.0
	MDM	  S4	 disabled  
	AUD	  S4	 disabled  pci:0000:00:02.7
	SLPB	  S4	*enabled   

Eventually this file should be removed, but until then it's almost the only way we have to tell how the relevant ACPI tables are broken (and cope). In that example, two devices don't actually exist (USB3, S139), one can't issue wakeup events (PCI0), and two seem harmlessly (?) confused (MDM and AUD are the same PCI device, but it's the _modem_ that does wake-on-ring).

In particular, we need to be sure driver model nodes are properly hooked up before we can get rid of this ACPI-only interface for wakeup events.

drivers/acpi/sleep/proc.c +13 -4
@@ -360,21 +360,31 @@ acpi_system_wakeup_device_seq_show(struc
 {
 	struct list_head *node, *next;
 
-	seq_printf(seq, "Device	Sleep state	Status\n");
+	seq_printf(seq, "Device\tS-state\t  Status   Sysfs node\n");
 
 	spin_lock(&acpi_device_lock);
 	list_for_each_safe(node, next, &acpi_wakeup_device_list) {
 		struct acpi_device *dev =
 		    container_of(node, struct acpi_device, wakeup_list);
+		struct device *ldev;
 
 		if (!dev->wakeup.flags.valid)
 			continue;
 		spin_unlock(&acpi_device_lock);
-		seq_printf(seq, "%4s	%4d		%s%8s\n",
+
+		ldev = acpi_get_physical_device(dev->handle);
+		seq_printf(seq, "%s\t  S%d\t%c%-8s  ",
 			   dev->pnp.bus_id,
 			   (u32) dev->wakeup.sleep_state,
-			   dev->wakeup.flags.run_wake ? "*" : "",
+			   dev->wakeup.flags.run_wake ? '*' : ' ',
 			   dev->wakeup.state.enabled ? "enabled" : "disabled");
+		if (ldev)
+			seq_printf(seq, "%s:%s",
+				ldev->bus ? ldev->bus->name : "no-bus",
+				ldev->bus_id);
+		seq_printf(seq, "\n");
+		put_device(ldev);
+
 		spin_lock(&acpi_device_lock);
 	}
 	spin_unlock(&acpi_device_lock);
-

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/