Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/xen/xen Do not re-expose the innards of evtchn.c, n...
details: https://anonhg.NetBSD.org/src/rev/f23405ad1ef8
branches: trunk
changeset: 993921:f23405ad1ef8
user: cherry <cherry%NetBSD.org@localhost>
date: Wed Oct 10 03:54:54 2018 +0000
description:
Do not re-expose the innards of evtchn.c, now that we have a way
to register interrupts via intr.c:intr_establish_xname()
evtchn.c is going to get refactored soon, so use the latter method.
diffstat:
sys/arch/xen/xen/xenevt.c | 50 ++++++++++++++++++++++++++--------------------
1 files changed, 28 insertions(+), 22 deletions(-)
diffs (87 lines):
diff -r b122f005c63c -r f23405ad1ef8 sys/arch/xen/xen/xenevt.c
--- a/sys/arch/xen/xen/xenevt.c Wed Oct 10 02:34:08 2018 +0000
+++ b/sys/arch/xen/xen/xenevt.c Wed Oct 10 03:54:54 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xenevt.c,v 1.48 2017/11/30 20:25:54 christos Exp $ */
+/* $NetBSD: xenevt.c,v 1.49 2018/10/10 03:54:54 cherry Exp $ */
/*
* Copyright (c) 2005 Manuel Bouyer.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.48 2017/11/30 20:25:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.49 2018/10/10 03:54:54 cherry Exp $");
#include "opt_xen.h"
#include <sys/param.h>
@@ -145,15 +145,28 @@
long xenevt_ev2[NR_EVENT_CHANNELS];
static int xenevt_processevt(void *);
+static evtchn_port_t xenevt_alloc_event(void)
+{
+ evtchn_op_t op;
+ op.cmd = EVTCHNOP_alloc_unbound;
+ op.u.alloc_unbound.dom = DOMID_SELF;
+ op.u.alloc_unbound.remote_dom = DOMID_SELF;
+ if (HYPERVISOR_event_channel_op(&op) != 0)
+ panic("%s: Failed to allocate loopback event\n", __func__);
+
+ return op.u.alloc_unbound.port;
+}
+
/* called at boot time */
void
xenevtattach(int n)
{
struct intrhand *ih;
- int s;
int level = IPL_HIGH;
#ifdef MULTIPROCESSOR
bool mpsafe = (level != IPL_VM);
+#else
+ bool mpsafe = false;
#endif /* MULTIPROCESSOR */
mutex_init(&devevent_lock, MUTEX_DEFAULT, IPL_HIGH);
@@ -165,26 +178,19 @@
xenevt_ev1 = 0;
memset(xenevt_ev2, 0, sizeof(xenevt_ev2));
- /* register a handler at splhigh, so that spllower() will call us */
- ih = malloc(sizeof (struct intrhand), M_DEVBUF,
- M_WAITOK|M_ZERO);
- if (ih == NULL)
- panic("can't allocate xenevt interrupt source");
- ih->ih_level = level;
- ih->ih_fun = ih->ih_realfun = xenevt_processevt;
- ih->ih_arg = ih->ih_realarg = NULL;
- ih->ih_next = NULL;
- ih->ih_cpu = &cpu_info_primary;
-#ifdef MULTIPROCESSOR
- if (!mpsafe) {
- ih->ih_fun = xen_intr_biglock_wrapper;
- ih->ih_arg = ih;
- }
-#endif /* MULTIPROCESSOR */
+ /*
+ * Allocate a loopback event port.
+ * This helps us massage xenevt_processevt() into the
+ * callchain at the appropriate level using only
+ * intr_establish_xname().
+ */
+ evtchn_port_t evtchn = xenevt_alloc_event();
- s = splhigh();
- event_set_iplhandler(ih->ih_cpu, ih, level);
- splx(s);
+ /* The real objective here is to wiggle into the ih callchain for IPL level */
+ ih = intr_establish_xname(0, &xen_pic, evtchn, IST_LEVEL, level,
+ xenevt_processevt, NULL, mpsafe, "xenevt");
+
+ KASSERT(ih != NULL);
}
/* register pending event - always called with interrupt disabled */
Home |
Main Index |
Thread Index |
Old Index