From: jmatthew Date: Wed, 10 Jul 2024 08:48:20 +0000 (+0000) Subject: as per if_ixl.c r1.88, protect the admin queue with a muteX X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=bd6a7aba14394edd8b4fccb2822ad30704e0d098;p=openbsd as per if_ixl.c r1.88, protect the admin queue with a muteX cVS: ---------------------------------------------------------------------- --- diff --git a/sys/dev/pci/if_iavf.c b/sys/dev/pci/if_iavf.c index 6d7bf200402..11897f2f6f0 100644 --- a/sys/dev/pci/if_iavf.c +++ b/sys/dev/pci/if_iavf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iavf.c,v 1.14 2024/07/09 16:04:15 jmatthew Exp $ */ +/* $OpenBSD: if_iavf.c,v 1.15 2024/07/10 08:48:20 jmatthew Exp $ */ /* * Copyright (c) 2013-2015, Intel Corporation @@ -2393,11 +2393,15 @@ iavf_atq_done(struct iavf_softc *sc) unsigned int cons; unsigned int prod; + mtx_enter(&sc->sc_atq_mtx); + prod = sc->sc_atq_prod; cons = sc->sc_atq_cons; - if (prod == cons) + if (prod == cons) { + mtx_leave(&sc->sc_atq_mtx); return; + } atq = IAVF_DMA_KVA(&sc->sc_atq); @@ -2421,6 +2425,8 @@ iavf_atq_done(struct iavf_softc *sc) BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); sc->sc_atq_cons = cons; + + mtx_leave(&sc->sc_atq_mtx); } static int @@ -2429,6 +2435,8 @@ iavf_atq_post(struct iavf_softc *sc, struct iavf_aq_desc *iaq) struct iavf_aq_desc *atq, *slot; unsigned int prod; + mtx_enter(&sc->sc_atq_mtx); + atq = IAVF_DMA_KVA(&sc->sc_atq); prod = sc->sc_atq_prod; slot = atq + prod; @@ -2446,6 +2454,9 @@ iavf_atq_post(struct iavf_softc *sc, struct iavf_aq_desc *iaq) prod &= IAVF_AQ_MASK; sc->sc_atq_prod = prod; iavf_wr(sc, sc->sc_aq_regs->atq_tail, prod); + + mtx_leave(&sc->sc_atq_mtx); + return (prod); }