All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen: always handle VIRQ_TIMER first.
@ 2010-10-15 10:52 Ian Campbell
  2010-10-15 17:18 ` Jeremy Fitzhardinge
  0 siblings, 1 reply; 10+ messages in thread
From: Ian Campbell @ 2010-10-15 10:52 UTC (permalink / raw)
  To: jeremy; +Cc: xen-devel, keir, Ian Campbell

This ensures that system is updated before calling any hard irq
handlers after a long period of ticklessness. If we do not do this
then hardirq will see a jiffies from before the period of ticklessness
and make intcorrect decisions regarding timer expiry etc.

This resolves issues e.g. with USB keyboard timer repeats.

Based on a patch by Keir Fraser.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: keir@xen.org
---
 drivers/xen/events.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index c9d1d4a..1496ba5 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -1052,6 +1052,7 @@ static void __xen_evtchn_do_upcall(struct pt_regs *regs)
 
 	do {
 		unsigned long pending_words;
+		int irq;
 
 		vcpu_info->evtchn_upcall_pending = 0;
 
@@ -1062,6 +1063,24 @@ static void __xen_evtchn_do_upcall(struct pt_regs *regs)
 		/* Clear master flag /before/ clearing selector flag. */
 		wmb();
 #endif
+
+		/*
+		 * Handle timer interrupts before all others, so that all
+		 * hardirq handlers see an up-to-date system time even if we
+		 * have just woken from a long idle period.
+		 */
+		irq = percpu_read(virq_to_irq[VIRQ_TIMER]);
+		if (irq != -1) {
+			int word_idx;
+			int bit_idx;
+			int port = evtchn_from_irq(irq);
+			word_idx = port / BITS_PER_LONG;
+			bit_idx = port % BITS_PER_LONG;
+			if (VALID_EVTCHN(port) &&
+			    (active_evtchns(cpu, s, word_idx) & (1UL<<bit_idx)))
+				(void)handle_irq(irq, regs);
+		}
+
 		pending_words = xchg(&vcpu_info->evtchn_pending_sel, 0);
 		while (pending_words != 0) {
 			unsigned long pending_bits;
@@ -1071,9 +1090,10 @@ static void __xen_evtchn_do_upcall(struct pt_regs *regs)
 			while ((pending_bits = active_evtchns(cpu, s, word_idx)) != 0) {
 				int bit_idx = __ffs(pending_bits);
 				int port = (word_idx * BITS_PER_LONG) + bit_idx;
-				int irq = evtchn_to_irq[port];
 				struct irq_desc *desc;
 
+				irq = evtchn_to_irq[port];
+
 				mask_evtchn(port);
 				clear_evtchn(port);
 
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-10-18 16:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-15 10:52 [PATCH] xen: always handle VIRQ_TIMER first Ian Campbell
2010-10-15 17:18 ` Jeremy Fitzhardinge
2010-10-15 18:30   ` Keir Fraser
2010-10-15 21:11     ` Jeremy Fitzhardinge
2010-10-16  6:48       ` Ian Campbell
2010-10-16  7:14       ` Keir Fraser
2010-10-17  6:11         ` Jeremy Fitzhardinge
2010-10-17  7:38           ` Keir Fraser
2010-10-18 13:20           ` Jan Beulich
2010-10-18 16:52             ` Jeremy Fitzhardinge

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.