Module Name: src Committed By: cherry Date: Fri Oct 26 05:33:21 UTC 2018
Modified Files: src/sys/arch/xen/include: hypervisor.h src/sys/arch/xen/x86: hypervisor_machdep.c xen_ipi.c src/sys/arch/xen/xen: clock.c evtchn.c if_xennet_xenbus.c pciback.c xbd_xenbus.c xbdback_xenbus.c xencons.c xennetback_xenbus.c src/sys/arch/xen/xenbus: xenbus_comms.c Log Message: Decompose hypervisor_enable_event() into functional steps. The hypervisor_unmask_event() step is relevant for any event. The pirq related step is only relevant for pirq bound events. Prune blanket usage of this, so that usage is semantically appropriate. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/arch/xen/include/hypervisor.h cvs rdiff -u -r1.28 -r1.29 src/sys/arch/xen/x86/hypervisor_machdep.c cvs rdiff -u -r1.27 -r1.28 src/sys/arch/xen/x86/xen_ipi.c cvs rdiff -u -r1.71 -r1.72 src/sys/arch/xen/xen/clock.c cvs rdiff -u -r1.81 -r1.82 src/sys/arch/xen/xen/evtchn.c cvs rdiff -u -r1.80 -r1.81 src/sys/arch/xen/xen/if_xennet_xenbus.c cvs rdiff -u -r1.16 -r1.17 src/sys/arch/xen/xen/pciback.c cvs rdiff -u -r1.89 -r1.90 src/sys/arch/xen/xen/xbd_xenbus.c cvs rdiff -u -r1.68 -r1.69 src/sys/arch/xen/xen/xbdback_xenbus.c cvs rdiff -u -r1.45 -r1.46 src/sys/arch/xen/xen/xencons.c cvs rdiff -u -r1.70 -r1.71 src/sys/arch/xen/xen/xennetback_xenbus.c cvs rdiff -u -r1.19 -r1.20 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/include/hypervisor.h diff -u src/sys/arch/xen/include/hypervisor.h:1.45 src/sys/arch/xen/include/hypervisor.h:1.46 --- src/sys/arch/xen/include/hypervisor.h:1.45 Sun Sep 23 02:27:24 2018 +++ src/sys/arch/xen/include/hypervisor.h Fri Oct 26 05:33:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.h,v 1.45 2018/09/23 02:27:24 cherry Exp $ */ +/* $NetBSD: hypervisor.h,v 1.46 2018/10/26 05:33:21 cherry Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -55,7 +55,8 @@ #define _XEN_HYPERVISOR_H_ #include "opt_xen.h" - +#include "isa.h" +#include "pci.h" struct hypervisor_attach_args { const char *haa_busname; @@ -130,8 +131,10 @@ extern volatile shared_info_t *HYPERVISO struct intrframe; struct cpu_info; void do_hypervisor_callback(struct intrframe *regs); +#if NPCI > 0 || NISA > 0 void hypervisor_prime_pirq_event(int, unsigned int); -void hypervisor_enable_event(unsigned int); +void hypervisor_ack_pirq_event(unsigned int); +#endif /* NPCI > 0 || NISA > 0 */ extern int xen_version; #define XEN_MAJOR(x) (((x) & 0xffff0000) >> 16) Index: src/sys/arch/xen/x86/hypervisor_machdep.c diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.28 src/sys/arch/xen/x86/hypervisor_machdep.c:1.29 --- src/sys/arch/xen/x86/hypervisor_machdep.c:1.28 Sun Sep 21 12:46:15 2014 +++ src/sys/arch/xen/x86/hypervisor_machdep.c Fri Oct 26 05:33:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor_machdep.c,v 1.28 2014/09/21 12:46:15 bouyer Exp $ */ +/* $NetBSD: hypervisor_machdep.c,v 1.29 2018/10/26 05:33:21 cherry Exp $ */ /* * @@ -54,7 +54,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.28 2014/09/21 12:46:15 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.29 2018/10/26 05:33:21 cherry Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -71,6 +71,8 @@ __KERNEL_RCSID(0, "$NetBSD: hypervisor_m #include <xen/xenpmap.h> #include "opt_xen.h" +#include "isa.h" +#include "pci.h" /* * arch-dependent p2m frame lists list (L3 and L2) @@ -392,7 +394,10 @@ evt_enable_event(unsigned int port, unsi unsigned int l2i, void *args) { KASSERT(args == NULL); - hypervisor_enable_event(port); + hypervisor_unmask_event(port); +#if NPCI > 0 || NISA > 0 + hypervisor_ack_pirq_event(port); +#endif /* NPCI > 0 || NISA > 0 */ } void Index: src/sys/arch/xen/x86/xen_ipi.c diff -u src/sys/arch/xen/x86/xen_ipi.c:1.27 src/sys/arch/xen/x86/xen_ipi.c:1.28 --- src/sys/arch/xen/x86/xen_ipi.c:1.27 Wed Oct 24 03:59:33 2018 +++ src/sys/arch/xen/x86/xen_ipi.c Fri Oct 26 05:33:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: xen_ipi.c,v 1.27 2018/10/24 03:59:33 cherry Exp $ */ +/* $NetBSD: xen_ipi.c,v 1.28 2018/10/26 05:33:21 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.27 2018/10/24 03:59:33 cherry Exp $"); + * __KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.28 2018/10/26 05:33:21 cherry Exp $"); */ -__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.27 2018/10/24 03:59:33 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.28 2018/10/26 05:33:21 cherry Exp $"); #include "opt_ddb.h" @@ -143,7 +143,7 @@ xen_ipi_init(void) /* NOTREACHED */ } - hypervisor_enable_event(evtchn); + hypervisor_unmask_event(evtchn); } #ifdef DIAGNOSTIC Index: src/sys/arch/xen/xen/clock.c diff -u src/sys/arch/xen/xen/clock.c:1.71 src/sys/arch/xen/xen/clock.c:1.72 --- src/sys/arch/xen/xen/clock.c:1.71 Wed Oct 24 03:59:33 2018 +++ src/sys/arch/xen/xen/clock.c Fri Oct 26 05:33:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.71 2018/10/24 03:59:33 cherry Exp $ */ +/* $NetBSD: clock.c,v 1.72 2018/10/26 05:33:21 cherry Exp $ */ /*- * Copyright (c) 2017, 2018 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #endif #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.71 2018/10/24 03:59:33 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.72 2018/10/26 05:33:21 cherry Exp $"); #include <sys/param.h> #include <sys/types.h> @@ -769,7 +769,7 @@ xen_resumeclocks(struct cpu_info *ci) if (ci->ci_xen_timer_intrhand == NULL) panic("failed to establish timer interrupt handler"); - hypervisor_enable_event(evtch); + hypervisor_unmask_event(evtch); aprint_verbose("Xen %s: using event channel %d\n", intr_xname, evtch); Index: src/sys/arch/xen/xen/evtchn.c diff -u src/sys/arch/xen/xen/evtchn.c:1.81 src/sys/arch/xen/xen/evtchn.c:1.82 --- src/sys/arch/xen/xen/evtchn.c:1.81 Sun Sep 23 02:27:24 2018 +++ src/sys/arch/xen/xen/evtchn.c Fri Oct 26 05:33:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: evtchn.c,v 1.81 2018/09/23 02:27:24 cherry Exp $ */ +/* $NetBSD: evtchn.c,v 1.82 2018/10/26 05:33:21 cherry Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -54,7 +54,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.81 2018/09/23 02:27:24 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.82 2018/10/26 05:33:21 cherry Exp $"); #include "opt_xen.h" #include "isa.h" @@ -269,8 +269,10 @@ events_init(void) */ evtsource[debug_port] = (void *)-1; xen_atomic_set_bit(&curcpu()->ci_evtmask[0], debug_port); - hypervisor_enable_event(debug_port); - + hypervisor_unmask_event(debug_port); +#if NPCI > 0 || NISA > 0 + hypervisor_ack_pirq_event(debug_port); +#endif /* NPCI > 0 || NISA > 0 */ x86_enable_intr(); /* at long last... */ } @@ -331,7 +333,10 @@ evtchn_do_event(int evtch, struct intrfr */ if (__predict_false(evtch == debug_port)) { xen_debug_handler(NULL); - hypervisor_enable_event(evtch); + hypervisor_unmask_event(debug_port); +#if NPCI > 0 || NISA > 0 + hypervisor_ack_pirq_event(debug_port); +#endif /* NPCI > 0 || NISA > 0 */ return 0; } @@ -391,7 +396,11 @@ evtchn_do_event(int evtch, struct intrfr } mutex_spin_exit(&evtlock[evtch]); cli(); - hypervisor_enable_event(evtch); + hypervisor_unmask_event(evtch); +#if NPCI > 0 || NISA > 0 + hypervisor_ack_pirq_event(evtch); +#endif /* NPCI > 0 || NISA > 0 */ + splx: /* * C version of spllower(). ASTs will be checked when @@ -759,7 +768,8 @@ pirq_establish(int pirq, int evtch, int } hypervisor_prime_pirq_event(pirq, evtch); - hypervisor_enable_event(evtch); + hypervisor_unmask_event(evtch); + hypervisor_ack_pirq_event(evtch); return ih; } @@ -994,10 +1004,10 @@ event_remove_handler(int evtch, int (*fu return 0; } +#if NPCI > 0 || NISA > 0 void hypervisor_prime_pirq_event(int pirq, unsigned int evtch) { -#if NPCI > 0 || NISA > 0 physdev_op_t physdev_op; physdev_op.cmd = PHYSDEVOP_IRQ_STATUS_QUERY; physdev_op.u.irq_status_query.irq = pirq; @@ -1010,19 +1020,16 @@ hypervisor_prime_pirq_event(int pirq, un printf("pirq %d needs notify\n", pirq); #endif } -#endif /* NPCI > 0 || NISA > 0 */ } void -hypervisor_enable_event(unsigned int evtch) +hypervisor_ack_pirq_event(unsigned int evtch) { #ifdef IRQ_DEBUG if (evtch == IRQ_DEBUG) - printf("hypervisor_enable_evtch: evtch %d\n", evtch); + printf("%s: evtch %d\n", __func__, evtch); #endif - hypervisor_unmask_event(evtch); -#if NPCI > 0 || NISA > 0 if (pirq_needs_unmask_notify[evtch >> 5] & (1 << (evtch & 0x1f))) { #ifdef IRQ_DEBUG if (evtch == IRQ_DEBUG) @@ -1030,8 +1037,8 @@ hypervisor_enable_event(unsigned int evt #endif (void)HYPERVISOR_physdev_op(&physdev_op_notify); } -#endif /* NPCI > 0 || NISA > 0 */ } +#endif /* NPCI > 0 || NISA > 0 */ int xen_debug_handler(void *arg) Index: src/sys/arch/xen/xen/if_xennet_xenbus.c diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.80 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.81 --- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.80 Wed Oct 24 03:59:33 2018 +++ src/sys/arch/xen/xen/if_xennet_xenbus.c Fri Oct 26 05:33:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: if_xennet_xenbus.c,v 1.80 2018/10/24 03:59:33 cherry Exp $ */ +/* $NetBSD: if_xennet_xenbus.c,v 1.81 2018/10/26 05:33:21 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.80 2018/10/24 03:59:33 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.81 2018/10/26 05:33:21 cherry Exp $"); #include "opt_xen.h" #include "opt_nfs_boot.h" @@ -1386,7 +1386,7 @@ xennet_init(struct ifnet *ifp) if ((ifp->if_flags & IFF_RUNNING) == 0) { sc->sc_rx_ring.sring->rsp_event = sc->sc_rx_ring.rsp_cons + 1; - hypervisor_enable_event(sc->sc_evtchn); + hypervisor_unmask_event(sc->sc_evtchn); hypervisor_notify_via_evtchn(sc->sc_evtchn); xennet_reset(sc); } Index: src/sys/arch/xen/xen/pciback.c diff -u src/sys/arch/xen/xen/pciback.c:1.16 src/sys/arch/xen/xen/pciback.c:1.17 --- src/sys/arch/xen/xen/pciback.c:1.16 Wed Oct 24 03:59:33 2018 +++ src/sys/arch/xen/xen/pciback.c Fri Oct 26 05:33:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pciback.c,v 1.16 2018/10/24 03:59:33 cherry Exp $ */ +/* $NetBSD: pciback.c,v 1.17 2018/10/26 05:33:21 cherry Exp $ */ /* * Copyright (c) 2009 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pciback.c,v 1.16 2018/10/24 03:59:33 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pciback.c,v 1.17 2018/10/26 05:33:21 cherry Exp $"); #include "opt_xen.h" @@ -622,7 +622,7 @@ pciback_xenbus_frontend_changed(void *ar pbxi->pbx_ih = intr_establish_xname(-1, &xen_pic, pbxi->pbx_evtchn, IST_LEVEL, IPL_BIO, pciback_xenbus_evthandler, pbxi, true, "pciback"); KASSERT(pbxi->pbx_ih != NULL); - hypervisor_enable_event(pbxi->pbx_evtchn); + hypervisor_unmask_event(pbxi->pbx_evtchn); hypervisor_notify_via_evtchn(pbxi->pbx_evtchn); break; Index: src/sys/arch/xen/xen/xbd_xenbus.c diff -u src/sys/arch/xen/xen/xbd_xenbus.c:1.89 src/sys/arch/xen/xen/xbd_xenbus.c:1.90 --- src/sys/arch/xen/xen/xbd_xenbus.c:1.89 Wed Oct 24 03:59:33 2018 +++ src/sys/arch/xen/xen/xbd_xenbus.c Fri Oct 26 05:33:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: xbd_xenbus.c,v 1.89 2018/10/24 03:59:33 cherry Exp $ */ +/* $NetBSD: xbd_xenbus.c,v 1.90 2018/10/26 05:33:21 cherry Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -50,7 +50,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.89 2018/10/24 03:59:33 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.90 2018/10/26 05:33:21 cherry Exp $"); #include "opt_xen.h" @@ -509,7 +509,7 @@ again: */ sc->sc_backend_status = BLKIF_STATE_CONNECTED; xenbus_device_resume(sc->sc_xbusd); - hypervisor_enable_event(sc->sc_evtchn); + hypervisor_unmask_event(sc->sc_evtchn); xenbus_switch_state(sc->sc_xbusd, NULL, XenbusStateConnected); } @@ -568,8 +568,7 @@ xbd_backend_changed(void *arg, XenbusSta xbd_connect(sc); sc->sc_shutdown = BLKIF_SHUTDOWN_RUN; - hypervisor_enable_event(sc->sc_evtchn); - + hypervisor_unmask_event(sc->sc_evtchn); sc->sc_xbdsize = sc->sc_sectors * (uint64_t)sc->sc_secsize / DEV_BSIZE; dg = &sc->sc_dksc.sc_dkdev.dk_geom; Index: src/sys/arch/xen/xen/xbdback_xenbus.c diff -u src/sys/arch/xen/xen/xbdback_xenbus.c:1.68 src/sys/arch/xen/xen/xbdback_xenbus.c:1.69 --- src/sys/arch/xen/xen/xbdback_xenbus.c:1.68 Wed Oct 24 03:59:33 2018 +++ src/sys/arch/xen/xen/xbdback_xenbus.c Fri Oct 26 05:33:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: xbdback_xenbus.c,v 1.68 2018/10/24 03:59:33 cherry Exp $ */ +/* $NetBSD: xbdback_xenbus.c,v 1.69 2018/10/26 05:33:21 cherry Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.68 2018/10/24 03:59:33 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.69 2018/10/26 05:33:21 cherry Exp $"); #include <sys/atomic.h> #include <sys/buf.h> @@ -654,7 +654,7 @@ xbdback_connect(struct xbdback_instance /* enable the xbdback event handler machinery */ xbdi->xbdi_status = WAITING; - hypervisor_enable_event(xbdi->xbdi_evtchn); + hypervisor_unmask_event(xbdi->xbdi_evtchn); hypervisor_notify_via_evtchn(xbdi->xbdi_evtchn); if (kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL, Index: src/sys/arch/xen/xen/xencons.c diff -u src/sys/arch/xen/xen/xencons.c:1.45 src/sys/arch/xen/xen/xencons.c:1.46 --- src/sys/arch/xen/xen/xencons.c:1.45 Wed Oct 24 03:59:33 2018 +++ src/sys/arch/xen/xen/xencons.c Fri Oct 26 05:33:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: xencons.c,v 1.45 2018/10/24 03:59:33 cherry Exp $ */ +/* $NetBSD: xencons.c,v 1.46 2018/10/26 05:33:21 cherry Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -53,7 +53,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.45 2018/10/24 03:59:33 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.46 2018/10/26 05:33:21 cherry Exp $"); #include "opt_xen.h" @@ -249,7 +249,7 @@ xencons_resume(device_t dev, const pmf_q if (evtch != -1) { aprint_verbose_dev(dev, "using event channel %d\n", evtch); - hypervisor_enable_event(evtch); + hypervisor_unmask_event(evtch); } return true; Index: src/sys/arch/xen/xen/xennetback_xenbus.c diff -u src/sys/arch/xen/xen/xennetback_xenbus.c:1.70 src/sys/arch/xen/xen/xennetback_xenbus.c:1.71 --- src/sys/arch/xen/xen/xennetback_xenbus.c:1.70 Wed Oct 24 03:59:33 2018 +++ src/sys/arch/xen/xen/xennetback_xenbus.c Fri Oct 26 05:33:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: xennetback_xenbus.c,v 1.70 2018/10/24 03:59:33 cherry Exp $ */ +/* $NetBSD: xennetback_xenbus.c,v 1.71 2018/10/26 05:33:21 cherry Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.70 2018/10/24 03:59:33 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.71 2018/10/26 05:33:21 cherry Exp $"); #include "opt_xen.h" @@ -561,7 +561,7 @@ xennetback_connect(struct xnetback_insta xneti->xni_if.if_xname); KASSERT(xneti->xni_ih != NULL); xennetback_ifinit(&xneti->xni_if); - hypervisor_enable_event(xneti->xni_evtchn); + hypervisor_unmask_event(xneti->xni_evtchn); hypervisor_notify_via_evtchn(xneti->xni_evtchn); return 0; Index: src/sys/arch/xen/xenbus/xenbus_comms.c diff -u src/sys/arch/xen/xenbus/xenbus_comms.c:1.19 src/sys/arch/xen/xenbus/xenbus_comms.c:1.20 --- src/sys/arch/xen/xenbus/xenbus_comms.c:1.19 Wed Oct 24 03:59:33 2018 +++ src/sys/arch/xen/xenbus/xenbus_comms.c Fri Oct 26 05:33:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: xenbus_comms.c,v 1.19 2018/10/24 03:59:33 cherry Exp $ */ +/* $NetBSD: xenbus_comms.c,v 1.20 2018/10/26 05:33:21 cherry Exp $ */ /****************************************************************************** * xenbus_comms.c * @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: xenbus_comms.c,v 1.19 2018/10/24 03:59:33 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xenbus_comms.c,v 1.20 2018/10/26 05:33:21 cherry Exp $"); #include <sys/types.h> #include <sys/null.h> @@ -224,7 +224,7 @@ xb_init_comms(device_t dev) ih = intr_establish_xname(-1, &xen_pic, evtchn, IST_LEVEL, IPL_TTY, wake_waiting, NULL, false, device_xname(dev)); - hypervisor_enable_event(evtchn); + hypervisor_unmask_event(evtchn); aprint_verbose_dev(dev, "using event channel %d\n", evtchn); return 0;