Skip to content
New issue

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

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

Already on GitHub? # to your account

early out of (un)maskInterrupts() if no GPIO interrupts need to be masked #2831

Merged

Conversation

jepler
Copy link
Contributor

@jepler jepler commented Feb 28, 2025

My application is designed to generate HSTX data on core0 in interrupts, but also uses hardware SPI for SD card access.

It turns out that the amount of time spent in maskInterrupts/unmaskInterrupts with interrupts disabled, even with an empty _usingIRQs, is too long.

Add a quick check and avoid touching the interrupt disable flag if there's not actually any GPIO interrupt to (un)mask.

@ladyada this fixes the hstx video glitches during SPI SD card access

My application is designed to generate HSTX data on core0 in interrupts,
but also uses hardware SPI for SD card access.

It turns out that the amount of time spent in maskInterrupts/
unmaskInterrupts, even with an empty _usingIRQs, is too long.

Add a quick check and avoid touching the interrupt disable flag if
there's not actually any GPIO interrupt to (un)mask.
Copy link
Owner

@earlephilhower earlephilhower left a comment

Choose a reason for hiding this comment

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

Wow, that's tight timing. I wonder if the STL is doing actual memory allocations/etc. in the for (auto x: y) iteration even with an empty list...

You'll need to adjust formatting using tools/restyle.sh or just manually indent/format the new short-circuit path to get through CI.

-edit- update formatting -edit-

 if (_usingIRQs.empty()) {
    return;
}

OTW, LGTM!

@jepler
Copy link
Contributor Author

jepler commented Feb 28, 2025

Thanks, I've tried to update the branch with the correct style.

@jepler jepler force-pushed the spi-maskinterrupts-earlyout branch from e95fac5 to 66d8fa1 Compare February 28, 2025 20:12
Copy link
Owner

@earlephilhower earlephilhower left a comment

Choose a reason for hiding this comment

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

Third time's the charm. 😆

@earlephilhower earlephilhower merged commit 46a58fb into earlephilhower:master Feb 28, 2025
26 checks passed
@jepler
Copy link
Contributor Author

jepler commented Mar 5, 2025

thank you

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

Successfully merging this pull request may close these issues.

2 participants