phy: make the PHY I2C critical section nesting safe - #74
Merged
Merged
Conversation
The blob nests phy_i2c_enter_critical, but the old PS was kept in one static value. The inner call saved INTLEVEL 3 over the outer value, so PS stayed at INTLEVEL 3 after BLE init. This blocked all level 1 interrupts, for example GPIO and I2S, on programs that use BLE without WiFi. Now only the outer pair saves and restores PS. Tested on a xiao-esp32s3. PS is at INTLEVEL 0 after BLE init, the I2S interrupt runs while BLE advertises, and WiFi scans still work. The same change for the classic ESP32 builds but is not tested on hardware. Signed-off-by: deadprogram <ron@hybridgroup.com>
Member
Author
|
Any feedback before merge here? |
Member
Author
|
Merging since hardware testing shows it is quite needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes PS being left at INTLEVEL 3 after BLE init on the ESP32-S3 and the classic ESP32.
The blob nests
phy_i2c_enter_critical. The old PS was kept in one static value, so the inner call saved INTLEVEL 3 over the outer value. When both calls exited, PS stayed at INTLEVEL 3, and that blocked all level 1 interrupts, for example GPIO and I2S. WiFi hid the bug, becauseespradio_wifi_unmasklowers INTLEVEL on each pass. A program that uses BLE without WiFi never got those interrupts again.Now only the outer enter and exit pair saves and restores PS.
Testing on a xiao-esp32s3
This has been tested on actual hardware, which is correction from the original description.