Skip to content

drivers: udc: add helper to estimate FIFO and largest endpoint MPS#94766

Open
jfischer-no wants to merge 6 commits intozephyrproject-rtos:mainfrom
jfischer-no:pr-udc-maximum-mps
Open

drivers: udc: add helper to estimate FIFO and largest endpoint MPS#94766
jfischer-no wants to merge 6 commits intozephyrproject-rtos:mainfrom
jfischer-no:pr-udc-maximum-mps

Conversation

@jfischer-no
Copy link
Copy Markdown
Contributor

To configure FIFOs properly, UDC controllers with internal endpoint FIFO
memory may require information such as the largest endpoint MPS, the
number of endpoints, and the estimated RX and TX FIFO sizes.

@jfischer-no jfischer-no self-assigned this Aug 20, 2025
@jfischer-no jfischer-no added area: Drivers area: USB Universal Serial Bus labels Aug 20, 2025
@sonarqubecloud
Copy link
Copy Markdown

* USB device controller endpoint status
*/
struct udc_ep_stat {
/** Endpoint is claimed */
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.

What does it mean that endpoint is claimed?

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.

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.

The commit does not explain what claimed means.

The stack uses the function to test the endpoint configuration, calling
it for any alternate settings. We could also use it to mark the endpoint
as claimed

What exactly does it mean that endpoint is claimed?

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.

It means that the stack "demands" it for use in a configuration. The driver can then determine which of its resources are being used.

Comment on lines +203 to +207
void udc_get_eps_fifo_size(const struct device *dev,
size_t *const rx_size,
size_t *const tx_size,
uint16_t *const out_mps,
uint16_t *const in_mps);
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.

rx_size and tx_size sounds way too specific. Why not just have the function populate 16-element array for OUT and 16-element array for IN endpoints? Then the driver could use that information according to actual hardware constraints.

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.

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.

Where exactly? Can you point exact lines?

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.

Exactly: It is stored for each endpoint in struct udc_ep_config, L119..L120

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions Bot added the Stale label Jan 19, 2026
@github-actions github-actions Bot closed this Feb 2, 2026
@jfischer-no jfischer-no reopened this Feb 4, 2026
@jfischer-no jfischer-no removed the Stale label Feb 4, 2026
If the stack passes a zero MPS value during initialization, there is a
function to update the bulk/interrupt endpoint MPS. This function is no
longer used in the tree and is a bit problematic because it does not
take supported speed into account.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
The stack uses the function to test the endpoint configuration, calling
it for any alternate settings. We could also use it to mark the endpoint
as claimed, determine the largest endpoint size, and store it in the
endpoint configuration. Rename it to udc_ep_claim_config().

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
To configure FIFOs properly, UDC controllers with internal endpoint FIFO
memory may require information such as the largest endpoint MPS, the
number of endpoints, and the estimated RX and TX FIFO sizes.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
To ensure that the alternate endpoint setting does not result in a
memory window that is too small being allocated and locked because a
higher FIFO is still in use, use the maximum MPS value for FIFO memory
allocation.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Check that the memory usage calculated by the stack does not exceed the
available DPRAM space for the interface endpoints.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Use largest OUT endpoint MPS and number of OUT endpoints to configure
RX FIFO based on the stack configuration.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Feb 5, 2026

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

@github-actions
Copy link
Copy Markdown

This pull request has been marked as stale because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 7 days. Note, that you can always re-open a closed pull request at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Drivers area: Tests Issues related to a particular existing or missing test area: USB Universal Serial Bus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants