Skip to contentSkip to conversation

ACPI: Make /proc/acpi/wakeup interface handle PCI devices (again)

PATCH Rafael J. Wysocki 2 participants 5 messages Sep 26, 2008 – Oct 3, 2008 ACPI

lore
Share & tools
lore
#0 lore raw

Len,

I think we should do this in .27.

Thanks,
Rafael

---
From: Rafael J. Wysocki <[email protected]>

ACPI: Make /proc/acpi/wakeup interface handle PCI devices (again)

Make the ACPI /proc/acpi/wakeup interface set the appropriate wake-up bits of physical devices corresponding to the ACPI devices and make those bits be set initially for devices that are enabled to wake up by default. This is needed to restore the previous behavior for the PCI devices that were previously handled correctly with the help of the /proc/acpi/wakeup interface.

---
 drivers/acpi/glue.c       |    5 ++++-
 drivers/acpi/sleep/proc.c |   10 ++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
drivers/acpi/sleep/proc.c +10 -0
Index: linux-2.6/drivers/acpi/sleep/proc.c
===================================================================
@@ -377,6 +377,14 @@ acpi_system_wakeup_device_seq_show(struc
 	return 0;
 }
 
+static void physical_device_enable_wakeup(struct acpi_device *adev)
+{
+	struct device *dev = acpi_get_physical_device(adev->handle);
+
+	if (dev && device_can_wakeup(dev))
+		device_set_wakeup_enable(dev, adev->wakeup.state.enabled);
+}
+
 static ssize_t
 acpi_system_write_wakeup_device(struct file *file,
 				const char __user * buffer,
@@ -411,6 +419,7 @@ acpi_system_write_wakeup_device(struct f
 		}
 	}
 	if (found_dev) {
+		physical_device_enable_wakeup(found_dev);
 		list_for_each_safe(node, next, &acpi_wakeup_device_list) {
 			struct acpi_device *dev = container_of(node,
 							       struct
@@ -428,6 +437,7 @@ acpi_system_write_wakeup_device(struct f
 				       dev->pnp.bus_id, found_dev->pnp.bus_id);
 				dev->wakeup.state.enabled =
 				    found_dev->wakeup.state.enabled;
+				physical_device_enable_wakeup(dev);
 			}
 		}
 	}
drivers/acpi/glue.c +4 -1
Index: linux-2.6/drivers/acpi/glue.c
===================================================================
@@ -165,8 +165,11 @@ static int acpi_bind_one(struct device *
 				"firmware_node");
 		ret = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj,
 				"physical_node");
-		if (acpi_dev->wakeup.flags.valid)
+		if (acpi_dev->wakeup.flags.valid) {
 			device_set_wakeup_capable(dev, true);
+			device_set_wakeup_enable(dev,
+						acpi_dev->wakeup.state.enabled);
+		}
 	}
 
 	return 0;
#1 lore raw
Quoted 3 lines · On Fri, 26 Sep 2008 22:21:47 +0200 "Rafael J. Wysocki" <[email protected]> wrote:

Len,

I think we should do this in .27.

Is Len not there? Can some other acpi person please review this for 2.6.27 inclusion?

Quoted 10 lines

From: Rafael J. Wysocki <[email protected]>

ACPI: Make /proc/acpi/wakeup interface handle PCI devices (again)

Make the ACPI /proc/acpi/wakeup interface set the appropriate wake-up bits of physical devices corresponding to the ACPI devices and make those bits be set initially for devices that are enabled to wake up by default. This is needed to restore the previous behavior for the PCI devices that were previously handled correctly with the help of the /proc/acpi/wakeup interface.

hm, if you say so. It's a bit hard to judge the impact of not fixing this?

When is "previous"? Was 2.6.26 similarly busted?

Thanks.

Quoted 58 lines
---
 drivers/acpi/glue.c       |    5 ++++-
 drivers/acpi/sleep/proc.c |   10 ++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/acpi/sleep/proc.c
===================================================================

drivers/acpi/sleep/proc.c +10 -0
@@ -377,6 +377,14 @@ acpi_system_wakeup_device_seq_show(struc
 	return 0;
 }
 
+static void physical_device_enable_wakeup(struct acpi_device *adev)
+{
+	struct device *dev = acpi_get_physical_device(adev->handle);
+
+	if (dev && device_can_wakeup(dev))
+		device_set_wakeup_enable(dev, adev->wakeup.state.enabled);
+}
+
 static ssize_t
 acpi_system_write_wakeup_device(struct file *file,
 				const char __user * buffer,
@@ -411,6 +419,7 @@ acpi_system_write_wakeup_device(struct f
 		}
 	}
 	if (found_dev) {
+		physical_device_enable_wakeup(found_dev);
 		list_for_each_safe(node, next, &acpi_wakeup_device_list) {
 			struct acpi_device *dev = container_of(node,
 							       struct
@@ -428,6 +437,7 @@ acpi_system_write_wakeup_device(struct f
 				       dev->pnp.bus_id, found_dev->pnp.bus_id);
 				dev->wakeup.state.enabled =
 				    found_dev->wakeup.state.enabled;
+				physical_device_enable_wakeup(dev);
 			}
 		}
 	}

Index: linux-2.6/drivers/acpi/glue.c
===================================================================

drivers/acpi/glue.c +4 -1
@@ -165,8 +165,11 @@ static int acpi_bind_one(struct device *
 				"firmware_node");
 		ret = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj,
 				"physical_node");
-		if (acpi_dev->wakeup.flags.valid)
+		if (acpi_dev->wakeup.flags.valid) {
 			device_set_wakeup_capable(dev, true);
+			device_set_wakeup_enable(dev,
+						acpi_dev->wakeup.state.enabled);
+		}
 	}
 
 	return 0;
#2 lore raw
In reply to Rafael J. Wysocki
Quoted 3 lines · On Fri, 26 Sep 2008 22:21:47 +0200 "Rafael J. Wysocki" <[email protected]> wrote:

Len,

I think we should do this in .27.

Is Len not there? Can some other acpi person please review this for 2.6.27 inclusion?

Quoted 10 lines

From: Rafael J. Wysocki <[email protected]>

ACPI: Make /proc/acpi/wakeup interface handle PCI devices (again)

Make the ACPI /proc/acpi/wakeup interface set the appropriate wake-up bits of physical devices corresponding to the ACPI devices and make those bits be set initially for devices that are enabled to wake up by default. This is needed to restore the previous behavior for the PCI devices that were previously handled correctly with the help of the /proc/acpi/wakeup interface.

hm, if you say so. It's a bit hard to judge the impact of not fixing this?

When is "previous"? Was 2.6.26 similarly busted?

Thanks.

Quoted 58 lines
---
 drivers/acpi/glue.c       |    5 ++++-
 drivers/acpi/sleep/proc.c |   10 ++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/acpi/sleep/proc.c
===================================================================

drivers/acpi/sleep/proc.c +10 -0
@@ -377,6 +377,14 @@ acpi_system_wakeup_device_seq_show(struc
 	return 0;
 }
 
+static void physical_device_enable_wakeup(struct acpi_device *adev)
+{
+	struct device *dev = acpi_get_physical_device(adev->handle);
+
+	if (dev && device_can_wakeup(dev))
+		device_set_wakeup_enable(dev, adev->wakeup.state.enabled);
+}
+
 static ssize_t
 acpi_system_write_wakeup_device(struct file *file,
 				const char __user * buffer,
@@ -411,6 +419,7 @@ acpi_system_write_wakeup_device(struct f
 		}
 	}
 	if (found_dev) {
+		physical_device_enable_wakeup(found_dev);
 		list_for_each_safe(node, next, &acpi_wakeup_device_list) {
 			struct acpi_device *dev = container_of(node,
 							       struct
@@ -428,6 +437,7 @@ acpi_system_write_wakeup_device(struct f
 				       dev->pnp.bus_id, found_dev->pnp.bus_id);
 				dev->wakeup.state.enabled =
 				    found_dev->wakeup.state.enabled;
+				physical_device_enable_wakeup(dev);
 			}
 		}
 	}

Index: linux-2.6/drivers/acpi/glue.c
===================================================================

drivers/acpi/glue.c +4 -1
@@ -165,8 +165,11 @@ static int acpi_bind_one(struct device *
 				"firmware_node");
 		ret = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj,
 				"physical_node");
-		if (acpi_dev->wakeup.flags.valid)
+		if (acpi_dev->wakeup.flags.valid) {
 			device_set_wakeup_capable(dev, true);
+			device_set_wakeup_enable(dev,
+						acpi_dev->wakeup.state.enabled);
+		}
 	}
 
 	return 0;
#3 lore raw
Quoted 14 lines · Andrew Morton
Quoted 3 lines · On Fri, 26 Sep 2008 22:21:47 +0200 "Rafael J. Wysocki" <[email protected]> wrote:

Len,

I think we should do this in .27.

Is Len not there? Can some other acpi person please review this for 2.6.27 inclusion?

Quoted 4 lines

From: Rafael J. Wysocki <[email protected]>

ACPI: Make /proc/acpi/wakeup interface handle PCI devices (again)

Quoted 8 lines
Quoted 6 lines

Make the ACPI /proc/acpi/wakeup interface set the appropriate wake-up bits of physical devices corresponding to the ACPI devices and make those bits be set initially for devices that are enabled to wake up by default. This is needed to restore the previous behavior for the PCI devices that were previously handled correctly with the help of the /proc/acpi/wakeup interface.

hm, if you say so. It's a bit hard to judge the impact of not fixing this?

There are people for whom /proc/acpi/wakeup worked, but since Tino Keitel was the only person reporting this problem, I think it's not widespread.

Quoted 1 line

When is "previous"? Was 2.6.26 similarly busted?

Well, "previous" means "as in 2.6.26 and earlier", so this is a recent regression.

/proc/acpi/ is going to go away at one point, but I think we shouldn't break working setups given that the fix is not very intrusive.

Quoted 61 lines
Quoted 58 lines
---
 drivers/acpi/glue.c       |    5 ++++-
 drivers/acpi/sleep/proc.c |   10 ++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/acpi/sleep/proc.c
===================================================================

drivers/acpi/sleep/proc.c +10 -0
@@ -377,6 +377,14 @@ acpi_system_wakeup_device_seq_show(struc
 	return 0;
 }
 
+static void physical_device_enable_wakeup(struct acpi_device *adev)
+{
+	struct device *dev = acpi_get_physical_device(adev->handle);
+
+	if (dev && device_can_wakeup(dev))
+		device_set_wakeup_enable(dev, adev->wakeup.state.enabled);
+}
+
 static ssize_t
 acpi_system_write_wakeup_device(struct file *file,
 				const char __user * buffer,
@@ -411,6 +419,7 @@ acpi_system_write_wakeup_device(struct f
 		}
 	}
 	if (found_dev) {
+		physical_device_enable_wakeup(found_dev);
 		list_for_each_safe(node, next, &acpi_wakeup_device_list) {
 			struct acpi_device *dev = container_of(node,
 							       struct
@@ -428,6 +437,7 @@ acpi_system_write_wakeup_device(struct f
 				       dev->pnp.bus_id, found_dev->pnp.bus_id);
 				dev->wakeup.state.enabled =
 				    found_dev->wakeup.state.enabled;
+				physical_device_enable_wakeup(dev);
 			}
 		}
 	}

Index: linux-2.6/drivers/acpi/glue.c
===================================================================

drivers/acpi/glue.c +4 -1
@@ -165,8 +165,11 @@ static int acpi_bind_one(struct device *
 				"firmware_node");
 		ret = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj,
 				"physical_node");
-		if (acpi_dev->wakeup.flags.valid)
+		if (acpi_dev->wakeup.flags.valid) {
 			device_set_wakeup_capable(dev, true);
+			device_set_wakeup_enable(dev,
+						acpi_dev->wakeup.state.enabled);
+		}
 	}
 
 	return 0;
#4 lore raw
In reply to Andrew Morton
Quoted 14 lines · Andrew Morton
Quoted 3 lines · On Fri, 26 Sep 2008 22:21:47 +0200 "Rafael J. Wysocki" <[email protected]> wrote:

Len,

I think we should do this in .27.

Is Len not there? Can some other acpi person please review this for 2.6.27 inclusion?

Quoted 4 lines

From: Rafael J. Wysocki <[email protected]>

ACPI: Make /proc/acpi/wakeup interface handle PCI devices (again)

Quoted 8 lines
Quoted 6 lines

Make the ACPI /proc/acpi/wakeup interface set the appropriate wake-up bits of physical devices corresponding to the ACPI devices and make those bits be set initially for devices that are enabled to wake up by default. This is needed to restore the previous behavior for the PCI devices that were previously handled correctly with the help of the /proc/acpi/wakeup interface.

hm, if you say so. It's a bit hard to judge the impact of not fixing this?

There are people for whom /proc/acpi/wakeup worked, but since Tino Keitel was the only person reporting this problem, I think it's not widespread.

Quoted 1 line

When is "previous"? Was 2.6.26 similarly busted?

Well, "previous" means "as in 2.6.26 and earlier", so this is a recent regression.

/proc/acpi/ is going to go away at one point, but I think we shouldn't break working setups given that the fix is not very intrusive.

Quoted 61 lines
Quoted 58 lines
---
 drivers/acpi/glue.c       |    5 ++++-
 drivers/acpi/sleep/proc.c |   10 ++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/acpi/sleep/proc.c
===================================================================

drivers/acpi/sleep/proc.c +10 -0
@@ -377,6 +377,14 @@ acpi_system_wakeup_device_seq_show(struc
 	return 0;
 }
 
+static void physical_device_enable_wakeup(struct acpi_device *adev)
+{
+	struct device *dev = acpi_get_physical_device(adev->handle);
+
+	if (dev && device_can_wakeup(dev))
+		device_set_wakeup_enable(dev, adev->wakeup.state.enabled);
+}
+
 static ssize_t
 acpi_system_write_wakeup_device(struct file *file,
 				const char __user * buffer,
@@ -411,6 +419,7 @@ acpi_system_write_wakeup_device(struct f
 		}
 	}
 	if (found_dev) {
+		physical_device_enable_wakeup(found_dev);
 		list_for_each_safe(node, next, &acpi_wakeup_device_list) {
 			struct acpi_device *dev = container_of(node,
 							       struct
@@ -428,6 +437,7 @@ acpi_system_write_wakeup_device(struct f
 				       dev->pnp.bus_id, found_dev->pnp.bus_id);
 				dev->wakeup.state.enabled =
 				    found_dev->wakeup.state.enabled;
+				physical_device_enable_wakeup(dev);
 			}
 		}
 	}

Index: linux-2.6/drivers/acpi/glue.c
===================================================================

drivers/acpi/glue.c +4 -1
@@ -165,8 +165,11 @@ static int acpi_bind_one(struct device *
 				"firmware_node");
 		ret = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj,
 				"physical_node");
-		if (acpi_dev->wakeup.flags.valid)
+		if (acpi_dev->wakeup.flags.valid) {
 			device_set_wakeup_capable(dev, true);
+			device_set_wakeup_enable(dev,
+						acpi_dev->wakeup.state.enabled);
+		}
 	}
 
 	return 0;