diff options
-rw-r--r-- | sys/dev/pv/xen.c | 15 | ||||
-rw-r--r-- | sys/dev/pv/xenvar.h | 30 |
2 files changed, 19 insertions, 26 deletions
diff --git a/sys/dev/pv/xen.c b/sys/dev/pv/xen.c index f03d7459300..6841c05a761 100644 --- a/sys/dev/pv/xen.c +++ b/sys/dev/pv/xen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xen.c,v 1.61 2016/08/05 18:31:21 mikeb Exp $ */ +/* $OpenBSD: xen.c,v 1.62 2016/08/17 17:18:38 mikeb Exp $ */ /* * Copyright (c) 2015 Mike Belopuhov @@ -744,7 +744,7 @@ xen_intr_establish(evtchn_port_t port, xen_intr_handle_t *xih, int domain, SLIST_INSERT_HEAD(&sc->sc_intrs, xi, xi_entry); /* Mask the event port */ - atomic_setbit_ptr(&sc->sc_ipg->evtchn_mask[0], xi->xi_port); + set_bit(xi->xi_port, &sc->sc_ipg->evtchn_mask[0]); #if defined(XEN_DEBUG) && disabled memset(&es, 0, sizeof(es)); @@ -790,8 +790,8 @@ xen_intr_disestablish(xen_intr_handle_t xih) taskq_destroy(xi->xi_taskq); - atomic_setbit_ptr(&sc->sc_ipg->evtchn_mask[0], xi->xi_port); - atomic_clearbit_ptr(&sc->sc_ipg->evtchn_pending[0], xi->xi_port); + set_bit(xi->xi_port, &sc->sc_ipg->evtchn_mask[0]); + clear_bit(xi->xi_port, &sc->sc_ipg->evtchn_pending[0]); if (!xi->xi_noclose) { ec.port = xi->xi_port; @@ -820,8 +820,7 @@ xen_intr_enable(void) printf("%s: unmasking port %u failed\n", sc->sc_dev.dv_xname, xi->xi_port); virtio_membar_sync(); - if (isset((char *)&sc->sc_ipg->evtchn_mask[0], - xi->xi_port)) + if (test_bit(xi->xi_port, &sc->sc_ipg->evtchn_mask[0])) printf("%s: port %u is still masked\n", sc->sc_dev.dv_xname, xi->xi_port); } @@ -837,7 +836,7 @@ xen_intr_mask(xen_intr_handle_t xih) if ((xi = xen_lookup_intsrc(sc, port)) != NULL) { xi->xi_masked = 1; - atomic_setbit_ptr(&sc->sc_ipg->evtchn_mask[0], xi->xi_port); + set_bit(xi->xi_port, &sc->sc_ipg->evtchn_mask[0]); } } @@ -851,7 +850,7 @@ xen_intr_unmask(xen_intr_handle_t xih) if ((xi = xen_lookup_intsrc(sc, port)) != NULL) { xi->xi_masked = 0; - if (!isset((char *)&sc->sc_ipg->evtchn_mask[0], xi->xi_port)) + if (!test_bit(xi->xi_port, &sc->sc_ipg->evtchn_mask[0])) return (0); eu.port = xi->xi_port; return (xen_evtchn_hypercall(sc, EVTCHNOP_unmask, &eu, diff --git a/sys/dev/pv/xenvar.h b/sys/dev/pv/xenvar.h index 428002d6a72..980f5910b34 100644 --- a/sys/dev/pv/xenvar.h +++ b/sys/dev/pv/xenvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xenvar.h,v 1.35 2016/08/03 17:14:41 mikeb Exp $ */ +/* $OpenBSD: xenvar.h,v 1.36 2016/08/17 17:18:38 mikeb Exp $ */ /* * Copyright (c) 2015 Mike Belopuhov @@ -143,28 +143,22 @@ struct xs_transaction { struct xs_softc *xst_sc; }; -static inline int -atomic_setbit_ptr(volatile void *ptr, int bit) +static __inline void +clear_bit(u_int b, volatile void *p) { - int obit; - - __asm__ __volatile__ ("lock btsl %2,%1; sbbl %0,%0" : - "=r" (obit), "=m" (*(volatile long *)ptr) : "Ir" (bit) : - "memory"); - - return (obit); + atomic_clearbits_int(((volatile u_int *)p) + (b >> 5), 1 << (b & 0x1f)); } -static inline int -atomic_clearbit_ptr(volatile void *ptr, int bit) +static __inline void +set_bit(u_int b, volatile void *p) { - int obit; - - __asm__ __volatile__ ("lock btrl %2,%1; sbbl %0,%0" : - "=r" (obit), "=m" (*(volatile long *)ptr) : "Ir" (bit) : - "memory"); + atomic_setbits_int(((volatile u_int *)p) + (b >> 5), 1 << (b & 0x1f)); +} - return (obit); +static __inline int +test_bit(u_int b, volatile void *p) +{ + return !!(((volatile u_int *)p)[b >> 5] & (1 << (b & 0x1f))); } int xs_cmd(struct xs_transaction *, int, const char *, struct iovec **, |