Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[arm][gic] Ensure context switch doesn't happen from irq #276

Closed

Conversation

vishals4gh
Copy link
Contributor

Context switches should not happen from within the interrupt
context before interrupt is cleared by write to GIC EOIR register,
without it GIC will simply keep that interrupt active even if
the hardware source clears the interrupt to the gic, causing
subsequent irqs from the source to not get delivered to the CPU.

This change adds an assertion that context switch doesn't happen
from irq context before interrupt is EOIed. TCB field is added
to convey if the current thread has interrupt context active, if
so thread_resched should ideally not get called.

Signed-off-by: vannapurve [email protected]

/* Flag to indicate that interrupt
* context is active for the thread */
uint32_t intr_ctxt_active;

char name[32];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably this could have been better handled by per CPU interrupt state.

Copy link
Member

Choose a reason for hiding this comment

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

Also problematic is it is only implemented on ARM. For a new feature like this it really should be implemented on all of the architectures, at least if possible.

IIRC, there's an arch_in_interrupt_handler() routine that may be actually what you're looking for. Or at least having it be an arch_ routine that can be stubbed out by default if the arch doesn't want to implement it. I'm leery about adding state at the thread level.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, actually looks like the arch_in_int_handler() is only basically implemented on cortex-m, since the 'big arm' one implements it as a global bool which is clearly not SMP safe. Looks like might make sense to fix that first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Travis for the feedback, makes sense. I will try to upload something for all the archs, assuming no arch wants to allow context switching to happen between IRQ handling.

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

Successfully merging this pull request may close these issues.

2 participants