Sleeping in USB network drivers

Andrew Thompson thompsa at freebsd.org
Tue Jun 6 17:08:12 PDT 2006


Hi,


I am looking into the reported panics with the if_aue driver and have
come across a locking problem with usb adapters that is not obvious how
to fix.

The problem is that usbd_do_request() may sleep and most drivers are
careful to call it without any locks held. in_addmulti() will grab
in_multi_mtx before calling if_addmulti() to update the cards multicast
hash, this effectively means that the driver can not sleep in
*_setmulti but this is unavoidable with USB.

Does anyone have any suggestions? (panic and bt below)


Andrew


Sleeping on "usbsyn" with the following non-sleepable locks held:
exclusive sleep mutex in_multi_mtx r = 0 (0xc0996cc0) locked @
/usr/src/sys/netinet/in.c:971
KDB: enter: witness_warn
[thread pid 1605 tid 100088 ]
Stopped at kdb_enter+0x2b: nop
db> bt
Tracing pid 1605 tid 100088 td 0xc24d0d80
kdb_enter(c0823f4e) at kdb_enter+0x2b
witness_warn(5,0,c086b211,c0860db5) at witness_warn+0x175
msleep(c250b200,0,4c,c0860db5,0) at msleep+0x42
usbd_transfer(c250b200,cc9e9aac,c05ac779,c250b200,c0600e78) at
 usbd_transfer+0x121
usbd_sync_transfer(c250b200,c0600e78,c203c600,cc9e9acc,c2116b00) at
 usbd_sync_transfer+0x11
usbd_do_request_flags_pipe(c2121b00,c2121a80,cc9e9b08,cc9e9b07,0) at
 usbd_do_request_flags_pipe+0x5d
usbd_do_request_flags(c2121b00,cc9e9b08,cc9e9b07,0,0) at
 usbd_do_request_flags+0x20
usbd_do_request(c2121b00,cc9e9b08,cc9e9b07) at usbd_do_request+0x1a
aue_csr_read_1(c2116b00,0) at aue_csr_read_1+0x50
aue_setmulti(c2116b00,c21d7460,c2111400,cc9e9ba8,cc9e9b78) at
 aue_setmulti+0x50
aue_ioctl(c2111400,80206931,0) at aue_ioctl+0x106
if_addmulti(c2111400,cc9e9ba8,cc9e9ba4,cc9e9ba8,10,c0996cc0,0,c0879e0e,3cb)
at if_addmulti+0x1b8
in_addmulti(cc9e9bdc,c2111400) at in_addmulti+0x69
in_ifinit(c2111400,c2509b00,c24e73d0,0,cc9e9c38) at in_ifinit+0x529
in_control(c2508164,8040691a,c24e73c0,c2111400,c24d0d80) at
 in_control+0x882
ifioctl(c2508164,8040691a,c24e73c0,c24d0d80,0) at ifioctl+0x198
soo_ioctl(c21e6e58,8040691a,c24e73c0,c203ce80,c24d0d80) at
 soo_ioctl+0x2db
ioctl(c24d0d80,cc9e9d04,3,1,286) at ioctl+0x370
syscall(3b,3b,3b,8056080,80583c0) at syscall+0x22f
Xint0x80_syscall() at Xint0x80_syscall+0x1f
--- syscall (54, FreeBSD ELF32, ioctl), eip = 0x28131603, esp =
0xbfbfe59c, ebp
= 0xbfbfede8 ---
db> show alllocks
Process 1605 (ifconfig) thread 0xc24d0d80 (100088)
exclusive sleep mutex in_multi_mtx r = 0 (0xc0996cc0) locked @
/usr/src/sys/neti
net/in.c:971
exclusive sleep mutex Giant r = 1 (0xc09479a0) locked @
/usr/src/sys/net/if.c:20
30
db>


More information about the freebsd-net mailing list