2.6.14 USB vs. sleep issues
Subsystems (4)
For those who experience crashes on sleep and/or wakeup (typically due to USB) with 2.6.14, I made a test patch that might help. Please let me know if it makes things more reliable.
http://gate.crashing.org/~benh/fix-ohci-sleep.diff
Note that the patch is totally untested here so it may be just plain bogus :)
Ben.
Quoted 5 lines · Benjamin Herrenschmidt
For those who experience crashes on sleep and/or wakeup (typically due to USB) with 2.6.14, I made a test patch that might help. Please let me know if it makes things more reliable.
So this supposed to work with the USB sleep support enabled, right? If this works then I will be very thankful!
I hope I have the time to test this patch this evening.
Quoted 2 lines
Note that the patch is totally untested here so it may be just plain bogus :)
No problem.
AIUI, this should allow me to put my PB 5,2 to sleep while a usb stick is mounted and come back from sleep with no problem and the stick to be still mounted, right?
--
Regards,
EddyP =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D "Imagination is more important than knowledge" A.Einstein
Quoted 5 lines
So this supposed to work with the USB sleep support enabled, right? If this works then I will be very thankful!
I hope I have the time to test this patch this evening.
Quoted 8 lines
Quoted 2 lines
Note that the patch is totally untested here so it may be just plain bogus :)
No problem.
AIUI, this should allow me to put my PB 5,2 to sleep while a usb stick is mounted and come back from sleep with no problem and the stick to be still mounted, right?
Heh, in _theory_ :) The first aim of the patch is to remove the crash on sleep/wakeup in 2.6.14. If it doesn't blow up, that's already a good first step :) Wether suspend with your USB stick works is a different matter, mostly due to the USB stack itself.
Ben.
Quoted 8 lines · Benjamin Herrenschmidt
Quoted 8 lines
So this supposed to work with the USB sleep support enabled, right? If this works then I will be very thankful!
I hope I have the time to test this patch this evening.Quoted 2 lines
Note that the patch is totally untested here so it may be just plain bogus :)
Quoted 8 lines
Quoted 5 lines
No problem.
AIUI, this should allow me to put my PB 5,2 to sleep while a usb stick is mounted and come back from sleep with no problem and the stick to be still mounted, right?
Heh, in _theory_ :) The first aim of the patch is to remove the crash on sleep/wakeup in 2.6.14. If it doesn't blow up, that's already a good
Well, I couldn't get to that point (getting back from sleep) :-D
Quoted 2 lines
first step :) Wether suspend with your USB stick works is a different matter, mostly due to the USB stack itself.
The kernel oopsed when it was supposed to go to sleep:
Nov 4 09:01:34 localhost kernel: usb 3-1: no poweroff yet, suspending inst= ead Nov 4 09:01:34 localhost kernel: usb usb4: no poweroff yet, suspending ins= tead Nov 4 09:01:34 localhost kernel: Oops: Exception in kernel mode, sig: 5 [#= 1] Nov 4 09:01:34 localhost kernel: PREEMPT Nov 4 09:01:34 localhost kernel: NIP: C00184F4 LR: D224199C SP: CD7D5D00 REGS: cd7d5c50 TRAP: 0700 Not tainted Nov 4 09:01:34 localhost kernel: MSR: 00029032 EE: 1 PR: 0 FP: 0 ME: 1 IR/DR: 11 Nov 4 09:01:34 localhost kernel: TASK =3D cec8f2e0[2751] 'pbbuttonsd' THREAD: cd7d4000 Nov 4 09:01:34 localhost kernel: Last syscall: 54 Nov 4 09:01:34 localhost kernel: GPR00: 00000001 CD7D5D00 CEC8F2E0 00000001 00001000 00001000 000007D0 FFFFFFFC Nov 4 09:01:34 localhost kernel: GPR08: D220C064 CD7D4000 00000000 00000000 0000D903 1002C830 100D0000 100E2CB8 Nov 4 09:01:34 localhost kernel: GPR16: 100D0000 100A0000 00000000 100D0000 100EC488 10010000 10010000 D20C0000 Nov 4 09:01:34 localhost kernel: GPR24: D20C0000 D20C0000 C0310000 00000000 C0300000 00000006 CF3EDC00 CF3EDCD0 Nov 4 09:01:34 localhost kernel: NIP [c00184f4] sub_preempt_count+0x14/0x7= 0 Nov 4 09:01:34 localhost kernel: LR [d224199c] ehci_hub_suspend+0x1ac/0x210 [ehci_hcd] Nov 4 09:01:34 localhost kernel: Call trace: Nov 4 09:01:34 localhost kernel: [d20b47e4] hcd_hub_suspend+0x34/0x50 [usbcore] Nov 4 09:01:34 localhost kernel: [d20b2958] __usb_suspend_device+0x308/0x330 [usbcore] Nov 4 09:01:34 localhost kernel: [d20b2ae0] usb_suspend_device+0x40/0x70 [usbcore] Nov 4 09:01:34 localhost kernel: [d20aead0] usb_generic_suspend+0xa0/0xb0 [usbcore] Nov 4 09:01:34 localhost kernel: [c01d7904] suspend_device+0x104/0x160 Nov 4 09:01:34 localhost kernel: [c01d7b40] device_suspend+0x110/0x320 Nov 4 09:01:34 localhost kernel: [c037d6b0] pmac_suspend_devices+0x50/0x1= d0 Nov 4 09:01:34 localhost kernel: [c037de58] pmu_ioctl+0x388/0x9f0 Nov 4 09:01:34 localhost kernel: [c00961dc] do_ioctl+0x9c/0xb0 Nov 4 09:01:34 localhost kernel: [c009627c] vfs_ioctl+0x8c/0x4c0 Nov 4 09:01:34 localhost kernel: [c0096744] sys_ioctl+0x94/0xb0 Nov 4 09:01:34 localhost kernel: [c0004840] ret_from_syscall+0x0/0x44
--
Regards,
EddyP =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D "Imagination is more important than knowledge" A.Einstein
Quoted 10 lines
Quoted 3 lines
Heh, in _theory_ :) The first aim of the patch is to remove the crash on sleep/wakeup in 2.6.14. If it doesn't blow up, that's already a good
Well, I couldn't get to that point (getting back from sleep) :-D
Quoted 2 lines
first step :) Wether suspend with your USB stick works is a different matter, mostly due to the USB stack itself.
The kernel oopsed when it was supposed to go to sleep:
I would say your first mistake is to use PREEMPT :) There are various issues with PREEMPT on ppc32 that have not really been addressed so far, and the USB code has some "holes" that I wouldn't trust in a PREEMPT environment.
Anyway, I'll try to come up with a better patch this week-end. Please, continue giving me feedback with oops backtraces etc...
Ben.
Quoted 6 lines · Benjamin Herrenschmidt
I would say your first mistake is to use PREEMPT :) There are various issues with PREEMPT on ppc32 that have not really been addressed so far, and the USB code has some "holes" that I wouldn't trust in a PREEMPT environment.
What do you mean exactly? Should CONFIG_PREEMPT not be used? And what about CONFIG_PREEMPT_VOLUNTARY?
Vivenzio
Quoted 10 lines · Vivenzio Pagliari
Quoted 6 lines · Benjamin Herrenschmidt
I would say your first mistake is to use PREEMPT :) There are various issues with PREEMPT on ppc32 that have not really been addressed so far, and the USB code has some "holes" that I wouldn't trust in a PREEMPT environment.
What do you mean exactly? Should
CONFIG_PREEMPTnot be used? And what aboutCONFIG_PREEMPT_VOLUNTARY?
I would avoid both for now.
Ben.
Quoted 4 lines · Benjamin Herrenschmidt
For those who experience crashes on sleep and/or wakeup (typically due to USB) with 2.6.14, I made a test patch that might help. Please let me know if it makes things more reliable.
I've tried your patch with usb wifi dlink dwl-g122 (my eth1). It works. There are some differences in /var/log/syslog :
-----------------------
resume without your patch :
Nov 5 22:39:27 localhost anacron[5244]: Anacron 2.3 started on 2005-11-05 Nov 5 22:39:27 localhost anacron[5244]: Normal exit (0 jobs run) Nov 5 22:39:27 localhost /usr/sbin/gpm[5268]: oops() invoked from gpn.c(20= 5) Nov 5 22:39:27 localhost /usr/sbin/gpm[5268]: /var/run/gpm.pid: No such file or directory Nov 5 22:39:28 localhost pbbuttonsd: INFO: Script '/etc/power/pmcs-pbbuttonsd suspend ac ram' launched and exited normally Nov 5 22:39:28 localhost kernel: ural 4-1:1.0: resume is unsafe! Nov 5 22:39:28 localhost kernel: usb 4-1: no poweroff yet, suspending inst= ead Nov 5 22:39:28 localhost kernel: failed to set volume Nov 5 22:39:28 localhost kernel: usb usb4: no poweroff yet, suspending ins= tead Nov 5 22:39:28 localhost kernel: usb 1-1: no poweroff yet, suspending inst= ead Nov 5 22:39:28 localhost kernel: usb usb3: no poweroff yet, suspending ins= tead Nov 5 22:39:28 localhost kernel: usb usb2: no poweroff yet, suspending ins= tead Nov 5 22:39:28 localhost kernel: usb usb1: no poweroff yet, suspending ins= tead Nov 5 22:39:29 localhost kernel: eth0: suspending, WakeOnLan disabled Nov 5 22:39:29 localhost kernel: radeonfb (0000:00:10.0): suspending to state: 2... Nov 5 22:39:29 localhost kernel: uninorth-agp: disabling AGP on device 0000:00:10.0 Nov 5 22:39:29 localhost kernel: uninorth-agp: disabling AGP on bridge 0000:00:0b.0 Nov 5 22:39:29 localhost kernel: radeonfb (0000:00:10.0): resuming from state: 2... Nov 5 22:39:29 localhost kernel: PCI: Enabling device 0000:00:10.0 (0000 -> 0003) Nov 5 22:39:29 localhost kernel: radeon: PAD_CTLR_STRENGTH doesn't stabili= ze ! Nov 5 22:39:29 localhost kernel: agpgart: Putting AGP V2 device at 0000:00:0b.0 into 4x mode Nov 5 22:39:29 localhost kernel: agpgart: Putting AGP V2 device at 0000:00:10.0 into 4x mode Nov 5 22:39:29 localhost kernel: PCI: Enabling device 0001:10:1b.0 (0000 -> 0002) Nov 5 22:39:29 localhost kernel: PCI: Enabling device 0001:10:1b.1 (0000 -> 0002) Nov 5 22:39:29 localhost kernel: PCI: Enabling device 0001:10:1b.2 (0000 -> 0002) Nov 5 22:39:29 localhost kernel: ehci_hcd 0001:10:1b.2: park 0 Nov 5 22:39:29 localhost kernel: ehci_hcd 0001:10:1b.2: USB 2.0 restarted, EHCI 1.00, driver 10 Dec 2004 Nov 5 22:39:31 localhost kernel: eth0: resuming Nov 5 22:39:31 localhost kernel: PHY ID: 4061e4, addr: 0 Nov 5 22:39:32 localhost kernel: hda: Enabling Ultra DMA 5 Nov 5 22:39:32 localhost kernel: hdc: Enabling MultiWord DMA 2 Nov 5 22:39:32 localhost dhclient: receive_packet failed on eth1: Network is down Nov 5 22:39:32 localhost kernel: usb 4-1: USB disconnect, address 3 Nov 5 22:39:32 localhost kernel: usb 4-1: new high speed USB device using ehci_hcd and address 4 Nov 5 22:39:32 localhost postfix/postfix-script: refreshing the Postfix mail system Nov 5 22:39:32 localhost postfix/master[3972]: reload configuration /etc/postfix Nov 5 22:39:32 localhost kernel: ural_eeprom_read: 4 -> 00:11:95:87:2c:ad Nov 5 22:39:32 localhost kernel: eth1: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mb= ps Nov 5 22:39:32 localhost kernel: eth1: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps Nov 5 22:39:32 localhost kernel: eth1: RT2570 (rev 0x03), RF RT2526, ether 00:11:95:87:2c:ad at usb-0001:10:1b.2-1 Nov 5 22:39:39 localhost kernel: adb: starting probe task... Nov 5 22:39:39 localhost dhclient: Internet Software Consortium DHCP Client 2.0pl5 Nov 5 22:39:39 localhost dhclient: Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. Nov 5 22:39:39 localhost dhclient: All rights reserved. Nov 5 22:39:39 localhost dhclient: Nov 5 22:39:39 localhost dhclient: Please contribute if you find this software useful. Nov 5 22:39:39 localhost dhclient: For info, please visit http://www.isc.org/dhcp-contrib.html Nov 5 22:39:39 localhost dhclient: Nov 5 22:39:39 localhost dhclient: sit0: unknown hardware address type 776 Nov 5 22:39:39 localhost kernel: ural_set_macaddr: 00:11:95:87:2c:ad Nov 5 22:39:39 localhost kernel: setting MAC address to 00:11:95:87:2c:ad Nov 5 22:39:39 localhost kernel: leaving promiscuous mode Nov 5 22:39:39 localhost kernel: ural_set_macaddr: 00:11:95:87:2c:ad Nov 5 22:39:39 localhost kernel: setting MAC address to 00:11:95:87:2c:ad Nov 5 22:39:39 localhost kernel: adb devices: [2]: 2 c4 [3]: 3 1 [7]: 7 1f Nov 5 22:39:39 localhost kernel: ADB keyboard at 2, handler 1 Nov 5 22:39:39 localhost kernel: ADB mouse at 3, handler set to 4 (trackpa= d) Nov 5 22:39:39 localhost kernel: adb: finished probe task... Nov 5 22:39:39 localhost kernel: agpgart: Putting AGP V2 device at 0000:00:0b.0 into 4x mode Nov 5 22:39:39 localhost kernel: agpgart: Putting AGP V2 device at 0000:00:10.0 into 4x mode Nov 5 22:39:39 localhost kernel: [drm] Loading R200 Microcode Nov 5 22:39:39 localhost ifd[5442]: starting Nov 5 22:39:39 localhost ifd[5442]: executing: '/usr/share/laptop-net/link-change eth0 managed unknown up,running,disconnected' Nov 5 22:39:39 localhost ifd: PID file written: /var/run/ifd.pid Nov 5 22:39:39 localhost pbbuttonsd: INFO: Script '/etc/power/pmcs-pbbuttonsd resume ac ram' launched and exited normally Nov 5 22:39:39 localhost laptop-net: Stopping network interface "eth0" Nov 5 22:39:40 localhost dhclient: sit0: unknown hardware address type 776 Nov 5 22:39:40 localhost dhclient: Listening on LPF/eth1/00:11:95:87:2c:ad Nov 5 22:39:40 localhost dhclient: Sending on LPF/eth1/00:11:95:87:2c:ad Nov 5 22:39:40 localhost dhclient: Sending on Socket/fallback/fallback-n= et Nov 5 22:39:40 localhost dhclient: DHCPREQUEST on eth1 to 255.255.255.255 port 67 Nov 5 22:39:42 localhost kernel: ural_set_macaddr: 00:11:95:87:2c:ad Nov 5 22:39:42 localhost kernel: setting MAC address to 00:11:95:87:2c:ad Nov 5 22:39:42 localhost kernel: ural_set_macaddr: 00:11:95:87:2c:ad Nov 5 22:39:42 localhost kernel: setting MAC address to 00:11:95:87:2c:ad Nov 5 22:39:42 localhost kernel: ural_set_macaddr: 00:11:95:87:2c:ad Nov 5 22:39:42 localhost kernel: setting MAC address to 00:11:95:87:2c:ad Nov 5 22:39:44 localhost dhclient: DHCPREQUEST on eth1 to 255.255.255.255 port 67 Nov 5 22:39:45 localhost kernel: setting BSSID to 00:11:95:36:fc:f7 Nov 5 22:39:45 localhost kernel: enabling TSF synchronization Nov 5 22:39:49 localhost kernel: eth1: no IPv6 routers present Nov 5 22:39:53 localhost dhclient: DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 5 Nov 5 22:39:53 localhost dhclient: DHCPOFFER from 192.168.0.1 Nov 5 22:39:55 localhost dhclient: DHCPREQUEST on eth1 to 255.255.255.255 port 67 Nov 5 22:39:55 localhost dhclient: DHCPACK from 192.168.0.1 Nov 5 22:39:55 localhost kernel: leaving promiscuous mode Nov 5 22:39:55 localhost kernel: leaving promiscuous mode Nov 5 22:39:56 localhost postfix/postfix-script: refreshing the Postfix mail system Nov 5 22:39:56 localhost postfix/master[3972]: reload configuration /etc/postfix Nov 5 22:39:56 localhost dhclient: bound to 192.168.0.101 -- renewal in 302400 seconds. Nov 5 22:39:56 localhost ifd[5442]: + cat: /var/run/dhclient.eth0.pid: No such file or directory Nov 5 22:40:08 localhost kernel: eth0: no IPv6 routers present
--------------------------------------
----------------------------------
resume with your patch :
Nov 5 22:28:21 localhost anacron[6603]: Anacron 2.3 started on 2005-11-05 Nov 5 22:28:21 localhost anacron[6603]: Normal exit (0 jobs run) Nov 5 22:28:21 localhost /usr/sbin/gpm[6627]: oops() invoked from gpn.c(20= 5) Nov 5 22:28:21 localhost /usr/sbin/gpm[6627]: /var/run/gpm.pid: No such file or directory Nov 5 22:28:21 localhost pbbuttonsd: INFO: Script '/etc/power/pmcs-pbbuttonsd suspend ac ram' launched and exited normally Nov 5 22:28:22 localhost kernel: ural 2-1:1.0: resume is unsafe! Nov 5 22:28:22 localhost kernel: usb 2-1: no poweroff yet, suspending inst= ead Nov 5 22:28:22 localhost kernel: failed to set volume Nov 5 22:28:22 localhost kernel: usb 1-1: no poweroff yet, suspending inst= ead Nov 5 22:28:22 localhost kernel: usb usb3: no poweroff yet, suspending ins= tead Nov 5 22:28:22 localhost kernel: usb usb2: no poweroff yet, suspending ins= tead Nov 5 22:28:22 localhost kernel: usb usb1: no poweroff yet, suspending ins= tead Nov 5 22:28:22 localhost kernel: eth0: suspending, WakeOnLan disabled Nov 5 22:28:22 localhost kernel: radeonfb (0000:00:10.0): suspending to state: 2... Nov 5 22:28:22 localhost kernel: uninorth-agp: disabling AGP on device 0000:00:10.0 Nov 5 22:28:22 localhost kernel: uninorth-agp: disabling AGP on bridge 0000:00:0b.0 Nov 5 22:28:23 localhost kernel: radeonfb (0000:00:10.0): resuming from state: 2... Nov 5 22:28:23 localhost kernel: PCI: Enabling device 0000:00:10.0 (0000 -> 0003) Nov 5 22:28:23 localhost kernel: radeon: PAD_CTLR_STRENGTH doesn't stabili= ze ! Nov 5 22:28:23 localhost kernel: agpgart: Putting AGP V2 device at 0000:00:0b.0 into 4x mode Nov 5 22:28:23 localhost kernel: agpgart: Putting AGP V2 device at 0000:00:10.0 into 4x mode Nov 5 22:28:23 localhost kernel: PCI: Enabling device 0001:10:1b.0 (0000 -> 0002) Nov 5 22:28:23 localhost kernel: PCI: Enabling device 0001:10:1b.1 (0000 -> 0002) Nov 5 22:28:24 localhost kernel: eth0: resuming Nov 5 22:28:24 localhost kernel: PHY ID: 4061e4, addr: 0 Nov 5 22:28:25 localhost kernel: hda: Enabling Ultra DMA 5 Nov 5 22:28:25 localhost kernel: hdc: Enabling MultiWord DMA 2 Nov 5 22:28:38 localhost kernel: adb: starting probe task... Nov 5 22:28:38 localhost kernel: adb devices: [2]: 2 c4 [3]: 3 1 [7]: 7 1f Nov 5 22:28:38 localhost kernel: ADB keyboard at 2, handler 1 Nov 5 22:28:38 localhost kernel: ADB mouse at 3, handler set to 4 (trackpa= d) Nov 5 22:28:38 localhost kernel: adb: finished probe task... Nov 5 22:28:38 localhost kernel: agpgart: Putting AGP V2 device at 0000:00:0b.0 into 4x mode Nov 5 22:28:38 localhost kernel: agpgart: Putting AGP V2 device at 0000:00:10.0 into 4x mode Nov 5 22:28:38 localhost kernel: [drm] Loading R200 Microcode Nov 5 22:28:38 localhost ifd[6680]: starting Nov 5 22:28:38 localhost ifd[6680]: executing: '/usr/share/laptop-net/link-change eth0 managed unknown up,running,disconnected' Nov 5 22:28:38 localhost ifd: PID file written: /var/run/ifd.pid Nov 5 22:28:38 localhost pbbuttonsd: INFO: Script '/etc/power/pmcs-pbbuttonsd resume ac ram' launched and exited normally Nov 5 22:28:39 localhost laptop-net: Stopping network interface "eth0" Nov 5 22:28:39 localhost ifd[6680]: + cat: /var/run/dhclient.eth0.pid: No such file or directory Nov 5 22:28:50 localhost kernel: eth0: no IPv6 routers present
-------------------------------------------------------------------
Thanks,
Bin
Quoted 5 lines
http://gate.crashing.org/~benh/fix-ohci-sleep.diff
Note that the patch is totally untested here so it may be just plain bogus :)
Quoted 7 lines
Ben.
--
To UNSUBSCRIBE, email to [email protected] with a subject of "unsubscribe". Trouble? Contact [email protected]=
.org
Quoted 2 lines
Quoted 7 lines · Bin Zhang
Quoted 4 lines · Benjamin Herrenschmidt
For those who experience crashes on sleep and/or wakeup (typically due to USB) with 2.6.14, I made a test patch that might help. Please let me know if it makes things more reliable.
I've tried your patch with usb wifi dlink dwl-g122 (my eth1). It works. There are some differences in
/var/log/syslog:
I have another patch tho:
drivers/usb/core/hcd-pci.c +31 -1
@@ -32,6 +32,13 @@#include <linux/usb.h> #include "hcd.h" +#ifdef CONFIG_PPC_PMAC +#include <asm/machdep.h> +#include <asm/pmac_feature.h> +#include <asm/pci-bridge.h> +#include <asm/prom.h> +#endif +/* PCI-based HCs are common, but plenty of non-PCI HCs are used too */
@@ -278,6 +285,18 @@break ; } +#ifdef CONFIG_PPC_PMAC +if (retval ==0 && _machine == _MACH_Pmac) { +struct device_node *of_node; + +/* Disable USB PAD & cell clock */ + of_node =pci_device_to_OF_node (to_pci_dev (hcd->self. + controller)); +if (of_node) +pmac_call_feature (PMAC_FTR_USB_ENABLE , of_node,0 ,0 ); + } +#endif /* CONFIG_PPC_PMAC */ +/* update power_state **ONLY** to make sysfs happier */ if (retval ==0 ) dev->dev.power.power_state = message;
@@ -303,6 +322,18 @@return 0 ; } +#ifdef CONFIG_PPC_PMAC +if (_machine == _MACH_Pmac) { +struct device_node *of_node; + +/* Re-enable USB PAD & cell clock */ + of_node =pci_device_to_OF_node (to_pci_dev (hcd->self. + controller)); +if (of_node) +pmac_call_feature (PMAC_FTR_USB_ENABLE , of_node,0 ,1 ); + } +#endif /* CONFIG_PPC_PMAC */ +/* NOTE: chip docs cover clean "real suspend" cases (what Linux * calls "standby", "suspend to RAM", and so on). There are also * dirty cases when swsusp fakes a suspend in "shutdown" mode.
@@ -381,7 +412,6 @@usb_hc_died (hcd); } - retval =pci_enable_device (dev);return retval; }EXPORT_SYMBOL (usb_hcd_pci_resume);
drivers/usb/host/ehci-hcd.c +12 -0
@@ -750,6 +750,15 @@if (time_before (jiffies, ehci->next_statechange))msleep (100 ); +/* Disable emission of interrupts during suspend */ +writel (0 , &ehci->regs->intr_enable); +mb (); +clear_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +synchronize_irq (dev->irq); + +/* Tell root hub not to bother trying to resume */ +set_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags); +#ifdef CONFIG_USB_SUSPEND (void )usb_suspend_device (hcd->self.root_hub, message);#else
@@ -776,6 +785,9 @@if (time_before (jiffies, ehci->next_statechange))msleep (100 ); +clear_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags); +set_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +/* If any port is suspended (or owned by the companion), * we know we can/must resume the HC (and mustn't reset it). */
drivers/usb/host/ehci-q.c +5 -0
@@ -926,6 +926,11 @@#endif spin_lock_irqsave (&ehci->lock, flags); +if (HC_IS_SUSPENDED (ehci_to_hcd (ehci)->state)) { +spin_unlock_irqrestore (&ehci->lock, flags); +return -ESHUTDOWN ; + } + qh =qh_append_tds (ehci, urb, qtd_list, epnum, &ep->hcpriv);/* Control/bulk operations through TTs don't need scheduling,
drivers/usb/host/ehci-sched.c +15 -0
@@ -602,6 +602,11 @@spin_lock_irqsave (&ehci->lock, flags); +if (HC_IS_SUSPENDED (ehci_to_hcd (ehci)->state)) { +spin_unlock_irqrestore (&ehci->lock, flags); +return -ESHUTDOWN ; + } +/* get qh and force any scheduling errors */ INIT_LIST_HEAD (&empty); qh =qh_append_tds (ehci, urb, &empty, epnum, &ep->hcpriv);
@@ -1456,6 +1461,11 @@/* schedule ... need to lock */ spin_lock_irqsave (&ehci->lock, flags); +if (HC_IS_SUSPENDED (ehci_to_hcd (ehci)->state)) { +spin_unlock_irqrestore (&ehci->lock, flags); + status = -ESHUTDOWN ; + goto done; + } status =iso_stream_schedule (ehci, urb, stream);if (likely (status ==0 ))itd_link_urb (ehci, urb, ehci->periodic_size <<3 , stream);
@@ -1815,6 +1825,11 @@/* schedule ... need to lock */ spin_lock_irqsave (&ehci->lock, flags); +if (HC_IS_SUSPENDED (ehci_to_hcd (ehci)->state)) { +spin_unlock_irqrestore (&ehci->lock, flags); + status = -ESHUTDOWN ; + goto done; + } status =iso_stream_schedule (ehci, urb, stream);if (status ==0 )sitd_link_urb (ehci, urb, ehci->periodic_size <<3 , stream);
drivers/usb/host/ohci-hcd.c +4 -0
@@ -252,6 +252,10 @@spin_lock_irqsave (&ohci->lock, flags); +if (HC_IS_SUSPENDED (hcd->state)) { + retval = -ESHUTDOWN ; + goto fail; + }/* don't submit to a dead HC */ if (!HC_IS_RUNNING (hcd->state)) { retval = -ENODEV ;
drivers/usb/host/ohci-hub.c +19 -7
@@ -139,6 +139,9 @@u32 temp, enables;int status = -EINPROGRESS ; +if (test_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags)) +return -ESHUTDOWN ; +if (time_before (jiffies, ohci->next_statechange))msleep (5 );
@@ -219,13 +222,6 @@/* Sometimes PCI D3 suspend trashes frame timings ... */ periodic_reinit (ohci); -/* interrupts might have been disabled */ -ohci_writel (ohci,OHCI_INTR_INIT , &ohci->regs->intrenable); -if (ohci->ed_rm_list) -ohci_writel (ohci,OHCI_INTR_SF , &ohci->regs->intrenable); -ohci_writel (ohci,ohci_readl (ohci, &ohci->regs->intrstatus), - &ohci->regs->intrstatus); -/* Then re-enable operations */ ohci_writel (ohci,OHCI_USB_OPER , &ohci->regs->control); (void )ohci_readl (ohci, &ohci->regs->control);
@@ -241,6 +237,13 @@/* TRSMRCY */ msleep (10 ); +/* interrupts might have been disabled */ +ohci_writel (ohci,OHCI_INTR_INIT , &ohci->regs->intrenable); +if (ohci->ed_rm_list) +ohci_writel (ohci,OHCI_INTR_SF , &ohci->regs->intrenable); +ohci_writel (ohci,ohci_readl (ohci, &ohci->regs->intrstatus), + &ohci->regs->intrstatus); +/* keep it alive for ~5x suspend + resume costs */ ohci->next_statechange = jiffies +msecs_to_jiffies (250 );
@@ -308,6 +311,9 @@int can_suspend = hcd->can_wakeup;unsigned long flags; +if (test_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags)) +return 0 ; +spin_lock_irqsave (&ohci->lock, flags);/* handle autosuspended root: finish resuming before
@@ -441,6 +447,9 @@return -EINVAL ; port--; +if (test_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags)) +return -ESHUTDOWN ; +/* start port reset before HNP protocol times out */ status =ohci_readl (ohci, &ohci->regs->roothub.portstatus [port]);if (!(status &RH_PS_CCS ))
@@ -526,6 +535,9 @@u32 temp;int retval =0 ; +if (test_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags)) +return -ESHUTDOWN ; +switch (typeReq) {case ClearHubFeature:switch (wValue) {
drivers/usb/host/ohci-pci.c +13 -28
68 lines not on this page · raw message
drivers/usb/core/hcd.c +5 -1
@@ -1600,7 +1600,8 @@struct usb_hcd *hcd = __hcd;int start = hcd->state; -if (start ==HC_STATE_HALT ) +if (start ==HC_STATE_HALT || + !test_bit (HC_FLAG_IRQ_ON , &hcd->bitflags))return IRQ_NONE ;if (hcd->driver->irq (hcd, r) ==IRQ_NONE )return IRQ_NONE ;
@@ -1736,6 +1737,9 @@if (hcd->driver->irq) {char buf[8 ], *bufp = buf; +set_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +wmb (); +#ifdef __sparc__ bufp =__irq_itoa (irqnum);#else
drivers/usb/core/hcd.h +4 -0
@@ -71,6 +71,10 @@/* * hardware info/state */ +unsigned long bitflags;/* various single-bit flags */ +#define HC_FLAG_IRQ_ON 0 +#define HC_FLAG_SUSPEND_RH 1 +const struct hc_driver *driver;/* hw-specific hooks */ unsigned saw_irq : 1; unsigned can_wakeup:1; /* hw supports wakeup? */
drivers/usb/host/ehci-hub.c +8 -1
@@ -90,8 +90,12 @@int i;int intr_enable; +if (test_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags)) +return -ESHUTDOWN ; +if (time_before (jiffies, ehci->next_statechange))msleep (5 ); +spin_lock_irq (&ehci->lock);/* re-init operational registers in case we lost power */
@@ -215,7 +219,8 @@unsigned long flags;/* if !USB_SUSPEND, root hub timers won't get shut down ... */ -if (!HC_IS_RUNNING (hcd->state)) +if (!HC_IS_RUNNING (hcd->state) || +test_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags))return 0 ;/* init status to no-changes */
@@ -313,6 +318,8 @@unsigned long flags;int retval =0 ; +if (test_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags)) +return -ESHUTDOWN ;/* * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR. * HCS_INDICATOR may say we can change LEDs to off/amber/green.
drivers/usb/host/uhci-hcd.c +8 -1
@@ -770,6 +770,12 @@dev_dbg (uhci_dev (uhci),"%s\n" , __FUNCTION__); +/* Disable emission of interrupts during suspend */ +pci_write_config_word (to_pci_dev (uhci_dev (uhci)),USBLEGSUP ,0 ); +mb (); +clear_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +synchronize_irq (dev->irq); +spin_lock_irq (&uhci->lock);if (uhci->hc_inaccessible)/* Dead or already suspended */ goto done;
@@ -787,7 +793,8 @@ };/* All PCI host controllers are required to disable IRQ generation -* at the source, so we must turn off PIRQ. +* at the source, so we must turn off PIRQ. Already done earlier +* but better be safe than sorry... */ pci_write_config_word (to_pci_dev (uhci_dev (uhci)),USBLEGSUP ,0 ); uhci->hc_inaccessible =1 ;
Quoted 3 lines · Benjamin Herrenschmidt
Quoted 2 lines · Bin Zhang
Quoted 1 line · Benjamin Herrenschmidt
For those who experience crashes on sleep and/or wakeup (typically du=
e
Quoted 1 line
Quoted 1 line
Quoted 1 line
to USB) with 2.6.14, I made a test patch that might help. Please let =
me
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
know if it makes things more reliable.
I've tried your patch with usb wifi dlink dwl-g122 (my eth1). It works. There are some differences in
/var/log/syslog:I have another patch tho:
The new patch works for me.
With or without the new patch, now I get almost the same syslogs.
Thanks,
Bin
Quoted 2 lines
Index:
linux-2.6.14-benh/drivers/usb/core/hcd-pci.c=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Quoted 1 line
---
linux-2.6.14-benh.orig/drivers/usb/core/hcd-pci.c2005-10-31 10:54:=
44.000000000 +1100
Quoted 1 line
+++
linux-2.6.14-benh/drivers/usb/core/hcd-pci.c2005-11-05 11:58:=
55.000000000 +1100
Quoted 17 lines
drivers/usb/core/hcd-pci.c +7
-0@@ -32,6 +32,13 @@#include <linux/usb.h> #include "hcd.h" +#ifdef CONFIG_PPC_PMAC +#include <asm/machdep.h> +#include <asm/pmac_feature.h> +#include <asm/pci-bridge.h> +#include <asm/prom.h> +#endif +/* PCI-based HCs are common, but plenty of non-PCI HCs are used too */ @@ -278,6 +285,18 @@break ; }
drivers/usb/core/hcd-pci.c line 296
Quoted 10 lines
drivers/usb/core/hcd-pci.c +9
-0+#ifdef CONFIG_PPC_PMAC + if (retval =3D=3D 0 && _machine =3D=3D _MACH_Pmac) { +struct device_node *of_node; + +/* Disable USB PAD & cell clock */ + of_node =3D pci_device_to_OF_node (to_pci_dev(hcd->self. + controller)); +if (of_node) + pmac_call_feature(PMAC_FTR_USB_ENABLE, of_node, 0=
, 0);
Quoted 9 lines
drivers/usb/core/hcd-pci.c +3
-0+ } +#endif /* CONFIG_PPC_PMAC */ +/* update power_state **ONLY** to make sysfs happier */ if (retval =3D=3D 0) dev->dev.power.power_state =3D message;@@ -303,6 +322,18 @@return 0 ; }
drivers/usb/core/hcd-pci.c line 333
Quoted 10 lines
drivers/usb/core/hcd-pci.c +9
-0+#ifdef CONFIG_PPC_PMAC + if (_machine =3D=3D _MACH_Pmac) { +struct device_node *of_node; + +/* Re-enable USB PAD & cell clock */ + of_node =3D pci_device_to_OF_node (to_pci_dev(hcd->self. + controller)); +if (of_node) + pmac_call_feature(PMAC_FTR_USB_ENABLE, of_node, 0=
, 1);
Quoted 14 lines
drivers/usb/core/hcd-pci.c +3
-1+ } +#endif /* CONFIG_PPC_PMAC */ +/* NOTE: chip docs cover clean "real suspend" cases (what Linux * calls "standby", "suspend to RAM", and so on). There are also * dirty cases when swsusp fakes a suspend in "shutdown" mode. @@ -381,7 +412,6 @@usb_hc_died (hcd); } - retval =3D pci_enable_device(dev);return retval; }EXPORT_SYMBOL (usb_hcd_pci_resume);
Quoted 2 lines
Index:
linux-2.6.14-benh/drivers/usb/host/ehci-hcd.c=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Quoted 1 line
---
linux-2.6.14-benh.orig/drivers/usb/host/ehci-hcd.c2005-10-31 10:54:=
44.000000000 +1100
Quoted 1 line
+++
linux-2.6.14-benh/drivers/usb/host/ehci-hcd.c2005-11-06 08:26:=
42.000000000 +1100
Quoted 26 lines
drivers/usb/host/ehci-hcd.c +12
-0@@ -750,6 +750,15 @@if (time_before (jiffies, ehci->next_statechange))msleep (100 ); +/* Disable emission of interrupts during suspend */ +writel (0 , &ehci->regs->intr_enable); +mb (); +clear_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +synchronize_irq (dev->irq); + +/* Tell root hub not to bother trying to resume */ +set_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags); +#ifdef CONFIG_USB_SUSPEND (void )usb_suspend_device (hcd->self.root_hub, message);#else @@ -776,6 +785,9 @@if (time_before (jiffies, ehci->next_statechange))msleep (100 ); +clear_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags); +set_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +/* If any port is suspended (or owned by the companion), * we know we can/must resume the HC (and mustn't reset it). */
Quoted 2 lines
Index:
linux-2.6.14-benh/drivers/usb/host/ehci-q.c=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Quoted 1 line
---
linux-2.6.14-benh.orig/drivers/usb/host/ehci-q.c2005-10-31 10:54:=
44.000000000 +1100
Quoted 1 line
+++
linux-2.6.14-benh/drivers/usb/host/ehci-q.c2005-11-03 17:03:27.00000=
0000 +1100
Quoted 12 lines
drivers/usb/host/ehci-q.c +5
-0@@ -926,6 +926,11 @@#endif spin_lock_irqsave (&ehci->lock, flags); +if (HC_IS_SUSPENDED (ehci_to_hcd (ehci)->state)) { +spin_unlock_irqrestore (&ehci->lock, flags); +return -ESHUTDOWN ; + } + qh =3D qh_append_tds (ehci, urb, qtd_list, epnum, &ep->hcpriv);/* Control/bulk operations through TTs don't need scheduling,
Quoted 2 lines
Index:
linux-2.6.14-benh/drivers/usb/host/ehci-sched.c=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Quoted 1 line
---
linux-2.6.14-benh.orig/drivers/usb/host/ehci-sched.c2005-10-3=
1 10:54:44.000000000 +1100
Quoted 1 line
+++
linux-2.6.14-benh/drivers/usb/host/ehci-sched.c2005-11-03 17:05:=
54.000000000 +1100
Quoted 14 lines
drivers/usb/host/ehci-sched.c +5
-0@@ -602,6 +602,11 @@spin_lock_irqsave (&ehci->lock, flags); +if (HC_IS_SUSPENDED (ehci_to_hcd (ehci)->state)) { +spin_unlock_irqrestore (&ehci->lock, flags); +return -ESHUTDOWN ; + } +/* get qh and force any scheduling errors */ INIT_LIST_HEAD (&empty); qh =3D qh_append_tds (ehci, urb, &empty, epnum, &ep->hcpriv);@@ -1456,6 +1461,11 @@
drivers/usb/host/ehci-sched.c line 1471
Quoted 10 lines
drivers/usb/host/ehci-sched.c +5
-0/* schedule ... need to lock */ spin_lock_irqsave (&ehci->lock, flags); +if (HC_IS_SUSPENDED (ehci_to_hcd (ehci)->state)) { +spin_unlock_irqrestore (&ehci->lock, flags); + status =3D -ESHUTDOWN ; + goto done; + } status =3D iso_stream_schedule (ehci, urb, stream); if (likely (status =3D=3D 0)) itd_link_urb (ehci, urb, ehci->periodic_size << 3, stream=
);
drivers/usb/host/ehci-sched.c line 1835
Quoted 12 lines
drivers/usb/host/ehci-sched.c +5
-0@@ -1815,6 +1825,11 @@/* schedule ... need to lock */ spin_lock_irqsave (&ehci->lock, flags); +if (HC_IS_SUSPENDED (ehci_to_hcd (ehci)->state)) { +spin_unlock_irqrestore (&ehci->lock, flags); + status =3D -ESHUTDOWN ; + goto done; + } status =3D iso_stream_schedule (ehci, urb, stream); if (status =3D=3D 0) sitd_link_urb (ehci, urb, ehci->periodic_size << 3, strea=
m);
Quoted 2 lines
Index:
linux-2.6.14-benh/drivers/usb/host/ohci-hcd.c=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Quoted 1 line
---
linux-2.6.14-benh.orig/drivers/usb/host/ohci-hcd.c2005-10-31 10:54:=
44.000000000 +1100
Quoted 1 line
+++
linux-2.6.14-benh/drivers/usb/host/ohci-hcd.c2005-11-06 08:34:=
41.000000000 +1100
Quoted 11 lines
drivers/usb/host/ohci-hcd.c +4
-0@@ -252,6 +252,10 @@spin_lock_irqsave (&ohci->lock, flags); +if (HC_IS_SUSPENDED (hcd->state)) { + retval =3D -ESHUTDOWN ; + goto fail; + }/* don't submit to a dead HC */ if (!HC_IS_RUNNING (hcd->state)) { retval =3D -ENODEV ;
Quoted 2 lines
Index:
linux-2.6.14-benh/drivers/usb/host/ohci-hub.c=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Quoted 1 line
---
linux-2.6.14-benh.orig/drivers/usb/host/ohci-hub.c2005-10-31 10:54:=
44.000000000 +1100
Quoted 1 line
+++
linux-2.6.14-benh/drivers/usb/host/ohci-hub.c2005-11-05 13:12:=
24.000000000 +1100
Quoted 11 lines
drivers/usb/host/ohci-hub.c +3
-0@@ -139,6 +139,9 @@u32 temp, enables;int status =3D -EINPROGRESS ; +if (test_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags)) +return -ESHUTDOWN ; +if (time_before (jiffies, ohci->next_statechange))msleep (5 );
drivers/usb/host/ohci-hub.c line 225
Quoted 7 lines
drivers/usb/host/ohci-hub.c +0
-4@@ -219,13 +222,6 @@/* Sometimes PCI D3 suspend trashes frame timings ... */ periodic_reinit (ohci); -/* interrupts might have been disabled */ -ohci_writel (ohci,OHCI_INTR_INIT , &ohci->regs->intrenable); -if (ohci->ed_rm_list) - ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrenable)=
;
Quoted 7 lines
drivers/usb/host/ohci-hub.c +0
-3-ohci_writel (ohci,ohci_readl (ohci, &ohci->regs->intrstatus), - &ohci->regs->intrstatus); -/* Then re-enable operations */ ohci_writel (ohci,OHCI_USB_OPER , &ohci->regs->control); (void )ohci_readl (ohci, &ohci->regs->control);
drivers/usb/host/ohci-hub.c line 243
Quoted 7 lines
drivers/usb/host/ohci-hub.c +4
-0@@ -241,6 +237,13 @@/* TRSMRCY */ msleep (10 ); +/* interrupts might have been disabled */ +ohci_writel (ohci,OHCI_INTR_INIT , &ohci->regs->intrenable); +if (ohci->ed_rm_list) + ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrenable)=
;
Quoted 17 lines
drivers/usb/host/ohci-hub.c +6
-0+ohci_writel (ohci,ohci_readl (ohci, &ohci->regs->intrstatus), + &ohci->regs->intrstatus); +/* keep it alive for ~5x suspend + resume costs */ ohci->next_statechange =3D jiffies + msecs_to_jiffies (250);@@ -308,6 +311,9 @@ int can_suspend =3D hcd->can_wakeup;unsigned long flags; +if (test_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags)) +return 0 ; +spin_lock_irqsave (&ohci->lock, flags);/* handle autosuspended root: finish resuming before
drivers/usb/host/ohci-hub.c line 454
Quoted 8 lines
drivers/usb/host/ohci-hub.c +3
-0@@ -441,6 +447,9 @@return -EINVAL ; port--; +if (test_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags)) +return -ESHUTDOWN ; +/* start port reset before HNP protocol times out */ status =3D ohci_readl(ohci, &ohci->regs->roothub.portstatus [port=
]);
Quoted 11 lines
drivers/usb/host/ohci-hub.c +3
-0if (!(status &RH_PS_CCS ))@@ -526,6 +535,9 @@u32 temp; int retval =3D 0; +if (test_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags)) +return -ESHUTDOWN ; +switch (typeReq) {case ClearHubFeature:switch (wValue) {
Quoted 2 lines
Index:
linux-2.6.14-benh/drivers/usb/host/ohci-pci.c=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Quoted 1 line
---
linux-2.6.14-benh.orig/drivers/usb/host/ohci-pci.c2005-10-31 10:52:=
24.000000000 +1100
Quoted 1 line
+++
linux-2.6.14-benh/drivers/usb/host/ohci-pci.c2005-11-05 12:46:=
53.000000000 +1100
Quoted 31 lines
drivers/usb/host/ohci-pci.c +9
-7@@ -14,13 +14,6 @@* This file is licenced under the GPL. */ -#ifdef CONFIG_PPC_PMAC -#include <asm/machdep.h> -#include <asm/pmac_feature.h> -#include <asm/pci-bridge.h> -#include <asm/prom.h> -#endif -#ifndef CONFIG_PCI #error "This file is PCI bus glue. CONFIG_PCI must be defined."#endif @@ -118,6 +111,15 @@if (time_before (jiffies, ohci->next_statechange))msleep (100 ); +/* Disable emission of interrupts during suspend */ +ohci_writel (ohci,OHCI_INTR_MIE , &ohci->regs->intrdisable); +mb (); +clear_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +synchronize_irq (dev->irq); + +/* Tell root hub not to bother trying to resume */ +set_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags); +#ifdef CONFIG_USB_SUSPEND (void )usb_suspend_device (hcd->self.root_hub, message);#else
drivers/usb/host/ohci-pci.c line 137
Quoted 9 lines
drivers/usb/host/ohci-pci.c +0
-6@@ -129,16 +131,6 @@/* let things settle down a bit */ msleep (100 ); -#ifdef CONFIG_PPC_PMAC - if (_machine =3D=3D _MACH_Pmac) { - struct device_node *of_node; - - /* Disable USB PAD & cell clock */ - of_node =3D pci_device_to_OF_node (to_pci_dev(hcd->self.c=
ontroller));
Review line 139
Quoted 2 lines
(quoted diff) +0
-2- if (of_node) - pmac_call_feature(PMAC_FTR_USB_ENABLE, of_node, 0=
, 0);
Quoted 6 lines
drivers/usb/host/ohci-pci.c +0
-2- } -#endif /* CONFIG_PPC_PMAC */ return 0 ; }
drivers/usb/host/ohci-pci.c line 156
Quoted 9 lines
drivers/usb/host/ohci-pci.c +0
-6@@ -148,20 +140,13 @@ struct ohci_hcd *ohci =3D hcd_to_ohci (hcd); int retval =3D 0; -#ifdef CONFIG_PPC_PMAC - if (_machine =3D=3D _MACH_Pmac) { - struct device_node *of_node; - - /* Re-enable USB PAD & cell clock */ - of_node =3D pci_device_to_OF_node (to_pci_dev(hcd->self.c=
ontroller));
Review line 158
Quoted 2 lines
(quoted diff) +0
-2- if (of_node) - pmac_call_feature (PMAC_FTR_USB_ENABLE, of_node, =
0, 1);
Quoted 13 lines
drivers/usb/host/ohci-pci.c +4
-3- } -#endif /* CONFIG_PPC_PMAC */ -/* resume root hub */ if (time_before (jiffies, ohci->next_statechange))msleep (100 ); + +clear_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags); +set_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +#ifdef CONFIG_USB_SUSPEND /* get extra cleanup even if remote wakeup isn't in use */ retval =3D usb_resume_device (hcd->self.root_hub);
Quoted 2 lines
Index:
linux-2.6.14-benh/drivers/usb/core/hcd.c=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Quoted 1 line
---
linux-2.6.14-benh.orig/drivers/usb/core/hcd.c2005-10-31 10:54:=
44.000000000 +1100
Quoted 1 line
+++
linux-2.6.14-benh/drivers/usb/core/hcd.c2005-11-05 11:56:48.00000=
0000 +1100
Quoted 20 lines
drivers/usb/core/hcd.c +5
-1@@ -1600,7 +1600,8 @@ struct usb_hcd *hcd =3D __hcd; int start =3D hcd->state; - if (start =3D=3D HC_STATE_HALT) + if (start =3D=3D HC_STATE_HALT || + !test_bit (HC_FLAG_IRQ_ON , &hcd->bitflags))return IRQ_NONE ; if (hcd->driver->irq (hcd, r) =3D=3D IRQ_NONE)return IRQ_NONE ;@@ -1736,6 +1737,9 @@if (hcd->driver->irq) { char buf[8], *bufp =3D buf; +set_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +wmb (); +#ifdef __sparc__ bufp =3D __irq_itoa(irqnum);#else
Quoted 2 lines
Index:
linux-2.6.14-benh/drivers/usb/core/hcd.h=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Quoted 1 line
---
linux-2.6.14-benh.orig/drivers/usb/core/hcd.h2005-10-31 10:54:=
44.000000000 +1100
Quoted 1 line
+++
linux-2.6.14-benh/drivers/usb/core/hcd.h2005-11-05 12:19:11.00000=
0000 +1100
drivers/usb/core/hcd.h line 74
Quoted 5 lines
drivers/usb/core/hcd.h +1
-0@@ -71,6 +71,10 @@/* * hardware info/state */ +unsigned long bitflags;/* various single-bit fla=
gs */
Quoted 8 lines
drivers/usb/core/hcd.h +3
-0+#define HC_FLAG_IRQ_ON 0 +#define HC_FLAG_SUSPEND_RH 1 +const struct hc_driver *driver;/* hw-specific hooks */ unsigned saw_irq : 1; unsigned can_wakeup:1; /* hw supports wakeup? */Index:
linux-2.6.14-benh/drivers/usb/host/ehci-hub.c=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Quoted 1 line
---
linux-2.6.14-benh.orig/drivers/usb/host/ehci-hub.c2005-10-31 10:54:=
44.000000000 +1100
Quoted 1 line
+++
linux-2.6.14-benh/drivers/usb/host/ehci-hub.c2005-11-05 13:12:=
39.000000000 +1100
Quoted 32 lines
drivers/usb/host/ehci-hub.c +8
-1@@ -90,8 +90,12 @@int i;int intr_enable; +if (test_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags)) +return -ESHUTDOWN ; +if (time_before (jiffies, ehci->next_statechange))msleep (5 ); +spin_lock_irq (&ehci->lock);/* re-init operational registers in case we lost power */ @@ -215,7 +219,8 @@unsigned long flags;/* if !USB_SUSPEND, root hub timers won't get shut down ... */ -if (!HC_IS_RUNNING (hcd->state)) +if (!HC_IS_RUNNING (hcd->state) || +test_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags))return 0 ;/* init status to no-changes */ @@ -313,6 +318,8 @@unsigned long flags; int retval =3D 0; +if (test_bit (HC_FLAG_SUSPEND_RH , &hcd->bitflags)) +return -ESHUTDOWN ;/* * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR. * HCS_INDICATOR may say we can change LEDs to off/amber/green.
Quoted 2 lines
Index:
linux-2.6.14-benh/drivers/usb/host/uhci-hcd.c=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Quoted 1 line
---
linux-2.6.14-benh.orig/drivers/usb/host/uhci-hcd.c2005-10-31 10:54:=
44.000000000 +1100
Quoted 1 line
+++
linux-2.6.14-benh/drivers/usb/host/uhci-hcd.c2005-11-06 08:35:=
39.000000000 +1100
Quoted 14 lines
drivers/usb/host/uhci-hcd.c +6
-0@@ -770,6 +770,12 @@dev_dbg (uhci_dev (uhci),"%s\n" , __FUNCTION__); +/* Disable emission of interrupts during suspend */ +pci_write_config_word (to_pci_dev (uhci_dev (uhci)),USBLEGSUP ,0 ); +mb (); +clear_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +synchronize_irq (dev->irq); +spin_lock_irq (&uhci->lock);if (uhci->hc_inaccessible)/* Dead or already suspended */ goto done;
drivers/usb/host/uhci-hcd.c line 795
Quoted 3 lines
drivers/usb/host/uhci-hcd.c +0
-0@@ -787,7 +793,8 @@ };/* All PCI host controllers are required to disable IRQ generatio=
n
Quoted 9 lines
drivers/usb/host/uhci-hcd.c +2
-1-* at the source, so we must turn off PIRQ. +* at the source, so we must turn off PIRQ. Already done earlier +* but better be safe than sorry... */ pci_write_config_word (to_pci_dev (uhci_dev (uhci)),USBLEGSUP ,0 ); uhci->hc_inaccessible =3D 1;
Quoted 4 lines · Benjamin Herrenschmidt
For those who experience crashes on sleep and/or wakeup (typically due to USB) with 2.6.14, I made a test patch that might help. Please let me know if it makes things more reliable.
Quoted 11 lines
http://gate.crashing.org/~benh/fix-ohci-sleep.diff
Note that the patch is totally untested here so it may be just plain bogus :)
Ben.
Hi Ben,
i've applied your patch and it seems that when i put my powerbook to sleep ( by closing the lid ) the kernel just crashes since everytime i come back, the machine is turned off. I had a look at the logs and i see that i'm having a reboot almost immediateley after the lid is closed. However i've got no trace of a kernel panic .....
my conf:
Linux kaluha 2.6.14 #1 PREEMPT Mon Oct 31 10:28:22 CET 2005 ppc GNU/Linux
processor : 0
cpu : 7447/7457, altivec supported
clock : 612MHz
revision : 0.1 (pvr 8002 0101)
bogomips : 406.52
machine : PowerBook5,2
motherboard : PowerBook5,2 MacRISC3 Power Macintosh
detected as : 287 (PowerBook G4 15")
pmac flags : 0000001b
L2 cache : 512K unified
memory : 768MB
pmac-generation : NewWorld
I have a usb mouse that i unplug before closing the lid. Anything else that can be usefull ?
Thanks for your time.
Regards.
Signature · 9 lines
Charles-Edouard Ruault +33 1 55 34 76 65 [email protected] Idtect SA 37 Bd des Capucines 75002 Paris, France www.idtect.com
Hi Charles-Edouard,
On Mon, Nov 07, 2005 at 10:13:02AM +0100, Charles-Edouard Ruault wrote:
[...snip...]
Quoted 26 lines
Hi Ben,
i've applied your patch and it seems that when i put my powerbook to sleep ( by closing the lid ) the kernel just crashes since everytime i come back, the machine is turned off. I had a look at the logs and i see that i'm having a reboot almost immediateley after the lid is closed. However i've got no trace of a kernel panic .....
my conf:Linux kaluha 2.6.14 #1 PREEMPT Mon Oct 31 10:28:22 CET 2005 ppc GNU/Linux
processor : 0
cpu : 7447/7457, altivec supported
clock : 612MHz
revision : 0.1 (pvr 8002 0101)
bogomips : 406.52
machine : PowerBook5,2
motherboard : PowerBook5,2 MacRISC3 Power Macintosh
detected as : 287 (PowerBook G4 15")
pmac flags :0000001b
L2 cache : 512K unified
memory : 768MB
pmac-generation : NewWorldI have a usb mouse that i unplug before closing the lid. Anything else that can be usefull ?
Thanks for your time.
Regards.
Quoted 9 lines · Benjamin Herrenschmidt
Quoted 9 lines
Quoted 8 lines
I would say your first mistake is to use PREEMPT :) There are various
issues with PREEMPT on ppc32 that have not really been addressed so far,
and the USB code has some "holes" that I wouldn't trust in a PREEMPT environment.
Quoted 6 lines
Quoted 2 lines
What do you mean exactly? Should
CONFIG_PREEMPTnot be used? And what aboutCONFIG_PREEMPT_VOLUNTARY?I would avoid both for now.
Ben.
If I interpret your version string correctly, you also havre preemption enabled. Please try without and report back success and/or problems.
With best regards,
Wolfi
Quoted 7 lines
i've applied your patch and it seems that when i put my powerbook to sleep ( by closing the lid ) the kernel just crashes since everytime i come back, the machine is turned off. I had a look at the logs and i see that i'm having a reboot almost immediateley after the lid is closed. However i've got no trace of a kernel panic .....
my conf:
What about this patch ?
drivers/usb/core/hcd-pci.c +31 -0
@@ -32,6 +32,13 @@#include <linux/usb.h> #include "hcd.h" +#ifdef CONFIG_PPC_PMAC +#include <asm/machdep.h> +#include <asm/pmac_feature.h> +#include <asm/pci-bridge.h> +#include <asm/prom.h> +#endif +/* PCI-based HCs are common, but plenty of non-PCI HCs are used too */
@@ -278,6 +285,18 @@break ; } +#ifdef CONFIG_PPC_PMAC +if (retval ==0 && _machine == _MACH_Pmac) { +struct device_node *of_node; + +/* Disable USB PAD & cell clock */ + of_node =pci_device_to_OF_node (to_pci_dev (hcd->self. + controller)); +if (of_node) +pmac_call_feature (PMAC_FTR_USB_ENABLE , of_node,0 ,0 ); + } +#endif /* CONFIG_PPC_PMAC */ +/* update power_state **ONLY** to make sysfs happier */ if (retval ==0 ) dev->dev.power.power_state = message;
@@ -303,6 +322,18 @@return 0 ; } +#ifdef CONFIG_PPC_PMAC +if (_machine == _MACH_Pmac) { +struct device_node *of_node; + +/* Re-enable USB PAD & cell clock */ + of_node =pci_device_to_OF_node (to_pci_dev (hcd->self. + controller)); +if (of_node) +pmac_call_feature (PMAC_FTR_USB_ENABLE , of_node,0 ,1 ); + } +#endif /* CONFIG_PPC_PMAC */ +/* NOTE: chip docs cover clean "real suspend" cases (what Linux * calls "standby", "suspend to RAM", and so on). There are also * dirty cases when swsusp fakes a suspend in "shutdown" mode.
drivers/usb/core/hcd.c +5 -1
@@ -1600,7 +1600,8 @@struct usb_hcd *hcd = __hcd;int start = hcd->state; -if (start ==HC_STATE_HALT ) +if (start ==HC_STATE_HALT || + !test_bit (HC_FLAG_IRQ_ON , &hcd->bitflags))return IRQ_NONE ;if (hcd->driver->irq (hcd, r) ==IRQ_NONE )return IRQ_NONE ;
@@ -1736,6 +1737,9 @@if (hcd->driver->irq) {char buf[8 ], *bufp = buf; +set_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +mb (); +#ifdef __sparc__ bufp =__irq_itoa (irqnum);#else
drivers/usb/core/hcd.h +3 -0
@@ -71,6 +71,9 @@/* * hardware info/state */ +unsigned long bitflags;/* various single-bit flags */ +#define HC_FLAG_IRQ_ON 0 +const struct hc_driver *driver;/* hw-specific hooks */ unsigned saw_irq : 1; unsigned can_wakeup:1; /* hw supports wakeup? */
drivers/usb/host/ehci-hcd.c +8 -0
@@ -750,6 +750,12 @@if (time_before (jiffies, ehci->next_statechange))msleep (100 ); +/* Disable emission of interrupts during suspend */ +writel (0 , &ehci->regs->intr_enable); +mb (); +clear_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +synchronize_irq (to_pci_dev (hcd->self.controller)->irq); +#ifdef CONFIG_USB_SUSPEND (void )usb_suspend_device (hcd->self.root_hub, message);#else
@@ -776,6 +782,8 @@if (time_before (jiffies, ehci->next_statechange))msleep (100 ); +set_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +/* If any port is suspended (or owned by the companion), * we know we can/must resume the HC (and mustn't reset it). */
drivers/usb/host/ehci-q.c +5 -0
@@ -926,6 +926,11 @@#endif spin_lock_irqsave (&ehci->lock, flags); +if (HC_IS_SUSPENDED (ehci_to_hcd (ehci)->state)) { +spin_unlock_irqrestore (&ehci->lock, flags); +return -ESHUTDOWN ; + } + qh =qh_append_tds (ehci, urb, qtd_list, epnum, &ep->hcpriv);/* Control/bulk operations through TTs don't need scheduling,
drivers/usb/host/ehci-sched.c +15 -0
@@ -602,6 +602,11 @@spin_lock_irqsave (&ehci->lock, flags); +if (HC_IS_SUSPENDED (ehci_to_hcd (ehci)->state)) { +spin_unlock_irqrestore (&ehci->lock, flags); +return -ESHUTDOWN ; + } +/* get qh and force any scheduling errors */ INIT_LIST_HEAD (&empty); qh =qh_append_tds (ehci, urb, &empty, epnum, &ep->hcpriv);
@@ -1456,6 +1461,11 @@/* schedule ... need to lock */ spin_lock_irqsave (&ehci->lock, flags); +if (HC_IS_SUSPENDED (ehci_to_hcd (ehci)->state)) { +spin_unlock_irqrestore (&ehci->lock, flags); + status = -ESHUTDOWN ; + goto done; + } status =iso_stream_schedule (ehci, urb, stream);if (likely (status ==0 ))itd_link_urb (ehci, urb, ehci->periodic_size <<3 , stream);
@@ -1815,6 +1825,11 @@/* schedule ... need to lock */ spin_lock_irqsave (&ehci->lock, flags); +if (HC_IS_SUSPENDED (ehci_to_hcd (ehci)->state)) { +spin_unlock_irqrestore (&ehci->lock, flags); + status = -ESHUTDOWN ; + goto done; + } status =iso_stream_schedule (ehci, urb, stream);if (status ==0 )sitd_link_urb (ehci, urb, ehci->periodic_size <<3 , stream);
drivers/usb/host/ohci-hcd.c +4 -0
@@ -252,6 +252,10 @@spin_lock_irqsave (&ohci->lock, flags); +if (HC_IS_SUSPENDED (hcd->state)) { + retval = -ESHUTDOWN ; + goto fail; + }/* don't submit to a dead HC */ if (!HC_IS_RUNNING (hcd->state)) { retval = -ENODEV ;
drivers/usb/host/ohci-hub.c +7 -7
@@ -219,13 +219,6 @@/* Sometimes PCI D3 suspend trashes frame timings ... */ periodic_reinit (ohci); -/* interrupts might have been disabled */ -ohci_writel (ohci,OHCI_INTR_INIT , &ohci->regs->intrenable); -if (ohci->ed_rm_list) -ohci_writel (ohci,OHCI_INTR_SF , &ohci->regs->intrenable); -ohci_writel (ohci,ohci_readl (ohci, &ohci->regs->intrstatus), - &ohci->regs->intrstatus); -/* Then re-enable operations */ ohci_writel (ohci,OHCI_USB_OPER , &ohci->regs->control); (void )ohci_readl (ohci, &ohci->regs->control);
@@ -241,6 +234,13 @@/* TRSMRCY */ msleep (10 ); +/* interrupts might have been disabled */ +ohci_writel (ohci,OHCI_INTR_INIT , &ohci->regs->intrenable); +if (ohci->ed_rm_list) +ohci_writel (ohci,OHCI_INTR_SF , &ohci->regs->intrenable); +ohci_writel (ohci,ohci_readl (ohci, &ohci->regs->intrstatus), + &ohci->regs->intrstatus); +/* keep it alive for ~5x suspend + resume costs */ ohci->next_statechange = jiffies +msecs_to_jiffies (250 );
drivers/usb/host/ohci-pci.c +8 -28
@@ -14,13 +14,6 @@* This file is licenced under the GPL. */ -#ifdef CONFIG_PPC_PMAC -#include <asm/machdep.h> -#include <asm/pmac_feature.h> -#include <asm/pci-bridge.h> -#include <asm/prom.h> -#endif -#ifndef CONFIG_PCI #error "This file is PCI bus glue. CONFIG_PCI must be defined."#endif
@@ -118,6 +111,12 @@if (time_before (jiffies, ohci->next_statechange))msleep (100 ); +/* Disable emission of interrupts during suspend */ +ohci_writel (ohci,OHCI_INTR_MIE , &ohci->regs->intrdisable); +mb (); +clear_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +synchronize_irq (to_pci_dev (hcd->self.controller)->irq); +#ifdef CONFIG_USB_SUSPEND (void )usb_suspend_device (hcd->self.root_hub, message);#else
@@ -129,16 +128,6 @@/* let things settle down a bit */ msleep (100 ); -#ifdef CONFIG_PPC_PMAC -if (_machine == _MACH_Pmac) { -struct device_node *of_node; - -/* Disable USB PAD & cell clock */ - of_node =pci_device_to_OF_node (to_pci_dev (hcd->self.controller)); -if (of_node) -pmac_call_feature (PMAC_FTR_USB_ENABLE , of_node,0 ,0 ); - } -#endif /* CONFIG_PPC_PMAC */ return 0 ; }
@@ -148,20 +137,11 @@struct ohci_hcd *ohci =hcd_to_ohci (hcd);int retval =0 ; -#ifdef CONFIG_PPC_PMAC -if (_machine == _MACH_Pmac) { -struct device_node *of_node; - -/* Re-enable USB PAD & cell clock */ - of_node =pci_device_to_OF_node (to_pci_dev (hcd->self.controller)); -if (of_node) -pmac_call_feature (PMAC_FTR_USB_ENABLE , of_node,0 ,1 ); - } -#endif /* CONFIG_PPC_PMAC */ -/* resume root hub */ if (time_before (jiffies, ohci->next_statechange))msleep (100 ); +set_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +#ifdef CONFIG_USB_SUSPEND /* get extra cleanup even if remote wakeup isn't in use */ retval =usb_resume_device (hcd->self.root_hub);
drivers/usb/host/uhci-hcd.c +9 -1
@@ -770,6 +770,12 @@dev_dbg (uhci_dev (uhci),"%s\n" , __FUNCTION__); +/* Disable emission of interrupts during suspend */ +pci_write_config_word (to_pci_dev (uhci_dev (uhci)),USBLEGSUP ,0 ); +mb (); +clear_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +synchronize_irq (to_pci_dev (uhci_dev (uhci))->irq); +spin_lock_irq (&uhci->lock);if (uhci->hc_inaccessible)/* Dead or already suspended */ goto done;
@@ -782,12 +788,14 @@if (uhci->rh_state >UHCI_RH_SUSPENDED ) {dev_warn (uhci_dev (uhci),"Root hub isn't suspended!\n" ); hcd->state =HC_STATE_RUNNING ; +set_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); rc = -EBUSY ; goto done; };/* All PCI host controllers are required to disable IRQ generation -* at the source, so we must turn off PIRQ. +* at the source, so we must turn off PIRQ. Already done earlier +* but better be safe than sorry... */ pci_write_config_word (to_pci_dev (uhci_dev (uhci)),USBLEGSUP ,0 ); uhci->hc_inaccessible =1 ;
Quoted 4 lines · Benjamin Herrenschmidt
Quoted 4 lines
i've applied your patch and it seems that when i put my powerbook to sleep ( by closing the lid ) the kernel just crashes since everytime i come back, the machine is turned off. I had a look at the logs and i se=
e
Quoted 5 lines
Quoted 3 lines
that i'm having a reboot almost immediateley after the lid is closed. However i've got no trace of a kernel panic .....
my conf:What about this patch ?
I tried to apply this patch and the previous one over 2.6.14, but they fail= ed.
I also tied to apply the second patch over the first, also the third over the first, but I had the same result.
Over which version should these pacthes be applied?
--
Regards,
EddyP =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D "Imagination is more important than knowledge" A.Einstein
Quoted 9 lines · Eddy Petrişor
Quoted 8 lines · Benjamin Herrenschmidt
Quoted 7 lines
i've applied your patch and it seems that when i put my powerbook to sleep ( by closing the lid ) the kernel just crashes since everytime i come back, the machine is turned off. I had a look at the logs and i see that i'm having a reboot almost immediateley after the lid is closed. However i've got no trace of a kernel panic .....
my conf:
Quoted 7 lines
Quoted 1 line
What about this patch ?
I tried to apply this patch and the previous one over 2.6.14, but they failed. I also tied to apply the second patch over the first, also the third over the first, but I had the same result.
Over which version should these pacthes be applied?
2.6.14 :) (But not some git checkout from after 2.6.14 release)
Ben.
Hi Ben
Thanks for your work, for the patches: on a Titanium IV a kernel-org based, self-made (via "make-kpkg") 2.6.14.1 patched kernel works. USB seems being fine here: I put the machine to sleep with a camera and a Logitech mouse plugged in to USB connectors: After resuming the system from sleep the mouse is still working, and the camera is usable and fine. I'm running pbbuttons here.
It seems I have problems because of a - I still can't believe that - missing pcmciautils package on Debian. But that's unrelated to what we're discussing here, I believe. I'll start another thread perhaps for this latter issue ...
Quoted 5 lines · Benjamin Herrenschmidt
For those who experience crashes on sleep and/or wakeup (typically due to USB) with 2.6.14, I made a test patch that might help. Please let me know if it makes things more reliable.
[ ... ]
I didn't use the one above, but just the one you posted here Nov.8 (this thread), IINM:
$ patch -p1 < /home/shorty/downloads/ben-patches/benh.nov.8.sleep.diff patching file drivers/usb/core/hcd-pci.c patching file drivers/usb/core/hcd.c patching file drivers/usb/core/hcd.h patching file drivers/usb/host/ehci-hcd.c patching file drivers/usb/host/ehci-q.c patching file drivers/usb/host/ehci-sched.c patching file drivers/usb/host/ohci-hcd.c patching file drivers/usb/host/ohci-hub.c patching file drivers/usb/host/ohci-pci.c patching file drivers/usb/host/uhci-hcd.c
Following that, provided my .bash_history is well organised enough to be trusted ( ... :) I applied the 2.6.14.1 patch ("patch-2.6.14.1.bz2")
So: As to sleep/USB: Everything seems being fine here on 2.6.14.1.
FYI:
Kismet still does not seem work for hermes/orinoco on 2.6.14.1.
Thanks again for the patches, Ben.
Best Regards
Wolfgang
Signature · 5 lines
Wolfgang Pfeiffer http://profiles.yahoo.com/wolfgangpfeiffer Key ID: E3037113 Key fingerprint = A8CA 9D8C 54C4 4CC1 0B26 AA3C 9108 FB42 E303 7113
Quoted 9 lines · Benjamin Herrenschmidt
Quoted 7 lines · Bin Zhang
Quoted 4 lines · Benjamin Herrenschmidt
For those who experience crashes on sleep and/or wakeup (typically due to USB) with 2.6.14, I made a test patch that might help. Please let me know if it makes things more reliable.
Quoted 5 lines
Quoted 2 lines
I've tried your patch with usb wifi dlink dwl-g122 (my eth1). It works. There are some differences in
/var/log/syslog:I have another patch tho:
With this patch the kernel panics on my PowerBook 5,2
I made a few pictures with my phone and I can put them smewhere, if needed.
I will try tonight the third patch you proposed and the kernel is compiling now...
BTW, is there any difference between the resulted .ko files when made with:
make SUBDIRS=drivers/usb/core
make SUBDIRS=drivers/usb/core modules
and what the make command ran from the root of the kernel source?
Signature · 4 lines
Regards, EddyP ============================================= "Imagination is more important than knowledge" A.Einstein
The latest patch that is candidate for upstream is:
drivers/usb/core/hcd-pci.c +31 -0
@@ -32,6 +32,13 @@#include <linux/usb.h> #include "hcd.h" +#ifdef CONFIG_PPC_PMAC +#include <asm/machdep.h> +#include <asm/pmac_feature.h> +#include <asm/pci-bridge.h> +#include <asm/prom.h> +#endif +/* PCI-based HCs are common, but plenty of non-PCI HCs are used too */
@@ -278,6 +285,18 @@ int usb_hcd_pci_suspend (struct pci_devbreak ; } +#ifdef CONFIG_PPC_PMAC +if (retval ==0 && _machine == _MACH_Pmac) { +struct device_node *of_node; + +/* Disable USB PAD & cell clock */ + of_node =pci_device_to_OF_node (to_pci_dev (hcd->self. + controller)); +if (of_node) +pmac_call_feature (PMAC_FTR_USB_ENABLE , of_node,0 ,0 ); + } +#endif /* CONFIG_PPC_PMAC */ +/* update power_state **ONLY** to make sysfs happier */ if (retval ==0 ) dev->dev.power.power_state = message;
@@ -303,6 +322,18 @@ int usb_hcd_pci_resume (struct pci_dev *return 0 ; } +#ifdef CONFIG_PPC_PMAC +if (_machine == _MACH_Pmac) { +struct device_node *of_node; + +/* Re-enable USB PAD & cell clock */ + of_node =pci_device_to_OF_node (to_pci_dev (hcd->self. + controller)); +if (of_node) +pmac_call_feature (PMAC_FTR_USB_ENABLE , of_node,0 ,1 ); + } +#endif /* CONFIG_PPC_PMAC */ +/* NOTE: chip docs cover clean "real suspend" cases (what Linux * calls "standby", "suspend to RAM", and so on). There are also * dirty cases when swsusp fakes a suspend in "shutdown" mode.
drivers/usb/core/hcd.c +5 -1
@@ -1600,7 +1600,8 @@ irqreturn_t usb_hcd_irq (int irq, void *struct usb_hcd *hcd = __hcd;int start = hcd->state; -if (start ==HC_STATE_HALT ) +if (start ==HC_STATE_HALT || + !test_bit (HC_FLAG_IRQ_ON , &hcd->bitflags))return IRQ_NONE ;if (hcd->driver->irq (hcd, r) ==IRQ_NONE )return IRQ_NONE ;
@@ -1736,6 +1737,9 @@ int usb_add_hcd(struct usb_hcd *hcd,if (hcd->driver->irq) {char buf[8 ], *bufp = buf; +set_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +mb (); +#ifdef __sparc__ bufp =__irq_itoa (irqnum);#else
drivers/usb/core/hcd.h +3 -0
@@ -71,6 +71,9 @@ struct usb_hcd { /* usb_bus.hcpriv point/* * hardware info/state */ +unsigned long bitflags;/* various single-bit flags */ +#define HC_FLAG_IRQ_ON 0 +const struct hc_driver *driver;/* hw-specific hooks */ unsigned saw_irq : 1; unsigned can_wakeup:1; /* hw supports wakeup? */
drivers/usb/host/ehci-hcd.c +8 -0
@@ -750,6 +750,12 @@ static int ehci_suspend (struct usb_hcdif (time_before (jiffies, ehci->next_statechange))msleep (100 ); +/* Disable emission of interrupts during suspend */ +writel (0 , &ehci->regs->intr_enable); +mb (); +clear_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +synchronize_irq (to_pci_dev (hcd->self.controller)->irq); +#ifdef CONFIG_USB_SUSPEND (void )usb_suspend_device (hcd->self.root_hub, message);#else
@@ -776,6 +782,8 @@ static int ehci_resume (struct usb_hcd *if (time_before (jiffies, ehci->next_statechange))msleep (100 ); +set_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +/* If any port is suspended (or owned by the companion), * we know we can/must resume the HC (and mustn't reset it). */
drivers/usb/host/ehci-q.c +5 -0
@@ -926,6 +926,11 @@ submit_async (#endif spin_lock_irqsave (&ehci->lock, flags); +if (HC_IS_SUSPENDED (ehci_to_hcd (ehci)->state)) { +spin_unlock_irqrestore (&ehci->lock, flags); +return -ESHUTDOWN ; + } + qh =qh_append_tds (ehci, urb, qtd_list, epnum, &ep->hcpriv);/* Control/bulk operations through TTs don't need scheduling,
drivers/usb/host/ehci-sched.c +15 -0
@@ -602,6 +602,11 @@ static int intr_submit (spin_lock_irqsave (&ehci->lock, flags); +if (HC_IS_SUSPENDED (ehci_to_hcd (ehci)->state)) { +spin_unlock_irqrestore (&ehci->lock, flags); +return -ESHUTDOWN ; + } +/* get qh and force any scheduling errors */ INIT_LIST_HEAD (&empty); qh =qh_append_tds (ehci, urb, &empty, epnum, &ep->hcpriv);
@@ -1456,6 +1461,11 @@ static int itd_submit (struct ehci_hcd */* schedule ... need to lock */ spin_lock_irqsave (&ehci->lock, flags); +if (HC_IS_SUSPENDED (ehci_to_hcd (ehci)->state)) { +spin_unlock_irqrestore (&ehci->lock, flags); + status = -ESHUTDOWN ; + goto done; + } status =iso_stream_schedule (ehci, urb, stream);if (likely (status ==0 ))itd_link_urb (ehci, urb, ehci->periodic_size <<3 , stream);
@@ -1815,6 +1825,11 @@ static int sitd_submit (struct ehci_hcd/* schedule ... need to lock */ spin_lock_irqsave (&ehci->lock, flags); +if (HC_IS_SUSPENDED (ehci_to_hcd (ehci)->state)) { +spin_unlock_irqrestore (&ehci->lock, flags); + status = -ESHUTDOWN ; + goto done; + } status =iso_stream_schedule (ehci, urb, stream);if (status ==0 )sitd_link_urb (ehci, urb, ehci->periodic_size <<3 , stream);
drivers/usb/host/ohci-hcd.c +4 -0
@@ -252,6 +252,10 @@ static int ohci_urb_enqueue (spin_lock_irqsave (&ohci->lock, flags); +if (HC_IS_SUSPENDED (hcd->state)) { + retval = -ESHUTDOWN ; + goto fail; + }/* don't submit to a dead HC */ if (!HC_IS_RUNNING (hcd->state)) { retval = -ENODEV ;
drivers/usb/host/ohci-hub.c +7 -7
@@ -219,13 +219,6 @@ static int ohci_hub_resume (struct usb_h/* Sometimes PCI D3 suspend trashes frame timings ... */ periodic_reinit (ohci); -/* interrupts might have been disabled */ -ohci_writel (ohci,OHCI_INTR_INIT , &ohci->regs->intrenable); -if (ohci->ed_rm_list) -ohci_writel (ohci,OHCI_INTR_SF , &ohci->regs->intrenable); -ohci_writel (ohci,ohci_readl (ohci, &ohci->regs->intrstatus), - &ohci->regs->intrstatus); -/* Then re-enable operations */ ohci_writel (ohci,OHCI_USB_OPER , &ohci->regs->control); (void )ohci_readl (ohci, &ohci->regs->control);
@@ -241,6 +234,13 @@ static int ohci_hub_resume (struct usb_h/* TRSMRCY */ msleep (10 ); +/* interrupts might have been disabled */ +ohci_writel (ohci,OHCI_INTR_INIT , &ohci->regs->intrenable); +if (ohci->ed_rm_list) +ohci_writel (ohci,OHCI_INTR_SF , &ohci->regs->intrenable); +ohci_writel (ohci,ohci_readl (ohci, &ohci->regs->intrstatus), + &ohci->regs->intrstatus); +/* keep it alive for ~5x suspend + resume costs */ ohci->next_statechange = jiffies +msecs_to_jiffies (250 );
drivers/usb/host/ohci-pci.c +8 -28
@@ -14,13 +14,6 @@* This file is licenced under the GPL. */ -#ifdef CONFIG_PPC_PMAC -#include <asm/machdep.h> -#include <asm/pmac_feature.h> -#include <asm/pci-bridge.h> -#include <asm/prom.h> -#endif -#ifndef CONFIG_PCI #error "This file is PCI bus glue. CONFIG_PCI must be defined."#endif
@@ -118,6 +111,12 @@ static int ohci_pci_suspend (struct usb_if (time_before (jiffies, ohci->next_statechange))msleep (100 ); +/* Disable emission of interrupts during suspend */ +ohci_writel (ohci,OHCI_INTR_MIE , &ohci->regs->intrdisable); +mb (); +clear_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +synchronize_irq (to_pci_dev (hcd->self.controller)->irq); +#ifdef CONFIG_USB_SUSPEND (void )usb_suspend_device (hcd->self.root_hub, message);#else
@@ -129,16 +128,6 @@ static int ohci_pci_suspend (struct usb_/* let things settle down a bit */ msleep (100 ); -#ifdef CONFIG_PPC_PMAC -if (_machine == _MACH_Pmac) { -struct device_node *of_node; - -/* Disable USB PAD & cell clock */ - of_node =pci_device_to_OF_node (to_pci_dev (hcd->self.controller)); -if (of_node) -pmac_call_feature (PMAC_FTR_USB_ENABLE , of_node,0 ,0 ); - } -#endif /* CONFIG_PPC_PMAC */ return 0 ; }
@@ -148,20 +137,11 @@ static int ohci_pci_resume (struct usb_hstruct ohci_hcd *ohci =hcd_to_ohci (hcd);int retval =0 ; -#ifdef CONFIG_PPC_PMAC -if (_machine == _MACH_Pmac) { -struct device_node *of_node; - -/* Re-enable USB PAD & cell clock */ - of_node =pci_device_to_OF_node (to_pci_dev (hcd->self.controller)); -if (of_node) -pmac_call_feature (PMAC_FTR_USB_ENABLE , of_node,0 ,1 ); - } -#endif /* CONFIG_PPC_PMAC */ -/* resume root hub */ if (time_before (jiffies, ohci->next_statechange))msleep (100 ); +set_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +#ifdef CONFIG_USB_SUSPEND /* get extra cleanup even if remote wakeup isn't in use */ retval =usb_resume_device (hcd->self.root_hub);
drivers/usb/host/uhci-hcd.c +7 -0
@@ -797,6 +797,11 @@ static int uhci_suspend(struct usb_hcd * done:spin_unlock_irq (&uhci->lock); +if (rc ==0 ) { +mb (); +clear_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +synchronize_irq (hcd->irq); + }return rc; }
@@ -818,6 +823,8 @@ static int uhci_resume(struct usb_hcd *h* system wakeup. Check it and reconfigure to avoid problems. */ check_and_reset_hc (uhci); +set_bit (HC_FLAG_IRQ_ON , &hcd->bitflags); +mb ();configure_hc (uhci);#ifndef CONFIG_USB_SUSPEND
Quoted 3 lines · Benjamin Herrenschmidt
The latest patch that is candidate for upstream is:
Index:
2.6.14-ben/drivers/usb/core/hcd-pci.c
This version also panics :(
Signature · 4 lines
Regards, EddyP ============================================= "Imagination is more important than knowledge" A.Einstein
Quoted 7 lines · Eddy Petrisor
Quoted 3 lines · Benjamin Herrenschmidt
The latest patch that is candidate for upstream is:
Index:
2.6.14-ben/drivers/usb/core/hcd-pci.cThis version also panics :(
Just as a note, the third and the second paniced, too.
--
Regards,
EddyP =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D "Imagination is more important than knowledge" A.Einstein
Quoted 1 line · Benjamin Herrenschmidt
The latest patch that is candidate for upstream is:
Oopsed for one pld user in a way shown in attachment after connecting usb device while laptop (recent ibook g4 afaik) was in sleep and then waking it up. That was with 2.6.14.2+your patch.
Signature · 2 lines
Arkadiusz Miśkiewicz PLD/Linux Team http://www.t17.ds.pwr.wroc.pl/~misiek/ http://ftp.pld-linux.org/
Quoted 6 lines · Arkadiusz Miskiewicz
Quoted 1 line · Benjamin Herrenschmidt
The latest patch that is candidate for upstream is:
Oopsed for one pld user in a way shown in attachment after connecting usb device while laptop (recent ibook g4 afaik) was in sleep and then waking it up. That was with 2.6.14.2+your patch.
Ok, so there are still unresolved issues in the USB layer, which doesn't surprise me. I'm trying to work with the USB folks to get those resolved in 2.6.15 at least, we'll see if I succeed...
Ben.
Quoted 2 lines · Benjamin Herrenschmidt
For those who experience crashes on sleep and/or wakeup (typically due to USB) with 2.6.14, I made a test patch that might help. [ ... ]
Ben, I just compiled and installed a 2.6.14.1 from kernel.org with none of your patches from this thread applied to it, and I have no sleep/wakeup probs with it so far: about 3 instances of sleep/wakeup until now, all of them successful.
Maybe I even made it a bit more complicated for the system, as I connected a USB HUB, with 4 ports, to the machine: It just seems to work ...
-------------------------------------
$ cat /proc/cpuinfo processor : 0 cpu : 7455, altivec supported clock : 867MHz revision : 0.2 (pvr 8001 0302) bogomips : 865.18 machine : PowerBook3,5 motherboard : PowerBook3,5 MacRISC2 MacRISC Power Macintosh detected as : 80 (PowerBook Titanium IV) pmac flags : 0000001b L2 cache : 256K unified memory : 768MB pmac-generation : NewWorld -----------------------------------
HTH
Best Regards
Wolfgang
Signature · 5 lines
Wolfgang Pfeiffer http://profiles.yahoo.com/wolfgangpfeiffer Key ID: E3037113 Key fingerprint = A8CA 9D8C 54C4 4CC1 0B26 AA3C 9108 FB42 E303 7113
Quoted 8 lines · Wolfgang Pfeiffer
Ben, I just compiled and installed a 2.6.14.1 from kernel.org with none of your patches from this thread applied to it, and I have no sleep/wakeup probs with it so far: about 3 instances of sleep/wakeup until now, all of them successful.
Maybe I even made it a bit more complicated for the system, as I connected a USB HUB, with 4 ports, to the machine: It just seems to work ... [ ... ]
Just for the sake of completeness: I have (SCSI) problems with 2.6.14.1, but none of them seem to be USB/sleep related:
<http://sourceforge.net/mailarchive/forum.php?thread_id=8964383&forum_id=5389>
Not being sure whether this latter URL works: I just read "The SourceForge.net Website is currently down for maintenance" But the name of the thread up there is:
"Fw: 2.6.14.1: Loading FireWire disk fails. Fix: "modprobe ieee1394 disable_irm=1""
Best Regards
Wolfgang
Signature · 5 lines
Wolfgang Pfeiffer http://profiles.yahoo.com/wolfgangpfeiffer Key ID: E3037113 Key fingerprint = A8CA 9D8C 54C4 4CC1 0B26 AA3C 9108 FB42 E303 7113
Quoted 4 lines · Wolfgang Pfeiffer
Quoted 2 lines · Benjamin Herrenschmidt
For those who experience crashes on sleep and/or wakeup (typically due to USB) with 2.6.14, I made a test patch that might help. [ ... ]
Quoted 8 lines
Ben, I just compiled and installed a 2.6.14.1 from kernel.org with none of your patches from this thread applied to it, and I have no sleep/wakeup probs with it so far: about 3 instances of sleep/wakeup until now, all of them successful.
Maybe I even made it a bit more complicated for the system, as I connected a USB HUB, with 4 ports, to the machine: It just seems to work ...
Only newer machines with a NEC USB2 chip that shares interrupts appear to be affected by the problem.
Ben.
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 2 lines · Wolfgang Pfeiffer
Quoted 2 lines
For those who experience crashes on sleep and/or wakeup (typically due to USB) with 2.6.14, I made a test patch that might help. [ ... ]
Only newer machines with a NEC USB2 chip that shares interrupts appear to be affected by the problem.
So is there any chance that the sleep issue is fixed until 2.6.15?
Signature · 4 lines
Regards, EddyP ============================================= "Imagination is more important than knowledge" A.Einstein
Quoted 5 lines · Gaudenz Steinlin
Hi Ben
Quoted 1 line · Benjamin Herrenschmidt
The latest patch that is candidate for upstream is:
Quoted 8 lines
I have the same USB wakeup problem with my new powerbook 5,8 (oct 2005 15"). Without the patch I get a kernel oops on wakeup just like the others. With this patch applied (and the pb 5,8 basic enablement patch) the lcd gets distorted colors on wakeup. It looks quite insane, like a broken lcd.
I'm useing a vanilla 2.6.14.2 kernel.
CONFIG_USB_SUSPENDis set, PREEMPT is disabled. Is there a newer version of the patch available for testing?
The USB patch has nothing to do with your screen problems. Does the screen issue goes away after a couple of sleep/wakeup cycles ? i'm waiting on the same machine model that I just ordered from Apple, so I'll be able to fix remaining issues soon.
Ben.
Hi Ben
Quoted 1 line · Benjamin Herrenschmidt
The latest patch that is candidate for upstream is:
I have the same USB wakeup problem with my new powerbook 5,8 (oct 2005 15"). Without the patch I get a kernel oops on wakeup just like the others. With this patch applied (and the pb 5,8 basic enablement patch) the lcd gets distorted colors on wakeup. It looks quite insane, like a broken lcd.
I'm useing a vanilla 2.6.14.2 kernel. CONFIG_USB_SUSPEND is set, PREEMPT is disabled. Is there a newer version of the patch available for testing?
Gaudenz