From 5128d2cb1525f6b4a36535fd7348e6d8c0c81ab1 Mon Sep 17 00:00:00 2001 From: dlg Date: Wed, 1 Jun 2022 06:33:46 +0000 Subject: [PATCH] mark the mvneta interrupt handler as mpsafe. link state changes still take the kernel lock, but packet processing is unlocked now. --- sys/dev/fdt/if_mvneta.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sys/dev/fdt/if_mvneta.c b/sys/dev/fdt/if_mvneta.c index df5105c4fb7..8a8721683df 100644 --- a/sys/dev/fdt/if_mvneta.c +++ b/sys/dev/fdt/if_mvneta.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_mvneta.c,v 1.23 2022/06/01 04:31:08 dlg Exp $ */ +/* $OpenBSD: if_mvneta.c,v 1.24 2022/06/01 06:33:46 dlg Exp $ */ /* $NetBSD: if_mvneta.c,v 1.41 2015/04/15 10:15:40 hsuenaga Exp $ */ /* * Copyright (c) 2007, 2008, 2013 KIYOHARA Takashi @@ -135,6 +135,7 @@ struct mvneta_softc { bus_space_tag_t sc_iot; bus_space_handle_t sc_ioh; bus_dma_tag_t sc_dmat; + void *sc_ih; struct arpcom sc_ac; #define sc_enaddr sc_ac.ac_enaddr @@ -694,8 +695,8 @@ mvneta_attach(struct device *parent, struct device *self, void *aux) while (MVNETA_READ(sc, MVNETA_PMACC2) & MVNETA_PMACC2_PORTMACRESET) ; - fdt_intr_establish(faa->fa_node, IPL_NET, mvneta_intr, sc, - sc->sc_dev.dv_xname); + sc->sc_ih = fdt_intr_establish(faa->fa_node, IPL_NET | IPL_MPSAFE, + mvneta_intr, sc, sc->sc_dev.dv_xname); ifp = &sc->sc_ac.ac_if; ifp->if_softc = sc; @@ -822,6 +823,7 @@ mvneta_intr(void *arg) ic = MVNETA_READ(sc, MVNETA_PRXTXTIC); if (ic & MVNETA_PRXTXTI_PMISCICSUMMARY) { + KERNEL_LOCK(); misc = MVNETA_READ(sc, MVNETA_PMIC); MVNETA_WRITE(sc, MVNETA_PMIC, 0); if (sc->sc_inband_status && (misc & @@ -830,9 +832,10 @@ mvneta_intr(void *arg) MVNETA_PMI_PSCSYNCCHNG))) { mvneta_inband_statchg(sc); } + KERNEL_UNLOCK(); } - if (!(ifp->if_flags & IFF_RUNNING)) + if (!ISSET(ifp->if_flags, IFF_RUNNING)) return 1; if (ic & MVNETA_PRXTXTI_TBTCQ(0)) @@ -1202,6 +1205,8 @@ mvneta_down(struct mvneta_softc *sc) DPRINTFN(2, ("mvneta_down\n")); timeout_del(&sc->sc_tick_ch); + ifp->if_flags &= ~IFF_RUNNING; + intr_barrier(sc->sc_ih); /* Stop Rx port activity. Check port Rx activity. */ reg = MVNETA_READ(sc, MVNETA_RQC); @@ -1312,7 +1317,6 @@ mvneta_down(struct mvneta_softc *sc) MVNETA_WRITE(sc, MVNETA_PRXINIT, 0); MVNETA_WRITE(sc, MVNETA_PTXINIT, 0); - ifp->if_flags &= ~IFF_RUNNING; ifq_clr_oactive(&ifp->if_snd); } -- 2.20.1