Skip to content

drivers: usb: udc: fix for control buffer rework#106339

Merged
MaureenHelm merged 4 commits intozephyrproject-rtos:mainfrom
ccli8:nvt_hsusbd_fix_for_ctrl_rework
Mar 30, 2026
Merged

drivers: usb: udc: fix for control buffer rework#106339
MaureenHelm merged 4 commits intozephyrproject-rtos:mainfrom
ccli8:nvt_hsusbd_fix_for_ctrl_rework

Conversation

@ccli8
Copy link
Copy Markdown
Contributor

@ccli8 ccli8 commented Mar 26, 2026

For Nuvoton NuMaker SoC series, this has the following modifications after USB UDC rework #103493. It includes:

  1. Fix STALL causes the device to hang
  2. Fix NULL buffer access

ccli8 added 4 commits March 26, 2026 09:24
Slightly refine the format

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
The crash results from Control transfer STALL interrupt flag
not cleared. To catch all uncleared interrupt flags, all Control
transfer interrupt flags are cleared altogether at one place
instead of separately, with their handling order not changed.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
The scheduled transfer message can be just a hint and its attached
transfer buffer can be NULL. Skip this case.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
Remove the error check because it may misjudge some right cases.
For example, for HSUSBD, in the case Setup-DataIn-StatusOut and
immediately following Setup-DataOut-StatusIn, the DataOut in the
second Control transfer has arrived but user buffer for OUT may
be only ready for StatusOut in the first Control transfer.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
@zephyrbot zephyrbot added the area: USB Universal Serial Bus label Mar 26, 2026
@sonarqubecloud
Copy link
Copy Markdown

priv->ctrlout_tailroom -= data_len;
}

if (data_rmn) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DataOut in the second Control transfer has arrived but user buffer for OUT may be only ready for StatusOut in the first Control transfer

What I found problematic is that the hardware automatically receives first Data Out transfer. The workaround for this in software is to mask HSUSBD_CEPINTEN_RXPKIEN_Msk so even that data packet was received, it won't be processed until data buffer is enqueued. Is it possible for the HW to not automatically accept first Data Out packet?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the HSUSBD hardware will automatically receive the first Data Out transfer. However, the hardware doesn't open related control to disable it.

@jfischer-no jfischer-no added bug The issue is a bug, or the PR is fixing a bug area: Drivers labels Mar 26, 2026
@jfischer-no jfischer-no added this to the v4.4.0 milestone Mar 26, 2026
@MaureenHelm MaureenHelm merged commit 4a7f05b into zephyrproject-rtos:main Mar 30, 2026
32 of 34 checks passed
@ccli8 ccli8 deleted the nvt_hsusbd_fix_for_ctrl_rework branch March 31, 2026 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Drivers area: USB Universal Serial Bus bug The issue is a bug, or the PR is fixing a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants