Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/xen Switch XEN drivers to use intr_establish_xname(...
details: https://anonhg.NetBSD.org/src/rev/4a538077e9d7
branches: trunk
changeset: 827640:4a538077e9d7
user: cherry <cherry%NetBSD.org@localhost>
date: Mon Nov 06 15:27:09 2017 +0000
description:
Switch XEN drivers to use intr_establish_xname()/intr_disestablish()
This completes the API transition.
diffstat:
sys/arch/xen/x86/xen_ipi.c | 23 +++++++++++++++--------
sys/arch/xen/xen/clock.c | 21 +++++++++++++--------
sys/arch/xen/xen/if_xennet_xenbus.c | 16 +++++++++-------
sys/arch/xen/xen/xbd_xenbus.c | 16 ++++++++++------
sys/arch/xen/xen/xbdback_xenbus.c | 13 +++++++------
sys/arch/xen/xen/xencons.c | 24 +++++++++++-------------
sys/arch/xen/xen/xennetback_xenbus.c | 15 +++++++++------
sys/arch/xen/xenbus/xenbus_comms.c | 11 +++++++----
8 files changed, 81 insertions(+), 58 deletions(-)
diffs (truncated from 452 to 300 lines):
diff -r bdb36afbd7fe -r 4a538077e9d7 sys/arch/xen/x86/xen_ipi.c
--- a/sys/arch/xen/x86/xen_ipi.c Mon Nov 06 15:21:23 2017 +0000
+++ b/sys/arch/xen/x86/xen_ipi.c Mon Nov 06 15:27:09 2017 +0000
@@ -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 @@
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 @@
/* NOTREACHED */
}
}
+
+ return 0;
}
/* Must be called once for every cpu that expects to send/recv ipis */
@@ -118,9 +125,9 @@
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 */
}
diff -r bdb36afbd7fe -r 4a538077e9d7 sys/arch/xen/xen/clock.c
--- a/sys/arch/xen/xen/clock.c Mon Nov 06 15:21:23 2017 +0000
+++ b/sys/arch/xen/xen/clock.c Mon Nov 06 15:27:09 2017 +0000
@@ -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 @@
#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 @@
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 @@
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 @@
/* 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);
diff -r bdb36afbd7fe -r 4a538077e9d7 sys/arch/xen/xen/if_xennet_xenbus.c
--- a/sys/arch/xen/xen/if_xennet_xenbus.c Mon Nov 06 15:21:23 2017 +0000
+++ b/sys/arch/xen/xen/if_xennet_xenbus.c Mon Nov 06 15:27:09 2017 +0000
@@ -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 @@
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 @@
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 @@
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 @@
*/
sc->sc_backend_status = BEST_SUSPENDED;
- event_remove_handler(sc->sc_evtchn, &xennet_handler, sc);
+ intr_disestablish(sc->sc_ih);
splx(s);
diff -r bdb36afbd7fe -r 4a538077e9d7 sys/arch/xen/xen/xbd_xenbus.c
--- a/sys/arch/xen/xen/xbd_xenbus.c Mon Nov 06 15:21:23 2017 +0000
+++ b/sys/arch/xen/xen/xbd_xenbus.c Mon Nov 06 15:27:09 2017 +0000
@@ -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 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 @@
}
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 @@
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 @@
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();
diff -r bdb36afbd7fe -r 4a538077e9d7 sys/arch/xen/xen/xbdback_xenbus.c
--- a/sys/arch/xen/xen/xbdback_xenbus.c Mon Nov 06 15:21:23 2017 +0000
+++ b/sys/arch/xen/xen/xbdback_xenbus.c Mon Nov 06 15:27:09 2017 +0000
@@ -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 @@
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 @@
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 @@
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;
diff -r bdb36afbd7fe -r 4a538077e9d7 sys/arch/xen/xen/xencons.c
--- a/sys/arch/xen/xen/xencons.c Mon Nov 06 15:21:23 2017 +0000
+++ b/sys/arch/xen/xen/xencons.c Mon Nov 06 15:27:09 2017 +0000
@@ -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 $ */
Home |
Main Index |
Thread Index |
Old Index