Module Name: src
Committed By: cherry
Date: Mon Nov 6 15:27:09 UTC 2017
Modified Files:
src/sys/arch/xen/x86: xen_ipi.c
src/sys/arch/xen/xen: clock.c if_xennet_xenbus.c xbd_xenbus.c
xbdback_xenbus.c xencons.c xennetback_xenbus.c
src/sys/arch/xen/xenbus: xenbus_comms.c
Log Message:
Switch XEN drivers to use intr_establish_xname()/intr_disestablish()
This completes the API transition.
To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/xen/x86/xen_ipi.c
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/xen/xen/clock.c
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/xen/xen/if_xennet_xenbus.c
cvs rdiff -u -r1.76 -r1.77 src/sys/arch/xen/xen/xbd_xenbus.c
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/xen/xen/xbdback_xenbus.c
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/xen/xen/xencons.c
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/xen/xen/xennetback_xenbus.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/xen/xenbus/xenbus_comms.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/xen/x86/xen_ipi.c
diff -u src/sys/arch/xen/x86/xen_ipi.c:1.22 src/sys/arch/xen/x86/xen_ipi.c:1.23
--- src/sys/arch/xen/x86/xen_ipi.c:1.22 Tue Aug 15 09:16:59 2017
+++ src/sys/arch/xen/x86/xen_ipi.c Mon Nov 6 15:27:09 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: xen_ipi.c,v 1.22 2017/08/15 09:16:59 maxv Exp $ */
+/* $NetBSD: xen_ipi.c,v 1.23 2017/11/06 15:27:09 cherry Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -33,10 +33,10 @@
/*
* Based on: x86/ipi.c
- * __KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.22 2017/08/15 09:16:59 maxv Exp $");
+ * __KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.23 2017/11/06 15:27:09 cherry Exp $");
*/
-__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.22 2017/08/15 09:16:59 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.23 2017/11/06 15:27:09 cherry Exp $");
#include <sys/types.h>
@@ -78,12 +78,17 @@ static void (*ipifunc[XEN_NIPIS])(struct
xen_ipi_generic,
};
-static void
-xen_ipi_handler(struct cpu_info *ci, struct intrframe *regs)
+static int
+xen_ipi_handler(void *arg)
{
uint32_t pending;
int bit;
+ struct cpu_info *ci;
+ struct intrframe *regs;
+ ci = curcpu();
+ regs = arg;
+
pending = atomic_swap_32(&ci->ci_ipis, 0);
KDASSERT((pending >> XEN_NIPIS) == 0);
@@ -98,6 +103,8 @@ xen_ipi_handler(struct cpu_info *ci, str
/* NOTREACHED */
}
}
+
+ return 0;
}
/* Must be called once for every cpu that expects to send/recv ipis */
@@ -118,9 +125,9 @@ xen_ipi_init(void)
KASSERT(evtchn != -1 && evtchn < NR_EVENT_CHANNELS);
- if (0 != event_set_handler(evtchn, (int (*)(void *))xen_ipi_handler,
- ci, IPL_HIGH, "ipi")) {
- panic("event_set_handler(...) KPI violation\n");
+ if(intr_establish_xname(0, &xen_pic, evtchn, IST_LEVEL, IPL_HIGH,
+ xen_ipi_handler, ci, true, "ipi") == NULL) {
+ panic("%s: unable to register ipi handler\n", __func__);
/* NOTREACHED */
}
Index: src/sys/arch/xen/xen/clock.c
diff -u src/sys/arch/xen/xen/clock.c:1.64 src/sys/arch/xen/xen/clock.c:1.65
--- src/sys/arch/xen/xen/clock.c:1.64 Sun Jun 12 09:08:09 2016
+++ src/sys/arch/xen/xen/clock.c Mon Nov 6 15:27:09 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: clock.c,v 1.64 2016/06/12 09:08:09 jnemeth Exp $ */
+/* $NetBSD: clock.c,v 1.65 2017/11/06 15:27:09 cherry Exp $ */
/*
*
@@ -29,7 +29,7 @@
#include "opt_xen.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.64 2016/06/12 09:08:09 jnemeth Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.65 2017/11/06 15:27:09 cherry Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -49,7 +49,8 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.
#include <dev/clock_subr.h>
#include <x86/rtc.h>
-static int xen_timer_handler(void *, struct intrframe *);
+static int xen_timer_handler(void *);
+static struct intrhand *ih;
/* A timecounter: Xen system_time extrapolated with a TSC. */
u_int xen_get_timecount(struct timecounter*);
@@ -509,7 +510,7 @@ xen_suspendclocks(struct cpu_info *ci)
KASSERT(evtch != -1);
hypervisor_mask_event(evtch);
- event_remove_handler(evtch, (int (*)(void *))xen_timer_handler, ci);
+ intr_disestablish(ih);
aprint_verbose("Xen clock: removed event channel %d\n", evtch);
}
@@ -522,8 +523,11 @@ xen_resumeclocks(struct cpu_info *ci)
evtch = bind_virq_to_evtch(VIRQ_TIMER);
KASSERT(evtch != -1);
- event_set_handler(evtch, (int (*)(void *))xen_timer_handler,
- ci, IPL_CLOCK, "clock");
+ ih = intr_establish_xname(0, &xen_pic, evtch, IST_LEVEL, IPL_CLOCK,
+ xen_timer_handler, ci, true, "clock");
+
+ KASSERT(ih != NULL);
+
hypervisor_enable_event(evtch);
aprint_verbose("Xen clock: using event channel %d\n", evtch);
@@ -531,11 +535,12 @@ xen_resumeclocks(struct cpu_info *ci)
/* ARGSUSED */
static int
-xen_timer_handler(void *arg, struct intrframe *regs)
+xen_timer_handler(void *arg)
{
int64_t delta;
struct cpu_info *ci = curcpu();
- KASSERT(arg == ci);
+ struct intrframe *regs = arg;
+
int err;
again:
mutex_enter(&tmutex);
Index: src/sys/arch/xen/xen/if_xennet_xenbus.c
diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.71 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.72
--- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.71 Wed Aug 30 16:01:55 2017
+++ src/sys/arch/xen/xen/if_xennet_xenbus.c Mon Nov 6 15:27:09 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: if_xennet_xenbus.c,v 1.71 2017/08/30 16:01:55 maxv Exp $ */
+/* $NetBSD: if_xennet_xenbus.c,v 1.72 2017/11/06 15:27:09 cherry Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -84,7 +84,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.71 2017/08/30 16:01:55 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.72 2017/11/06 15:27:09 cherry Exp $");
#include "opt_xen.h"
#include "opt_nfs_boot.h"
@@ -181,7 +181,8 @@ struct xennet_xenbus_softc {
unsigned int sc_evtchn;
void *sc_softintr;
-
+ struct intrhand *sc_ih;
+
grant_ref_t sc_tx_ring_gntref;
grant_ref_t sc_rx_ring_gntref;
@@ -422,7 +423,7 @@ xennet_xenbus_detach(device_t self, int
DPRINTF(("%s: xennet_xenbus_detach\n", device_xname(self)));
s0 = splnet();
xennet_stop(ifp, 1);
- event_remove_handler(sc->sc_evtchn, &xennet_handler, sc);
+ intr_disestablish(sc->sc_ih);
/* wait for pending TX to complete, and collect pending RX packets */
xennet_handler(sc);
while (sc->sc_tx_ring.sring->rsp_prod != sc->sc_tx_ring.rsp_cons) {
@@ -513,8 +514,9 @@ xennet_xenbus_resume(device_t dev, const
goto abort_resume;
aprint_verbose_dev(dev, "using event channel %d\n",
sc->sc_evtchn);
- event_set_handler(sc->sc_evtchn, &xennet_handler, sc,
- IPL_NET, device_xname(dev));
+ sc->sc_ih = intr_establish_xname(0, &xen_pic, sc->sc_evtchn, IST_LEVEL, IPL_NET,
+ &xennet_handler, sc, true, device_xname(dev));
+ KASSERT(sc->sc_ih != NULL);
return true;
abort_resume:
@@ -635,7 +637,7 @@ xennet_xenbus_suspend(device_t dev, cons
*/
sc->sc_backend_status = BEST_SUSPENDED;
- event_remove_handler(sc->sc_evtchn, &xennet_handler, sc);
+ intr_disestablish(sc->sc_ih);
splx(s);
Index: src/sys/arch/xen/xen/xbd_xenbus.c
diff -u src/sys/arch/xen/xen/xbd_xenbus.c:1.76 src/sys/arch/xen/xen/xbd_xenbus.c:1.77
--- src/sys/arch/xen/xen/xbd_xenbus.c:1.76 Sun Mar 5 23:07:12 2017
+++ src/sys/arch/xen/xen/xbd_xenbus.c Mon Nov 6 15:27:09 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: xbd_xenbus.c,v 1.76 2017/03/05 23:07:12 mlelstv Exp $ */
+/* $NetBSD: xbd_xenbus.c,v 1.77 2017/11/06 15:27:09 cherry Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.76 2017/03/05 23:07:12 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.77 2017/11/06 15:27:09 cherry Exp $");
#include "opt_xen.h"
@@ -123,6 +123,8 @@ struct xbd_xenbus_softc {
struct dk_softc sc_dksc; /* Must be first in this struct */
struct xenbus_device *sc_xbusd;
+ struct intrhand *sc_ih; /* Interrupt handler for this instance. */
+
blkif_front_ring_t sc_ring;
unsigned int sc_evtchn;
@@ -368,7 +370,8 @@ xbd_xenbus_detach(device_t dev, int flag
}
hypervisor_mask_event(sc->sc_evtchn);
- event_remove_handler(sc->sc_evtchn, &xbd_handler, sc);
+ intr_disestablish(sc->sc_ih);
+
while (xengnt_status(sc->sc_ring_gntref)) {
tsleep(xbd_xenbus_detach, PRIBIO, "xbd_ref", hz/2);
}
@@ -397,7 +400,7 @@ xbd_xenbus_suspend(device_t dev, const p
hypervisor_mask_event(sc->sc_evtchn);
sc->sc_backend_status = BLKIF_STATE_SUSPENDED;
- event_remove_handler(sc->sc_evtchn, xbd_handler, sc);
+ intr_disestablish(sc->sc_ih);
splx(s);
@@ -449,8 +452,9 @@ xbd_xenbus_resume(device_t dev, const pm
aprint_verbose_dev(dev, "using event channel %d\n",
sc->sc_evtchn);
- event_set_handler(sc->sc_evtchn, &xbd_handler, sc,
- IPL_BIO, device_xname(dev));
+ sc->sc_ih = intr_establish_xname(0, &xen_pic, sc->sc_evtchn, IST_LEVEL, IPL_BIO, &xbd_handler, sc, true, "clock");
+
+ KASSERT(sc->sc_ih != NULL);
again:
xbt = xenbus_transaction_start();
Index: src/sys/arch/xen/xen/xbdback_xenbus.c
diff -u src/sys/arch/xen/xen/xbdback_xenbus.c:1.63 src/sys/arch/xen/xen/xbdback_xenbus.c:1.64
--- src/sys/arch/xen/xen/xbdback_xenbus.c:1.63 Mon Dec 26 08:16:28 2016
+++ src/sys/arch/xen/xen/xbdback_xenbus.c Mon Nov 6 15:27:09 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: xbdback_xenbus.c,v 1.63 2016/12/26 08:16:28 skrll Exp $ */
+/* $NetBSD: xbdback_xenbus.c,v 1.64 2017/11/06 15:27:09 cherry Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.63 2016/12/26 08:16:28 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.64 2017/11/06 15:27:09 cherry Exp $");
#include <sys/atomic.h>
#include <sys/buf.h>
@@ -170,6 +170,7 @@ struct xbdback_instance {
bool xbdi_ro; /* is device read-only ? */
/* parameters for the communication */
unsigned int xbdi_evtchn;
+ struct intrhand *xbdi_ih;
/* private parameters for communication */
blkif_back_ring_proto_t xbdi_ring;
enum xbdi_proto xbdi_proto;
@@ -636,8 +637,9 @@ xbdback_connect(struct xbdback_instance
XENPRINTF(("xbdback %s: connect evchannel %d\n", xbusd->xbusd_path, xbdi->xbdi_evtchn));
xbdi->xbdi_evtchn = evop.u.bind_interdomain.local_port;
- event_set_handler(xbdi->xbdi_evtchn, xbdback_evthandler,
- xbdi, IPL_BIO, xbdi->xbdi_name);
+ xbdi->xbdi_ih = intr_establish_xname(0, &xen_pic, xbdi->xbdi_evtchn, IST_LEVEL, IPL_BIO,
+ xbdback_evthandler, xbdi, true, xbdi->xbdi_name);
+ KASSERT(xbdi->xbdi_ih != NULL);
aprint_verbose("xbd backend domain %d handle %#x (%d) "
"using event channel %d, protocol %s\n", xbdi->xbdi_domid,
xbdi->xbdi_handle, xbdi->xbdi_handle, xbdi->xbdi_evtchn, proto);
@@ -681,8 +683,7 @@ xbdback_disconnect(struct xbdback_instan
return;
}
hypervisor_mask_event(xbdi->xbdi_evtchn);
- event_remove_handler(xbdi->xbdi_evtchn, xbdback_evthandler,
- xbdi);
+ intr_disestablish(xbdi->xbdi_ih);
/* signal thread that we want to disconnect, then wait for it */
xbdi->xbdi_status = DISCONNECTING;
Index: src/sys/arch/xen/xen/xencons.c
diff -u src/sys/arch/xen/xen/xencons.c:1.41 src/sys/arch/xen/xen/xencons.c:1.42
--- src/sys/arch/xen/xen/xencons.c:1.41 Fri Jul 25 08:10:35 2014
+++ src/sys/arch/xen/xen/xencons.c Mon Nov 6 15:27:09 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: xencons.c,v 1.41 2014/07/25 08:10:35 dholland Exp $ */
+/* $NetBSD: xencons.c,v 1.42 2017/11/06 15:27:09 cherry Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -53,7 +53,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.41 2014/07/25 08:10:35 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.42 2017/11/06 15:27:09 cherry Exp $");
#include "opt_xen.h"
@@ -90,6 +90,7 @@ __KERNEL_RCSID(0, "$NetBSD: xencons.c,v
static int xencons_isconsole = 0;
static struct xencons_softc *xencons_console_device = NULL;
+static struct intrhand *ih;
#define XENCONS_UNIT(x) (minor(x))
#define XENCONS_BURST 128
@@ -216,13 +217,8 @@ xencons_suspend(device_t dev, const pmf_
if (!xendomain_is_dom0()) {
evtch = xen_start_info.console_evtchn;
hypervisor_mask_event(evtch);
- if (event_remove_handler(evtch, xencons_handler,
- xencons_console_device) != 0) {
- aprint_error_dev(dev,
- "can't remove handler: xencons_handler\n");
- }
-
- aprint_verbose_dev(dev, "removed event channel %d\n", evtch);
+ intr_disestablish(ih);
+ aprint_verbose_dev(dev, "removed event channel %d\n", ih->ih_pin);
}
return true;
@@ -237,13 +233,15 @@ xencons_resume(device_t dev, const pmf_q
/* dom0 console resume is required only during first start-up */
if (cold) {
evtch = bind_virq_to_evtch(VIRQ_CONSOLE);
- event_set_handler(evtch, xencons_intr,
- xencons_console_device, IPL_TTY, "xencons");
+ ih = intr_establish_xname(0, &xen_pic, evtch, IST_LEVEL, IPL_TTY,
+ xencons_intr, xencons_console_device, true, "xencons");
+ KASSERT(ih != NULL);
}
} else {
evtch = xen_start_info.console_evtchn;
- event_set_handler(evtch, xencons_handler,
- xencons_console_device, IPL_TTY, "xencons");
+ ih = intr_establish_xname(0, &xen_pic, evtch, IST_LEVEL, IPL_TTY,
+ xencons_handler, xencons_console_device, true, "xencons");
+ KASSERT(ih != NULL);
}
if (evtch != -1) {
Index: src/sys/arch/xen/xen/xennetback_xenbus.c
diff -u src/sys/arch/xen/xen/xennetback_xenbus.c:1.59 src/sys/arch/xen/xen/xennetback_xenbus.c:1.60
--- src/sys/arch/xen/xen/xennetback_xenbus.c:1.59 Wed Aug 30 16:01:55 2017
+++ src/sys/arch/xen/xen/xennetback_xenbus.c Mon Nov 6 15:27:09 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: xennetback_xenbus.c,v 1.59 2017/08/30 16:01:55 maxv Exp $ */
+/* $NetBSD: xennetback_xenbus.c,v 1.60 2017/11/06 15:27:09 cherry Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.59 2017/08/30 16:01:55 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.60 2017/11/06 15:27:09 cherry Exp $");
#include "opt_xen.h"
@@ -112,7 +112,8 @@ struct xnetback_instance {
uint8_t xni_enaddr[ETHER_ADDR_LEN];
/* remote domain communication stuff */
- unsigned int xni_evtchn; /* our even channel */
+ unsigned int xni_evtchn; /* our event channel */
+ struct intrhand *xni_ih;
netif_tx_back_ring_t xni_txring;
netif_rx_back_ring_t xni_rxring;
grant_handle_t xni_tx_ring_handle; /* to unmap the ring */
@@ -389,7 +390,8 @@ xennetback_xenbus_destroy(void *arg)
#endif
aprint_verbose_ifnet(&xneti->xni_if, "disconnecting\n");
hypervisor_mask_event(xneti->xni_evtchn);
- event_remove_handler(xneti->xni_evtchn, xennetback_evthandler, xneti);
+ intr_disestablish(xneti->xni_ih);
+
if (xneti->xni_softintr) {
softint_disestablish(xneti->xni_softintr);
xneti->xni_softintr = NULL;
@@ -549,8 +551,9 @@ xennetback_connect(struct xnetback_insta
xneti->xni_status = CONNECTED;
xen_wmb();
- event_set_handler(xneti->xni_evtchn, xennetback_evthandler,
- xneti, IPL_NET, xneti->xni_if.if_xname);
+ xneti->xni_ih = intr_establish_xname(0, &xen_pic, xneti->xni_evtchn, IST_LEVEL, IPL_NET,
+ xennetback_evthandler, xneti, true, xneti->xni_if.if_xname);
+ KASSERT(xneti->xni_ih != NULL);
xennetback_ifinit(&xneti->xni_if);
hypervisor_enable_event(xneti->xni_evtchn);
hypervisor_notify_via_evtchn(xneti->xni_evtchn);
Index: src/sys/arch/xen/xenbus/xenbus_comms.c
diff -u src/sys/arch/xen/xenbus/xenbus_comms.c:1.15 src/sys/arch/xen/xenbus/xenbus_comms.c:1.16
--- src/sys/arch/xen/xenbus/xenbus_comms.c:1.15 Thu Jul 7 06:55:40 2016
+++ src/sys/arch/xen/xenbus/xenbus_comms.c Mon Nov 6 15:27:09 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: xenbus_comms.c,v 1.15 2016/07/07 06:55:40 msaitoh Exp $ */
+/* $NetBSD: xenbus_comms.c,v 1.16 2017/11/06 15:27:09 cherry Exp $ */
/******************************************************************************
* xenbus_comms.c
*
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xenbus_comms.c,v 1.15 2016/07/07 06:55:40 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xenbus_comms.c,v 1.16 2017/11/06 15:27:09 cherry Exp $");
#include <sys/types.h>
#include <sys/null.h>
@@ -51,6 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: xenbus_comms
#define XENPRINTF(x)
#endif
+static struct intrhand *ih;
struct xenstore_domain_interface *xenstore_interface;
extern int xenstored_ready;
@@ -220,7 +221,9 @@ xb_init_comms(device_t dev)
evtchn = xen_start_info.store_evtchn;
- event_set_handler(evtchn, wake_waiting, NULL, IPL_TTY, "xenbus");
+ ih = intr_establish_xname(0, &xen_pic, evtchn, IST_LEVEL, IPL_TTY,
+ wake_waiting, NULL, true, "xenbus");
+
hypervisor_enable_event(evtchn);
aprint_verbose_dev(dev, "using event channel %d\n", evtchn);
@@ -235,7 +238,7 @@ xb_suspend_comms(device_t dev)
evtchn = xen_start_info.store_evtchn;
hypervisor_mask_event(evtchn);
- event_remove_handler(evtchn, wake_waiting, NULL);
+ intr_disestablish(ih);
aprint_verbose_dev(dev, "removed event channel %d\n", evtchn);
}