fix(i2c_master): yield from ISR when no matching device is found (IDFGH-17648)#18569
Open
DatanoiseTV wants to merge 1 commit into
Open
fix(i2c_master): yield from ISR when no matching device is found (IDFGH-17648)#18569DatanoiseTV wants to merge 1 commit into
DatanoiseTV wants to merge 1 commit into
Conversation
`i2c_master_isr_handler_default()` may set HPTaskAwoken to pdTRUE via `xQueueSendFromISR()` (event_queue), `xSemaphoreTakeFromISR()` and `xSemaphoreGiveFromISR()` on `bus_lock_mux`. When the device list lookup returns no matching device, the function returned directly, skipping the `portYIELD_FROM_ISR()` at the bottom of the handler. A higher- priority task waiting on the bus mux or the event queue would then have to wait for the next scheduler tick instead of being preempted into immediately, inflating worst-case event latency. Replace the early return with a goto to the existing yield check at the end of the ISR.
Collaborator
|
sha=0f0d7a758ee3f591515e5cd9173a78236490452b |
espressif-bot
pushed a commit
that referenced
this pull request
May 14, 2026
`i2c_master_isr_handler_default()` may set HPTaskAwoken to pdTRUE via `xQueueSendFromISR()` (event_queue), `xSemaphoreTakeFromISR()` and `xSemaphoreGiveFromISR()` on `bus_lock_mux`. When the device list lookup returns no matching device, the function returned directly, skipping the `portYIELD_FROM_ISR()` at the bottom of the handler. A higher- priority task waiting on the bus mux or the event queue would then have to wait for the next scheduler tick instead of being preempted into immediately, inflating worst-case event latency. Replace the early return with a goto to the existing yield check at the end of the ISR. Merges #18569
espressif-bot
pushed a commit
that referenced
this pull request
May 29, 2026
`i2c_master_isr_handler_default()` may set HPTaskAwoken to pdTRUE via `xQueueSendFromISR()` (event_queue), `xSemaphoreTakeFromISR()` and `xSemaphoreGiveFromISR()` on `bus_lock_mux`. When the device list lookup returns no matching device, the function returned directly, skipping the `portYIELD_FROM_ISR()` at the bottom of the handler. A higher- priority task waiting on the bus mux or the event queue would then have to wait for the next scheduler tick instead of being preempted into immediately, inflating worst-case event latency. Replace the early return with a goto to the existing yield check at the end of the ISR. Merges #18569
espressif-bot
pushed a commit
that referenced
this pull request
Jun 1, 2026
`i2c_master_isr_handler_default()` may set HPTaskAwoken to pdTRUE via `xQueueSendFromISR()` (event_queue), `xSemaphoreTakeFromISR()` and `xSemaphoreGiveFromISR()` on `bus_lock_mux`. When the device list lookup returns no matching device, the function returned directly, skipping the `portYIELD_FROM_ISR()` at the bottom of the handler. A higher- priority task waiting on the bus mux or the event queue would then have to wait for the next scheduler tick instead of being preempted into immediately, inflating worst-case event latency. Replace the early return with a goto to the existing yield check at the end of the ISR. Merges #18569
espressif-bot
pushed a commit
that referenced
this pull request
Jun 2, 2026
`i2c_master_isr_handler_default()` may set HPTaskAwoken to pdTRUE via `xQueueSendFromISR()` (event_queue), `xSemaphoreTakeFromISR()` and `xSemaphoreGiveFromISR()` on `bus_lock_mux`. When the device list lookup returns no matching device, the function returned directly, skipping the `portYIELD_FROM_ISR()` at the bottom of the handler. A higher- priority task waiting on the bus mux or the event queue would then have to wait for the next scheduler tick instead of being preempted into immediately, inflating worst-case event latency. Replace the early return with a goto to the existing yield check at the end of the ISR. Merges #18569
espressif-bot
pushed a commit
that referenced
this pull request
Jun 2, 2026
`i2c_master_isr_handler_default()` may set HPTaskAwoken to pdTRUE via `xQueueSendFromISR()` (event_queue), `xSemaphoreTakeFromISR()` and `xSemaphoreGiveFromISR()` on `bus_lock_mux`. When the device list lookup returns no matching device, the function returned directly, skipping the `portYIELD_FROM_ISR()` at the bottom of the handler. A higher- priority task waiting on the bus mux or the event queue would then have to wait for the next scheduler tick instead of being preempted into immediately, inflating worst-case event latency. Replace the early return with a goto to the existing yield check at the end of the ISR. Merges #18569
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.
Summary
i2c_master_isr_handler_default()may setHPTaskAwokentopdTRUEthrough the FromISR primitives it calls earlier in the handler:
xQueueSendFromISR(i2c_master->event_queue, ...)near the top of thehandler when an event needs to be reported,
xSemaphoreTakeFromISR(i2c_master->bus_lock_mux, ...)/xSemaphoreGiveFromISR(i2c_master->bus_lock_mux, ...)around thedevice-list lookup in the
async_transbranch.When the device-list lookup at lines 822-828 fails to find a device
matching
i2c_trans.device_address, the handler took an earlyreturn;at line 830, skipping theportYIELD_FROM_ISR()at thebottom of the function. A higher-priority task waiting on the bus
lock or on the event queue would therefore have to wait for the next
scheduler tick instead of being preempted into immediately, inflating
worst-case event latency on this path.
Fix
Replace the early
returnwith agoto outto the existing yieldcheck at the end of the ISR. Behavior is otherwise unchanged.
Reproduction
The path is exercised whenever an interrupt fires for a transaction
whose configured device is no longer present in the device list (for
example after
i2c_master_bus_rm_device()removes a device while atransaction is in flight, or under fault conditions where the address
in
i2c_transdoesn't match any registered handle). The fix is acorrectness improvement on a latency-critical path; behavior is
verifiable by tracing the
out:path with an instrumented build.Test plan
master.components/esp_driver_i2c/test_apps/i2c_test_appsregression suite continues to pass on supported targets.