On Fri, 23 Dec 2005, Guennadi Liakhovetski wrote:

[Full quote since the discussion is a bit old]

This is odd though. The device reset in zdusb.c probably isn't working
properly on your machine. Perhaps 2.6 doesn't like
usb_lock_device_for_reset/usb_unlock_device missing. Could anyone create a
patch? (I don't run 2.6 here)
No. I think, reset in disconnect doesn't make any sense at all. I just
removed it and tested - of course, nothing bad heppens, as it anyway
didn't have any effect due to wrong state.
The reset was introduced because of
https://sourceforge.net/mailarchive/message.php?msg_id=12569588
<[EMAIL PROTECTED]>
. At least at that time this made sense. However, it may be possible
that for example changes in the stick's firmware made the reset
superfluous.
Ok, I see. Interesting. On one my PC - where I normally use zd1211 I got
the same message in the log "reset not allowed in state 0" and rmmod +
modprobe indeed don't work without replugging the device. Whereas on the
other PC rmmod produces "resetting device..." and everything is fine.
Moving the reset early in probe seems to work on both machines. Patch
below. Would be good if people seeing "reset not allowed in state 0" on
rmmod could test it (re-adding Fernando to CC:).

I just found out this change seems to cause kernel panics here.
Kernel 2.4.32, driver loaded by hotplug. The panic is due to a null pointer dereference in the hotplug process. If I revert the change everything seems to be fine. It seems moving the reset to initialization confuses hotplug's data structures.

I'll move the reset code to zd1211_disconnect again if there are no objections.

Regards

[Old patch]
Index: src/zdusb.c
===================================================================
--- a/src/zdusb.c       (revision 48)
+++ b/src/zdusb.c       (working copy)
@@ -102,6 +102,7 @@
#else

        struct usb_device *dev = interface_to_usbdev(interface);
+       int locked;
#endif

        struct net_device *net = NULL;
@@ -152,8 +153,24 @@
        //usb_string(dev, dev->descriptor.iSerialNumber, serial_number, 29);
        //printk("Device serial number is %s\n", serial_number);

+        // The running firmware seems to "block" ep0.
+        // To avoid timeouts during insmod on ep0 and
+        //   the inability to subsequently reload the driver properly,
+        //   put the device in its initial state.
+        // Since resetting the device is probably a bit crude,
+       //   we do it before the device gets to do any useful work.
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+        usb_reset_device(dev);
+#else
+       locked = usb_lock_device_for_reset(interface_to_usbdev(interface), 
interface);
+       if (locked >= 0)
+               usb_reset_device(interface_to_usbdev(interface));
+       if (locked > 0)
+               usb_unlock_device(interface_to_usbdev(interface));
+#endif

+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+
        if (usb_set_configuration(dev, dev->config[0].bConfigurationValue))
        {
                printk(KERN_ERR "usb_set_configuration() failed\n");
@@ -371,21 +388,6 @@

        kfree(macp);

-        // The running firmware seems to "block" ep0.
-        // To avoid timeouts during insmod on ep0 and
-        //   the inability to subsequently reload the driver properly,
-        //   put the device in its initial state.
-        // Since resetting the device is probably a bit crude,
-        //   it should only be done after the device has been stopped and
-        //   all its data structures have been freeed,
-        //   so the possibility for data corruption is minimal.(hopefully zero)
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-        usb_reset_device(dev);
-#else
-        usb_reset_device(interface_to_usbdev(interface));
-#endif
-
-
       g_dev = NULL;
        //ZEXIT(0);
}


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Zd1211-devs mailing list - http://zd1211.ath.cx/
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/zd1211-devs

Reply via email to