diff options
author | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2016-01-22 19:26:41 +0000 |
---|---|---|
committer | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2016-01-22 19:26:41 +0000 |
commit | b92e17c72adafa04f28fcea28a5acdeecd8660be (patch) | |
tree | db673a7049fccb00bad65386309f7fea0eaa01ac /sys/dev/pv | |
parent | bf5cd320f452c472d1e14172e8aa98fa7bde1ada (diff) |
Convert membar_* calls into virtio_membar_sync where it matters
membar_* functions are defined only as compiler barriers on !MP
kernels, while we're trying to be conservative in our use of the
barriers. Barriers are placed only where loads and stores might
get reordered and it matters at the same time. Shared info page
operations are using atomic instructions on Linux, so they get
barriers as well.
Diffstat (limited to 'sys/dev/pv')
-rw-r--r-- | sys/dev/pv/xen.c | 16 | ||||
-rw-r--r-- | sys/dev/pv/xenstore.c | 13 |
2 files changed, 13 insertions, 16 deletions
diff --git a/sys/dev/pv/xen.c b/sys/dev/pv/xen.c index cc08c6e6ec0..44e83142687 100644 --- a/sys/dev/pv/xen.c +++ b/sys/dev/pv/xen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xen.c,v 1.31 2016/01/19 13:36:00 mikeb Exp $ */ +/* $OpenBSD: xen.c,v 1.32 2016/01/22 19:26:40 mikeb Exp $ */ /* * Copyright (c) 2015 Mike Belopuhov @@ -379,7 +379,7 @@ xen_print_info_page(void) struct vcpu_info *v; int i; - membar_sync(); + virtio_membar_sync(); for (i = 0; i < XEN_LEGACY_MAX_VCPUS; i++) { v = &s->vcpu_info[i]; if (!v->evtchn_upcall_pending && !v->evtchn_upcall_mask && @@ -479,7 +479,6 @@ xen_init_interrupts(struct xen_softc *sc) for (i = 0; i < nitems(sc->sc_ipg->evtchn_pending); i++) { sc->sc_ipg->evtchn_pending[i] = 0; sc->sc_ipg->evtchn_mask[i] = ~0UL; - membar_producer(); } SLIST_INIT(&sc->sc_intrs); @@ -523,6 +522,7 @@ xen_intr_ack(void) struct vcpu_info *v = &s->vcpu_info[CPU_INFO_UNIT(ci)]; v->evtchn_upcall_pending = 0; + virtio_membar_sync(); } void @@ -550,7 +550,7 @@ xen_intr(void) if ((pending & 1) == 0) continue; sc->sc_ipg->evtchn_pending[row] &= ~(1 << bit); - membar_producer(); + virtio_membar_producer(); port = (row * LONG_BIT) + bit; if ((xi = xen_lookup_intsrc(sc, port)) == NULL) { printf("%s: unhandled interrupt on port %u\n", @@ -687,7 +687,7 @@ xen_intr_disestablish(xen_intr_handle_t xih) setbit((char *)&sc->sc_ipg->evtchn_mask[0], xi->xi_port); clrbit((char *)&sc->sc_ipg->evtchn_pending[0], xi->xi_port); - membar_producer(); + virtio_membar_sync(); if (!xi->xi_noclose) { ec.port = xi->xi_port; @@ -715,7 +715,7 @@ xen_intr_enable(void) sizeof(eu))) printf("%s: unmasking port %u failed\n", sc->sc_dev.dv_xname, xi->xi_port); - membar_sync(); + virtio_membar_sync(); if (isset((char *)&sc->sc_ipg->evtchn_mask[0], xi->xi_port)) printf("%s: port %u is still masked\n", @@ -734,7 +734,7 @@ xen_intr_mask(xen_intr_handle_t xih) if ((xi = xen_lookup_intsrc(sc, port)) != NULL) { xi->xi_masked = 1; setbit((char *)&sc->sc_ipg->evtchn_mask[0], xi->xi_port); - membar_producer(); + virtio_membar_sync(); } } @@ -918,7 +918,7 @@ xen_grant_table_enter(struct xen_softc *sc, grant_ref_t ref, paddr_t pa, mtx_enter(&ge->ge_mtx); ge->ge_table[ref].frame = atop(pa); ge->ge_table[ref].domid = 0; - membar_producer(); + virtio_membar_sync(); ge->ge_table[ref].flags = GTF_permit_access | flags; mtx_leave(&ge->ge_mtx); return (0); diff --git a/sys/dev/pv/xenstore.c b/sys/dev/pv/xenstore.c index 8915c843f0c..b9c2224155a 100644 --- a/sys/dev/pv/xenstore.c +++ b/sys/dev/pv/xenstore.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xenstore.c,v 1.19 2016/01/18 18:54:38 mikeb Exp $ */ +/* $OpenBSD: xenstore.c,v 1.20 2016/01/22 19:26:40 mikeb Exp $ */ /* * Copyright (c) 2015 Mike Belopuhov @@ -310,7 +310,6 @@ xs_ring_avail(struct xs_ring *xsr, int req) uint32_t cons = req ? xsr->xsr_req_cons : xsr->xsr_rsp_cons; uint32_t prod = req ? xsr->xsr_req_prod : xsr->xsr_rsp_prod; - membar_consumer(); KASSERT(prod - cons <= XS_RING_SIZE); return (req ? XS_RING_SIZE - (prod - cons) : prod - cons); } @@ -349,7 +348,7 @@ xs_output(struct xs_transaction *xst, uint8_t *bp, int len) } else tsleep(xs->xs_wchan, PRIBIO, xs->xs_wchan, XST_DELAY * hz >> 2); - membar_sync(); + virtio_membar_sync(); } } return (0); @@ -440,7 +439,6 @@ xs_ring_put(struct xs_softc *xs, void *src, size_t size) uint32_t avail = xs_ring_avail(xsr, 1); size_t left; - membar_consumer(); if (size > XS_RING_SIZE) return (-1); if (avail == 0) @@ -455,7 +453,7 @@ xs_ring_put(struct xs_softc *xs, void *src, size_t size) memcpy(&xsr->xsr_req[prod], src, left); memcpy(&xsr->xsr_req[0], (caddr_t)src + left, size - left); - membar_producer(); + virtio_membar_sync(); xsr->xsr_req_prod += size; return (size); } @@ -468,7 +466,6 @@ xs_ring_get(struct xs_softc *xs, void *dst, size_t size) uint32_t avail = xs_ring_avail(xsr, 0); size_t left; - membar_consumer(); if (size > XS_RING_SIZE) return (-1); if (avail == 0) @@ -483,7 +480,7 @@ xs_ring_get(struct xs_softc *xs, void *dst, size_t size) memcpy(dst, &xsr->xsr_rsp[cons], left); memcpy((caddr_t)dst + left, &xsr->xsr_rsp[0], size - left); - membar_producer(); + virtio_membar_sync(); xsr->xsr_rsp_cons += size; return (size); } @@ -499,7 +496,7 @@ xs_intr(void *arg) uint32_t avail; int len; - membar_sync(); + virtio_membar_sync(); if (xsr->xsr_rsp_cons == xsr->xsr_rsp_prod) return; |