Re: [PATCH 1/1] usb: add xhci warm reset if get device descripor return error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi Greg:

2014-05-31 0:02 GMT+08:00 Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx>:
> On Fri, May 30, 2014 at 11:28:36PM +0800, che-chun Kuo wrote:
>> We found when we plug in/out usb3.0 device for stress testing, once
>> usb_get_device_descriptor fail in hub_port_init, we will call hub_port_disable.
>> Then usb3.0 device may not recover successfully with only hot reset like below function
>>     retval = hub_port_reset(hub, port1, udev, delay, false);
>>
>> For covering this error handling, we add warm reset if getting device descriptor fail on usb3.0 devices.
>
> Odd linewrapping :(
since I try to make the explanation more readable, I purposely add
more blank like.
sorry for making you confused. ^^
>
> Anyway, what makes USB 3 devices so "special" here that they need a
> reset vs. all other devices?
in the beginning, I try to add quirk determination in usb driver.
But get descriptor is the 1st command we get.
if getting descriptor fail, I have no idea how to add quirk
determination in usb driver.

>
> Are you sure your device isn't just broken somehow?
Yes, your concern is reasonable.
for accelerating the issue happen, I purposely create diff at the end of mail.
And I try 5 devices on my hand, 2 of them will not successfully return
back with only hot reset.

In usb3.0 spec, warm reset will force usb3.0 jump to Rx.detect.
But hot reset will direct down stream port from to ss.Disabled only
only if time out happen.
That is why I add warm reset when get device descriptor fail.

appreciate your help,

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
old mode 100644
new mode 100755
index f829a1a..ffc5241
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -18,6 +18,9 @@

 #include "usb.h"

+static int try_flag = 0;
+module_param(try_flag, int, S_IRUGO|S_IWUSR);
+
 static void cancel_async_set_config(struct usb_device *udev);

 struct api_context {
@@ -912,6 +915,12 @@ int usb_get_device_descriptor(struct usb_device
*dev, unsigned int size)
        if (!desc)
                return -ENOMEM;

+
+       if ((try_flag <= 3) &&(dev->speed == USB_SPEED_SUPER) &&
(dev->state == USB_STATE_ADDRESS) && (dev->devpath[0] != '0')){
+               printk(KERN_ERR"purposely let get device descriptor fail\n");
+               try_flag ++;
+               return -2;
+       }
        ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, size);
        if (ret >= 0)
                memcpy(&dev->descriptor, desc, size);
--
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




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux