On Thu, 22 Jan 2004, Rogério Brito wrote:

> Hi, Alan.
> 
> I have some more information about the problem. I tried generating dmesg
> logs from both a cold boot and a warm boot to see if things were
> different and they were. I don't know if this information is significant
> or not. Please feel free to guide me however you want.

I'm not sure if it's significant either, but I agree that starting from a 
cold boot is a good idea.

Also, don't worry for now about what happens after you unplug the drive.  
I'm more interested in the part where you first plug it in.

Here's another patch to try.  Unlike the others, this one includes an 
important change.  It doesn't start the periodic status request going 
until _after_ the ports have been powered on.  This might be crucial; I 
noticed in your Windows packet trace that this is how the Windows driver 
works.  It also fits in with the intermittent nature of your problem -- it 
might depend on details of the timing interaction between the status 
request and the power-on requests.

Alan Stern


--- 2.6/drivers/usb/core/hub.c.orig     Tue Jan 20 16:10:29 2004
+++ 2.6/drivers/usb/core/hub.c  Thu Jan 22 14:46:50 2004
@@ -270,13 +270,18 @@
 {
        struct usb_device *dev;
        int i;
+       int ret;
 
        /* Enable power to the ports */
        dev_dbg(hubdev(interface_to_usbdev(hub->intf)),
                "enabling power on all ports\n");
        dev = interface_to_usbdev(hub->intf);
-       for (i = 0; i < hub->descriptor->bNbrPorts; i++)
-               set_port_feature(dev, i + 1, USB_PORT_FEAT_POWER);
+       for (i = 0; i < hub->descriptor->bNbrPorts; i++) {
+               ret = set_port_feature(dev, i + 1, USB_PORT_FEAT_POWER);
+               dev_dbg(hubdev(interface_to_usbdev(hub->intf)),
+                       "port %d power on: %d\n", i+1, ret);
+               wait_ms(500);
+       }
 
        /* Wait for power to be enabled */
        wait_ms(hub->descriptor->bPwrOn2PwrGood * 2);
@@ -452,6 +457,8 @@
        dev_dbg(hub_dev, "%sover-current condition exists\n",
                (hubstatus & HUB_STATUS_OVERCURRENT) ? "" : "no ");
 
+       hub_power_on(hub);
+
        /* Start the interrupt endpoint */
        pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
        maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
@@ -477,11 +484,6 @@
        }
        hub->urb_active = 1;
 
-       /* Wake up khubd */
-       wake_up(&khubd_wait);
-
-       hub_power_on(hub);
-
        return 0;
 
 fail:
@@ -741,6 +743,8 @@
 
                /* read and decode port status */
                ret = hub_port_status(hub, port, &portstatus, &portchange);
+               dev_dbg(hubdev(hub), "wait_reset %d, port %d, status %x, change %x\n",
+                               ret, port+1, portstatus, portchange);
                if (ret < 0) {
                        return -1;
                }
@@ -785,7 +789,8 @@
 
        /* Reset the port */
        for (i = 0; i < HUB_RESET_TRIES; i++) {
-               set_port_feature(hub, port + 1, USB_PORT_FEAT_RESET);
+               status = set_port_feature(hub, port + 1, USB_PORT_FEAT_RESET);
+               dev_dbg(hubdev(hub), "port reset = %d\n", status);
 
                /* return on disconnect or reset */
                status = hub_port_wait_reset(hub, port, dev, delay);
@@ -855,6 +860,8 @@
                wait_ms(HUB_DEBOUNCE_STEP);
 
                ret = hub_port_status(hub, port, &portstatus, &portchange);
+               dev_dbg(hubdev(hub), "port_status= %d, port %d status %x change %x\n",
+                       ret, port+1, portstatus, portchange);
                if (ret < 0)
                        return -1;
 
@@ -869,7 +876,8 @@
                connection = portstatus & USB_PORT_STAT_CONNECTION;
 
                if ((portchange & USB_PORT_STAT_C_CONNECTION)) {
-                       clear_port_feature(hub, port+1, USB_PORT_FEAT_C_CONNECTION);
+                       ret = clear_port_feature(hub, port+1, 
USB_PORT_FEAT_C_CONNECTION);
+                       dev_dbg(hubdev(hub), "clear C_CONNECTION2 = %d\n", ret);
                }
        }
 
@@ -893,7 +901,8 @@
                port + 1, portstatus, portchange, portspeed (portstatus));
 
        /* Clear the connection change status */
-       clear_port_feature(hub, port + 1, USB_PORT_FEAT_C_CONNECTION);
+       i = clear_port_feature(hub, port + 1, USB_PORT_FEAT_C_CONNECTION);
+       dev_dbg(&hubstate->intf->dev, "clear C_CONNECTION1 = %d\n", i);
 
        /* Disconnect any existing devices under this port */
        if (hub->children[port])
@@ -1064,6 +1073,8 @@
 
                for (i = 0; i < hub->descriptor->bNbrPorts; i++) {
                        ret = hub_port_status(dev, i, &portstatus, &portchange);
+                       dev_dbg(hubdev(dev),
+                               "initial port %d status: ret = %d\n", i+1, ret);
                        if (ret < 0) {
                                continue;
                        }



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to