Skip to contentSkip to conversation

usb: gadget: set maxpacket_limit

PATCH In review Ladislav Michl 2 participants 2 messages Oct 24, 2018 – Oct 26, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: gadget: set maxpacket_limit

Gadget update to 3.15 imported Linux patch e117e742d310 ("usb:
gadget: add "maxpacket_limit" field to struct usb_ep"):

This patch adds "maxpacket_limit" to struct usb_ep. This field contains maximum value of maxpacket supported by driver, and is set in driver probe. This value should be used by autoconfig() function, because value of field "maxpacket" is set to value from endpoint descriptor when endpoint becomes enabled. So when autoconfig() function will be called again for this endpoint, "maxpacket" value will contain wMaxPacketSize from descriptior instead of maximum packet size for this endpoint.

For this reason this patch adds new field "maxpacket_limit" which contains value of maximum packet size (which defines maximum endpoint capabilities). This value is used in ep_matches() function used by autoconfig().

Value of "maxpacket_limit" should be set in UDC driver probe function, using usb_ep_set_maxpacket_limit() function, defined in gadget.h. This function set choosen value to both "maxpacket_limit" and "maxpacket" fields.

However said update didn't bring in all driver changes. Do it now.

Fixes 2776d53d7ac8 ("USB: gadget: Update to 3.15")

---
Please note, that this patch was created to fix
simear4:/ usbgadget -a
multi_bind: creating ACM function
g_multi usbgadget: acm/23b68c88: can't bind, err -19 g_multi udc0: failed to start g_multi: -19
usbgadget: No such device
on at91_udc (autoconfig() was failing).
Thus fsl_udc and pxa27x_udc changes are untested.

 drivers/usb/gadget/at91_udc.c   | 2 +-
 drivers/usb/gadget/fsl_udc.c    | 3 ++-
 drivers/usb/gadget/pxa27x_udc.c | 5 ++++-
 3 files changed, 7 insertions(+), 3 deletions(-)
drivers/usb/gadget/at91_udc.c +1 -1
index 18427114d..d3fbcda21 100644
@@ -619,7 +619,7 @@ static void udc_reinit(struct at91_udc *udc)
 		ep->desc = NULL;
 		ep->stopped = 0;
 		ep->fifo_bank = 0;
-		ep->ep.maxpacket = ep->maxpacket;
+		usb_ep_set_maxpacket_limit(&ep->ep, ep->maxpacket);
 		ep->creg = (void __iomem *) udc->udp_baseaddr + AT91_UDP_CSR(i);
 		/* initialize one queue per endpoint */
 		INIT_LIST_HEAD(&ep->queue);
drivers/usb/gadget/fsl_udc.c +2 -1
index 9b5966977..99e569a97 100644
@@ -2270,7 +2270,8 @@ int ci_udc_register(struct device_d *dev, void __iomem *regs)
 	 * for other eps, gadget layer called ep_enable with defined desc
 	 */
 	udc_controller->eps[0].desc = &fsl_ep0_desc;
-	udc_controller->eps[0].ep.maxpacket = USB_MAX_CTRL_PAYLOAD;
+	usb_ep_set_maxpacket_limit(&udc_controller->eps[0].ep,
+				   USB_MAX_CTRL_PAYLOAD);
 
 	/* setup the udc->eps[] for non-control endpoints and link
 	 * to gadget.ep_list */
drivers/usb/gadget/pxa27x_udc.c +4 -1
index 4e6b85886..442c90ca0 100644
@@ -940,9 +940,12 @@ static __init void udc_init_data(struct pxa_udc *dev)
 	}
 
 	/* USB endpoints init */
-	for (i = 1; i < NR_USB_ENDPOINTS; i++)
+	for (i = 1; i < NR_USB_ENDPOINTS; i++) {
 		list_add_tail(&dev->udc_usb_ep[i].usb_ep.ep_list,
 				&dev->gadget.ep_list);
+		usb_ep_set_maxpacket_limit(&dev->udc_usb_ep[i].usb_ep,
+					   dev->udc_usb_ep[i].usb_ep.maxpacket);
+	}
 }
 
 static void udc_enable(struct pxa_udc *udc)
Signature · 7 lines
2.19.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw
Quoted 23 lines · Ladislav Michl

Gadget update to 3.15 imported Linux patch e117e742d310 ("usb:
gadget: add "maxpacket_limit" field to struct usb_ep"):

This patch adds "maxpacket_limit" to struct usb_ep. This field contains maximum value of maxpacket supported by driver, and is set in driver probe. This value should be used by autoconfig() function, because value of field "maxpacket" is set to value from endpoint descriptor when endpoint becomes enabled. So when autoconfig() function will be called again for this endpoint, "maxpacket" value will contain wMaxPacketSize from descriptior instead of maximum packet size for this endpoint.

For this reason this patch adds new field "maxpacket_limit" which contains value of maximum packet size (which defines maximum endpoint capabilities). This value is used in ep_matches() function used by autoconfig().

Value of "maxpacket_limit" should be set in UDC driver probe function, using usb_ep_set_maxpacket_limit() function, defined in gadget.h. This function set choosen value to both "maxpacket_limit" and "maxpacket" fields.

However said update didn't bring in all driver changes. Do it now.

Fixes 2776d53d7ac8 ("USB: gadget: Update to 3.15")
Quoted 9 lines

---
Please note, that this patch was created to fix
simear4:/ usbgadget -a
multi_bind: creating ACM function
g_multi usbgadget: acm/23b68c88: can't bind, err -19 g_multi udc0: failed to start g_multi: -19
usbgadget: No such device
on at91_udc (autoconfig() was failing).
Thus fsl_udc and pxa27x_udc changes are untested.

Tested on fsl_udc and applied, thanks

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox