summaryrefslogtreecommitdiff
path: root/sys/dev/pci/if_iavf.c
diff options
context:
space:
mode:
authorJonathan Matthew <jmatthew@cvs.openbsd.org>2024-07-10 08:48:21 +0000
committerJonathan Matthew <jmatthew@cvs.openbsd.org>2024-07-10 08:48:21 +0000
commitfb4f2ac4a89c4329e935e2696bd8966b4ae04ca6 (patch)
treeb29e18ecb8fc8da3f2d97ef6ba82a1219d3dcf01 /sys/dev/pci/if_iavf.c
parenta238e311993c6a94214ed3f1142a02ac3961bd4c (diff)
as per if_ixl.c r1.88, protect the admin queue with a muteX
cVS: ----------------------------------------------------------------------
Diffstat (limited to 'sys/dev/pci/if_iavf.c')
-rw-r--r--sys/dev/pci/if_iavf.c15
1 files changed, 13 insertions, 2 deletions
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);
}