usb: composite: Fix max packet size for USB3.0
PATCH 1/1 usb: composite: Fix max packet size for USB3.0
For USB3.0, the max packetsize for GET_DESCRIPTOR should be sent as exponent value for 2. This means for 512, max packet size should be filled with 9(2^9=512). Also, fill the USB version field with 3.0 if speed is negotiated to Superspeed. This fixes the issue of DFU gadget download failure with superspeed. Without this patch, the max packet size is overflowed to zero as the bMaxPacketsize is of u8 and hence host is not able to detect this device.
---
Changes from RFC:
- Fixed typo in description as per comment.
--- drivers/usb/gadget/composite.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/usb/gadget/composite.c +15 -2
@@ -735,8 +735,21 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)case USB_DT_DEVICE : cdev->desc.bNumConfigurations =count_configs (cdev,USB_DT_DEVICE ); - cdev->desc.bMaxPacketSize0 = - cdev->gadget->ep0->maxpacket; + +/* +* If the speed is Super speed, then the supported +* max packet size is 512 and it should be sent as +* exponent of 2. So, 9(2^9=512) should be filled in +* bMaxPacketSize0. Also fill USB version as 3.0 +* if speed is Super speed. +*/ +if (cdev->gadget->speed ==USB_SPEED_SUPER ) { + cdev->desc.bMaxPacketSize0 =9 ; + cdev->desc.bcdUSB =cpu_to_le16 (0x0300 ); + }else { + cdev->desc.bMaxPacketSize0 = + cdev->gadget->ep0->maxpacket; + } value =min (w_length, (u16 )sizeof cdev->desc);memcpy (req->buf, &cdev->desc, value);break ;
Signature · 1 line
2.7.4
Marek Vasut
AppliedPATCH 1/1 usb: composite: Fix max packet size for USB3.0
Quoted 37 lines · Siva Durga Prasad Paladugu
For USB3.0, the max packetsize for
GET_DESCRIPTORshould be sent as exponent value for 2. This means for 512, max packet size should be filled with 9(2^9=512). Also, fill the USB version field with 3.0 if speed is negotiated to Superspeed. This fixes the issue of DFU gadget download failure with superspeed. Without this patch, the max packet size is overflowed to zero as the bMaxPacketsize is of u8 and hence host is not able to detect this device.Signed-off-by Siva Durga Prasad Paladugu <[email protected]>Reviewed-by Bin Meng <[email protected]>---
Changes from RFC:
- Fixed typo in description as per comment.--- drivers/usb/gadget/composite.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)drivers/usb/gadget/composite.c +8
-2@@ -735,8 +735,21 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)case USB_DT_DEVICE : cdev->desc.bNumConfigurations =count_configs (cdev,USB_DT_DEVICE ); - cdev->desc.bMaxPacketSize0 = - cdev->gadget->ep0->maxpacket; + +/* +* If the speed is Super speed, then the supported +* max packet size is 512 and it should be sent as +* exponent of 2. So, 9(2^9=512) should be filled in +* bMaxPacketSize0. Also fill USB version as 3.0 +* if speed is Super speed. +*/
drivers/usb/gadget/composite.c composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) · line 755
Quoted 10 lines
drivers/usb/gadget/composite.c +7
-0+if (cdev->gadget->speed ==USB_SPEED_SUPER ) { + cdev->desc.bMaxPacketSize0 =9 ; + cdev->desc.bcdUSB =cpu_to_le16 (0x0300 ); + }else { + cdev->desc.bMaxPacketSize0 = + cdev->gadget->ep0->maxpacket; + } value =min (w_length, (u16 )sizeof cdev->desc);memcpy (req->buf, &cdev->desc, value);break ;
Applied, thanks
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/1 usb: composite: Fix max packet size for USB3.0
Quoted 48 lines · On Thu, 13 Dec 2018 14:24:32 +0100 Marek Vasut <[email protected]> wrote:
Quoted 47 lines · Siva Durga Prasad Paladugu
For USB3.0, the max packetsize for
GET_DESCRIPTORshould be sent as exponent value for 2. This means for 512, max packet size should be filled with 9(2^9=512). Also, fill the USB version field with 3.0 if speed is negotiated to Superspeed. This fixes the issue of DFU gadget download failure with superspeed. Without this patch, the max packet size is overflowed to zero as the bMaxPacketsize is of u8 and hence host is not able to detect this device.Signed-off-by: Siva Durga Prasad Paladugu <[email protected]> Reviewed-by: Bin Meng <[email protected]> ---
Changes from RFC:
- Fixed typo in description as per comment.--- drivers/usb/gadget/composite.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/usb/gadget/composite.cindex 5106cc5..c7e7623 100644drivers/usb/gadget/composite.c +0
-0@@ -735,8 +735,21 @@ composite_setup(struct usb_gadget *gadget,const struct
usb_ctrlrequest*ctrl) caseUSB_DT_DEVICE:drivers/usb/gadget/composite.c +3
-2cdev->desc.bNumConfigurations =count_configs (cdev,USB_DT_DEVICE ); - cdev->desc.bMaxPacketSize0 = - cdev->gadget->ep0->maxpacket; + +/* +* If the speed is Super speed, then the supported
drivers/usb/gadget/composite.c +1
-0+* max packet size is 512 and it should be sent as
drivers/usb/gadget/composite.c +1
-0+* exponent of 2. So, 9(2^9=512) should be filled in
drivers/usb/gadget/composite.c +1
-0+* bMaxPacketSize0. Also fill USB version as 3.0
drivers/usb/gadget/composite.c +3
-0+* if speed is Super speed. +*/ + if (cdev->gadget->speed ==
USB_SPEED_SUPER) {drivers/usb/gadget/composite.c +2
-0+ cdev->desc.bMaxPacketSize0 =9 ; + cdev->desc.bcdUSB =
cpu_to_le16(0x0300);drivers/usb/gadget/composite.c +2
-0+ }else { + cdev->desc.bMaxPacketSize0 =
Quoted 9 lines
Quoted 7 lines
+
cdev->gadget->ep0->maxpacket;drivers/usb/gadget/composite.c +1
-0+ } value = min(w_length, (u16) sizeof
cdev->desc);memcpy(req->buf, &cdev->desc, value);
break;Applied, thanks
Just for completeness:
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181213/fc3ce156/attachment.sig>