ANDROID: usb: gadget: fix MTP enumeration issue under super speed mode
authorJiebing Li <jiebing.li@intel.com>
Tue, 10 Mar 2015 03:24:00 +0000 (11:24 +0800)
committerDmitry Shmidt <dimitrysh@google.com>
Thu, 20 Apr 2017 19:43:54 +0000 (12:43 -0700)
MTP function doesn't show as a drive in Windows when the device
is connected to PC's USB3 port, because device fails to respond
ACK to BULK OUT transfer request.

This patch modifies MTP OUT request length as multiple of MaxPacketSize
per databook requirement in order to fix this issue.

Patchset: mtp

Change-Id: I090d7880ff00c499dc5ba7fd644b1fe7cd87fcb5
Signed-off-by: Jiebing Li <jiebing.li@intel.com>
Signed-off-by: Wang, Yu <yu.y.wang@intel.com>
Signed-off-by: Russ Weight <russell.h.weight@intel.com>
drivers/usb/gadget/function/f_mtp.c

index 5cdee7b..d34e41d 100644 (file)
@@ -540,10 +540,12 @@ static ssize_t mtp_read(struct file *fp, char __user *buf,
        ssize_t r = count;
        unsigned xfer;
        int ret = 0;
+       size_t len;
 
        DBG(cdev, "mtp_read(%zu)\n", count);
 
-       if (count > MTP_BULK_BUFFER_SIZE)
+       len = usb_ep_align_maybe(cdev->gadget, dev->ep_out, count);
+       if (len > MTP_BULK_BUFFER_SIZE)
                return -EINVAL;
 
        /* we will block until we're online */
@@ -567,7 +569,7 @@ static ssize_t mtp_read(struct file *fp, char __user *buf,
 requeue_req:
        /* queue a request */
        req = dev->rx_req[0];
-       req->length = count;
+       req->length = len;
        dev->rx_done = 0;
        ret = usb_ep_queue(dev->ep_out, req, GFP_KERNEL);
        if (ret < 0) {