VIRQ_TIMER virqs are allocated and tracked in a array

(virq_timer_to_evtch, indexed by cpuid) different from the
VIRQ <> event channel one (virq_to_evtch, indexed by event channel ID).

This is fine: fix a "harmless" bug that resulted in the event
channel of VIRQ_TIMER getting lost during bind as it was not stored
in the proper array.

"Harmless" because it is not critical for -current, however in the Xen
save/restore branch this completely cripples restore. Xen clock gets
suspended, but never comes back (fetched channel ID being invalid). Oops.

Add a small comment so we can better see the "get => allocate? => set"
chain of actions when binding/unbinding event channels.
This commit is contained in:
jym 2011-08-28 22:55:52 +00:00
parent 4128291e47
commit cb1f14140c

View File

@ -1,4 +1,4 @@
/* $NetBSD: evtchn.c,v 1.52 2011/08/28 22:36:17 jym Exp $ */
/* $NetBSD: evtchn.c,v 1.53 2011/08/28 22:55:52 jym Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@ -54,7 +54,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.52 2011/08/28 22:36:17 jym Exp $");
__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.53 2011/08/28 22:55:52 jym Exp $");
#include "opt_xen.h"
#include "isa.h"
@ -379,6 +379,7 @@ bind_virq_to_evtch(int virq)
return -1;
}
/* Get event channel from VIRQ */
if (virq == VIRQ_TIMER) {
evtchn = virq_timer_to_evtch[ci->ci_cpuid];
} else {
@ -393,7 +394,12 @@ bind_virq_to_evtch(int virq)
if (HYPERVISOR_event_channel_op(&op) != 0)
panic("Failed to bind virtual IRQ %d\n", virq);
evtchn = op.u.bind_virq.port;
}
/* Set event channel */
if (virq == VIRQ_TIMER) {
virq_timer_to_evtch[ci->ci_cpuid] = evtchn;
} else {
virq_to_evtch[virq] = evtchn;
}