Skip to content

usb: dwc3: part 2, make the resynced code work

Anders Roxell u-boot 6 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v12 Latest31 patches 1 replyIn review
  2. v1130 patches 10 repliesSuperseded
  3. v1030 patches 8 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v926 patches22 repliesSuperseded
v825 patches2 repliesSuperseded
v724 patches7 repliesSuperseded

Changes in v12 from the cover letter

- Rebased on next (794978160561) for v2027.04.
- dm helpers: kerneldoc for dev_count_u32(), and no parentheses around the return value in device_property_present(). (Marek)
- reset: new patch 3. reset_control_assert() and reset_control_deassert() were in the dm helpers patch. Now they have their own patch with kerneldoc. They still return 0 for a NULL reset like in Linux, because dwc3 calls reset_control_assert() with dwc->reset NULL. (Marek)
- core: dwc->dev is a struct udevice also without DM_USB, so the casts on the devm calls are gone. (Marek)
- udc-core: the usb_gadget_udc_bringup() comment is kerneldoc now.
- gadget: ep0_trb_addr is cast to unsigned long * for dma_alloc_coherent(), not long *.
- musb-new: no casts on bdata in musb_register(), it is a void pointer.

Patches in v12 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/31x86: asm: io.h: add rmb() and wmb()arch/x86/include/asm/io.h+2 -00 replies
2/31dm: add helpers needed by the resynced DWC3 codeinclude/dm/device_compat.h include/dm/read.h+62 -00 replies
3/31reset: add reset_control_assert() and reset_control_deassert()include/reset.h+32 -00 replies
4/31phy: cadence: use reset_control_assert() from reset.hdrivers/phy/cadence/phy-cadence-sierra.c drivers/phy/cadence/phy-cadence-torrent.c+0 -200 replies
5/31usb: phy: add the usb_phy helpers needed by the resynced DWC3 codeinclude/linux/usb/phy.h+57 -00 replies
6/31usb: gadget: adapt the gadget API after the resyncinclude/linux/usb/ch9.h include/linux/usb/gadget.h+110 -4410 replies
7/31usb: gadget: udc: make udc-core build in U-Bootdrivers/usb/gadget/epautoconf.c drivers/usb/gadget/udc/Makefile drivers/usb/gadget/udc/udc-core.c +1 more+157 -7840 replies
8/31usb: host: xhci: fix up after the resyncdrivers/usb/host/xhci-dwc3.c include/linux/usb/dwc3.h+2 -30 replies
9/31usb: dwc3: core: remove the code U-Boot does not usedrivers/usb/dwc3/core.c drivers/usb/dwc3/core.h+0 -14130 replies
10/31usb: dwc3: core: bring back the U-Boot entry pointsdrivers/usb/dwc3/core.c drivers/usb/dwc3/core.h+431 -00 replies
11/31usb: dwc3: core: adapt to the U-Boot APIsdrivers/usb/dwc3/core.c drivers/usb/dwc3/core.h+109 -890 replies
12/31usb: dwc3: adapt io.h, the Makefile and the TI gluedrivers/usb/dwc3/Makefile drivers/usb/dwc3/dwc3-omap.c drivers/usb/dwc3/io.h +1 more+24 -270 replies
13/31usb: dwc3: make gadget and ep0 build in U-Bootdrivers/usb/dwc3/ep0.c drivers/usb/dwc3/gadget.c drivers/usb/dwc3/gadget.h+183 -6490 replies
14/31usb: dwc3: ep0: flush and invalidate cache around ep0 transfersdrivers/usb/dwc3/ep0.c+10 -00 replies
15/31usb: dwc3: gadget: flush and invalidate cache around transfersdrivers/usb/dwc3/gadget.c+8 -00 replies
16/31usb: dwc3: core: flush the event buffer after allocationdrivers/usb/dwc3/core.c+2 -00 replies
17/31usb: dwc3: make the am62 glue build in U-Bootdrivers/usb/dwc3/dwc3-am62.c+67 -3570 replies
18/31usb: gadget: ci_udc: move to the udc-core registrationdrivers/usb/gadget/ci_udc.c+32 -310 replies
19/31usb: gadget: ci_udc: set endpoint capabilitiesdrivers/usb/gadget/ci_udc.c+29 -00 replies
20/31usb: gadget: dwc2_udc_otg: fix up after the resyncdrivers/usb/gadget/dwc2_udc_otg.c+11 -780 replies
21/31usb: gadget: fix up the function drivers after the resyncdrivers/usb/gadget/composite.c drivers/usb/gadget/ether.c drivers/usb/gadget/f_acm.c +5 more+58 -420 replies
22/31usb: gadget: at91_udc: register with udc-coredrivers/usb/gadget/at91_udc.c+10 -460 replies
23/31usb: gadget: atmel_usba_udc: fix up after the resyncdrivers/usb/gadget/atmel_usba_udc.c+23 -710 replies
24/31usb: gadget: atmel_usba_udc: set endpoint capabilitiesdrivers/usb/gadget/atmel_usba_udc.c+11 -10 replies
25/31usb: gadget: at91_udc: set endpoint capabilitiesdrivers/usb/gadget/at91_udc.c+18 -90 replies
26/31usb: musb-new: fix up after the resyncdrivers/usb/musb-new/musb_gadget_ep0.c drivers/usb/musb-new/musb_uboot.c+21 -560 replies
27/31usb: musb-new: set endpoint capabilitiesdrivers/usb/musb-new/musb_gadget.c+18 -30 replies
28/31usb: mtu3: fix up after the resyncdrivers/usb/mtu3/mtu3_gadget_ep0.c+8 -80 replies
29/31usb: mtu3: set endpoint capabilitiesdrivers/usb/mtu3/mtu3_gadget.c+10 -00 replies
30/31usb: cdns3: fix up after the resyncdrivers/usb/cdns3/ep0.c+4 -40 replies
31/31usb: dwc3: enable SUSPHY again after xhci is registereddrivers/usb/dwc3/dwc3-generic.c drivers/usb/dwc3/dwc3-layerscape.c+13 -30 replies

Reviews trailers per patch

3 of 31 patches have a Reviewed-by or Acked-by.

PatchQuentin SchulzAlexey CharkovMattijs Korpershoek
SeriesT-b T-b T-b
1/31
2/31R-b
3/31R-b
4/31
5/31R-b
6/31
7/31
8/31
9/31
10/31
11/31
12/31
13/31
14/31
15/31
16/31
17/31
18/31
19/31
20/31
21/31
22/31
23/31
24/31
25/31
26/31
27/31
28/31
29/31
30/31
31/31

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v12 thread

Cover letter [PATCH v12 00/31] usb: dwc3: part 2, make the resynced code work

Hi,

This is part two of two. It applies on top of part one [1], which resets the DWC3 driver and imports it up to Linux v6.16. Part one alone breaks the build for every board that enables DWC3. This part adds back the U-Boot glue, the XHCI and UDC updates and the build fixes, so the tree builds and the gadget works again. It builds on Jerome's work [2].

The two parts have to go in together, on top of next (794978160561). Part one did not change, so I do not resend it. The v10 patches [1] still apply on next.

The resynced epautoconf matches endpoints on their caps field instead of on their name. Five UDC drivers never filled that in, so each one gets a patch next to its other fixup: at91_udc, atmel_usba_udc, ci_udc, musb-new and mtu3. With those and dwc2, every UDC driver in the tree sets caps.

Build tested one board per driver: every DWC3 glue layer in the tree, dwc3 on riscv (spacemit_k1), RK3588 and RK3399, dwc2 with and without DM_USB_GADGET, at91_udc, atmel_usba_udc, ci_udc with SPL SDP, musb-new on sunxi and in the am335x_evm SPL, and mtu3. 24 boards, no warnings.

Ilias found a few bisect gaps, so I built eight of the boards at every patch. Gadget configs build again from patch 21, the other UDC drivers from their own fixup patch.

Tested on hardware with v10, per vendor:

- AMD/Xilinx: Love tested and sent a Tested-by.
- TI: DFU and ums on BeagleBoard-X15 (me), and on AM62p and BeaglePlay (Anshul).
- NXP: ci_udc with ums on an i.MX93 board (me).
- Amlogic: gadget and host on Khadas VIM3 (Mattijs).
- Rockchip: host on RK3399 Puma, same as master (Quentin). RK3588 Tiger had two regressions, see below.

Tested on hardware with v11:

- NXP: ci_udc with ums on i.MX93, chainloaded from the vendor U-Boot. Three ums rounds, the host read 64 MiB each time. It needs usbotg1 in peripheral mode.
- TI: dwc3 ums on BeagleBoard-X15, the host enumerates it at high speed. That is where I found the event buffer bug in patch 16.
- Rockchip: host on RK3399 Puma and RK3588 Tiger (Quentin). The two Tiger regressions from v10 are gone, and he sent a Tested-by:

- Rockchip: host and gadget on RK3576, a Flipper One and an RK3576 EVB1 (Alexey). No regressions against master, and he sent a Tested-by:

v12 only has the review fixes below, and they do not change what the code does. So the v11 hardware tests above still hold. I also ran dwc3 ums on BeagleBoard-X15 with v12. The host enumerates it at high speed, and what it reads back matches what U-Boot wrote to the card. ci_udc ums on i.MX93, chainloaded like for v11, works too.

One thing is still open.

Anshul sees a single "unknown endpoint event 0" line on AM62p during enumeration. I got the same line on the X15 from the event buffer bug that patch 16 fixes. I think it is the same on AM62p, but I have not tested it.

The branch has both parts [3].

[1] part one, subject: [PATCH v10 00/63] usb: dwc3: part 1, reset and
import from Linux v6.16
[2] Jerome's adaptation work: https://lore.kernel.org/all/[email protected]/
[3] https://github.com/roxell/u-boot/tree/usb_dwc3_sync_v12
[4] v11 part two: https://lore.kernel.org/u-boot/[email protected]/

v11 -> v12:
- Rebased on next (794978160561) for v2027.04.
- dm helpers: kerneldoc for dev_count_u32(), and no parentheses around the return value in device_property_present(). (Marek)
- reset: new patch 3. reset_control_assert() and reset_control_deassert() were in the dm helpers patch. Now they have their own patch with kerneldoc. They still return 0 for a NULL reset like in Linux, because dwc3 calls reset_control_assert() with dwc->reset NULL. (Marek)
- core: dwc->dev is a struct udevice also without DM_USB, so the casts on the devm calls are gone. (Marek)
- udc-core: the usb_gadget_udc_bringup() comment is kerneldoc now.
- gadget: ep0_trb_addr is cast to unsigned long * for dma_alloc_coherent(), not long *.
- musb-new: no casts on bdata in musb_register(), it is a void pointer.

Older changes are listed in v11 [4].

Cheers,
Anders

Anders Roxell (31):
x86: asm: io.h: add rmb() and wmb()
dm: add helpers needed by the resynced DWC3 code
reset: add reset_control_assert() and reset_control_deassert()
phy: cadence: use reset_control_assert() from reset.h
usb: phy: add the usb_phy helpers needed by the resynced DWC3 code
usb: gadget: adapt the gadget API after the resync
usb: gadget: udc: make udc-core build in U-Boot
usb: host: xhci: fix up after the resync
usb: dwc3: core: remove the code U-Boot does not use
usb: dwc3: core: bring back the U-Boot entry points
usb: dwc3: core: adapt to the U-Boot APIs
usb: dwc3: adapt io.h, the Makefile and the TI glue
usb: dwc3: make gadget and ep0 build in U-Boot
usb: dwc3: ep0: flush and invalidate cache around ep0 transfers
usb: dwc3: gadget: flush and invalidate cache around transfers
usb: dwc3: core: flush the event buffer after allocation
usb: dwc3: make the am62 glue build in U-Boot
usb: gadget: ci_udc: move to the udc-core registration
usb: gadget: ci_udc: set endpoint capabilities
usb: gadget: dwc2_udc_otg: fix up after the resync
usb: gadget: fix up the function drivers after the resync
usb: gadget: at91_udc: register with udc-core
usb: gadget: atmel_usba_udc: fix up after the resync
usb: gadget: atmel_usba_udc: set endpoint capabilities
usb: gadget: at91_udc: set endpoint capabilities
usb: musb-new: fix up after the resync
usb: musb-new: set endpoint capabilities
usb: mtu3: fix up after the resync
usb: mtu3: set endpoint capabilities
usb: cdns3: fix up after the resync
usb: dwc3: enable SUSPHY again after xhci is registered

 arch/x86/include/asm/io.h                 |    2 +
 drivers/phy/cadence/phy-cadence-sierra.c  |   18 -
 drivers/phy/cadence/phy-cadence-torrent.c |    2 -
 drivers/usb/cdns3/ep0.c                   |    8 +-
 drivers/usb/dwc3/Makefile                 |   11 +-
 drivers/usb/dwc3/core.c                   | 1773 +++++----------------
 drivers/usb/dwc3/core.h                   |   39 +-
 drivers/usb/dwc3/dwc3-am62.c              |  424 +----
 drivers/usb/dwc3/dwc3-generic.c           |    8 +-
 drivers/usb/dwc3/dwc3-layerscape.c        |    8 +-
 drivers/usb/dwc3/dwc3-omap.c              |    2 -
 drivers/usb/dwc3/ep0.c                    |  117 +-
 drivers/usb/dwc3/gadget.c                 |  727 ++-------
 drivers/usb/dwc3/gadget.h                 |    4 +-
 drivers/usb/dwc3/io.h                     |   36 +-
 drivers/usb/dwc3/ti_usb_phy.c             |    2 -
 drivers/usb/gadget/at91_udc.c             |   83 +-
 drivers/usb/gadget/atmel_usba_udc.c       |  106 +-
 drivers/usb/gadget/ci_udc.c               |   92 +-
 drivers/usb/gadget/composite.c            |    2 +-
 drivers/usb/gadget/dwc2_udc_otg.c         |   89 +-
 drivers/usb/gadget/epautoconf.c           |    2 -
 drivers/usb/gadget/ether.c                |   21 +-
 drivers/usb/gadget/f_acm.c                |   20 +-
 drivers/usb/gadget/f_fastboot.c           |   10 +-
 drivers/usb/gadget/f_mass_storage.c       |    5 +-
 drivers/usb/gadget/f_rockusb.c            |   11 +-
 drivers/usb/gadget/f_sdp.c                |   12 +-
 drivers/usb/gadget/f_thor.c               |   19 +-
 drivers/usb/gadget/udc/Makefile           |    1 +
 drivers/usb/gadget/udc/udc-core.c         |  935 ++---------
 drivers/usb/host/xhci-dwc3.c              |    4 +-
 drivers/usb/mtu3/mtu3_gadget.c            |   10 +
 drivers/usb/mtu3/mtu3_gadget_ep0.c        |   16 +-
 drivers/usb/musb-new/musb_gadget.c        |   21 +-
 drivers/usb/musb-new/musb_gadget_ep0.c    |   24 +-
 drivers/usb/musb-new/musb_uboot.c         |   53 +-
 include/dm/device_compat.h                |   11 +
 include/dm/read.h                         |   51 +
 include/linux/usb/ch9.h                   |   25 +-
 include/linux/usb/dwc3.h                  |    1 -
 include/linux/usb/gadget.h                |  529 ++----
 include/linux/usb/phy.h                   |   57 +
 include/reset.h                           |   32 +
 44 files changed, 1405 insertions(+), 4018 deletions(-)
Signature · 1 line
2.53.0