From b5553ee61edaca47830365fec899b78ad84b5dea Mon Sep 17 00:00:00 2001 From: patrick Date: Mon, 20 Dec 2021 19:24:32 +0000 Subject: [PATCH] bus_dmamem_unmap() should not be called from interrupt context, so free and close flowrings using bwfm_do_async(). Reported by and ok kettenis@ --- sys/dev/ic/bwfmvar.h | 6 +++++- sys/dev/pci/if_bwfm_pci.c | 21 ++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/sys/dev/ic/bwfmvar.h b/sys/dev/ic/bwfmvar.h index a641a74fa3b..f3304f71560 100644 --- a/sys/dev/ic/bwfmvar.h +++ b/sys/dev/ic/bwfmvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bwfmvar.h,v 1.25 2021/10/23 12:48:17 kettenis Exp $ */ +/* $OpenBSD: bwfmvar.h,v 1.26 2021/12/20 19:24:32 patrick Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation * Copyright (c) 2016,2017 Patrick Wildt @@ -130,6 +130,10 @@ struct bwfm_cmd_flowring_create { int prio; }; +struct bwfm_cmd_flowring_delete { + int flowid; +}; + struct bwfm_host_cmd_ring { #define BWFM_HOST_CMD_RING_COUNT 32 struct bwfm_host_cmd cmd[BWFM_HOST_CMD_RING_COUNT]; diff --git a/sys/dev/pci/if_bwfm_pci.c b/sys/dev/pci/if_bwfm_pci.c index e39163f1550..dc27d298055 100644 --- a/sys/dev/pci/if_bwfm_pci.c +++ b/sys/dev/pci/if_bwfm_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bwfm_pci.c,v 1.57 2021/10/23 12:48:17 kettenis Exp $ */ +/* $OpenBSD: if_bwfm_pci.c,v 1.58 2021/12/20 19:24:32 patrick Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation * Copyright (c) 2017 Patrick Wildt @@ -284,6 +284,7 @@ void bwfm_pci_flowring_create(struct bwfm_pci_softc *, struct mbuf *); void bwfm_pci_flowring_create_cb(struct bwfm_softc *, void *); void bwfm_pci_flowring_delete(struct bwfm_pci_softc *, int); +void bwfm_pci_flowring_delete_cb(struct bwfm_softc *, void *); int bwfm_pci_preinit(struct bwfm_softc *); void bwfm_pci_stop(struct bwfm_softc *); @@ -1542,6 +1543,7 @@ bwfm_pci_msg_rx(struct bwfm_pci_softc *sc, void *buf, struct mbuf_list *ml) struct msgbuf_common_hdr *msg; struct msgbuf_flowring_create_resp *fcr; struct msgbuf_flowring_delete_resp *fdr; + struct bwfm_cmd_flowring_create fdcmd; struct bwfm_pci_msgring *ring; struct mbuf *m; int flowid; @@ -1596,8 +1598,9 @@ bwfm_pci_msg_rx(struct bwfm_pci_softc *sc, void *buf, struct mbuf_list *ml) DEVNAME(sc), flowid); break; } - bwfm_pci_dmamem_free(sc, ring->ring); - ring->status = RING_CLOSED; + fdcmd.flowid = flowid; + bwfm_do_async(&sc->sc_sc, bwfm_pci_flowring_delete_cb, + &fdcmd, sizeof(fdcmd)); break; case MSGBUF_TYPE_IOCTLPTR_REQ_ACK: m = bwfm_pci_pktid_free(sc, &sc->sc_ioctl_pkts, @@ -1995,6 +1998,18 @@ bwfm_pci_flowring_delete(struct bwfm_pci_softc *sc, int flowid) splx(s); } +void +bwfm_pci_flowring_delete_cb(struct bwfm_softc *bwfm, void *arg) +{ + struct bwfm_pci_softc *sc = (void *)bwfm; + struct bwfm_cmd_flowring_create *cmd = arg; + struct bwfm_pci_msgring *ring; + + ring = &sc->sc_flowrings[cmd->flowid]; + bwfm_pci_dmamem_free(sc, ring->ring); + ring->status = RING_CLOSED; +} + void bwfm_pci_stop(struct bwfm_softc *bwfm) { -- 2.20.1