earlgrey: Properly ack flash operation done interrupt - #390
Open
jesultra wants to merge 1 commit into
Open
Conversation
|
|
In the blocking flash driver wait_for_notification(), clear the interrupt status on the flash IP before acking the interrupt with the PLIC. Before this change, the PLIC would re-latch the interrupt immediately after it being ack'ed, as the interrupt request was still active at the flash IP. As a result, next flash operation would erroneously be considered done immediately.
jesultra
force-pushed
the
blocking_flash
branch
from
August 5, 2026 10:14
ea33d2e to
83d5b6c
Compare
jesultra
marked this pull request as ready for review
August 5, 2026 11:31
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.
In the blocking flash driver wait_for_notification(), clear the interrupt status on the flash IP before acking the interrupt with the PLIC.
Before this change, the PLIC would re-latch the interrupt immediately after it being ack'ed, as the interrupt request was still active at the flash IP. As a result, next flash operation would erroneously be considered done immediately.
In this case of the flash controller, we were lucky that the interrupt status can be cleared without fully addressing the underlying cause. Had it been a UART input fifo non-empty, then we could not clear the interrupt from within
wait_for_notification(), so maybe we need to think about a more generic solution.The basic problem is that we can only call
syscall::interrupt_ack()AFTER the interrupt request from the relevant IP has been de-asserted, and for some IPs, that requires addressing the cause of the interrupt, such as emptying/filling FIFOs.We could break up the logic in
wait_for_notification(), such thatFlashCtrlInterruptwould have a new method, maybeack_notification(), and the convention would be that when handling an interrupt from a blocking thread, the sequence would be:That way, the
complete_op()gets a chance to address the source of interrupt, beforeack_notification()callssyscall::interrupt_ack().It may be risky to break it up like that, since any early exit from the function could lead to
ack_notification()not being called, in effect inhibiting the interrupt in question until next reset. Maybe instead some closure:This way,
handle_notificationwill wait for the notification, then call the closure in its argument, and finally ack the interrupt, no matter the return value from the closure. This comes at the cost of not adhering to theBlockingtrait anymore.I am not sure what will be the best "standard" way of handling interrupts that need non-trivial code to clear their status. This time, we were lucky that a single register write to the IP was sufficient.