5 Replies Latest reply on Jun 8, 2016 11:44 AM by RenatoM

    Disabling power to otg (without reboot)

    ehren_m

      Hello,

       

      In this thread: Disabling power to usb otg port - can we rely on "bug" where hostmode initialized on every OTHER reboot

       

      I was wondering about disabling power to the otg after a restart. However the ideal scenario for our application would be to disable power to the otg without requiring a restart (and ideally to be able to bring it back up).

       

      (Our application has the edison connected to a mobile device over bluetooth - it would be nice to power up / power down our attached usb hub and devices in response to bluetooth messages from the connected mobile device)

       

      Anyone attempting something similar?

       

      Here are my current (nonworking) steps

       

      # identify usb device

       

      root@ehren-edison-battery1:~# lspci

      00:00.0 Host bridge: Intel Corporation Device 1170 (rev 01)

      00:01.0 SD Host controller: Intel Corporation Device 1190 (rev 01)

      00:01.2 SD Host controller: Intel Corporation Device 1190 (rev 01)

      00:01.3 SD Host controller: Intel Corporation Device 1190 (rev 01)

      00:02.0 Display controller: Intel Corporation Device 1182 (rev 01)

      00:04.0 Serial controller: Intel Corporation Device 1191 (rev 01)

      00:04.1 Serial controller: Intel Corporation Device 1191 (rev 01)

      00:04.2 Serial controller: Intel Corporation Device 1191 (rev 01)

      00:04.3 Serial controller: Intel Corporation Device 1191 (rev 01)

      00:05.0 Serial controller: Intel Corporation Device 1192 (rev 01)

      00:06.0 System peripheral: Intel Corporation Device 1193 (rev 01)

      00:06.1 System peripheral: Intel Corporation Device 1193 (rev 01)

      00:07.0 System peripheral: Intel Corporation Device 1194 (rev 01)

      00:07.1 System peripheral: Intel Corporation Device 1194 (rev 01)

      00:07.2 System peripheral: Intel Corporation Device 1194 (rev 01)

      00:08.0 Communication controller: Intel Corporation Device 1195 (rev 01)

      00:08.1 Communication controller: Intel Corporation Device 1195 (rev 01)

      00:08.2 Communication controller: Intel Corporation Device 1195 (rev 01)

      00:08.3 Communication controller: Intel Corporation Device 1195 (rev 01)

      00:09.0 Communication controller: Intel Corporation Device 1196 (rev 01)

      00:09.1 Communication controller: Intel Corporation Device 1196 (rev 01)

      00:09.2 Communication controller: Intel Corporation Device 1196 (rev 01)

      00:0a.0 Communication controller: Intel Corporation Device 1197 (rev 01)

      00:0b.0 Encryption controller: Intel Corporation Device 1198 (rev 01)

      00:0c.0 System peripheral: Intel Corporation Device 1199 (rev 01)

      00:0d.0 Multimedia audio controller: Intel Corporation Device 119a (rev 01)

      00:0e.0 System peripheral: Intel Corporation Device 119b (rev 01)

      00:11.0 USB controller: Intel Corporation Device 119e (rev 01)

      00:12.0 Signal processing controller: Intel Corporation Device 119f (rev 01)

      00:13.0 Co-processor: Intel Corporation Device 11a0 (rev 01)

      00:14.0 Co-processor: Intel Corporation Device 11a1 (rev 01)

      00:15.0 System peripheral: Intel Corporation Device 11a2 (rev 01)

      00:16.0 Co-processor: Intel Corporation Device 11a3 (rev 01)

      00:16.1 Co-processor: Intel Corporation Device 11a4 (rev 01)

      00:17.0 System peripheral: Intel Corporation Device 11a5 (rev 01)

      00:18.0 Display controller: Intel Corporation Device 11a6 (rev 01)

       

       

      # disable otg driver

       

      # sometimes a hard reboot of board is required; other times the below stacktrace is echoed (but I can then immediately ssh back into board). In both cases, the otg is still getting power

       

      root@ehren-edison-battery1:~# echo 0000\:00\:11.0 > /sys/bus/pci/drivers/dwc3_otg/unbind

      [  138.203644] BUG: spinlock bad magic on CPU#1, sh/234

      [  138.203725] BUG: unable to handle kernel paging request at 00001f45

      [  138.203797] IP: [<c14e0d10>] spin_dump+0x60/0xf0

      [  138.203866] *pdpt = 00000000354d8001 *pde = 0000000000000000

      [  138.203929] Oops: 0000 [#1] PREEMPT SMP

      [  138.203984] Modules linked in: usb_f_acm u_serial g_multi libcomposite bcm_bt_lpm bcm4334x(O)

      [  138.204105] CPU: 1 PID: 234 Comm: sh Tainted: G        W  O 3.10.17-poky-edison+ #1

      [  138.204167] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 542 2015.01.21:18.19.48

      [  138.204237] task: f5771640 ti: f5746000 task.ti: f5746000

      [  138.204288] EIP: 0060:[<c14e0d10>] EFLAGS: 00010006 CPU: 1

      [  138.204341] EIP is at spin_dump+0x60/0xf0

      [  138.204382] EAX: 00000028 EBX: 00001d1d ECX: 00000000 EDX: 00000020

      [  138.204436] ESI: f5c05070 EDI: 000000ea EBP: f5747dd8 ESP: f5747db4

      [  138.204490]  DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068

      [  138.204539] CR0: 8005003b CR2: 00001f45 CR3: 354bd000 CR4: 001007f0

      [  138.204592] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000

      [  138.204643] DR6: ffff0ff0 DR7: 00000400

      [  138.204678] Stack:

      [  138.204703]  c1b10078 c1b0f751 00000001 f5771940 000000ea f5747de4 f5c05070 c1b0f751

      [  138.204815]  00000001 f5747de8 c14e0dbb f5c05070 f5c05070 f5747e04 c14e0f4a c15e5852

      [  138.204925]  f5746000 f5c05070 f5c05070 00000001 f5747e10 c18df1c2 f5c05000 f5747e24

      [  138.205035] Call Trace:

      [  138.205084]  [<c14e0dbb>] spin_bug+0x1b/0x20

      [  138.205139]  [<c14e0f4a>] do_raw_spin_lock+0x11a/0x150

      [  138.205200]  [<c15e5852>] ? hcd_release+0x52/0x60

      [  138.205258]  [<c18df1c2>] _raw_spin_lock_irq+0x22/0x30

      [  138.205316]  [<c15926b9>] __pm_runtime_disable+0x19/0x110

      [  138.205378]  [<c161f6fe>] xhci_dwc_drv_remove+0x5e/0x80

      [  138.205437]  [<c1588f61>] platform_drv_remove+0x11/0x20

      [  138.205498]  [<c1587491>] __device_release_driver+0x61/0xc0

      [  138.205559]  [<c158750d>] device_release_driver+0x1d/0x30

      [  138.205618]  [<c1586da6>] bus_remove_device+0xb6/0x120

      [  138.205677]  [<c15839f1>] ? device_remove_attrs+0x21/0x50

      [  138.205736]  [<c158405a>] device_del+0xea/0x180

      [  138.205789]  [<c1589529>] platform_device_del+0x19/0x90

      [  138.205847]  [<c15895b0>] platform_device_unregister+0x10/0x20

      [  138.205909]  [<c1601275>] dwc_otg_remove+0x35/0xe0

      [  138.205964]  [<c1592581>] ? __pm_runtime_resume+0x51/0x80

      [  138.206023]  [<c150037d>] pci_device_remove+0x2d/0xa0

      [  138.206082]  [<c1587491>] __device_release_driver+0x61/0xc0

      [  138.206143]  [<c158750d>] device_release_driver+0x1d/0x30

      [  138.206202]  [<c15868e1>] driver_unbind+0x61/0xf0

      [  138.206257]  [<c1585e00>] ? klist_devices_get+0x20/0x20

      [  138.206316]  [<c1586880>] ? subsys_virtual_register+0x50/0x50

      [  138.206377]  [<c15859ca>] drv_attr_store+0x1a/0x30

      [  138.206434]  [<c13807ca>] sysfs_write_file+0x9a/0x100

      [  138.206490]  [<c1380730>] ? sysfs_remove_files+0x40/0x40

      [  138.206551]  [<c132611e>] vfs_write+0x9e/0x1c0

      [  138.206607]  [<c13267a9>] SyS_write+0x49/0x90

      [  138.206662]  [<c18df928>] syscall_call+0x7/0xb

      [  138.206704] Code: 00 c7 04 24 78 00 b1 c1 64 8b 0d 10 50 d0 c1 89 7c 24 10 89 44 24 0c 89 4c 24 08 e8 f8 71 3f 00 85 db 8b 56 08 0f 84 7e 00 00 00 <8b> 83 28 02 00 00 81 c3 00 03 00 00 89 44 24 10 8b 46 04 89 54

      [  138.207233] EIP: [<c14e0d10>] spin_dump+0x60/0xf0 SS:ESP 0068:f5747db4

      [  138.207308] CR2: 0000000000001f45

      [  138.207349] ---[ end trace 908089dd19b16d78 ]---

      [  138.207400] BUG: sleeping function called from invalid context at /data/jenkins_worker/workspace/edison-weekly/linux-kernel/kernel/rwsem.c:20

      [  138.207495] in_atomic(): 1, irqs_disabled(): 1, pid: 234, name: sh

      [  138.207555] CPU: 1 PID: 234 Comm: sh Tainted: G      D W  O 3.10.17-poky-edison+ #1

      [  138.207617] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 542 2015.01.21:18.19.48

      [  138.207684]  f5771640 000000ea f5747bcc c18d9eea f5747bf0 c126d689 c1adaaf8 00000001

      [  138.207798]  00000001 000000ea f5771940 f5daf968 f5771640 f5747bfc c18dcd1c f5771640

      [  138.207911]  f5747c10 c125573e 00000000 f5747c10 00000009 f5747c60 c12452fd 00000009

      [  138.208023] Call Trace:

      [  138.208070]  [<c18d9eea>] dump_stack+0x16/0x18

      [  138.208127]  [<c126d689>] __might_sleep+0xe9/0x110

      [  138.208184]  [<c18dcd1c>] down_read+0x1c/0x30

      [  138.208239]  [<c125573e>] exit_signals+0x1e/0x110

      [  138.208295]  [<c12452fd>] do_exit+0x8d/0x9d0

      [  138.208349]  [<c18d7f19>] ? printk+0x1c/0x1e

      [  138.208401]  [<c124413b>] ? kmsg_dump+0xcb/0xe0

      [  138.208457]  [<c18e060b>] oops_end+0x8b/0xd0

      [  138.208510]  [<c12293a4>] no_context+0x104/0x1e0

      [  138.208566]  [<c1229535>] __bad_area_nosemaphore+0xb5/0x140

      [  138.208628]  [<c15544c0>] ? serial_sched_cmd+0xf0/0x210

      [  138.208686]  [<c12295d7>] bad_area_nosemaphore+0x17/0x20

      [  138.208747]  [<c18e24c7>] __do_page_fault+0xa7/0x550

      [  138.208808]  [<c1242e51>] ? vprintk_emit+0x2d1/0x610

      [  138.208867]  [<c18e2970>] ? __do_page_fault+0x550/0x550

      [  138.208926]  [<c18e297d>] do_page_fault+0xd/0x10

      [  138.208980]  [<c18dfe6b>] error_code+0x5f/0x64

      [  138.209038]  [<c18e2970>] ? __do_page_fault+0x550/0x550

      [  138.209097]  [<c14e0d10>] ? spin_dump+0x60/0xf0

      [  138.209153]  [<c14e0dbb>] spin_bug+0x1b/0x20

      [  138.209206]  [<c14e0f4a>] do_raw_spin_lock+0x11a/0x150

      [  138.209266]  [<c15e5852>] ? hcd_release+0x52/0x60

      [  138.209321]  [<c18df1c2>] _raw_spin_lock_irq+0x22/0x30

      [  138.209379]  [<c15926b9>] __pm_runtime_disable+0x19/0x110

      [  138.209441]  [<c161f6fe>] xhci_dwc_drv_remove+0x5e/0x80

      [  138.209499]  [<c1588f61>] platform_drv_remove+0x11/0x20

      [  138.209561]  [<c1587491>] __device_release_driver+0x61/0xc0

      [  138.209622]  [<c158750d>] device_release_driver+0x1d/0x30

      [  138.209682]  [<c1586da6>] bus_remove_device+0xb6/0x120

      [  138.209741]  [<c15839f1>] ? device_remove_attrs+0x21/0x50

      [  138.209800]  [<c158405a>] device_del+0xea/0x180

      [  138.209854]  [<c1589529>] platform_device_del+0x19/0x90

      [  138.209911]  [<c15895b0>] platform_device_unregister+0x10/0x20

      [  138.209974]  [<c1601275>] dwc_otg_remove+0x35/0xe0

      [  138.210029]  [<c1592581>] ? __pm_runtime_resume+0x51/0x80

      [  138.210088]  [<c150037d>] pci_device_remove+0x2d/0xa0

      [  138.210147]  [<c1587491>] __device_release_driver+0x61/0xc0

      [  138.210208]  [<c158750d>] device_release_driver+0x1d/0x30

      [  138.210268]  [<c15868e1>] driver_unbind+0x61/0xf0

      [  138.210323]  [<c1585e00>] ? klist_devices_get+0x20/0x20

      [  138.210382]  [<c1586880>] ? subsys_virtual_register+0x50/0x50

      [  138.210445]  [<c15859ca>] drv_attr_store+0x1a/0x30

      [  138.210501]  [<c13807ca>] sysfs_write_file+0x9a/0x100

      [  138.210559]  [<c1380730>] ? sysfs_remove_files+0x40/0x40

      [  138.210619]  [<c132611e>] vfs_write+0x9e/0x1c0

      [  138.210675]  [<c13267a9>] SyS_write+0x49/0x90

      [  138.210730]  [<c18df928>] syscall_call+0x7/0xb

      [  138.210779] note: sh[234] exited with preempt_count 1

      [  138.810883] BUG: scheduling while atomic: sh/234/0x10000002

      [  138.810943] Modules linked in: usb_f_acm u_serial g_multi libcomposite bcm_bt_lpm bcm4334x(O)

      [  138.811071] CPU: 1 PID: 234 Comm: sh Tainted: G      D W  O 3.10.17-poky-edison+ #1

      [  138.811134] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 542 2015.01.21:18.19.48

      [  138.811202]  00000001 f5771640 f5747a68 c18d9eea f5747a84 c126d09e c1adaa14 f5771940

      [  138.811316]  000000ea 10000002 00000000 f5747b04 c18ddd56 00000001 00000001 f5747ab0

      [  138.811427]  c1d04000 ffffc0c8 00000001 f5747aa4 f5747aa4 f73fdc00 f5771640 00000000

      [  138.811539] Call Trace:

      [  138.811593]  [<c18d9eea>] dump_stack+0x16/0x18

      [  138.811650]  [<c126d09e>] __schedule_bug+0x5e/0x80

      [  138.811708]  [<c18ddd56>] __schedule+0x586/0x8f0

      [  138.811771]  [<c1271917>] __cond_resched+0x17/0x30

      [  138.811826]  [<c18de4db>] _cond_resched+0x2b/0x40

      [  138.811881]  [<c130d789>] unmap_single_vma+0x429/0x530

      [  138.811944]  [<c130de43>] unmap_vmas+0x43/0x60

      [  138.811999]  [<c13146e3>] exit_mmap+0x83/0x110

      [  138.812055]  [<c18df953>] ? restore_all_notrace+0x3/0x18

      [  138.812119]  [<c123e2c1>] mmput+0x41/0x90

      [  138.812169]  [<c12454b2>] do_exit+0x242/0x9d0

      [  138.812223]  [<c18d7f19>] ? printk+0x1c/0x1e

      [  138.812275]  [<c124413b>] ? kmsg_dump+0xcb/0xe0

      [  138.812331]  [<c18e060b>] oops_end+0x8b/0xd0

      [  138.812384]  [<c12293a4>] no_context+0x104/0x1e0

      [  138.812439]  [<c1229535>] __bad_area_nosemaphore+0xb5/0x140

      [  138.812502]  [<c15544c0>] ? serial_sched_cmd+0xf0/0x210

      [  138.812561]  [<c12295d7>] bad_area_nosemaphore+0x17/0x20

      [  138.812621]  [<c18e24c7>] __do_page_fault+0xa7/0x550

      [  138.812682]  [<c1242e51>] ? vprintk_emit+0x2d1/0x610

      [  138.812740]  [<c18e2970>] ? __do_page_fault+0x550/0x550

      [  138.812799]  [<c18e297d>] do_page_fault+0xd/0x10

      [  138.812854]  [<c18dfe6b>] error_code+0x5f/0x64

      [  138.812911]  [<c18e2970>] ? __do_page_fault+0x550/0x550

      [  138.812970]  [<c14e0d10>] ? spin_dump+0x60/0xf0

      [  138.813026]  [<c14e0dbb>] spin_bug+0x1b/0x20

      [  138.813079]  [<c14e0f4a>] do_raw_spin_lock+0x11a/0x150

      [  138.813139]  [<c15e5852>] ? hcd_release+0x52/0x60

      [  138.813195]  [<c18df1c2>] _raw_spin_lock_irq+0x22/0x30

      [  138.813253]  [<c15926b9>] __pm_runtime_disable+0x19/0x110

      [  138.813315]  [<c161f6fe>] xhci_dwc_drv_remove+0x5e/0x80

      [  138.813374]  [<c1588f61>] platform_drv_remove+0x11/0x20

      [  138.813435]  [<c1587491>] __device_release_driver+0x61/0xc0

      [  138.813496]  [<c158750d>] device_release_driver+0x1d/0x30

      [  138.813556]  [<c1586da6>] bus_remove_device+0xb6/0x120

      [  138.813615]  [<c15839f1>] ? device_remove_attrs+0x21/0x50

      [  138.813675]  [<c158405a>] device_del+0xea/0x180

      [  138.813728]  [<c1589529>] platform_device_del+0x19/0x90

      [  138.813786]  [<c15895b0>] platform_device_unregister+0x10/0x20

      [  139.060221]  [<c1601275>] dwc_otg_remove+0x35/0xe0

      [  139.060287]  [<c1592581>] ? __pm_runtime_resume+0x51/0x80

      [  139.060348]  [<c150037d>] pci_device_remove+0x2d/0xa0

      [  139.060408]  [<c1587491>] __device_release_driver+0x61/0xc0

      [  139.060470]  [<c158750d>] device_release_driver+0x1d/0x30

      [  139.060530]  [<c15868e1>] driver_unbind+0x61/0xf0

      [  139.060586]  [<c1585e00>] ? klist_devices_get+0x20/0x20

      [  139.060645]  [<c1586880>] ? subsys_virtual_register+0x50/0x50

      [  139.060707]  [<c15859ca>] drv_attr_store+0x1a/0x30

      [  139.060765]  [<c13807ca>] sysfs_write_file+0x9a/0x100

      [  139.060822]  [<c1380730>] ? sysfs_remove_files+0x40/0x40

      [  139.060883]  [<c132611e>] vfs_write+0x9e/0x1c0

      [  139.060939]  [<c13267a9>] SyS_write+0x49/0x90

      [  139.060995]  [<c18df928>] syscall_call+0x7/0xb

      [  139.131018] BUG: scheduling while atomic: sh/234/0x00000002

      [  139.131076] Modules linked in: usb_f_acm u_serial g_multi libcomposite bcm_bt_lpm bcm4334x(O)

      [  139.131205] CPU: 0 PID: 234 Comm: sh Tainted: G      D W  O 3.10.17-poky-edison+ #1

      [  139.131268] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 542 2015.01.21:18.19.48

      [  139.131336]  00000000 f5771640 f574797c c18d9eea f5747998 c126d09e c1adaa14 f5771940

      [  139.131459]  000000ea 00000002 f5747a3c f5747a18 c18ddd56 00000803 00000000 0000004f

      [  139.131570]  c1d04000 00000002 f5771640 00000000 f57479f4 f73efc00 f5771640 f73ead34

      [  139.131683] Call Trace:

      [  139.131735]  [<c18d9eea>] dump_stack+0x16/0x18

      [  139.131792]  [<c126d09e>] __schedule_bug+0x5e/0x80

      [  139.131850]  [<c18ddd56>] __schedule+0x586/0x8f0

      [  139.131911]  [<c124fd31>] ? __internal_add_timer+0x81/0xc0

      [  139.131971]  [<c18de0e3>] schedule+0x23/0x60

      [  139.132023]  [<c18db71d>] schedule_timeout+0x13d/0x2a0

      [  139.132083]  [<c124fd70>] ? __internal_add_timer+0xc0/0xc0

      [  139.132145]  [<c12514b3>] msleep_interruptible+0x43/0x70

      [  139.132206]  [<c154c4e5>] uart_wait_until_sent+0xb5/0x120

      [  139.132267]  [<c18df266>] ? _raw_spin_unlock_irqrestore+0x26/0x60

      [  139.132335]  [<c1534f8c>] tty_wait_until_sent+0x10c/0x140

      [  139.132394]  [<c18dc63d>] ? mutex_unlock+0xd/0x10

      [  139.132451]  [<c18df825>] ? tty_unlock+0x25/0x50

      [  139.132507]  [<c153861b>] tty_port_close_start+0xdb/0x1b0

      [  139.132565]  [<c1335b0f>] ? fasync_remove_entry+0x5f/0xb0

      [  139.132627]  [<c154ee1f>] uart_close+0x3f/0x200

      [  139.132682]  [<c152eb15>] ? __tty_fasync+0x55/0x140

      [  139.132739]  [<c1530104>] tty_release+0xd4/0x550

      [  139.132795]  [<c12f6ec2>] ? free_pages_prepare+0x102/0x170

      [  139.132869]  [<c126b1c4>] ? lg_local_unlock+0x24/0x40

      [  139.132929]  [<c1327468>] __fput+0xd8/0x230

      [  139.132984]  [<c132765d>] ____fput+0xd/0x10

      [  139.133037]  [<c1260629>] task_work_run+0x89/0xb0

      [  139.133093]  [<c12454f1>] do_exit+0x281/0x9d0

      [  139.133147]  [<c18d7f19>] ? printk+0x1c/0x1e

      [  139.133199]  [<c124413b>] ? kmsg_dump+0xcb/0xe0

      [  139.133255]  [<c18e060b>] oops_end+0x8b/0xd0

      [  139.133309]  [<c12293a4>] no_context+0x104/0x1e0

      [  139.133365]  [<c1229535>] __bad_area_nosemaphore+0xb5/0x140

      [  139.133426]  [<c15544c0>] ? serial_sched_cmd+0xf0/0x210

      [  139.133484]  [<c12295d7>] bad_area_nosemaphore+0x17/0x20

      [  139.133544]  [<c18e24c7>] __do_page_fault+0xa7/0x550

      [  139.133605]  [<c1242e51>] ? vprintk_emit+0x2d1/0x610

      [  139.133664]  [<c18e2970>] ? __do_page_fault+0x550/0x550

      [  139.133730]  [<c18e297d>] do_page_fault+0xd/0x10

      [  139.361292]  [<c18dfe6b>] error_code+0x5f/0x64

      [  139.361359]  [<c18e2970>] ? __do_page_fault+0x550/0x550

      [  139.361421]  [<c14e0d10>] ? spin_dump+0x60/0xf0

      [  139.361478]  [<c14e0dbb>] spin_bug+0x1b/0x20

      [  139.361531]  [<c14e0f4a>] do_raw_spin_lock+0x11a/0x150

      [  139.361590]  [<c15e5852>] ? hcd_release+0x52/0x60

      [  139.361646]  [<c18df1c2>] _raw_spin_lock_irq+0x22/0x30

      [  139.361705]  [<c15926b9>] __pm_runtime_disable+0x19/0x110

      [  139.361768]  [<c161f6fe>] xhci_dwc_drv_remove+0x5e/0x80

      [  139.361827]  [<c1588f61>] platform_drv_remove+0x11/0x20

      [  139.361887]  [<c1587491>] __device_release_driver+0x61/0xc0

      [  139.361949]  [<c158750d>] device_release_driver+0x1d/0x30

      [  139.362009]  [<c1586da6>] bus_remove_device+0xb6/0x120

      [  139.362068]  [<c15839f1>] ? device_remove_attrs+0x21/0x50

      [  139.362127]  [<c158405a>] device_del+0xea/0x180

      [  139.362181]  [<c1589529>] platform_device_del+0x19/0x90

      [  139.362239]  [<c15895b0>] platform_device_unregister+0x10/0x20

      [  139.362303]  [<c1601275>] dwc_otg_remove+0x35/0xe0

      [  139.362357]  [<c1592581>] ? __pm_runtime_resume+0x51/0x80

      [  139.362417]  [<c150037d>] pci_device_remove+0x2d/0xa0

      [  139.362476]  [<c1587491>] __device_release_driver+0x61/0xc0

      [  139.362538]  [<c158750d>] device_release_driver+0x1d/0x30

      [  139.362598]  [<c15868e1>] driver_unbind+0x61/0xf0

      [  139.362653]  [<c1585e00>] ? klist_devices_get+0x20/0x20

      [  139.362712]  [<c1586880>] ? subsys_virtual_register+0x50/0x50

      [  139.362774]  [<c15859ca>] drv_attr_store+0x1a/0x30

      [  139.362831]  [<c13807ca>] sysfs_write_file+0x9a/0x100

      [  139.362888]  [<c1380730>] ? sysfs_remove_files+0x40/0x40

      [  139.362949]  [<c132611e>] vfs_write+0x9e/0x1c0

      [  139.363005]  [<c13267a9>] SyS_write+0x49/0x90

      [  139.363061]  [<c18df928>] syscall_call+0x7/0xb

      [  139.363272] BUG: sleeping function called from invalid context at /data/jenkins_worker/workspace/edison-weekly/linux-kernel/kernel/mutex.c:95

      [  139.363395] in_atomic(): 1, irqs_disabled(): 0, pid: 234, name: sh

      [  139.363457] CPU: 1 PID: 234 Comm: sh Tainted: G      D W  O 3.10.17-poky-edison+ #1

      [  139.363519] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 542 2015.01.21:18.19.48

      [  139.363587]  f5771640 000000ea f5747aa4 c18d9eea f5747ac8 c126d689 c1adaaf8 00000001

      [  139.363701]  00000000 000000ea f5771940 f51eb46c 00000bb8 f5747ad4 c18dc9bc f51eb400

      [  139.363906]  f5747ae8 c18df734 f5747af0 c18df825 f6c14240 f5747af0 c18df79d f5747b14

      [  139.364020] Call Trace:

      [  139.364071]  [<c18d9eea>] dump_stack+0x16/0x18

      [  139.364127]  [<c126d689>] __might_sleep+0xe9/0x110

      [  139.364183]  [<c18dc9bc>] mutex_lock+0x1c/0x30

      [  139.364236]  [<c18df734>] tty_lock_nested.isra.0+0x34/0x90

      [  139.364294]  [<c18df825>] ? tty_unlock+0x25/0x50

      [  139.364347]  [<c18df79d>] tty_lock+0xd/0x10

      [  139.364398]  [<c1538622>] tty_port_close_start+0xe2/0x1b0

      [  139.364456]  [<c1335b0f>] ? fasync_remove_entry+0x5f/0xb0

      [  139.364517]  [<c154ee1f>] uart_close+0x3f/0x200

      [  139.364571]  [<c152eb15>] ? __tty_fasync+0x55/0x140

      [  139.364628]  [<c1530104>] tty_release+0xd4/0x550

      [  139.364683]  [<c12f6ec2>] ? free_pages_prepare+0x102/0x170

      [  139.364744]  [<c126b1c4>] ? lg_local_unlock+0x24/0x40

      [  139.364803]  [<c1327468>] __fput+0xd8/0x230

      [  139.364856]  [<c132765d>] ____fput+0xd/0x10

      [  139.364909]  [<c1260629>] task_work_run+0x89/0xb0

      [  139.364962]  [<c12454f1>] do_exit+0x281/0x9d0

      [  139.365015]  [<c18d7f19>] ? printk+0x1c/0x1e

      [  139.365067]  [<c124413b>] ? kmsg_dump+0xcb/0xe0

      [  139.365121]  [<c18e060b>] oops_end+0x8b/0xd0

      [  139.365173]  [<c12293a4>] no_context+0x104/0x1e0

      [  139.365226]  [<c1229535>] __bad_area_nosemaphore+0xb5/0x140

      [  139.365286]  [<c15544c0>] ? serial_sched_cmd+0xf0/0x210

      [  139.365344]  [<c12295d7>] bad_area_nosemaphore+0x17/0x20

      [  139.365402]  [<c18e24c7>] __do_page_fault+0xa7/0x550

      [  139.365462]  [<c1242e51>] ? vprintk_emit+0x2d1/0x610

      [  139.365519]  [<c18e2970>] ? __do_page_fault+0x550/0x550

      [  139.365576]  [<c18e297d>] do_page_fault+0xd/0x10

      [  139.365629]  [<c18dfe6b>] error_code+0x5f/0x64

      [  139.365685]  [<c18e2970>] ? __do_page_fault+0x550/0x550

      [  139.365742]  [<c14e0d10>] ? spin_dump+0x60/0xf0

      [  139.365797]  [<c14e0dbb>] spin_bug+0x1b/0x20

      [  139.365849]  [<c14e0f4a>] do_raw_spin_lock+0x11a/0x150

      [  139.365906]  [<c15e5852>] ? hcd_release+0x52/0x60

      [  139.365960]  [<c18df1c2>] _raw_spin_lock_irq+0x22/0x30

      [  139.366017]  [<c15926b9>] __pm_runtime_disable+0x19/0x110

      [  139.366077]  [<c161f6fe>] xhci_dwc_drv_remove+0x5e/0x80

      [  139.366134]  [<c1588f61>] platform_drv_remove+0x11/0x20

      [  139.366193]  [<c1587491>] __device_release_driver+0x61/0xc0

      [  139.366253]  [<c158750d>] device_release_driver+0x1d/0x30

      [  139.366312]  [<c1586da6>] bus_remove_device+0xb6/0x120

      [  139.366369]  [<c15839f1>] ? device_remove_attrs+0x21/0x50

      [  139.366427]  [<c158405a>] device_del+0xea/0x180

      [  139.366480]  [<c1589529>] platform_device_del+0x19/0x90

      [  139.366537]  [<c15895b0>] platform_device_unregister+0x10/0x20

      [  139.366597]  [<c1601275>] dwc_otg_remove+0x35/0xe0

      [  139.366651]  [<c1592581>] ? __pm_runtime_resume+0x51/0x80

      [  139.366709]  [<c150037d>] pci_device_remove+0x2d/0xa0

      [  139.366766]  [<c1587491>] __device_release_driver+0x61/0xc0

      [  139.366826]  [<c158750d>] device_release_driver+0x1d/0x30

      [  139.366887]  [<c15868e1>] driver_unbind+0x61/0xf0

      [  139.366941]  [<c1585e00>] ? klist_devices_get+0x20/0x20

      [  139.366999]  [<c1586880>] ? subsys_virtual_register+0x50/0x50

      [  139.367059]  [<c15859ca>] drv_attr_store+0x1a/0x30

      [  139.367113]  [<c13807ca>] sysfs_write_file+0x9a/0x100

      [  139.367169]  [<c1380730>] ? sysfs_remove_files+0x40/0x40

      [  139.367228]  [<c132611e>] vfs_write+0x9e/0x1c0

      [  139.367283]  [<c13267a9>] SyS_write+0x49/0x90

      [  139.367337]  [<c18df928>] syscall_call+0x7/0xb

      [  139.870026] BUG: scheduling while atomic: sh/234/0x00000002

      [  139.870080] Modules linked in: usb_f_acm u_serial g_multi libcomposite bcm_bt_lpm bcm4334x(O)

      [  139.870207] CPU: 1 PID: 234 Comm: sh Tainted: G      D W  O 3.10.17-poky-edison+ #1

      [  139.870269] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 542 2015.01.21:18.19.48

      [  139.870337]  00000001 f5771640 f57479d4 c18d9eea f57479f0 c126d09e c1adaa14 f5771940

      [  139.870451]  000000ea 00000002 f5747a94 f5747a70 c18ddd56 00000803 00000000 0000017a

      [  139.870562]  c1d04000 00000002 f5771640 00000001 f5747a4c f73fdc00 f5771640 f73f8d34

      [  139.870675] Call Trace:

      [  139.870723]  [<c18d9eea>] dump_stack+0x16/0x18

      [  139.870777]  [<c126d09e>] __schedule_bug+0x5e/0x80

      [  139.870834]  [<c18ddd56>] __schedule+0x586/0x8f0

      [  139.870895]  [<c124fd31>] ? __internal_add_timer+0x81/0xc0

      [  139.870954]  [<c18de0e3>] schedule+0x23/0x60

      [  139.871006]  [<c18db71d>] schedule_timeout+0x13d/0x2a0

      [  139.871065]  [<c124fd70>] ? __internal_add_timer+0xc0/0xc0

      [  139.871127]  [<c12514b3>] msleep_interruptible+0x43/0x70

      [  139.871192]  [<c154c4e5>] uart_wait_until_sent+0xb5/0x120

      [  139.871255]  [<c154ef9e>] uart_close+0x1be/0x200

      [  139.871310]  [<c152eb15>] ? __tty_fasync+0x55/0x140

      [  139.871368]  [<c1530104>] tty_release+0xd4/0x550

      [  139.871423]  [<c12f6ec2>] ? free_pages_prepare+0x102/0x170

      [  139.871486]  [<c126b1c4>] ? lg_local_unlock+0x24/0x40

      [  139.871547]  [<c1327468>] __fput+0xd8/0x230

      [  139.871605]  [<c132765d>] ____fput+0xd/0x10

      [  139.871658]  [<c1260629>] task_work_run+0x89/0xb0

      [  139.871712]  [<c12454f1>] do_exit+0x281/0x9d0

      [  139.871766]  [<c18d7f19>] ? printk+0x1c/0x1e

      [  139.871818]  [<c124413b>] ? kmsg_dump+0xcb/0xe0

      [  139.871874]  [<c18e060b>] oops_end+0x8b/0xd0

      [  139.871926]  [<c12293a4>] no_context+0x104/0x1e0

      [  139.871981]  [<c1229535>] __bad_area_nosemaphore+0xb5/0x140

      [  139.872043]  [<c15544c0>] ? serial_sched_cmd+0xf0/0x210

      [  139.872101]  [<c12295d7>] bad_area_nosemaphore+0x17/0x20

      [  139.872161]  [<c18e24c7>] __do_page_fault+0xa7/0x550

      [  139.872221]  [<c1242e51>] ? vprintk_emit+0x2d1/0x610

      [  139.872280]  [<c18e2970>] ? __do_page_fault+0x550/0x550

      [  139.872338]  [<c18e297d>] do_page_fault+0xd/0x10

      [  139.872393]  [<c18dfe6b>] error_code+0x5f/0x64

      [  139.872454]  [<c18e2970>] ? __do_page_fault+0x550/0x550

      [  139.872513]  [<c14e0d10>] ? spin_dump+0x60/0xf0

      [  139.872569]  [<c14e0dbb>] spin_bug+0x1b/0x20

      [  139.872622]  [<c14e0f4a>] do_raw_spin_lock+0x11a/0x150

      [  139.872680]  [<c15e5852>] ? hcd_release+0x52/0x60

      [  139.872736]  [<c18df1c2>] _raw_spin_lock_irq+0x22/0x30

      [  139.872793]  [<c15926b9>] __pm_runtime_disable+0x19/0x110

      [  139.872861]  [<c161f6fe>] xhci_dwc_drv_remove+0x5e/0x80

      [  139.872919]  [<c1588f61>] platform_drv_remove+0x11/0x20

      [  139.872979]  [<c1587491>] __device_release_driver+0x61/0xc0

      [  139.873040]  [<c158750d>] device_release_driver+0x1d/0x30

      [  139.873101]  [<c1586da6>] bus_remove_device+0xb6/0x120

      [  139.873159]  [<c15839f1>] ? device_remove_attrs+0x21/0x50

      [  139.873219]  [<c158405a>] device_del+0xea/0x180

      [  139.873275]  [<c1589529>] platform_device_del+0x19/0x90

      [  139.873333]  [<c15895b0>] platform_device_unregister+0x10/0x20

      [  139.873395]  [<c1601275>] dwc_otg_remove+0x35/0xe0

      [  139.873450]  [<c1592581>] ? __pm_runtime_resume+0x51/0x80

      [  139.873509]  [<c150037d>] pci_device_remove+0x2d/0xa0

      [  139.873568]  [<c1587491>] __device_release_driver+0x61/0xc0

      [  139.873629]  [<c158750d>] device_release_driver+0x1d/0x30

      [  140.181954]  [<c15868e1>] driver_unbind+0x61/0xf0

      [  140.182019]  [<c1585e00>] ? klist_devices_get+0x20/0x20

      [  140.182080]  [<c1586880>] ? subsys_virtual_register+0x50/0x50

      [  140.182143]  [<c15859ca>] drv_attr_store+0x1a/0x30

      [  140.182199]  [<c13807ca>] sysfs_write_file+0x9a/0x100

      [  140.182257]  [<c1380730>] ? sysfs_remove_files+0x40/0x40

      [  140.182317]  [<c132611e>] vfs_write+0x9e/0x1c0

      [  140.182374]  [<c13267a9>] SyS_write+0x49/0x90

      [  140.182430]  [<c18df928>] syscall_call+0x7/0xb

      [  140.226495] BUG: scheduling while atomic: sh/234/0x10000002

      [  140.226553] Modules linked in: usb_f_acm u_serial g_multi libcomposite bcm_bt_lpm bcm4334x(O)

      [  140.226687] CPU: 0 PID: 234 Comm: sh Tainted: G      D W  O 3.10.17-poky-edison+ #1

      [  140.226750] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 542 2015.01.21:18.19.48

      [  140.226818]  00000000 f5771640 f5747b50 c18d9eea f5747b6c c126d09e c1adaa14 f5771940

      [  140.226933]  000000ea 10000002 00000000 f5747bec c18ddd56 014eba20 f6c01d00 f5198680

      [  140.227045]  c1d04000 f5198680 f6392afc f5c8fcd0 f6fdc77c f73efc00 f5771640 f5747ba8

      [  140.227169] Call Trace:

      [  140.227221]  [<c18d9eea>] dump_stack+0x16/0x18

      [  140.227277]  [<c126d09e>] __schedule_bug+0x5e/0x80

      [  140.227335]  [<c18ddd56>] __schedule+0x586/0x8f0

      [  140.227391]  [<c126b1dd>] ? lg_local_unlock+0x3d/0x40

      [  140.227450]  [<c13416c1>] ? mntput_no_expire+0x31/0x110

      [  140.227507]  [<c13417bd>] ? mntput+0x1d/0x30

      [  140.227561]  [<c13274e9>] ? __fput+0x159/0x230

      [  140.227629]  [<c1271917>] __cond_resched+0x17/0x30

      [  140.227683]  [<c18de4db>] _cond_resched+0x2b/0x40

      [  140.227740]  [<c126063f>] task_work_run+0x9f/0xb0

      [  140.227796]  [<c12454f1>] do_exit+0x281/0x9d0

      [  140.227850]  [<c18d7f19>] ? printk+0x1c/0x1e

      [  140.227902]  [<c124413b>] ? kmsg_dump+0xcb/0xe0

      [  140.227958]  [<c18e060b>] oops_end+0x8b/0xd0

      [  140.228015]  [<c12293a4>] no_context+0x104/0x1e0

      [  140.228070]  [<c1229535>] __bad_area_nosemaphore+0xb5/0x140

      [  140.228132]  [<c15544c0>] ? serial_sched_cmd+0xf0/0x210

      [  140.228191]  [<c12295d7>] bad_area_nosemaphore+0x17/0x20

       

       

      [  140.228251]  [<c18e24c7>] __do_page_fault+0xa7/0x550

      [  140.228312]  [<c1242e51>] ? vprintk_emit+0x2d1/0x610

      [  140.228370]  [<c18e2970>] ? __do_page_fault+0x550/0x550

      [  140.228439]  [<c18e297d>] do_page_fault+0xd/0x10

      [  140.228493]  [<c18dfe6b>] error_code+0x5f/0x64

      [  140.228550]  [<c18e2970>] ? __do_page_fault+0x550/0x550

      [  140.228610]  [<c14e0d10>] ? spin_dump+0x60/0xf0

      [  140.228666]  [<c14e0dbb>] spin_bug+0x1b/0x20

      [  140.228719]  [<c14e0f4a>] do_raw_spin_lock+0x11a/0x150

      [  140.228778]  [<c15e5852>] ? hcd_release+0x52/0x60

      [  140.228834]  [<c18df1c2>] _raw_spin_lock_irq+0x22/0x30

      [  140.228893]  [<c15926b9>] __pm_runtime_disable+0x19/0x110

      [  140.228955]  [<c161f6fe>] xhci_dwc_drv_remove+0x5e/0x80

      [  140.229014]  [<c1588f61>] platform_drv_remove+0x11/0x20

      [  140.229075]  [<c1587491>] __device_release_driver+0x61/0xc0

      [  140.229136]  [<c158750d>] device_release_driver+0x1d/0x30

      [  140.229196]  [<c1586da6>] bus_remove_device+0xb6/0x120

      [  140.229255]  [<c15839f1>] ? device_remove_attrs+0x21/0x50

      [  140.229320]  [<c158405a>] device_del+0xea/0x180

      [  140.229373]  [<c1589529>] platform_device_del+0x19/0x90

      [  140.229431]  [<c15895b0>] platform_device_unregister+0x10/0x20

      [  140.229495]  [<c1601275>] dwc_otg_remove+0x35/0xe0

      [  140.229550]  [<c1592581>] ? __pm_runtime_resume+0x51/0x80

      [  140.229610]  [<c150037d>] pci_device_remove+0x2d/0xa0

      [  140.229669]  [<c1587491>] __device_release_driver+0x61/0xc0

      [  140.229737]  [<c158750d>] device_release_driver+0x1d/0x30

      [  140.229798]  [<c15868e1>] driver_unbind+0x61/0xf0

      [  140.229853]  [<c1585e00>] ? klist_devices_get+0x20/0x20

      [  140.229912]  [<c1586880>] ? subsys_virtual_register+0x50/0x50

      [  140.229973]  [<c15859ca>] drv_attr_store+0x1a/0x30

      [  140.230029]  [<c13807ca>] sysfs_write_file+0x9a/0x100

      [  140.230087]  [<c1380730>] ? sysfs_remove_files+0x40/0x40

      [  140.230153]  [<c132611e>] vfs_write+0x9e/0x1c0

      [  140.230210]  [<c13267a9>] SyS_write+0x49/0x90

      [  140.230264]  [<c18df928>] syscall_call+0x7/0xb

       

      Poky (Yocto Project Reference Distro) 1.7.2 ehren-edison-battery1 ttyMFD2

       

      ehren-edison-battery1 login:

       

      ----------------------------

       

      Trying to unload some modules prior to the above steps e.g.:

       

      modprobe -r g_multi

      modprobe -r usb_f_acm

       

      doesn't work

        • 1. Re: Disabling power to otg (without reboot)
          ehren_m

          So I've made a little progress.

           

          First use the technique from the thread linked above:

           

          cd /lib/modules/3.10.17-poky-edison+/kernel/drivers/usb/gadget/

          mv g_multi.ko g_multi.ko-blah

           

          Then reboot the board

           

          Once rebooted the board will be in such a state where the otg can be re-powered (without a reboot)

           

          # first undo rename

          cd /lib/modules/3.10.17-poky-edison+/kernel/drivers/usb/gadget/

          mv g_multi.ko-blah g_multi.ko

           

          # then restart load modules service

          systemctl restart systemd-modules-load

           

          At this point otg hostmode works (and a reboot wasn't required).

           

          However there is a large caveat - the bug where hostmode is initialized on every other reboot affects this.


          So on the last step the systemctl restart systemd-modules-load will only work "every other time" - that is, only if hostmode would have been initialized had you not performed the rename kernel modules step above. This is problematic in that after I've done the "rename kernel module then reboot board" step I have to trust that hostmode will be initialized when I restart the systemd-modules-load service (in response to a bluetooth command sent to the edison).


          (still investigating)

          • 2. Re: Disabling power to otg (without reboot)
            Intel_Peter

            Hello ehren_m,

             

            As stated in several posts, this is a known issue where the Edison will have issues detecting USB devices when the board soft reboots. A software fix has not been yet found but hopefully it will be included in future updates. Nevertheless, there is no ETA on it.

             

            However, a hardware fix might be possible as a "workaround". I mean, you could break the power signal and with a relay or an optocoupler have it reset. You will only need a pin that controls the optocoupler/relay and this pin can be set to toggle every time on boot with a system service.

             

            I know this is a less subtle option but it requires little circuitry and could help you work around this issue.

             

            Peter

            • 3. Re: Disabling power to otg (without reboot)
              ehren_m

              Hi Intel_Peter,

               

              Definitely understand there's no ETA for the fix which is totally understandable.

               

              Thanks for the info. Using some sort of relay would actually handle my desired use case (to cut and restore power to the otg port on demand -- so that connected usb devices do not draw power when unneeded). I'm still looking for a software-only approach to achieve this however (which I'm continuing to investigate).

               

              Ehren

              • 4. Re: Disabling power to otg (without reboot)
                Intel_Peter

                Unfortunately, there's no  software solution right now. However, the hardware solution should work in any case.

                 

                Peter.

                • 5. Re: Disabling power to otg (without reboot)
                  RenatoM

                  So I know that this may be an old question, but I stumbled upon this message while I was trying to do a similar thing.

                  A software-only solution that I found is the following: instead of unbinding the USB host PCI device from the PCI driver, unbind the USB hub from the USB driver. You can use the following:

                   

                  echo "1-1" > /sys/bus/usb/drivers/usb/unbind

                   

                  This should remove power to whatever is connected to the USB bus 1-1.

                  To re-enable power, re-bind the hub with:

                   

                  echo "1-1" > /sys/bus/usb/drivers/usb/bind

                   

                  Let me know if that works for you.

                  1 of 1 people found this helpful