Re: [PATCH 6/4] Fix forcedeth hibernate/wake-on-lan problems

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Tobias Diedrich
Date: Saturday, May 31, 2008 - 4:20 pm

From: Tobias Diedrich <ranma+kernel@tdiedrich.de>

This patch is the minimal amount of code needed to support
wake-on-lan in platform mode properly (i.e. "ethtool -s eth0 wol g"
is sufficient, no additional magic needed) for me.

This is derived from David Brownells patch
(http://lists.laptop.org/pipermail/devel/2007-April/004691.html).
However I decided to move the hook into pci-acpi.c since the other
two pci hooks also live there and pci and acpi are the only users of
the platform_enable_wakeup-hook.

As a 'side-effect' this also makes wake on usb activity work for me
and I had to disable usb wakeup (which is enabled by default) using
the power/wakeup sysfs functionality ("echo disabled >
${sysfs_path_to_device}/power/wakeup").

(BTW I first thought the 'immediate reboot because of usb wake' effect is
caused by the optical mouse generating a wake event, but it rather
seems to be a problem with a flaky secondary usb host controller,
which sees a connected device where nothing is attached)

Signed-off-by: Tobias Diedrich <ranma+kernel@tdiedrich.de>

Index: linux-2.6.26-rc4.forcedwol/drivers/pci/pci-acpi.c
===================================================================
--- linux-2.6.26-rc4.forcedwol.orig/drivers/pci/pci-acpi.c	2008-06-01 00:40:23.000000000 +0200
+++ linux-2.6.26-rc4.forcedwol/drivers/pci/pci-acpi.c	2008-06-01 00:46:55.000000000 +0200
@@ -315,6 +315,25 @@
 	}
 	return PCI_POWER_ERROR;
 }
+
+static int acpi_platform_enable_wakeup(struct device *dev, int is_on)
+{
+	struct acpi_device	*adev;
+	int			status;
+
+	if (!device_can_wakeup(dev))
+		return -EINVAL;
+
+	if (is_on && !device_may_wakeup(dev))
+		return -EINVAL;
+
+	status = acpi_bus_get_device(DEVICE_ACPI_HANDLE(dev), &adev);
+	if (status < 0)
+		return status;
+
+	adev->wakeup.state.enabled = !!is_on;
+	return 0;
+}
 #endif
 
 static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
@@ -399,6 +418,7 @@
 		return 0;
 #ifdef	CONFIG_ACPI_SLEEP
 	platform_pci_choose_state = acpi_pci_choose_state;
+	platform_enable_wakeup = acpi_platform_enable_wakeup;
 #endif
 	platform_pci_set_power_state = acpi_pci_set_power_state;
 	return 0;
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/4] Fix forcedeth hibernate/wake-on-lan problems, Tobias Diedrich, (Sun May 18, 5:57 am)
Re: [PATCH 1/4] Restore multicast settings on resume, Tobias Diedrich, (Sun May 18, 6:00 am)
Re: [PATCH 2/4] setup wake-on-lan before shutting down, Tobias Diedrich, (Sun May 18, 6:02 am)
Re: [PATCH 3/4] save/restore device configuration space, Tobias Diedrich, (Sun May 18, 6:03 am)
Re: [PATCH 4/4] reorder suspend/resume code, Tobias Diedrich, (Sun May 18, 6:04 am)
Re: [PATCH 0/4] Fix forcedeth hibernate/wake-on-lan problems, Tobias Diedrich, (Sun May 18, 8:09 am)
Re: [PATCH 0/4] Fix forcedeth hibernate/wake-on-lan problems, Rafael J. Wysocki, (Tue May 20, 3:39 pm)
Re: [PATCH 1/4] Restore multicast settings on resume, Jeff Garzik, (Thu May 22, 3:21 am)
Re: [PATCH 0/4] Fix forcedeth hibernate/wake-on-lan problems, Tobias Diedrich, (Sun May 25, 8:04 am)
Re: [PATCH 0/4] Fix forcedeth hibernate/wake-on-lan problems, Tobias Diedrich, (Sun May 25, 11:13 am)
Re: [PATCH 0/4] Fix forcedeth hibernate/wake-on-lan problems, Tobias Diedrich, (Mon May 26, 11:21 pm)
Re: [PATCH 2/4] setup wake-on-lan before shutting down, Jeff Garzik, (Fri May 30, 7:20 pm)
Re: [PATCH 0/4] Fix forcedeth hibernate/wake-on-lan problems, Tobias Diedrich, (Sat May 31, 3:12 pm)
Re: [PATCH 5/4] Fix forcedeth hibernate/wake-on-lan problems, Tobias Diedrich, (Sat May 31, 3:54 pm)
Re: [PATCH 6/4] Fix forcedeth hibernate/wake-on-lan problems, Tobias Diedrich, (Sat May 31, 4:20 pm)