Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dwc2: add endpoint allocation support. #2333

Merged
merged 4 commits into from
Mar 31, 2024
Merged

Conversation

HiFiPhile
Copy link
Collaborator

@HiFiPhile HiFiPhile commented Nov 21, 2023

Describe the PR
Add endpoint buffer allocation support, to avoid USB buffer alloc/free at runtime.

Currently something is wrong with runtime buffer size adjustment, after some endpoint close/open cycle there is a chance that the device stop transferring/receiving packets.

Also flush FIFO on bus reset, as incomplete iso transfers can cause some strange issues, seems flushing FIFO is a work around.

@@ -650,6 +658,108 @@ void dcd_edpt_close_all(uint8_t rhport) {
_allocated_fifo_words_tx = 16;
}

bool dcd_edpt_iso_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t largest_packet_size)
Copy link
Owner

Choose a reason for hiding this comment

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

we should refactor this to share code with dcd_edpt_open(), since it is quite a duplication. I can do it if you don't mind testing again :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes please do it.

@HiFiPhile
Copy link
Collaborator Author

For dcd_edpt_close_all(), shouldn't it stop pending transfer and flush FIFO, just like dcd_edpt_close() does ?

void dcd_edpt_close_all(uint8_t rhport) {

@HiFiPhile
Copy link
Collaborator Author

Refactor done, maybe you want to apply the new coding style.

Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

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

still haven't got time to test this out. I am off for TET holidays for a couple of weeks. Will try to review afterwards, thank you for your patient.

@HiFiPhile
Copy link
Collaborator Author

@kkitayam When you have time could you add ISO endpoint allocation support to UVC class ?

The idea is to avoid USB buffer alloc/free at runtime as it's hard to manage buffer on some devices.

It's pretty simple:


Currently the main problem is in dwc2 driver, something is wrong with runtime buffer size adjustment, after ISO endpoint closing there is a chance that the device stop transferring packets.

Packets have been acked but no interrupt fired:

image
image

dwc2.zip

@HiFiPhile
Copy link
Collaborator Author

@hathach Could you take a look of my pending PRs when you have some time ? Especially this one is necessary to make audio class running reliably.

@hathach
Copy link
Owner

hathach commented Mar 25, 2024

@hathach Could you take a look of my pending PRs when you have some time ? Especially this one is necessary to make audio class running reliably.

sorry, will review this asap.

Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

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

perfect, thank you. I rebased and make some minor clean up. It is good for the merge. Sorry for late review.

@hathach hathach merged commit 32743f1 into hathach:master Mar 31, 2024
49 checks passed
@HiFiPhile HiFiPhile deleted the dwc2_alloc branch April 1, 2024 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants