Re: Khubd calls disconnect() after driver module unloaded
David Woodhouse <[email protected]>
| Newsgroups | gmane.linux.usb.devel |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 2007-11-12 at 17:14 -0500, Alan Stern wrote: > [Moved to new thread and different mailing list] > > On Mon, 12 Nov 2007, David Woodhouse wrote: > > > Speaking of races with khubd.... I have observed it calling > > ->disconnect() for a device after the driver module has already been > > unloaded. Any thoughts on the following would be appreciated: > > http://dev.laptop.org/git?p=olpc-2.6;a=commitdiff;h=65f7bec3860eb3192cd37e4d449ae608add4d50a > > The comments in that patch don't provide enough details to tell what's > going wrong. The exit routine calls usb_deregister(), but then some > time later khubd calls the disconnect method? Yep. > That's not supposed to happen. Instead, the disconnect method should > be called by driver_detach() from within the usb_deregister() call > stack, not by khubd at all. If that's not happening then something is > wrong with the driver core. > > Is there some sort of race going on, where both the driver and the > device get unregistered at about the same time? We have an out-of-band reset line for kicking the wireless device in the head when it craps itself. We use it on driver unload, which means that the device is reliably removed from the bus right in the middle of our exit_module() function. When this happens, khubd is scheduled to deal with it and call device_detach(). But that doesn't actually happen until about a second later. By which time the module has already gone. > The device lock is supposed to serialize this so that no matter which > one comes first, the end result is correct. "supposed to". :) Let me take out the hack and show... [ 127.934681] Resetting OLPC wireless via EC... [ 127.961925] olpc-ec: running cmd 0x25 [ 127.991214] devpath 1 ep3in 3strikes [ 128.017892] usb 1-1: USB disconnect, address 2 [ 128.045418] PM: Removing info for No Bus:usbdev1.2_ep02 [ 128.074081] PM: Removing info for No Bus:usbdev1.2_ep83 [ 128.101835] msh0: no IPv6 routers present [ 128.146806] usbcore: deregistering interface driver usb8xxx [ 128.178823] Unloading libertas driver with refcount 1. Expect it to die soon... That's the last we see from the 'rmmod' thread. It's not _quite_ gone yet though, because we get into the disconnect() function and a little way through it... [ 128.255459] PM: Removing info for No Bus:msh0 [ 128.579911] libertas_remove_mesh free netdev c9f7c1e0 ... before the text pages go away and we die: [ 128.608637] BUG: unable to handle kernel paging request at virtual address d08a4ef3 [ 128.640367] printing eip: [ 128.666518] d08a4ef3 [ 128.691734] *pde = 0eb2d067 [ 128.717242] *pte = 00000000 [ 128.742284] Oops: 0000 [#1] [ 128.766925] PREEMPT [ 128.790619] Modules linked in: autofs4 sunrpc loop libertas(F) ieee80211 ieee80211_crypt serio_raw psmouse sdhci cs5535_gpio mmc_core sg joydev mov [ 128.851137] CPU: 0 [ 128.851146] EIP: 0060:[<d08a4ef3>] Tainted: GF VLI [ 128.851159] EFLAGS: 00010282 (2.6.22 #51) [ 128.932198] EIP is at 0xd08a4ef3 [ 128.958061] eax: 00000000 ebx: cadc59b0 ecx: c1244e28 edx: 00000001 [ 128.988217] esi: c914c460 edi: ce3a5258 ebp: c1244ea8 esp: c1244e90 [ 129.018282] ds: 007b es: 007b fs: 0000 gs: 0000 ss: 0068 [ 129.047485] Process khubd (pid: 49, ti=c1244000 task=c1242570 task.ti=c1244000) [ 129.055726] Stack: c1244ea8 c054376c cebfb990 ce3a5258 ce3a5270 d08a8580 c1244ebc c0545a13 [ 129.088659] ce3a5270 d08a85bc 00000000 c1244ecc c051ab86 ce3a5270 ce3a5270 c1244ed8 [ 129.122114] c051af6b ce3a5270 c1244ee4 c051a51a ce3a5270 c1244efc c0518ead cebfb9e8 [ 129.155900] Call Trace: [ 129.207216] [<c040436e>] show_trace_log_lvl+0x1a/0x2f [ 129.237619] [<c040441e>] show_stack_log_lvl+0x9b/0xa3 [ 129.267626] [<c0404605>] show_registers+0x1df/0x320 [ 129.297268] [<c040483f>] die+0xf9/0x20d [ 129.325578] [<c0619e5c>] do_page_fault+0x414/0x4e5 [ 129.355193] [<c06189ea>] error_code+0x6a/0x70 [ 129.384074] [<c0545a13>] usb_unbind_interface+0x30/0x72 [ 129.414358] [<c051ab86>] __device_release_driver+0x74/0x90 [ 129.444772] [<c051af6b>] device_release_driver+0x2f/0x45 [ 129.475038] [<c051a51a>] bus_remove_device+0x61/0x6f [ 129.505018] [<c0518ead>] device_del+0x1d6/0x24c [ 129.534427] [<c05436e6>] usb_disable_device+0x5f/0xbc [ 129.564329] [<c05401b3>] usb_disconnect+0x94/0xf0 [ 129.594118] [<c05407e0>] hub_thread+0x2ec/0x996 [ 129.623458] [<c0420d1e>] kthread+0x39/0x5f [ 129.652130] [<c0404017>] kernel_thread_helper+0x7/0x10 [ 129.681599] ======================= [ 129.708805] Code: Bad EIP value. [ 129.735632] EIP: [<d08a4ef3>] 0xd08a4ef3 SS:ESP 0068:c1244e90 -- dwmw2 ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ [email protected] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel