* [PATCH] usb: gadget: set maxpacket_limit
@ 2018-10-24 20:41 Ladislav Michl
2018-10-26 9:50 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ladislav Michl @ 2018-10-24 20:41 UTC (permalink / raw)
To: barebox
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")
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
---
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(-)
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 18427114d..d3fbcda21 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -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);
diff --git a/drivers/usb/gadget/fsl_udc.c b/drivers/usb/gadget/fsl_udc.c
index 9b5966977..99e569a97 100644
--- a/drivers/usb/gadget/fsl_udc.c
+++ b/drivers/usb/gadget/fsl_udc.c
@@ -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 */
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 4e6b85886..442c90ca0 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -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)
--
2.19.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: gadget: set maxpacket_limit
2018-10-24 20:41 [PATCH] usb: gadget: set maxpacket_limit Ladislav Michl
@ 2018-10-26 9:50 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2018-10-26 9:50 UTC (permalink / raw)
To: Ladislav Michl; +Cc: barebox
On Wed, Oct 24, 2018 at 10:41:47PM +0200, Ladislav Michl wrote:
> 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")
> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
> ---
> 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
--
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-10-26 9:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-24 20:41 [PATCH] usb: gadget: set maxpacket_limit Ladislav Michl
2018-10-26 9:50 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox