Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dwc_otg can't coexist with other USB drivers #881

Closed
ali1234 opened this issue Mar 11, 2015 · 12 comments
Closed

dwc_otg can't coexist with other USB drivers #881

ali1234 opened this issue Mar 11, 2015 · 12 comments

Comments

@ali1234
Copy link
Contributor

ali1234 commented Mar 11, 2015

dwc_otg exports usb_gadget_probe_driver function and patches out the udc-core module which normally exports it. This breaks other USB device controller drivers, most notably the virtual dummy_hcd ones, and causes the kernel compile to throw a load of errors if you try to build dwc_otg and gadget at the same time.

OpenWRT patched this issue:

https://lists.openwrt.org/pipermail/openwrt-devel/2012-November/017427.html

anholt pushed a commit to anholt/linux that referenced this issue Apr 21, 2015
In case we move the whole dev group to another netns,
we should call for_each_netdev_safe(), otherwise we get
a soft lockup:

 NMI watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [ip:798]
 irq event stamp: 255424
 hardirqs last  enabled at (255423): [<ffffffff81a2aa95>] restore_args+0x0/0x30
 hardirqs last disabled at (255424): [<ffffffff81a2ad5a>] apic_timer_interrupt+0x6a/0x80
 softirqs last  enabled at (255422): [<ffffffff81079ebc>] __do_softirq+0x2c1/0x3a9
 softirqs last disabled at (255417): [<ffffffff8107a190>] irq_exit+0x41/0x95
 CPU: 0 PID: 798 Comm: ip Not tainted 4.0.0-rc4+ raspberrypi#881
 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
 task: ffff8800d1b88000 ti: ffff880119530000 task.ti: ffff880119530000
 RIP: 0010:[<ffffffff810cad11>]  [<ffffffff810cad11>] debug_lockdep_rcu_enabled+0x28/0x30
 RSP: 0018:ffff880119533778  EFLAGS: 00000246
 RAX: ffff8800d1b88000 RBX: 0000000000000002 RCX: 0000000000000038
 RDX: 0000000000000000 RSI: ffff8800d1b888c8 RDI: ffff8800d1b888c8
 RBP: ffff880119533778 R08: 0000000000000000 R09: 0000000000000000
 R10: 0000000000000000 R11: 000000000000b5c2 R12: 0000000000000246
 R13: ffff880119533708 R14: 00000000001d5a40 R15: ffff88011a7d5a40
 FS:  00007fc01315f740(0000) GS:ffff88011a600000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
 CR2: 00007f367a120988 CR3: 000000011849c000 CR4: 00000000000007f0
 Stack:
  ffff880119533798 ffffffff811ac868 ffffffff811ac831 ffffffff811ac828
  ffff8801195337c8 ffffffff811ac8c9 ffff8801195339b0 ffff8801197633e0
  0000000000000000 ffff8801195339b0 ffff8801195337d8 ffffffff811ad2d7
 Call Trace:
  [<ffffffff811ac868>] rcu_read_lock+0x37/0x6e
  [<ffffffff811ac831>] ? rcu_read_unlock+0x5f/0x5f
  [<ffffffff811ac828>] ? rcu_read_unlock+0x56/0x5f
  [<ffffffff811ac8c9>] __fget+0x2a/0x7a
  [<ffffffff811ad2d7>] fget+0x13/0x15
  [<ffffffff811be732>] proc_ns_fget+0xe/0x38
  [<ffffffff817c7714>] get_net_ns_by_fd+0x11/0x59
  [<ffffffff817df359>] rtnl_link_get_net+0x33/0x3e
  [<ffffffff817df3d7>] do_setlink+0x73/0x87b
  [<ffffffff810b28ce>] ? trace_hardirqs_off+0xd/0xf
  [<ffffffff81a2aa95>] ? retint_restore_args+0xe/0xe
  [<ffffffff817e0301>] rtnl_newlink+0x40c/0x699
  [<ffffffff817dffe0>] ? rtnl_newlink+0xeb/0x699
  [<ffffffff81a29246>] ? _raw_spin_unlock+0x28/0x33
  [<ffffffff8143ed1e>] ? security_capable+0x18/0x1a
  [<ffffffff8107da51>] ? ns_capable+0x4d/0x65
  [<ffffffff817de5ce>] rtnetlink_rcv_msg+0x181/0x194
  [<ffffffff817de407>] ? rtnl_lock+0x17/0x19
  [<ffffffff817de407>] ? rtnl_lock+0x17/0x19
  [<ffffffff817de44d>] ? __rtnl_unlock+0x17/0x17
  [<ffffffff818327c6>] netlink_rcv_skb+0x4d/0x93
  [<ffffffff817de42f>] rtnetlink_rcv+0x26/0x2d
  [<ffffffff81830f18>] netlink_unicast+0xcb/0x150
  [<ffffffff8183198e>] netlink_sendmsg+0x501/0x523
  [<ffffffff8115cba9>] ? might_fault+0x59/0xa9
  [<ffffffff817b5398>] ? copy_from_user+0x2a/0x2c
  [<ffffffff817b7b74>] sock_sendmsg+0x34/0x3c
  [<ffffffff817b7f6d>] ___sys_sendmsg+0x1b8/0x255
  [<ffffffff8115c5eb>] ? handle_pte_fault+0xbd5/0xd4a
  [<ffffffff8100a2b0>] ? native_sched_clock+0x35/0x37
  [<ffffffff8109e94b>] ? sched_clock_local+0x12/0x72
  [<ffffffff8109eb9c>] ? sched_clock_cpu+0x9e/0xb7
  [<ffffffff810cadbf>] ? rcu_read_lock_held+0x3b/0x3d
  [<ffffffff811ac1d8>] ? __fcheck_files+0x4c/0x58
  [<ffffffff811ac946>] ? __fget_light+0x2d/0x52
  [<ffffffff817b8adc>] __sys_sendmsg+0x42/0x60
  [<ffffffff817b8b0c>] SyS_sendmsg+0x12/0x1c
  [<ffffffff81a29e32>] system_call_fastpath+0x12/0x17

Fixes: e7ed828 ("netlink: support setting devgroup parameters")
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
@TheSin-
Copy link

TheSin- commented Sep 29, 2015

I'm also seeing this issue in the latest 4.1.8, has anything been found here to allow use to build both together? The referenced commit doesn't seems to even be part of the issue.

@popcornmix
Copy link
Collaborator

Are you talking about raspberrypi/linux or some other tree? This linked openwrt patch doesn't apply to raspberrypi/linux (the files aren't even named the same).

The Pi kernel doesn't define CONFIG_USB_GADGET so just removing usb_gadget_probe_driver/usb_gadget_unregister_driver won't work.
Something like http://paste.ubuntu.com/12617280/ may be possible though. Does that help your case?

@TheSin-
Copy link

TheSin- commented Sep 29, 2015

I'm just saying that I can not build USB_GADGET with dwc_otg, if I build both when I try to load g_mass_storage I get a warning about udc_core exports duplicate symbol usb_gadget_probe_driver and g_mass_storage won't load.

I'm not saying the openwrt patch is a solution I didn't even want to try that cause I'm sure there is reason for it on the Pi, and it seems to be heavily dependant on dwc_otg. One of the things I wanted to mess around with was g_mass_storage, and since you helped me with building my own kernel it's one of the first new modules I tried to build, so I'm using the default config I'm just adding

CONFIG_USB_MASS_STORAGE=m
CONFIG_USB_GADGET=m

builds fine, boots fine, but when I run modprobe g_mass_storage

udc_core: exports duplicate symbol usb_gadget_probe_driver (owned by kernel)
modprobe: ERROR: could not insert 'g_mass_storage': Exec format error

I'm still working on debuging/figuring things out, to be fair I'm also trying to figure out hidapi so I can control the brightness not the display I bought at the same time so my thoughts are a little scattered. Let me try a few more things and get back to you.

@popcornmix
Copy link
Collaborator

Are you hoping to enable gadget mode for the in built USB ports or an external device of some sort?
Gadget mode is not possible on a model B Pi/Pi2 as there is a USB hub on the board.

@ali1234
Copy link
Contributor Author

ali1234 commented Sep 29, 2015

Original bug reporter here. I want to use dummy_hcd. This is a virtual loopback driver that allows you to write develop gadget code that can optionally run in userspace, while looking like real hardware to the kernel. None of that works on the Pi kernel though.

Working gadget mode for the A+ would be nice too, but I've got another bug report for that :)

@popcornmix
Copy link
Collaborator

Does it work with the patch I linked that avoids the duplicate symbol?

@TheSin-
Copy link

TheSin- commented Sep 29, 2015

@popcornmix I was hoping to do some testing with external devices, I wasn't sure if I could get an external one to work if it was attached to the Pi Hub, I knew the Pi Hub was not capable, but was hoping to play around and see what if anything was possible. Either way I can not build both due to that error.

I'm testing the patch right now

@TheSin-
Copy link

TheSin- commented Sep 29, 2015

okay so I tried with the patch and using

CONFIG_USB_MASS_STORAGE=m
CONFIG_USB_GADGET=y

built fine, booted fine and looks like it's loading fine (just need a device to test with now, but no major errors at least)

modprobe: ERROR: could not insert 'g_mass_storage': No such device

Going to make an other pass with gadget set to m next

@hh
Copy link

hh commented Dec 2, 2015

Do we know if this or #882 or #883 or #884 get us anywhere with regards to gadget support on the RPi zero?

@popcornmix
Copy link
Collaborator

I've not heard of success with gadget mode. The original (from 3 years ago) dwc_otg driver should support gadget mode (although it's never been used). It's quite likely that some of the fiq optimisations don't support gadget mode, so disabling the fiq would be advisable.
You'll want to revert 59e76bb to avoid forcing host mode (it should then use OTG cable to determine host/gadget mode).

@Ruffio
Copy link

Ruffio commented Aug 14, 2016

@ali1234 has your issue been resolved? If yes, then please close this issue.

@P33M
Copy link
Contributor

P33M commented May 4, 2017

Gadget is primarily supported by the upstream dwc2 driver. dwc_otg should only be used for host mode.

@P33M P33M closed this as completed May 4, 2017
pfpacket pushed a commit to pfpacket/linux-rpi-rust that referenced this issue Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants