xen: save previous spinlock when blocking
A spinlock can be interrupted while spinning, so make sure we preserve the previous lock of interest if we're taking a lock from within an interrupt handler. We also need to deal with the case where the blocking path gets interrupted between testing to see if the lock is free and actually blocking. If we get interrupted there and end up in the state where the lock is free but the irq isn't pending, then we'll block indefinitely in the hypervisor. This fix is to make sure that any nested lock-takers will always leave the irq pending if there's any chance the outer lock became free. Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Acked-by: Jan Beulich <jbeulich@novell.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
committed by
Ingo Molnar
parent
7708ad64a2
commit
168d2f464a
@@ -164,6 +164,12 @@ static inline void set_evtchn(int port)
|
||||
sync_set_bit(port, &s->evtchn_pending[0]);
|
||||
}
|
||||
|
||||
static inline int test_evtchn(int port)
|
||||
{
|
||||
struct shared_info *s = HYPERVISOR_shared_info;
|
||||
return sync_test_bit(port, &s->evtchn_pending[0]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* notify_remote_via_irq - send event to remote end of event channel via irq
|
||||
@@ -732,6 +738,25 @@ void xen_clear_irq_pending(int irq)
|
||||
clear_evtchn(evtchn);
|
||||
}
|
||||
|
||||
void xen_set_irq_pending(int irq)
|
||||
{
|
||||
int evtchn = evtchn_from_irq(irq);
|
||||
|
||||
if (VALID_EVTCHN(evtchn))
|
||||
set_evtchn(evtchn);
|
||||
}
|
||||
|
||||
bool xen_test_irq_pending(int irq)
|
||||
{
|
||||
int evtchn = evtchn_from_irq(irq);
|
||||
bool ret = false;
|
||||
|
||||
if (VALID_EVTCHN(evtchn))
|
||||
ret = test_evtchn(evtchn);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Poll waiting for an irq to become pending. In the usual case, the
|
||||
irq will be disabled so it won't deliver an interrupt. */
|
||||
void xen_poll_irq(int irq)
|
||||
|
Reference in New Issue
Block a user