> Please try the attached patch, and also send me the output
> of your dmesg, taken after the test. There is a special printout
> there to diagnose the problem.

Sorry for answering my own post, I forgot one thing. I would like
several unrelated people to try the patch, not only Tvertko.

When you do it, please also do "dmesg | grep Debounce".
If you see anything other than 100ms, please let me know.
Here's an example:
 Debounce: hub 1 port 1: delay 100ms stable 4 status 0x301

Of course, breakage reports are appreciated, together with
the Debounce printout. If it worked with 2.4.20 and stopped
working with the patch, it's important for me to know.

Main suspects are ancient mice (such as "KYE Genius USB
Wheel Mouse") and el-cheapo chineese hubs.

The patch should be applicable to 2.5.

-- Pete

--- linux-2.4.20/drivers/usb/hub.c      2002-12-06 18:07:21.000000000 -0800
+++ linux-2.4.20-usb/drivers/usb/hub.c  2002-12-07 11:41:33.000000000 -0800
@@ -639,35 +639,48 @@
  * Not covered by the spec - but easy to deal with.
  *
  * This implementation uses 400ms minimum debounce timeout and checks
- * every 100ms for transient disconnects to restart the delay.
+ * every 25ms for transient disconnects to restart the delay.
  */
 
 #define HUB_DEBOUNCE_TIMEOUT   400
-#define HUB_DEBOUNCE_STEP      100
+#define HUB_DEBOUNCE_STEP       25
+#define HUB_DEBOUNCE_STABLE      4
 
 /* return: -1 on error, 0 on success, 1 on disconnect.  */
 static int usb_hub_port_debounce(struct usb_device *hub, int port)
 {
        int ret;
-       unsigned delay_time;
+       int delay_time, stable_count;
        u16 portchange, portstatus;
+       unsigned connection;
 
-       for (delay_time = 0; delay_time < HUB_DEBOUNCE_TIMEOUT; /* empty */ ) {
-
-               /* wait debounce step increment */
+       connection = 0;
+       stable_count = 0;
+       for (delay_time = 0; delay_time < HUB_DEBOUNCE_TIMEOUT; delay_time += 
+HUB_DEBOUNCE_STEP) {
                wait_ms(HUB_DEBOUNCE_STEP);
 
                ret = usb_hub_port_status(hub, port, &portstatus, &portchange);
                if (ret < 0)
                        return -1;
 
+               if ((portstatus & USB_PORT_STAT_CONNECTION) == connection) {
+                       if (connection) {
+                               if (++stable_count == HUB_DEBOUNCE_STABLE)
+                                       break;
+                       }
+               } else {
+                       stable_count = 0;
+               }
+               connection = portstatus & USB_PORT_STAT_CONNECTION;
+
                if ((portchange & USB_PORT_STAT_C_CONNECTION)) {
                        usb_clear_port_feature(hub, port+1, 
USB_PORT_FEAT_C_CONNECTION);
-                       delay_time = 0;
                }
-               else
-                       delay_time += HUB_DEBOUNCE_STEP;
        }
+
+/* P3 */ printk("Debounce: hub %d port %d: delay %dms stable %d status 0x%x\n",
+   hub->devnum, port, delay_time, stable_count, portstatus);
+
        return ((portstatus&USB_PORT_STAT_CONNECTION)) ? 0 : 1;
 }
 


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to