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

Merged
jepler merged 2 commits from spi-maskinterrupts-earlyout into master 2025-02-28 23:44:47 +03:00
jepler commented 2025-02-28 18:19:50 +03:00 (Migrated from github.com)

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` 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
earlephilhower (Migrated from github.com) reviewed 2025-02-28 18:29:25 +03:00
earlephilhower (Migrated from github.com) left a comment

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!

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 commented 2025-02-28 22:49:12 +03:00 (Migrated from github.com)

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

Thanks, I've tried to update the branch with the correct style.
earlephilhower (Migrated from github.com) approved these changes 2025-02-28 23:44:27 +03:00
earlephilhower (Migrated from github.com) left a comment

Third time's the charm. 😆

Third time's the charm. :laughing:
jepler commented 2025-03-06 02:58:36 +03:00 (Migrated from github.com)

thank you

thank you
Sign in to join this conversation.