Commit bf1038cf authored by Jan Kiszka's avatar Jan Kiszka Committed by Philippe Gerum
Browse files

irq_pipeline: Clean up stage_info field and users



This field represents mutually exclusive states, namely

- IRQENTRY_INBAND_UNSTALLED
- IRQENTRY_INBAND_STALLED
- IRQENTRY_OOB

Encodes them as enum and test against them, rather than against state
bits that suggest they could be combined.

Also flip the inverted naming of INBAND_STALLED vs. INBAND_UNSTALLED:
Only when we entered under INBAND_UNSTALLED, certain actions need to be
taken on exit.

Finally, document the stage_info field of irqentry_state.
Signed-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
parent 281d47f0
......@@ -64,7 +64,7 @@ static irqentry_state_t pipeline_enter_rcu(void)
{
irqentry_state_t state = {
.exit_rcu = false,
.stage_info = 0,
.stage_info = IRQENTRY_INBAND_UNSTALLED,
};
if (!IS_ENABLED(CONFIG_TINY_RCU) && is_idle_task(current)) {
......@@ -202,6 +202,7 @@ static void do_sysvec_inband(struct irq_desc *desc, struct pt_regs *regs)
static void do_irq_inband(struct pt_regs *regs, u32 irq)
{
struct irq_desc *desc = irq_to_desc(irq);
desc->handle_irq(desc);
......
......@@ -813,7 +813,7 @@ static inline void cond_reenable_irqs_kernel(irqentry_state_t state,
struct pt_regs *regs)
{
if (regs->flags & X86_EFLAGS_IF) {
if (state.stage_info & IRQENTRY_INBAND_STALLED)
if (state.stage_info == IRQENTRY_INBAND_UNSTALLED)
unstall_inband_nocheck();
hard_local_irq_enable();
}
......
......@@ -399,6 +399,12 @@ void irqentry_enter_from_user_mode(struct pt_regs *regs);
*/
void irqentry_exit_to_user_mode(struct pt_regs *regs);
enum irqentry_info {
IRQENTRY_INBAND_UNSTALLED = 0,
IRQENTRY_INBAND_STALLED,
IRQENTRY_OOB,
};
#ifndef irqentry_state
/**
* struct irqentry_state - Opaque object for exception state storage
......@@ -406,6 +412,7 @@ void irqentry_exit_to_user_mode(struct pt_regs *regs);
* exit path has to invoke rcu_irq_exit().
* @lockdep: Used exclusively in the irqentry_nmi_*() calls; ensures that
* lockdep state is restored correctly on exit from nmi.
* @stage_info: Information about pipeline state and current stage on IRQ entry.
*
* This opaque object is filled in by the irqentry_*_enter() functions and
* must be passed back into the corresponding irqentry_*_exit() functions
......@@ -421,9 +428,7 @@ typedef struct irqentry_state {
bool lockdep;
};
#ifdef CONFIG_IRQ_PIPELINE
#define IRQENTRY_INBAND_STALLED BIT(0)
#define IRQENTRY_OOB_ENTRY BIT(1)
int stage_info;
enum irqentry_info stage_info;
#endif
} irqentry_state_t;
#endif
......
......@@ -404,13 +404,13 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs)
irqentry_state_t ret = {
.exit_rcu = false,
#ifdef CONFIG_IRQ_PIPELINE
.stage_info = 0,
.stage_info = IRQENTRY_INBAND_STALLED,
#endif
};
#ifdef CONFIG_IRQ_PIPELINE
if (running_oob()) {
ret.stage_info = IRQENTRY_OOB_ENTRY;
ret.stage_info = IRQENTRY_OOB;
return ret;
}
#endif
......@@ -419,7 +419,7 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs)
#ifdef CONFIG_IRQ_PIPELINE
WARN_ON_ONCE(irq_pipeline_debug() && irqs_disabled());
stall_inband_nocheck();
ret.stage_info = IRQENTRY_INBAND_STALLED;
ret.stage_info = IRQENTRY_INBAND_UNSTALLED;
#endif
irqentry_enter_from_user_mode(regs);
return ret;
......@@ -432,7 +432,7 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs)
* irqs are off on entry, we have to stall the in-band stage.
*/
if (!test_and_stall_inband_nocheck())
ret.stage_info = IRQENTRY_INBAND_STALLED;
ret.stage_info = IRQENTRY_INBAND_UNSTALLED;
#endif
/*
......@@ -510,7 +510,7 @@ static inline
bool irqexit_may_preempt_schedule(irqentry_state_t state,
struct pt_regs *regs)
{
return !!(state.stage_info & IRQENTRY_INBAND_STALLED);
return state.stage_info == IRQENTRY_INBAND_UNSTALLED;
}
#else
......@@ -579,7 +579,7 @@ noinstr void irqentry_exit(struct pt_regs *regs, irqentry_state_t state)
* irqentry_enter() raised it in order to mirror the hardware
* state.
*/
if (state.stage_info & IRQENTRY_INBAND_STALLED)
if (state.stage_info == IRQENTRY_INBAND_UNSTALLED)
unstall_inband();
#endif
return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment