On Wed, Oct 17, 2012 at 05:28:22PM -0400, Alan Stern wrote: > On Tue, 16 Oct 2012, Peter Chen wrote: > > > I have tested it at Freescale i.mx6Q sabrelite board, your patch is ok. > > Will you post a patch or I do it for you? > > I decided to use a different approach. The core should know which > ports are suspended without asking the HCD. Can you test this patch in > place of the other one? It shows below oops, you may not consider there is no device at port condition. Besides, how about using usleep_range instead of msleep? msleep is not precise, and should not be used at (<20ms) condition, at my platform, msleep 10 consumes about 19-20ms. Unable to handle kernel NULL pointer dereference at virtual address 00000018 pgd = 80004000 [00000018] *pgd=00000000 Internal error: Oops: 5 [#1] SMP ARM Modules linked in: CPU: 3 Not tainted (3.7.0-rc1+ #24) PC is at hcd_bus_resume+0x148/0x188 LR is at hdev_to_hub+0x40/0x44 pc : [<80366a9c>] lr : [<8036084c>] psr: 20000113 sp : bf87bdb0 ip : bf87bd88 fp : bf87bdd4 r10: 8072c30c r9 : 00000000 r8 : bf80ec90 r7 : 80739a28 r6 : 00000000 r5 : bf80f000 r4 : 00000001 r3 : 00000000 r2 : 00000001 r1 : 00000001 r0 : 00000000 Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel Control: 10c53c7d Table: 1000404a DAC: 00000017 Process kworker/u:0 (pid: 6, stack limit = 0xbf87a238) Stack: (0xbf87bdb0 to 0xbf87c000) bda0: bf80f068 bf80f000 00000010 00000000 bdc0: 8035ff98 00000000 bf87bde4 bf87bdd8 80373fb8 80366960 bf87be04 bf87bde8 bde0: 8036cb6c 80373fa0 bf80f068 bf80f068 00000000 00000000 bf87be14 bf87be08 be00: 8035ffac 8036ca00 bf87be4c bf87be18 802c9724 8035ffa4 00000000 8072c30c be20: 00000000 00000000 bf87be4c bf80f068 bf80f09c 00000010 8072c764 806e8d0c be40: bf87be6c bf87be50 802c99b8 802c96fc bf80f068 80737cc8 bf3cafc8 8072c764 be60: bf87be84 bf87be70 802c9b3c 802c98ec bf3cafc0 806ba2dc bf87becc bf87be88 be80: 8004a03c 802c9b28 8072c200 bf87a000 bf804800 bf3cafc8 00000000 8072c30c bea0: bf87bebc bf87beb0 bf826a40 8072c200 bf87a000 bf804800 bf3cafc8 00000000 bec0: bf87bf14 bf87bed0 80039c80 80049fbc bf2a5b00 806a5240 812b5240 bf826a40 bee0: bf804805 80049fb0 8072c314 bf826a40 8072c30c bf87a000 8072c314 bf826a50 bf00: 00000000 00000089 bf87bf54 bf87bf18 8003a3d0 80039b0c 00000000 bf861e34 bf20: bf826a50 8072c200 bf826a40 bf861e34 bf87bf5c 00000000 bf826a40 8003a2a0 bf40: 00000000 00000000 bf87bfac bf87bf58 80041ad0 8003a2ac 00000000 00000000 bf60: 00000000 bf826a40 00000000 00000000 bf87bf70 bf87bf70 00000000 00000000 bf80: bf87bf80 bf87bf80 800508d4 bf861e34 80041a20 00000000 00000000 00000000 bfa0: 00000000 bf87bfb0 8000ecd8 80041a2c 00000000 00000000 00000000 00000000 bfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 bfe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000 Backtrace: [<80366954>] (hcd_bus_resume+0x0/0x188) from [<80373fb8>] (generic_resume+0x24/0x28) r9:00000000 r8:8035ff98 r7:00000000 r6:00000010 r5:bf80f000 r4:bf80f068 [<80373f94>] (generic_resume+0x0/0x28) from [<8036cb6c>] (usb_resume+0x178/0x198) [<8036c9f4>] (usb_resume+0x0/0x198) from [<8035ffac>] (usb_dev_resume+0x14/0x18) r7:00000000 r6:00000000 r5:bf80f068 r4:bf80f068 [<8035ff98>] (usb_dev_resume+0x0/0x18) from [<802c9724>] (dpm_run_callback+0x34/0x7c) [<802c96f0>] (dpm_run_callback+0x0/0x7c) from [<802c99b8>] (device_resume+0xd8/0x23c) r8:806e8d0c r7:8072c764 r6:00000010 r5:bf80f09c r4:bf80f068 [<802c98e0>] (device_resume+0x0/0x23c) from [<802c9b3c>] (async_resume+0x20/0x4c) r7:8072c764 r6:bf3cafc8 r5:80737cc8 r4:bf80f068 [<802c9b1c>] (async_resume+0x0/0x4c) from [<8004a03c>] (async_run_entry_fn+0x8c/0x200) r5:806ba2dc r4:bf3cafc0 [<80049fb0>] (async_run_entry_fn+0x0/0x200) from [<80039c80>] (process_one_work+0x180/0x428) r9:00000000 r8:bf3cafc8 r7:bf804800 r6:bf87a000 r5:8072c200 r4:bf826a40 [<80039b00>] (process_one_work+0x0/0x428) from [<8003a3d0>] (worker_thread+0x130/0x528) [<8003a2a0>] (worker_thread+0x0/0x528) from [<80041ad0>] (kthread+0xb0/0xbc) [<80041a20>] (kthread+0x0/0xbc) from [<8000ecd8>] (ret_from_fork+0x14/0x3c) r8:00000000 r7:00000000 r6:00000000 r5:80041a20 r4:bf861e34 Code: e5952214 e1520004 e1a03000 baffffb7 (e5932018) ---[ end trace 9ee8ab26298c73ee ]--- Unable to handle kernel paging request at virtual address ffffffec pgd = 80004000 [ffffffec] *pgd=4fffe821, *pte=00000000, *ppte=00000000 Internal error: Oops: 17 [#2] SMP ARM Modules linked in: CPU: 3 Tainted: G D (3.7.0-rc1+ #24) PC is at kthread_data+0x10/0x18 LR is at wq_worker_sleeping+0x14/0xa4 pc : [<8004143c>] lr : [<8003d7c8>] psr: 20000193 sp : bf87bae8 ip : bf87baf8 fp : bf87baf4 r10: bf855080 r9 : 806a5240 r8 : 806af148 r7 : 00000003 r6 : 00000003 r5 : bf854f00 r4 : 812cd240 r3 : 00000000 r2 : 4b72695e r1 : 00000003 r0 : bf854f00 Flags: nzCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment user Control: 10c53c7d Table: 1000404a DAC: 00000015 Process kworker/u:0 (pid: 6, stack limit = 0xbf87a238) Stack: (0xbf87bae8 to 0xbf87c000) bae0: bf87bb14 bf87baf8 8003d7c8 80041438 812cd240 bf854f00 bb00: bf87a000 00000003 bf87bb5c bf87bb18 804e2c40 8003d7c0 00000001 80008f0c bb20: bf854f00 806a5240 bf87a000 806a5240 bf87bb5c bf854f00 00000001 0000000b bb40: bf854000 bf87bb94 bf855004 bf87a000 bf87bb6c bf87bb60 804e31d4 804e28cc bb60: bf87bba4 bf87bb70 800287ec 804e31a8 bf87a000 bf87bb8c 00000001 bf85515c bb80: bf855004 806e9060 bf87bba4 bf87bb8c bf87bb8c bf85504c bf87bc2c bf87bba8 bba0: 800129bc 80028288 bf87a238 0000000b 00000001 00000008 00000000 00000000 bbc0: 60000113 80366aa0 35393565 34313232 35316520 30303032 31652034 30333061 bbe0: 62203030 66666661 20376266 39356528 31303233 00202938 800159f0 804e10c0 bc00: 8061443c bf87bd68 00000018 00000000 00000005 00000000 bf854f00 00000018 bc20: bf87bc54 bf87bc30 80015abc 800127cc bf87a000 00000000 bf87bd68 00000005 bc40: bf80ec90 bf854f00 bf87bc9c bf87bc58 80015c38 80015a5c 6c703d4d 6f667461 bc60: 44006d72 00000000 00000028 6674616c 3a6d726f 00000005 806b2d20 00000018 bc80: bf87bd68 bf80ec90 00000000 8072c30c bf87bcbc bf87bca0 80015e64 80015ae8 bca0: 00000005 806b2d20 00000018 bf87bd68 bf87bd64 bf87bcc0 80008474 80015dcc bcc0: ffff963a 812cd240 00000001 00000003 bf80ecd0 00000000 00000010 00000004 bce0: bf87bd04 bf87bcf0 802bf8b4 802bf840 bf88801c bf87bd0c bf87bd24 bf87bd10 bd00: 802bf908 802bf89c 80600ef0 8061d458 bf845d00 bf87bd2c bf87bd44 bf87bd28 bd20: 802bfb78 802bf8c8 bf87bd4c bf87bd38 80019d10 804e3d7c bf80ecd0 806ae950 bd40: bf87bdac bf87bd50 80366a9c 20000113 ffffffff bf87bd9c bf87bdd4 bf87bd68 bd60: 8000e760 80008444 00000000 00000001 00000001 00000000 00000001 bf80f000 bd80: 00000000 80739a28 bf80ec90 00000000 8072c30c bf87bdd4 bf87bd88 bf87bdb0 bda0: 8036084c 80366a9c 20000113 ffffffff bf80f068 bf80f000 00000010 00000000 bdc0: 8035ff98 00000000 bf87bde4 bf87bdd8 80373fb8 80366960 bf87be04 bf87bde8 bde0: 8036cb6c 80373fa0 bf80f068 bf80f068 00000000 00000000 bf87be14 bf87be08 be00: 8035ffac 8036ca00 bf87be4c bf87be18 802c9724 8035ffa4 00000000 8072c30c be20: 00000000 00000000 bf87be4c bf80f068 bf80f09c 00000010 8072c764 806e8d0c be40: bf87be6c bf87be50 802c99b8 802c96fc bf80f068 80737cc8 bf3cafc8 8072c764 be60: bf87be84 bf87be70 802c9b3c 802c98ec bf3cafc0 806ba2dc bf87becc bf87be88 be80: 8004a03c 802c9b28 8072c200 bf87a000 bf804800 bf3cafc8 00000000 8072c30c bea0: bf87bebc bf87beb0 bf826a40 8072c200 bf87a000 bf804800 bf3cafc8 00000000 bec0: bf87bf14 bf87bed0 80039c80 80049fbc bf2a5b00 806a5240 812b5240 bf826a40 bee0: bf804805 80049fb0 8072c314 bf826a40 8072c30c bf87a000 8072c314 bf826a50 bf00: 00000000 00000089 bf87bf54 bf87bf18 8003a3d0 80039b0c 00000000 bf861e34 bf20: bf826a50 8072c200 bf826a40 bf861e34 bf87bf5c 00000000 bf826a40 8003a2a0 bf40: 00000000 00000000 bf87bfac bf87bf58 80041ad0 8003a2ac 00000000 00000000 bf60: 00000000 bf826a40 00000000 00000000 bf87bf70 bf87bf70 00000001 00010001 bf80: bf87bf80 bf87bf80 800508d4 bf861e34 80041a20 00000000 00000000 00000000 bfa0: 00000000 bf87bfb0 8000ecd8 80041a2c 00000000 00000000 00000000 00000000 bfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 bfe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000 Backtrace: [<8004142c>] (kthread_data+0x0/0x18) from [<8003d7c8>] (wq_worker_sleeping+0x14/0xa4) [<8003d7b4>] (wq_worker_sleeping+0x0/0xa4) from [<804e2c40>] (__schedule+0x380/0x5a4) r7:00000003 r6:bf87a000 r5:bf854f00 r4:812cd240 [<804e28c0>] (__schedule+0x0/0x5a4) from [<804e31d4>] (schedule+0x38/0x78) [<804e319c>] (schedule+0x0/0x78) from [<800287ec>] (do_exit+0x570/0x844) [<8002827c>] (do_exit+0x0/0x844) from [<800129bc>] (die+0x1fc/0x404) [<800127c0>] (die+0x0/0x404) from [<80015abc>] (__do_kernel_fault+0x6c/0x8c) [<80015a50>] (__do_kernel_fault+0x0/0x8c) from [<80015c38>] (do_page_fault+0x15c/0x270) r9:bf854f00 r8:bf80ec90 r7:00000005 r6:bf87bd68 r5:00000000 r4:bf87a000 [<80015adc>] (do_page_fault+0x0/0x270) from [<80015e64>] (do_translation_fault+0xa4/0xac) [<80015dc0>] (do_translation_fault+0x0/0xac) from [<80008474>] (do_DataAbort+0x3c/0xa4) r7:bf87bd68 r6:00000018 r5:806b2d20 r4:00000005 [<80008438>] (do_DataAbort+0x0/0xa4) from [<8000e760>] (__dabt_svc+0x40/0x60) Exception stack(0xbf87bd68 to 0xbf87bdb0) bd60: 00000000 00000001 00000001 00000000 00000001 bf80f000 bd80: 00000000 80739a28 bf80ec90 00000000 8072c30c bf87bdd4 bf87bd88 bf87bdb0 bda0: 8036084c 80366a9c 20000113 ffffffff r7:bf87bd9c r6:ffffffff r5:20000113 r4:80366a9c [<80366954>] (hcd_bus_resume+0x0/0x188) from [<80373fb8>] (generic_resume+0x24/0x28) r9:00000000 r8:8035ff98 r7:00000000 r6:00000010 r5:bf80f000 r4:bf80f068 [<80373f94>] (generic_resume+0x0/0x28) from [<8036cb6c>] (usb_resume+0x178/0x198) [<8036c9f4>] (usb_resume+0x0/0x198) from [<8035ffac>] (usb_dev_resume+0x14/0x18) r7:00000000 r6:00000000 r5:bf80f068 r4:bf80f068 [<8035ff98>] (usb_dev_resume+0x0/0x18) from [<802c9724>] (dpm_run_callback+0x34/0x7c) [<802c96f0>] (dpm_run_callback+0x0/0x7c) from [<802c99b8>] (device_resume+0xd8/0x23c) r8:806e8d0c r7:8072c764 r6:00000010 r5:bf80f09c r4:bf80f068 [<802c98e0>] (device_resume+0x0/0x23c) from [<802c9b3c>] (async_resume+0x20/0x4c) r7:8072c764 r6:bf3cafc8 r5:80737cc8 r4:bf80f068 [<802c9b1c>] (async_resume+0x0/0x4c) from [<8004a03c>] (async_run_entry_fn+0x8c/0x200) r5:806ba2dc r4:bf3cafc0 [<80049fb0>] (async_run_entry_fn+0x0/0x200) from [<80039c80>] (process_one_work+0x180/0x428) r9:00000000 r8:bf3cafc8 r7:bf804800 r6:bf87a000 r5:8072c200 r4:bf826a40 [<80039b00>] (process_one_work+0x0/0x428) from [<8003a3d0>] (worker_thread+0x130/0x528) [<8003a2a0>] (worker_thread+0x0/0x528) from [<80041ad0>] (kthread+0xb0/0xbc) [<80041a20>] (kthread+0x0/0xbc) from [<8000ecd8>] (ret_from_fork+0x14/0x3c) r8:00000000 r7:00000000 r6:00000000 r5:80041a20 r4:bf861e34 Code: e1a0c00d e92dd800 e24cb004 e5903154 (e5130014) ---[ end trace 9ee8ab26298c73ef ]--- Fixing recursive fault but reboot is needed! > > Alan Stern > > > > Index: usb-3.6/include/linux/usb.h > =================================================================== > --- usb-3.6.orig/include/linux/usb.h > +++ usb-3.6/include/linux/usb.h > @@ -482,6 +482,7 @@ struct usb3_lpm_parameters { > * @connect_time: time device was first connected > * @do_remote_wakeup: remote wakeup should be enabled > * @reset_resume: needs reset instead of resume > + * @port_is_suspended: the upstream port is suspended (L2 or U3) > * @wusb_dev: if this is a Wireless USB device, link to the WUSB > * specific data for the device. > * @slot_id: Slot ID assigned by xHCI > @@ -560,6 +561,7 @@ struct usb_device { > > unsigned do_remote_wakeup:1; > unsigned reset_resume:1; > + unsigned port_is_suspended:1; > #endif > struct wusb_dev *wusb_dev; > int slot_id; > Index: usb-3.6/drivers/usb/core/hub.c > =================================================================== > --- usb-3.6.orig/drivers/usb/core/hub.c > +++ usb-3.6/drivers/usb/core/hub.c > @@ -2876,6 +2876,7 @@ int usb_port_suspend(struct usb_device * > (PMSG_IS_AUTO(msg) ? "auto-" : ""), > udev->do_remote_wakeup); > usb_set_device_state(udev, USB_STATE_SUSPENDED); > + udev->port_is_suspended = 1; > msleep(10); > } > usb_mark_last_busy(hub->hdev); > @@ -3040,6 +3041,7 @@ int usb_port_resume(struct usb_device *u > > SuspendCleared: > if (status == 0) { > + udev->port_is_suspended = 0; > if (hub_is_superspeed(hub->hdev)) { > if (portchange & USB_PORT_STAT_C_LINK_STATE) > clear_port_feature(hub->hdev, port1, > Index: usb-3.6/drivers/usb/core/hcd.c > =================================================================== > --- usb-3.6.orig/drivers/usb/core/hcd.c > +++ usb-3.6/drivers/usb/core/hcd.c > @@ -2039,8 +2039,9 @@ int hcd_bus_resume(struct usb_device *rh > status = hcd->driver->bus_resume(hcd); > clear_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags); > if (status == 0) { > - /* TRSMRCY = 10 msec */ > - msleep(10); > + struct usb_device *udev; > + int port1; > + > spin_lock_irq(&hcd_root_hub_lock); > if (!HCD_DEAD(hcd)) { > usb_set_device_state(rhdev, rhdev->actconfig > @@ -2050,6 +2051,20 @@ int hcd_bus_resume(struct usb_device *rh > hcd->state = HC_STATE_RUNNING; > } > spin_unlock_irq(&hcd_root_hub_lock); > + > + /* > + * Check whether any of the enabled ports on the root hub are > + * unsuspended. If they are then a TRSMRCY delay is needed > + * (this is what the USB-2 spec calls a "global resume"). > + * Otherwise we can skip the delay. > + */ > + usb_hub_for_each_child(rhdev, port1, udev) { > + if (udev->state != USB_STATE_NOTATTACHED && > + !udev->port_is_suspended) { > + msleep(10); /* TRSMRCY */ > + break; > + } > + } > } else { > hcd->state = old_state; > dev_dbg(&rhdev->dev, "bus %s fail, err %d\n", > > -- Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html