Skip to content

Conversation

@bugadani
Copy link
Contributor

@bugadani bugadani commented Sep 17, 2023

Thank you!

Thank you for your contribution.
Please make sure that your submission includes the following:

Must

  • The code compiles without errors or warnings.
  • All examples work.
  • cargo fmt was run.
  • Your changes were added to the CHANGELOG.md in the proper section.
  • You updated existing examples or added examples (if applicable).
  • Added examples are checked in CI

Nice to have

  • You add a description of your work to this PR.
  • You added proper docs for your newly added features and code.

This PR optimizes the GPIO interrupt handler for devices that have multiple GPIO banks:

  • First commit is some cleanup, with the baseline of 105 instructions
  • Second commit removes two RSR instructions, 103
  • Third commit reduces instruction count to 95
  • Last commit removes the last RSR instruction for a final count of 94

Unfortunately it looks like get_core can't be optimized away by the compiler even if the read core ID isn't used, so I've removed the calls from the GPIO interrupt handler. If there is a way to make the compiler understand that RSR isn't supposed to be a volatile read, the log calls can be added back, but I don't consider this to be a big deal.

There is still an unnecessary bounds check (and panic) present in the generated code, because the compiler doesn't understand (even if masked) that the Bank1 interrupt status does not have more bits than NUM_PINS-32.

There's also a 16-byte stack reduction but I don't really know why.

@bugadani bugadani changed the title Optimize GPIO interrupt handler Remove unused Pin methods, optimize GPIO interrupt handler Sep 17, 2023
@bugadani bugadani marked this pull request as ready for review September 17, 2023 08:17
Copy link
Contributor

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

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

LGTM - Thanks

@bjoernQ bjoernQ merged commit 04a23f8 into esp-rs:main Sep 18, 2023
@bugadani bugadani deleted the gpio branch September 18, 2023 09:37
@bugadani
Copy link
Contributor Author

cc @MabezDev in case you are interested but missed this

SergioGasquez pushed a commit to SergioGasquez/esp-hal that referenced this pull request Sep 22, 2023
* Remove unused methods from Pin

* Avoid CPU ID lookup on S3

* Split up gpio handling into two loops

* Remove trace print

* Add changelog entries
playfulFence pushed a commit to playfulFence/esp-hal that referenced this pull request Sep 26, 2023
* Remove unused methods from Pin

* Avoid CPU ID lookup on S3

* Split up gpio handling into two loops

* Remove trace print

* Add changelog entries
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.

2 participants