On Fri, 23 Mar 2012, Johan Hovold wrote: > On Fri, Mar 23, 2012 at 01:11:57PM +0100, Johan Hovold wrote: > > Hi Alan and Greg, > > > > There seems to be a problem with the new API for serial driver > > registration/deregistration. > > > > I get the following oops with usb-next when unloading a usb-serial > > driver (verified with both ftdi_sio and pl2303) while the device is > > connected: > I forgot the actual oops which comes after the above warning. Here's the > full log for ftdi_sio: > > [ 66.109316] drivers/usb/serial/ftdi_sio.c: ftdi_exit > [ 66.109339] USB Serial deregistering driver FTDI USB Serial Device > [ 66.110531] usbcore: deregistering interface driver ftdi_sio > [ 66.110757] drivers/usb/serial/usb-serial.c: usb_serial_disconnect > [ 66.112323] ------------[ cut here ]------------ > [ 66.112343] WARNING: at fs/sysfs/inode.c:323 sysfs_hash_and_remove+0x97/0xa0() > [ 66.112353] Hardware name: Vostro 1520 > [ 66.112362] sysfs: can not remove 'ttyUSB0', no directory > [ 66.112371] Modules linked in: ftdi_sio(-) usbserial > [ 66.112418] Pid: 1107, comm: modprobe Not tainted 3.3.0-rc7+ #89 > [ 66.112428] Call Trace: > [ 66.112445] [<c102d862>] warn_slowpath_common+0x72/0xa0 > [ 66.112473] [<c113abb7>] ? sysfs_hash_and_remove+0x97/0xa0 > [ 66.112487] [<c113abb7>] ? sysfs_hash_and_remove+0x97/0xa0 > [ 66.112500] [<c102d933>] warn_slowpath_fmt+0x33/0x40 > [ 66.112516] [<c113abb7>] sysfs_hash_and_remove+0x97/0xa0 > [ 66.112532] [<c113d350>] sysfs_remove_link+0x20/0x30 > [ 66.112564] [<c12edd50>] driver_sysfs_remove+0x20/0x30 > [ 66.112578] [<c12edd8b>] __device_release_driver+0x2b/0xb0 > [ 66.112592] [<c12eded7>] device_release_driver+0x27/0x40 > [ 66.112608] [<c12ed4b4>] bus_remove_device+0xd4/0x130 > [ 66.112635] [<c12eb871>] ? device_remove_attrs+0x21/0x90 > [ 66.112649] [<c12eb9c5>] device_del+0xe5/0x170 > [ 66.112668] [<f806f74e>] usb_serial_disconnect+0xce/0x150 [usbserial] > [ 66.112685] [<c1338186>] usb_unbind_interface+0x46/0x160 > [ 66.112713] [<c12eddc4>] __device_release_driver+0x64/0xb0 > [ 66.112727] [<c12edea7>] driver_detach+0x97/0xa0 > [ 66.112742] [<c12ecfdc>] bus_remove_driver+0x6c/0xe0 > [ 66.112770] [<c12ee9b9>] driver_unregister+0x49/0x80 > [ 66.112785] [<c105adbb>] ? sub_preempt_count+0x7b/0xb0 > [ 66.112799] [<c1337f05>] usb_deregister+0xa5/0xb0 > [ 66.112828] [<f806e8ed>] usb_serial_deregister_drivers+0x2d/0x40 [usbserial] > [ 66.112846] [<f811aa02>] ftdi_exit+0x3a/0x3c [ftdi_sio] > [ 66.112861] [<c108038d>] sys_delete_module+0x15d/0x240 > [ 66.112890] [<c1104d5e>] ? mntput+0x1e/0x30 > [ 66.112906] [<c1458543>] ? sysenter_exit+0xf/0x18 > [ 66.112922] [<c107317c>] ? trace_hardirqs_on_caller+0xec/0x170 > [ 66.112949] [<c1458510>] sysenter_do_call+0x12/0x36 > [ 66.112960] ---[ end trace 6b4f15790c8ba039 ]--- > [ 66.113114] drivers/usb/serial/ftdi_sio.c: ftdi_sio_port_remove > [ 66.113124] drivers/usb/serial/ftdi_sio.c: remove_sysfs_attrs > [ 66.113901] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0 > [ 66.113944] BUG: unable to handle kernel NULL pointer dereference at 0000002c > [ 66.113965] IP: [<c1440e96>] klist_put+0x16/0x90 > [ 66.113986] *pde = 00000000 > [ 66.114000] Oops: 0000 [#1] PREEMPT SMP > [ 66.114026] Modules linked in: ftdi_sio(-) usbserial > [ 66.114052] > [ 66.114062] Pid: 1107, comm: modprobe Tainted: G W 3.3.0-rc7+ #89 Dell Inc. Vostro 1520/0T816J > [ 66.114090] EIP: 0060:[<c1440e96>] EFLAGS: 00010246 CPU: 1 > [ 66.114090] EIP is at klist_put+0x16/0x90 > [ 66.114090] EAX: f53fadc0 EBX: 00000000 ECX: 00000000 EDX: 00000001 > [ 66.114090] ESI: f53fadc0 EDI: f8073b20 EBP: f51d9dc4 ESP: f51d9db4 > [ 66.114090] DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068 > [ 66.114090] Process modprobe (pid: 1107, ti=f51d8000 task=f6102300 task.ti=f51d8000) > [ 66.114090] Stack: > [ 66.114090] f51d9dc0 f6102300 f53fadc0 f8073b20 f51d9dcc c1440f3d f51d9df4 c1440f8c > [ 66.114090] c166a480 c166a480 f53fadc0 f6102300 00000000 c12f0d19 f508524c f811ea94 > [ 66.114090] f51d9e04 c12edde0 f5085280 f508524c f51d9e14 c12eded7 f5153a4c f508524c > [ 66.114090] Call Trace: > [ 66.114090] [<c1440f3d>] klist_del+0xd/0x10 > [ 66.114090] [<c1440f8c>] klist_remove+0x4c/0x90 > [ 66.114090] [<c12f0d19>] ? devres_release_all+0x39/0x60 > [ 66.114090] [<c12edde0>] __device_release_driver+0x80/0xb0 > [ 66.114090] [<c12eded7>] device_release_driver+0x27/0x40 > [ 66.114090] [<c12ed4b4>] bus_remove_device+0xd4/0x130 > [ 66.114090] [<c12eb871>] ? device_remove_attrs+0x21/0x90 > [ 66.114090] [<c12eb9c5>] device_del+0xe5/0x170 > [ 66.114090] [<f806f74e>] usb_serial_disconnect+0xce/0x150 [usbserial] > [ 66.114090] [<c1338186>] usb_unbind_interface+0x46/0x160 > [ 66.114090] [<c12eddc4>] __device_release_driver+0x64/0xb0 > [ 66.114090] [<c12edea7>] driver_detach+0x97/0xa0 > [ 66.114090] [<c12ecfdc>] bus_remove_driver+0x6c/0xe0 > [ 66.114090] [<c12ee9b9>] driver_unregister+0x49/0x80 > [ 66.114090] [<c105adbb>] ? sub_preempt_count+0x7b/0xb0 > [ 66.114090] [<c1337f05>] usb_deregister+0xa5/0xb0 > [ 66.114090] [<f806e8ed>] usb_serial_deregister_drivers+0x2d/0x40 [usbserial] > [ 66.114090] [<f811aa02>] ftdi_exit+0x3a/0x3c [ftdi_sio] > [ 66.114090] [<c108038d>] sys_delete_module+0x15d/0x240 > [ 66.114090] [<c1104d5e>] ? mntput+0x1e/0x30 > [ 66.114090] [<c1458543>] ? sysenter_exit+0xf/0x18 > [ 66.114090] [<c107317c>] ? trace_hardirqs_on_caller+0xec/0x170 > [ 66.114090] [<c1458510>] sysenter_do_call+0x12/0x36 > [ 66.114090] Code: d0 2a 58 c1 e8 1c ca be ff 8b 4d e8 eb 85 8d b4 26 00 00 00 00 55 89 e5 83 ec 10 89 75 f8 89 5d f4 89 7d fc 89 c6 8b 18 83 e3 fe <8b> 7b 2c 89 d8 88 55 f0 e8 0d 63 01 00 0f b6 55 f0 84 d2 74 0b > [ 66.114090] EIP: [<c1440e96>] klist_put+0x16/0x90 SS:ESP 0068:f51d9db4 > [ 66.114090] CR2: 000000000000002c > [ 66.115395] ---[ end trace 6b4f15790c8ba03a ]--- > > > > The problem appears to be related to the reversed order of > > deregistration (usb-serial driver is now deregistered before usb > > driver). > > > > I've verified my suspicion in so far as commit 97b6b6d2339f67 > > ("usb-serial: use new registration API in [d-h]* drivers") in usb-next > > is indeed the commit introducing the regression for ftdi_sio. It's a little difficult to see what's going wrong, and I don't have my serial dongle here to test with now. In particular, I don't see why the WARNING's stack trace shows bus_remove_device() calling device_release_driver() -- by that point the driver should already have been unbound from the port device. That should have happened when usb_serial_deregister_drivers() called usb_serial_deregister(). Perhaps the problem is this code in usb_serial_disconnect: /* Make sure the port is bound so that the * driver's port_remove method is called. */ if (!port->dev.driver) { int rc; port->dev.driver = &serial->type->driver; rc = device_bind_driver(&port->dev); } port->dev_state = PORT_UNREGISTERING; device_del(&port->dev); port->dev_state = PORT_UNREGISTERED; It does look like it could cause this sort of thing to happen. I wrote that code to handle the case where the disconnect raced with the initial probing, so some of the ports might not have gotten probed yet; I don't remember the details. Still, maybe it's not necessary any more. If you remove that "if" statement, does it fix the problem? Alan Stern -- 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