aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy@goop.org>2008-08-20 20:02:18 -0400
committerIngo Molnar <mingo@elte.hu>2008-08-21 07:52:57 -0400
commit168d2f464ab9860f0d1e66cf1f9684973222f1c6 (patch)
treec3a4199cf2aa4c6322b7860c431fd5bfdc4220ef /drivers/xen
parent7708ad64a24a674f7905aa7a5099a50f055debec (diff)
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>
Diffstat (limited to 'drivers/xen')
-rw-r--r--drivers/xen/events.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index a0837036d898..b6c2b8f16bee 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -164,6 +164,12 @@ static inline void set_evtchn(int port)
164 sync_set_bit(port, &s->evtchn_pending[0]); 164 sync_set_bit(port, &s->evtchn_pending[0]);
165} 165}
166 166
167static inline int test_evtchn(int port)
168{
169 struct shared_info *s = HYPERVISOR_shared_info;
170 return sync_test_bit(port, &s->evtchn_pending[0]);
171}
172
167 173
168/** 174/**
169 * notify_remote_via_irq - send event to remote end of event channel via irq 175 * 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)
732 clear_evtchn(evtchn); 738 clear_evtchn(evtchn);
733} 739}
734 740
741void xen_set_irq_pending(int irq)
742{
743 int evtchn = evtchn_from_irq(irq);
744
745 if (VALID_EVTCHN(evtchn))
746 set_evtchn(evtchn);
747}
748
749bool xen_test_irq_pending(int irq)
750{
751 int evtchn = evtchn_from_irq(irq);
752 bool ret = false;
753
754 if (VALID_EVTCHN(evtchn))
755 ret = test_evtchn(evtchn);
756
757 return ret;
758}
759
735/* Poll waiting for an irq to become pending. In the usual case, the 760/* Poll waiting for an irq to become pending. In the usual case, the
736 irq will be disabled so it won't deliver an interrupt. */ 761 irq will be disabled so it won't deliver an interrupt. */
737void xen_poll_irq(int irq) 762void xen_poll_irq(int irq)