* [PATCH 0/2] usb: gadget: dwc2: Prepare for UDC core migration
@ 2026-07-03 13:29 Mattijs Korpershoek
2026-07-03 13:29 ` [PATCH 1/2] usb: gadget: dwc2: Use usb_ep_set_maxpacket_limit() for fifo sizes Mattijs Korpershoek
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Mattijs Korpershoek @ 2026-07-03 13:29 UTC (permalink / raw)
To: u-boot
Cc: Lukasz Majewski, Marek Vasut, Tom Rini, Ilias Apalodimas,
Jonas Karlman, Mattijs Korpershoek
Jens Wiklander started to migrate the DWC3 driver to a more recent
version of linux (v6.16) [1].
This migration also updates the UDC core and most notably how drivers
perform their endpoint matching.
While testing Jens' series on a Khadas VIM3 board, I reported [2] that
I can no longer bind the fastboot gadget to the dwc2 otg driver.
This series aims to fix the problems I've reported.
They can be applied to master/next (as they should not break
anything with the current UDC core). They can also be applied after we
merge Jens' work.
It has been tested on khadas-vim3_android_defconfig with the next branch
using base commit e800cc67f5b6 ("mtd: spi-nor: Add gd55lb02gf chips")
"""
U-Boot 2026.07-rc5-g89106934d3fb (Jul 03 2026 - 15:16:29 +0200) khadas-vim3
Model: Khadas VIM3
SoC: Amlogic Meson G12B (A311D) Revision 29:b (10:2)
DRAM: 2 GiB (total 3.8 GiB)
Core: 408 devices, 37 uclasses, devicetree: separate
MMC: mmc@ffe03000: 0, mmc@ffe05000: 1, mmc@ffe07000: 2
MMC Device -1 not foundm MMC...
*** Warning - No MMC card found, using default environment
In: usbkbd,serial
Out: vidconsole,serial
Err: vidconsole,serial
Net: eth0: ethernet@ff3f0000
Hit any key to stop autoboot: 0
=> fastboot usb 0
crq->brequest:0x0
"""
[1] https://lore.kernel.org/u-boot/20260629084507.3254232-1-jens.wiklander@linaro.org/
[2] https://lore.kernel.org/u-boot/87v7az6l03.fsf@kernel.org/
Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
---
Mattijs Korpershoek (2):
usb: gadget: dwc2: Use usb_ep_set_maxpacket_limit() for fifo sizes
usb: gadget: dwc2: Set endpoint capabilities via .caps field
drivers/usb/gadget/dwc2_udc_otg.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
---
base-commit: e800cc67f5b6cb50a20f37c993ec1cd4063bdbd3
change-id: 20260703-usb-prep-dwc3-sync-f564883ebd14
Best regards,
--
Mattijs Korpershoek <mkorpershoek@kernel.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] usb: gadget: dwc2: Use usb_ep_set_maxpacket_limit() for fifo sizes
2026-07-03 13:29 [PATCH 0/2] usb: gadget: dwc2: Prepare for UDC core migration Mattijs Korpershoek
@ 2026-07-03 13:29 ` Mattijs Korpershoek
2026-07-09 9:21 ` Ilias Apalodimas
2026-07-03 13:29 ` [PATCH 2/2] usb: gadget: dwc2: Set endpoint capabilities via .caps field Mattijs Korpershoek
2026-07-22 6:54 ` [PATCH 0/2] usb: gadget: dwc2: Prepare for UDC core migration Mattijs Korpershoek via U-Boot
2 siblings, 1 reply; 7+ messages in thread
From: Mattijs Korpershoek @ 2026-07-03 13:29 UTC (permalink / raw)
To: u-boot
Cc: Lukasz Majewski, Marek Vasut, Tom Rini, Ilias Apalodimas,
Jonas Karlman, Mattijs Korpershoek
More recent versions of usb_ep_autoconfig() use the maxpacket_limit
field from struct usb_ep.
This field has been introduced in the linux kernel via commit
e117e742d310 ("usb: gadget: add "maxpacket_limit" field to struct usb_ep")
And has been ported to U-Boot via commit
747a0a5b387f ("usb: dwc3: gadget: make dwc3 gadget build in uboot")
However, the dwc2 gadget driver was not converted to use
usb_ep_set_maxpacket_limit().
This is harmless for now, but the driver will break once
usb_ep_autoconfig() is updated to a more recent version.
Set maxpacket_limit via the recommended helper function to prepare for
a core gadget update.
Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
---
drivers/usb/gadget/dwc2_udc_otg.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
index e475b14b9ac3..9c85383fd62a 100644
--- a/drivers/usb/gadget/dwc2_udc_otg.c
+++ b/drivers/usb/gadget/dwc2_udc_otg.c
@@ -828,7 +828,6 @@ static struct dwc2_udc memory = {
.ep = {
.name = ep0name,
.ops = &dwc2_ep_ops,
- .maxpacket = EP0_FIFO_SIZE,
},
.dev = &memory,
@@ -843,7 +842,6 @@ static struct dwc2_udc memory = {
.ep = {
.name = "ep1in-bulk",
.ops = &dwc2_ep_ops,
- .maxpacket = EP_FIFO_SIZE,
},
.dev = &memory,
@@ -858,7 +856,6 @@ static struct dwc2_udc memory = {
.ep = {
.name = "ep2out-bulk",
.ops = &dwc2_ep_ops,
- .maxpacket = EP_FIFO_SIZE,
},
.dev = &memory,
@@ -873,7 +870,6 @@ static struct dwc2_udc memory = {
.ep = {
.name = "ep3in-int",
.ops = &dwc2_ep_ops,
- .maxpacket = EP_FIFO_SIZE,
},
.dev = &memory,
@@ -893,6 +889,7 @@ int dwc2_udc_probe(struct dwc2_plat_otg_data *pdata)
{
struct dwc2_udc *dev = &memory;
int retval = 0;
+ int i;
debug("%s: %p\n", __func__, pdata);
@@ -909,6 +906,10 @@ int dwc2_udc_probe(struct dwc2_plat_otg_data *pdata)
the_controller = dev;
+ usb_ep_set_maxpacket_limit(&dev->ep[0].ep, EP0_FIFO_SIZE);
+ for (i = 1; i < DWC2_MAX_ENDPOINTS; i++)
+ usb_ep_set_maxpacket_limit(&dev->ep[i].ep, EP_FIFO_SIZE);
+
usb_ctrl = memalign(CONFIG_SYS_CACHELINE_SIZE,
ROUND(sizeof(struct usb_ctrlrequest),
CONFIG_SYS_CACHELINE_SIZE));
--
2.54.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] usb: gadget: dwc2: Set endpoint capabilities via .caps field
2026-07-03 13:29 [PATCH 0/2] usb: gadget: dwc2: Prepare for UDC core migration Mattijs Korpershoek
2026-07-03 13:29 ` [PATCH 1/2] usb: gadget: dwc2: Use usb_ep_set_maxpacket_limit() for fifo sizes Mattijs Korpershoek
@ 2026-07-03 13:29 ` Mattijs Korpershoek
2026-07-09 9:22 ` Ilias Apalodimas
2026-07-22 6:54 ` [PATCH 0/2] usb: gadget: dwc2: Prepare for UDC core migration Mattijs Korpershoek via U-Boot
2 siblings, 1 reply; 7+ messages in thread
From: Mattijs Korpershoek @ 2026-07-03 13:29 UTC (permalink / raw)
To: u-boot
Cc: Lukasz Majewski, Marek Vasut, Tom Rini, Ilias Apalodimas,
Jonas Karlman, Mattijs Korpershoek
Endpoint capabilities can be described via the .caps field of
struct usb_ep since commit
77dcbdf3c1ce ("usb: gadget: Add match_ep() op to usb_gadget_ops")
In linux, the following commit introduces it:
b86f33a3a371 ("usb: gadget: epautoconf: add endpoint capabilities flags verification")
Linux's change also reworks the ep matching function by relying on
these new capabilities instead of guessing based on the endpoint name.
Prepare the dwc2 UDC driver for capability-based matching by adding the
required capabilities for each endpoint.
Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
---
drivers/usb/gadget/dwc2_udc_otg.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
index 9c85383fd62a..570fed347c9e 100644
--- a/drivers/usb/gadget/dwc2_udc_otg.c
+++ b/drivers/usb/gadget/dwc2_udc_otg.c
@@ -828,6 +828,11 @@ static struct dwc2_udc memory = {
.ep = {
.name = ep0name,
.ops = &dwc2_ep_ops,
+ .caps = {
+ .type_control = 1,
+ .dir_in = 1,
+ .dir_out = 1,
+ },
},
.dev = &memory,
@@ -842,6 +847,10 @@ static struct dwc2_udc memory = {
.ep = {
.name = "ep1in-bulk",
.ops = &dwc2_ep_ops,
+ .caps = {
+ .type_bulk = 1,
+ .dir_in = 1,
+ },
},
.dev = &memory,
@@ -856,6 +865,10 @@ static struct dwc2_udc memory = {
.ep = {
.name = "ep2out-bulk",
.ops = &dwc2_ep_ops,
+ .caps = {
+ .type_bulk = 1,
+ .dir_out = 1,
+ },
},
.dev = &memory,
@@ -870,6 +883,10 @@ static struct dwc2_udc memory = {
.ep = {
.name = "ep3in-int",
.ops = &dwc2_ep_ops,
+ .caps = {
+ .type_int = 1,
+ .dir_in = 1,
+ },
},
.dev = &memory,
--
2.54.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] usb: gadget: dwc2: Use usb_ep_set_maxpacket_limit() for fifo sizes
2026-07-03 13:29 ` [PATCH 1/2] usb: gadget: dwc2: Use usb_ep_set_maxpacket_limit() for fifo sizes Mattijs Korpershoek
@ 2026-07-09 9:21 ` Ilias Apalodimas
0 siblings, 0 replies; 7+ messages in thread
From: Ilias Apalodimas @ 2026-07-09 9:21 UTC (permalink / raw)
To: Mattijs Korpershoek
Cc: u-boot, Lukasz Majewski, Marek Vasut, Tom Rini, Jonas Karlman
Not really an expert on USB but this seems reasonable
On Fri, 3 Jul 2026 at 16:29, Mattijs Korpershoek <mkorpershoek@kernel.org>
wrote:
> More recent versions of usb_ep_autoconfig() use the maxpacket_limit
> field from struct usb_ep.
>
> This field has been introduced in the linux kernel via commit
> e117e742d310 ("usb: gadget: add "maxpacket_limit" field to struct usb_ep")
> And has been ported to U-Boot via commit
> 747a0a5b387f ("usb: dwc3: gadget: make dwc3 gadget build in uboot")
>
> However, the dwc2 gadget driver was not converted to use
> usb_ep_set_maxpacket_limit().
> This is harmless for now, but the driver will break once
> usb_ep_autoconfig() is updated to a more recent version.
>
> Set maxpacket_limit via the recommended helper function to prepare for
> a core gadget update.
>
> Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
> ---
>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> drivers/usb/gadget/dwc2_udc_otg.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/gadget/dwc2_udc_otg.c
> b/drivers/usb/gadget/dwc2_udc_otg.c
> index e475b14b9ac3..9c85383fd62a 100644
> --- a/drivers/usb/gadget/dwc2_udc_otg.c
> +++ b/drivers/usb/gadget/dwc2_udc_otg.c
> @@ -828,7 +828,6 @@ static struct dwc2_udc memory = {
> .ep = {
> .name = ep0name,
> .ops = &dwc2_ep_ops,
> - .maxpacket = EP0_FIFO_SIZE,
> },
> .dev = &memory,
>
> @@ -843,7 +842,6 @@ static struct dwc2_udc memory = {
> .ep = {
> .name = "ep1in-bulk",
> .ops = &dwc2_ep_ops,
> - .maxpacket = EP_FIFO_SIZE,
> },
> .dev = &memory,
>
> @@ -858,7 +856,6 @@ static struct dwc2_udc memory = {
> .ep = {
> .name = "ep2out-bulk",
> .ops = &dwc2_ep_ops,
> - .maxpacket = EP_FIFO_SIZE,
> },
> .dev = &memory,
>
> @@ -873,7 +870,6 @@ static struct dwc2_udc memory = {
> .ep = {
> .name = "ep3in-int",
> .ops = &dwc2_ep_ops,
> - .maxpacket = EP_FIFO_SIZE,
> },
> .dev = &memory,
>
> @@ -893,6 +889,7 @@ int dwc2_udc_probe(struct dwc2_plat_otg_data *pdata)
> {
> struct dwc2_udc *dev = &memory;
> int retval = 0;
> + int i;
>
> debug("%s: %p\n", __func__, pdata);
>
> @@ -909,6 +906,10 @@ int dwc2_udc_probe(struct dwc2_plat_otg_data *pdata)
>
> the_controller = dev;
>
> + usb_ep_set_maxpacket_limit(&dev->ep[0].ep, EP0_FIFO_SIZE);
> + for (i = 1; i < DWC2_MAX_ENDPOINTS; i++)
> + usb_ep_set_maxpacket_limit(&dev->ep[i].ep, EP_FIFO_SIZE);
> +
> usb_ctrl = memalign(CONFIG_SYS_CACHELINE_SIZE,
> ROUND(sizeof(struct usb_ctrlrequest),
> CONFIG_SYS_CACHELINE_SIZE));
>
> --
> 2.54.0
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] usb: gadget: dwc2: Set endpoint capabilities via .caps field
2026-07-03 13:29 ` [PATCH 2/2] usb: gadget: dwc2: Set endpoint capabilities via .caps field Mattijs Korpershoek
@ 2026-07-09 9:22 ` Ilias Apalodimas
0 siblings, 0 replies; 7+ messages in thread
From: Ilias Apalodimas @ 2026-07-09 9:22 UTC (permalink / raw)
To: Mattijs Korpershoek
Cc: u-boot, Lukasz Majewski, Marek Vasut, Tom Rini, Jonas Karlman
On Fri, 3 Jul 2026 at 16:29, Mattijs Korpershoek
<mkorpershoek@kernel.org> wrote:
>
> Endpoint capabilities can be described via the .caps field of
> struct usb_ep since commit
> 77dcbdf3c1ce ("usb: gadget: Add match_ep() op to usb_gadget_ops")
>
> In linux, the following commit introduces it:
> b86f33a3a371 ("usb: gadget: epautoconf: add endpoint capabilities flags verification")
>
> Linux's change also reworks the ep matching function by relying on
> these new capabilities instead of guessing based on the endpoint name.
>
> Prepare the dwc2 UDC driver for capability-based matching by adding the
> required capabilities for each endpoint.
>
> Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
> ---
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> drivers/usb/gadget/dwc2_udc_otg.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
> index 9c85383fd62a..570fed347c9e 100644
> --- a/drivers/usb/gadget/dwc2_udc_otg.c
> +++ b/drivers/usb/gadget/dwc2_udc_otg.c
> @@ -828,6 +828,11 @@ static struct dwc2_udc memory = {
> .ep = {
> .name = ep0name,
> .ops = &dwc2_ep_ops,
> + .caps = {
> + .type_control = 1,
> + .dir_in = 1,
> + .dir_out = 1,
> + },
> },
> .dev = &memory,
>
> @@ -842,6 +847,10 @@ static struct dwc2_udc memory = {
> .ep = {
> .name = "ep1in-bulk",
> .ops = &dwc2_ep_ops,
> + .caps = {
> + .type_bulk = 1,
> + .dir_in = 1,
> + },
> },
> .dev = &memory,
>
> @@ -856,6 +865,10 @@ static struct dwc2_udc memory = {
> .ep = {
> .name = "ep2out-bulk",
> .ops = &dwc2_ep_ops,
> + .caps = {
> + .type_bulk = 1,
> + .dir_out = 1,
> + },
> },
> .dev = &memory,
>
> @@ -870,6 +883,10 @@ static struct dwc2_udc memory = {
> .ep = {
> .name = "ep3in-int",
> .ops = &dwc2_ep_ops,
> + .caps = {
> + .type_int = 1,
> + .dir_in = 1,
> + },
> },
> .dev = &memory,
>
>
> --
> 2.54.0
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] usb: gadget: dwc2: Prepare for UDC core migration
2026-07-03 13:29 [PATCH 0/2] usb: gadget: dwc2: Prepare for UDC core migration Mattijs Korpershoek
2026-07-03 13:29 ` [PATCH 1/2] usb: gadget: dwc2: Use usb_ep_set_maxpacket_limit() for fifo sizes Mattijs Korpershoek
2026-07-03 13:29 ` [PATCH 2/2] usb: gadget: dwc2: Set endpoint capabilities via .caps field Mattijs Korpershoek
@ 2026-07-22 6:54 ` Mattijs Korpershoek via U-Boot
2026-07-22 7:02 ` Mattijs Korpershoek via U-Boot
2 siblings, 1 reply; 7+ messages in thread
From: Mattijs Korpershoek via U-Boot @ 2026-07-22 6:54 UTC (permalink / raw)
To: u-boot, Mattijs Korpershoek
Cc: Lukasz Majewski, Marek Vasut, Tom Rini, Ilias Apalodimas,
Jonas Karlman
Hi,
On Fri, 03 Jul 2026 15:29:35 +0200, Mattijs Korpershoek wrote:
> Jens Wiklander started to migrate the DWC3 driver to a more recent
> version of linux (v6.16) [1].
>
> This migration also updates the UDC core and most notably how drivers
> perform their endpoint matching.
>
> While testing Jens' series on a Khadas VIM3 board, I reported [2] that
> I can no longer bind the fastboot gadget to the dwc2 otg driver.
>
> [...]
Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu (u-boot-dfu)
[1/2] usb: gadget: dwc2: Use usb_ep_set_maxpacket_limit() for fifo sizes
https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/6f9c431a20627db34e0c41ea865c611f0d2c2016
[2/2] usb: gadget: dwc2: Set endpoint capabilities via .caps field
https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/c5c4cc4c6b9887858e168d5106f8f1d3dfb6c3e8
--
Mattijs
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] usb: gadget: dwc2: Prepare for UDC core migration
2026-07-22 6:54 ` [PATCH 0/2] usb: gadget: dwc2: Prepare for UDC core migration Mattijs Korpershoek via U-Boot
@ 2026-07-22 7:02 ` Mattijs Korpershoek via U-Boot
0 siblings, 0 replies; 7+ messages in thread
From: Mattijs Korpershoek via U-Boot @ 2026-07-22 7:02 UTC (permalink / raw)
To: u-boot
Cc: Lukasz Majewski, Marek Vasut, Tom Rini, Ilias Apalodimas,
Jonas Karlman
On Wed, Jul 22, 2026 at 08:54, Mattijs Korpershoek <mkorpershoek@kernel.org> wrote:
> Hi,
>
> On Fri, 03 Jul 2026 15:29:35 +0200, Mattijs Korpershoek wrote:
>> Jens Wiklander started to migrate the DWC3 driver to a more recent
>> version of linux (v6.16) [1].
>>
>> This migration also updates the UDC core and most notably how drivers
>> perform their endpoint matching.
>>
>> While testing Jens' series on a Khadas VIM3 board, I reported [2] that
>> I can no longer bind the fastboot gadget to the dwc2 otg driver.
>>
>> [...]
>
> Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu (u-boot-dfu)
>
> [1/2] usb: gadget: dwc2: Use usb_ep_set_maxpacket_limit() for fifo sizes
> https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/6f9c431a20627db34e0c41ea865c611f0d2c2016
> [2/2] usb: gadget: dwc2: Set endpoint capabilities via .caps field
> https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/c5c4cc4c6b9887858e168d5106f8f1d3dfb6c3e8
Err, my automation is not up to date.
I can confirm the patches have been applied to the new u-boot location:
https://git.u-boot-project.org/u-boot/custodians/u-boot-dfu/-/commit/6f9c431a20627db34e0c41ea865c611f0d2c2016
https://git.u-boot-project.org/u-boot/custodians/u-boot-dfu/-/commit/c5c4cc4c6b9887858e168d5106f8f1d3dfb6c3e8
>
> --
> Mattijs
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-07-22 7:02 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-03 13:29 [PATCH 0/2] usb: gadget: dwc2: Prepare for UDC core migration Mattijs Korpershoek
2026-07-03 13:29 ` [PATCH 1/2] usb: gadget: dwc2: Use usb_ep_set_maxpacket_limit() for fifo sizes Mattijs Korpershoek
2026-07-09 9:21 ` Ilias Apalodimas
2026-07-03 13:29 ` [PATCH 2/2] usb: gadget: dwc2: Set endpoint capabilities via .caps field Mattijs Korpershoek
2026-07-09 9:22 ` Ilias Apalodimas
2026-07-22 6:54 ` [PATCH 0/2] usb: gadget: dwc2: Prepare for UDC core migration Mattijs Korpershoek via U-Boot
2026-07-22 7:02 ` Mattijs Korpershoek via U-Boot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox