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

Add check for max number of endpoints #20

Merged
merged 1 commit into from
Mar 28, 2024

Conversation

peter-marcisovsky
Copy link
Collaborator

@peter-marcisovsky peter-marcisovsky commented Feb 13, 2024

Change description

  • added check for opening and closing endpoints based on number of available endpoints on a target
  • check if an endpoint is available before opening it
  • release an endpoint once it is closed

closes espressif/esp-idf#13005

Copy link
Collaborator

@tore-espressif tore-espressif left a comment

Choose a reason for hiding this comment

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

@peter-marcisovsky Only 1 comment, I'll also check on HW

src/device/usbd.c Outdated Show resolved Hide resolved
src/device/usbd.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@roma-jam roma-jam left a comment

Choose a reason for hiding this comment

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

Sorry for such a delayed review.
One nitpick and one crucial point about the way, how we control the amount of opened EP.

src/portable/synopsys/dwc2/dcd_dwc2.c Outdated Show resolved Hide resolved
src/device/usbd.h Outdated Show resolved Hide resolved
@peter-marcisovsky peter-marcisovsky force-pushed the feature/check_max_endpoint_count branch 2 times, most recently from 4c24ffb to 3c141f2 Compare February 27, 2024 09:26
@roma-jam roma-jam self-requested a review February 27, 2024 15:23
Copy link
Collaborator

@roma-jam roma-jam left a comment

Choose a reason for hiding this comment

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

@peter-marcisovsky Thanks a lot! But I was just offered an approach, not suggest anything...

Yes, seems that right now the logic is more clearer, but again, I think that couple of things still could be done better.

One comment about general way.
As always, I am ready to discuss it anytime.

src/portable/synopsys/dwc2/dcd_dwc2.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@roma-jam roma-jam left a comment

Choose a reason for hiding this comment

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

Hey @peter-marcisovsky,

Sorry, probably I was not so clear in my previous review. I have tried to make more comments and suggestions about my idea and to be more concise.

Important thing: not to forget to decrease the dwc_ep_config[rhport].in_ep or dwc_ep_config[rhport].out_ep during dcd_edpt_close_all and dcd_edpt_close.

src/portable/synopsys/dwc2/dwc2_type.h Outdated Show resolved Hide resolved
src/portable/synopsys/dwc2/dwc2_esp32.h Outdated Show resolved Hide resolved
src/portable/synopsys/dwc2/dcd_dwc2.c Outdated Show resolved Hide resolved
src/portable/synopsys/dwc2/dcd_dwc2.c Outdated Show resolved Hide resolved
Dazza0
Dazza0 previously requested changes Mar 7, 2024
Copy link

@Dazza0 Dazza0 left a comment

Choose a reason for hiding this comment

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

@peter-marcisovsky Left some comments

src/portable/synopsys/dwc2/dcd_dwc2.c Outdated Show resolved Hide resolved
src/portable/synopsys/dwc2/dwc2_esp32.h Outdated Show resolved Hide resolved
src/portable/synopsys/dwc2/dwc2_esp32.h Outdated Show resolved Hide resolved
src/portable/synopsys/dwc2/dcd_dwc2.c Outdated Show resolved Hide resolved
@peter-marcisovsky peter-marcisovsky force-pushed the feature/check_max_endpoint_count branch 2 times, most recently from 30047cb to 6296166 Compare March 11, 2024 15:02
@peter-marcisovsky peter-marcisovsky force-pushed the feature/check_max_endpoint_count branch from 6296166 to 6cede67 Compare March 11, 2024 16:15
Copy link
Collaborator

@roma-jam roma-jam left a comment

Choose a reason for hiding this comment

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

Hey @peter-marcisovsky,
Basically, everything is great! Good job.

Just a couple of suggestion, how to make it better.
I have added several comments from my side.

Regarding those comments, we will have two tasks to complete:

  1. Eliminate or accept the fact that without debug it will be a silent fail inside the tud_task.
  2. Think about migrating to OUT_EP_NUM instead of having them here (in two different places actually: DWC2_FS_EP_MAX and TUP_DCD_ENDPOINT_MAX inside tusb_mcu.h)

But IMO it is better to do them as a separate MRs (jira for the first one I have already created).

src/portable/synopsys/dwc2/dcd_dwc2.c Outdated Show resolved Hide resolved
src/portable/synopsys/dwc2/dcd_dwc2.c Outdated Show resolved Hide resolved
src/portable/synopsys/dwc2/dcd_dwc2.c Show resolved Hide resolved
src/portable/synopsys/dwc2/dcd_dwc2.c Outdated Show resolved Hide resolved
@peter-marcisovsky
Copy link
Collaborator Author

@roma-jam thanks for another valuable suggestions. PTAL at the changes so I can squash the commits.
And, as you are saying, let's leave those two related tasks for another PRs.

@roma-jam roma-jam self-requested a review March 27, 2024 14:18
Copy link
Collaborator

@roma-jam roma-jam left a comment

Choose a reason for hiding this comment

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

@peter-marcisovsky Well done!
Please, squash the history.

Also, please update the PR description, according to the last changes (not macros but runtime EP verification an so on).

Otherwise, LGTM!

            - Check if endpoint is avaliable while opening it
            - Release endponint once is closed
@peter-marcisovsky peter-marcisovsky force-pushed the feature/check_max_endpoint_count branch from 9dadcc0 to 1b81220 Compare March 28, 2024 10:52
@roma-jam roma-jam dismissed Dazza0’s stale review March 28, 2024 19:55

All requests were resolved

@roma-jam roma-jam merged commit 9b30b6d into release/v0.15 Mar 28, 2024
TU_ASSERT(epnum < ep_count);
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32P4)
if (!dcd_edpt_available(rhport, dir)) {
TU_LOG(1, "No endpoints available (ep_max=%d) \r\n", dwc_ep_config[rhport].ep_max_count);
Copy link

Choose a reason for hiding this comment

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

Would have been good to make this an error, spent some time to figure out I ran out of endpoints as this 'silently' passes... Before there was an assert.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @bollenn,
Sorry for the inconveniences.

Actually, the whole idea of that MR was exactly as you have said: to display the message when there are no more EPs available.
Before, there was the assert, but the comparison itself was between wrong values, so the assert never worked, even in case when there no more vacant EPs available.

May I ask, why is was "silent" in your case? TU_LOG was configured to 0?

Copy link

Choose a reason for hiding this comment

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

Can't remember, LOG level to low or return value check missing and this log just passing by in between a lot of other logs...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants