Hi Anders,

On 9/16/26 2:38 PM, Anders Roxell wrote:
Hi,

This is part two of two. It applies on top of part one [5], 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.

Part one is unchanged since v7, so I did not resend it. All 63 patches
there have a Reviewed-by from Mattijs.

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,
dwc2 with and without DM_USB_GADGET, at91_udc, atmel_usba_udc, ci_udc,
musb-new and mtu3. 17 boards in total.

DFU and ums are tested on hardware on BeagleBoard-X15. Anshul tested DFU
and ums on AM62p and BeaglePlay. ci_udc is tested on an i.MX93 board with
ums. Love tested v7 on AMD/Xilinx boards. The rest is build tested only.

One thing is still open. Anshul sees a single "unknown endpoint event 0"
line on AM62p during enumeration. It is there with and without the cache
patch, and the transfers work anyway. I do not see it on X15, and we do
not know yet if it is older than this series.

x86 builds again, but CI still fails on am335x_evm. The SPL does not fit
in SRAM anymore, it is 184 bytes too big. The resynced udc-core is bigger
and am335x_evm had almost no room left before this series. I would like
some input on how to handle it.

The branch has both parts [4].

[1] v5: 
https://lore.kernel.org/u-boot/[email protected]/
[2] Jerome's adaptation work: 
https://lore.kernel.org/all/[email protected]/
[3] dwc2 prep: 
https://lore.kernel.org/all/[email protected]/
[4] https://github.com/roxell/u-boot/tree/usb_dwc3_sync_v9
[5] part one: 
https://lore.kernel.org/u-boot/[email protected]/
     subject: [PATCH v7 00/63] usb: dwc3: part 1, reset and import from
     Linux v6.16
[6] v7 part two: 
https://lore.kernel.org/u-boot/[email protected]/
[7] v8 part two: 
https://lore.kernel.org/u-boot/[email protected]/

v8 -> v9:
- New patch first in the series, "x86: asm: io.h: add rmb() and wmb()".
   v8 kept the two wmb() in dwc3 gadget.c, but x86 only had dmb() and
   mb(). So the x86 boards did not build and Marek's CI failed [7].
- "dm: add helpers needed by the resynced DWC3 code": picked up
   Reviewed-by from Mattijs.
- "usb: phy: add the usb_phy helpers needed by the resynced DWC3 code":
   picked up Reviewed-by from Mattijs. Added the blank line before the
   last return that he asked for.
- u-boot -> U-Boot in all commit messages. Mattijs pointed it out on two
   patches, and the same spelling was used in 8 more. Four subjects change
   because of this.
- Part one is untouched.

v7 -> v8:
- New patch, "usb: dwc3: gadget: flush and invalidate cache around
   transfers". The resync dropped the cache maintenance for the normal
   endpoints, so ums did not work. Anshul found it on AM62p and
   BeaglePlay, and we both tested the fix.
- "make gadget and ep0 build in u-boot" no longer comments out the two
   wmb() in dwc3 gadget.c. They come from the kernel import and the port
   had no reason to remove them.

Older changes are listed in v7 [6] and v5 [1].


I applied both series on top of current main (c92d8c3c431e "board: beacon: Remove i.MX8MP Beacon EmbeddedWorks Devkit support") and tested on RK3588 Tiger (three DWC3 controllers exposed) and RK3399 Puma (two DWC3 controllers exposed). For each board, one of the DWC3 is routed to a micro-USB OTG port which doesn't seem to work (before or after your patch). Considering it's historically finicky in Linux, I wouldn't read too much into this. For RK3588 Tiger, the third controller doesn't even appear in the usb tree output. On RK3399 Puma, it does but no USB stick detected (either via a micro USB-OTG USB2 or USB3 adapter).

Tests are performed like this: I insert one stick in a port and power reset the board and run the commands. Tests for different ports for the same boards are run with a reset in-between tries. If you want some other tests or a different test procedure, I can do that too, but only in a month as I will not have physical access to my devices for that amount of time.

Some information about the HW routing for those boards. RK3588 Tiger directly routes individual USB ports to separate controllers. RK3399 Puma has a dedicated DWC3 controller for its micro-USB USB3 OTG port, the second DWC3 controller is routed to an onboard USB hub that provides two USB3 ports and two USB2 ports (one exposed on the carrierboard, the other one used for our onboard USB/CAN adapter).

I also have an RK3588 Jaguar but the DWC3 controllers are routed to two USB-C connectors and I couldn't quickly make them work (the defconfig currently doesn't even have the necessary drivers enabled). This is a problem for future Quentin (we have a USB2 port that should work so that is enough at the moment).

# RK3588 Tiger: Q7 USB P0 lower
=> usb reset && usb tree && random $loadaddr 0x8000 && mw.q $kernel_addr_r 0xffffffffffffffff 0x1000 && usb dev 0 && usb write $loadaddr 0 0x40 && usb read $kernel_addr_r 0 0x40 && cmp.q $loadaddr $kernel_addr_r 0x1000
resetting USB...
USB EHCI 1.00
USB OHCI 1.0
USB EHCI 1.00
USB OHCI 1.0
USB XHCI 1.10
USB XHCI 1.10
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
Bus usb@fc800000: 1 USB Device(s) found
Bus usb@fc840000: 1 USB Device(s) found
Bus usb@fc880000: 1 USB Device(s) found
Bus usb@fc8c0000: 1 USB Device(s) found
Bus usb@fcd00000: 1 USB Device(s) found
Bus usb@fc400000: 2 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
USB device tree:
  1  Hub (480 Mb/s, 0mA)
     u-boot EHCI Host Controller

  1  Hub (12 Mb/s, 0mA)
      U-Boot Root Hub

  1  Hub (480 Mb/s, 0mA)
     u-boot EHCI Host Controller

  1  Hub (12 Mb/s, 0mA)
      U-Boot Root Hub

  1  Hub (5 Gb/s, 0mA)
     U-Boot XHCI Host Controller

  1  Hub (5 Gb/s, 0mA)
  |  U-Boot XHCI Host Controller
  |
  +-2  Mass Storage (5 Gb/s, 126mA)

32768 bytes filled with random data

Device 0: Vendor: Kingston Rev: PMAP Prod: DataTraveler 3.0
            Type: Removable Hard Disk
            Capacity: 14784.0 MB = 14.4 GB (30277632 x 512)
... is now current device

usb write: device 0 block # 0, count 64 ... WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
Resetting EP 3...
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
Resetting EP 3...
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
Resetting EP 3...
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
WARN endpoint is halted
0 blocks written: ERROR

# RK3588 Tiger: Q7 USB P0 lower retry with another USB stick
=> usb reset && usb tree && random $loadaddr 0x8000 && mw.q $kernel_addr_r 0xffffffffffffffff 0x1000 && usb dev 0 && usb write $loadaddr 0 0x40 && usb read $kernel_addr_r 0 0x40 && cmp.q $loadaddr $kernel_addr_r 0x1000
resetting USB...
USB EHCI 1.00
USB OHCI 1.0
USB EHCI 1.00
USB OHCI 1.0
USB XHCI 1.10
USB XHCI 1.10
cannot reset port 1!?
** Read outside partition 0
Bus usb@fc800000: 1 USB Device(s) found
Bus usb@fc840000: 1 USB Device(s) found
Bus usb@fc880000: 1 USB Device(s) found
Bus usb@fc8c0000: 1 USB Device(s) found
Bus usb@fcd00000: 1 USB Device(s) found
Bus usb@fc400000: 2 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
USB device tree:
  1  Hub (480 Mb/s, 0mA)
     u-boot EHCI Host Controller

  1  Hub (12 Mb/s, 0mA)
      U-Boot Root Hub

  1  Hub (480 Mb/s, 0mA)
     u-boot EHCI Host Controller

  1  Hub (12 Mb/s, 0mA)
      U-Boot Root Hub

  1  Hub (5 Gb/s, 0mA)
     U-Boot XHCI Host Controller

  1  Hub (5 Gb/s, 0mA)
  |  U-Boot XHCI Host Controller
  |
  +-2  Mass Storage (5 Gb/s, 224mA)
       SanDisk SanDisk 3.2 Gen 1 5B4C0BC01FBB

32768 bytes filled with random data

Device 0: Vendor: SanDisk  Rev: 0    Prod: 3.2 Gen 1
            Type: Hard Disk
            Capacity: 117864.0 MB = 115.1 GB (241385472 x 512)
... is now current device

usb write: device 0 block # 0, count 64 ... 64 blocks written: OK

usb read: device 0 block # 0, count 64 ... 64 blocks read: OK
Total of 4096 double word(s) were the same

# RK3588 Tiger: Q7 USB P2 upper
=> usb reset && usb tree && random $loadaddr 0x8000 && mw.q $kernel_addr_r 0xffffffffffffffff 0x1000 && usb dev 0 && usb write $loadaddr 0 0x40 && usb read $kernel_addr_r 0 0x40 && cmp.q $loadaddr $kernel_addr_r 0x1000
resetting USB...
USB EHCI 1.00
USB OHCI 1.0
USB EHCI 1.00
USB OHCI 1.0
USB XHCI 1.10
USB XHCI 1.10
cannot reset port 1!?
Bus usb@fc800000: 1 USB Device(s) found
Bus usb@fc840000: 1 USB Device(s) found
Bus usb@fc880000: 1 USB Device(s) found
Bus usb@fc8c0000: 1 USB Device(s) found
Bus usb@fcd00000: 2 USB Device(s) found
Bus usb@fc400000: 1 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
USB device tree:
  1  Hub (480 Mb/s, 0mA)
     u-boot EHCI Host Controller

  1  Hub (12 Mb/s, 0mA)
      U-Boot Root Hub

  1  Hub (480 Mb/s, 0mA)
     u-boot EHCI Host Controller

  1  Hub (12 Mb/s, 0mA)
      U-Boot Root Hub

  1  Hub (5 Gb/s, 0mA)
  |  U-Boot XHCI Host Controller
  |
  +-2  Mass Storage (5 Gb/s, 126mA)
       Kingston DataTraveler 3.0 1C6F654E48EBB161D95D8F07

  1  Hub (5 Gb/s, 0mA)
     U-Boot XHCI Host Controller

32768 bytes filled with random data

Device 0: Vendor: Kingston Rev: PMAP Prod: DataTraveler 3.0
            Type: Removable Hard Disk
            Capacity: 14784.0 MB = 14.4 GB (30277632 x 512)
... is now current device

usb write: device 0 block # 0, count 64 ... 64 blocks written: OK

usb read: device 0 block # 0, count 64 ... 64 blocks read: OK
Total of 4096 double word(s) were the same

# RK3399 Puma: Q7 USB P2 upper
=> usb reset && usb tree && random $loadaddr 0x8000 && mw.q $kernel_addr_r 0xffffffffffffffff 0x1000 && usb dev 0 && usb write $loadaddr 0 0x40 && usb read $kernel_addr_r 0 0x40 && cmp.q $loadaddr $kernel_addr_r 0x1000
resetting USB...
USB XHCI 1.10
WARN endpoint is halted
WARN endpoint is halted
unable to get device descriptor (error=-22)
Bus usb@fe900000: 5 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
USB device tree:
  1  Hub (5 Gb/s, 0mA)
  |  U-Boot XHCI Host Controller
  |
  +-2  Hub (480 Mb/s, 0mA)
  | |
  | +-4  Vendor specific (12 Mb/s, 100mA)
  |      Theobroma Systems Mule USB/CAN Adapter 002A00244356530720323439
  |
  +-3  Hub (5 Gb/s, 0mA)
    |
    +-5  Mass Storage (5 Gb/s, 126mA)
         Kingston DataTraveler 3.0 1C6F654E48EBB161D95D8F07

32768 bytes filled with random data

Device 0: Vendor: Kingston Rev: PMAP Prod: DataTraveler 3.0
            Type: Removable Hard Disk
            Capacity: 14784.0 MB = 14.4 GB (30277632 x 512)
... is now current device

usb write: device 0 block # 0, count 64 ... 64 blocks written: OK

usb read: device 0 block # 0, count 64 ... 64 blocks read: OK
Total of 4096 double word(s) were the same

# RK3399 Puma: Q7 USB P0 upper
=> usb reset && usb tree && random $loadaddr 0x8000 && mw.q $kernel_addr_r 0xffffffffffffffff 0x1000 && usb dev 0 && usb write $loadaddr 0 0x40 && usb read $kernel_addr_r 0 0x40 && cmp.q $loadaddr $kernel_addr_r 0x1000
resetting USB...
USB XHCI 1.10
WARN endpoint is halted
WARN endpoint is halted
unable to get device descriptor (error=-22)
WARN endpoint is halted [QSC note: repeated 355 times]
[...]
Bus usb@fe900000: 5 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
USB device tree:
  1  Hub (5 Gb/s, 0mA)
  |  U-Boot XHCI Host Controller
  |
  +-2  Hub (480 Mb/s, 0mA)
  | |
  | +-4  Vendor specific (12 Mb/s, 100mA)
  |      Theobroma Systems Mule USB/CAN Adapter 002A00244356530720323439
  |
  +-3  Hub (5 Gb/s, 0mA)
    |
    +-5  Mass Storage (5 Gb/s, 126mA)
         Kingston DataTraveler 3.0 1C6F654E48EBB161D95D8F07

32768 bytes filled with random data

Device 0: Vendor: Kingston Rev: PMAP Prod: DataTraveler 3.0
            Type: Removable Hard Disk
            Capacity: 14784.0 MB = 14.4 GB (30277632 x 512)
... is now current device

usb write: device 0 block # 0, count 64 ... 64 blocks written: OK

usb read: device 0 block # 0, count 64 ... 64 blocks read: OK
Total of 4096 double word(s) were the same

I also have two SanDisk Corp. Ultra Flair that are USB3 but they are consistently detected as USB2 in U-Boot for some reason.

Cheers,
Quentin

Cheers,
Anders

Anders Roxell (26):
   x86: asm: io.h: add rmb() and wmb()
   dm: add helpers needed by the resynced DWC3 code
   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: dwc3: make the core driver build in U-Boot
   usb: dwc3: bring back the samsung usb phy driver
   usb: dwc3: make gadget and ep0 build in U-Boot
   usb: gadget: udc: enable async callbacks on bind
   usb: dwc3: ep0: flush and invalidate cache around ep0 transfers
   usb: dwc3: gadget: flush and invalidate cache around transfers
   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: fix up the last UDC drivers after the resync
   usb: gadget: atmel_usba_udc: set endpoint capabilities
   usb: gadget: at91_udc: register with udc-core
   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: host: xhci: fix up after the resync
   usb: cdns3: fix up after the resync

  arch/x86/include/asm/io.h              |    2 +
  drivers/usb/cdns3/ep0.c                |    8 +-
  drivers/usb/dwc3/Makefile              |   16 +-
  drivers/usb/dwc3/core.c                | 1761 ++++++------------------
  drivers/usb/dwc3/core.h                |   39 +-
  drivers/usb/dwc3/dwc3-am62.c           |  424 +-----
  drivers/usb/dwc3/dwc3-omap.c           |    2 -
  drivers/usb/dwc3/ep0.c                 |  117 +-
  drivers/usb/dwc3/gadget.c              |  724 ++--------
  drivers/usb/dwc3/gadget.h              |    4 +-
  drivers/usb/dwc3/io.h                  |   36 +-
  drivers/usb/dwc3/samsung_usb_phy.c     |   77 ++
  drivers/usb/dwc3/ti_usb_phy.c          |    2 -
  drivers/usb/gadget/at91_udc.c          |   83 +-
  drivers/usb/gadget/atmel_usba_udc.c    |  114 +-
  drivers/usb/gadget/ci_udc.c            |   86 +-
  drivers/usb/gadget/composite.c         |    2 +-
  drivers/usb/gadget/dwc2_udc_otg.c      |   86 +-
  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      |  933 ++-----------
  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      |   39 -
  include/dm/device_compat.h             |   13 +
  include/dm/read.h                      |   51 +
  include/linux/compat.h                 |   15 +
  include/linux/usb/ch9.h                |   25 +-
  include/linux/usb/gadget.h             |  529 ++-----
  include/linux/usb/phy.h                |   57 +
  40 files changed, 1416 insertions(+), 4005 deletions(-)
  create mode 100644 drivers/usb/dwc3/samsung_usb_phy.c


Reply via email to