bus_dmamem_unmap() should not be called from interrupt context, so free
authorpatrick <patrick@openbsd.org>
Mon, 20 Dec 2021 19:24:32 +0000 (19:24 +0000)
committerpatrick <patrick@openbsd.org>
Mon, 20 Dec 2021 19:24:32 +0000 (19:24 +0000)
and close flowrings using bwfm_do_async().

Reported by and ok kettenis@

sys/dev/ic/bwfmvar.h
sys/dev/pci/if_bwfm_pci.c

index a641a74..f3304f7 100644 (file)
@@ -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 <patrick@blueri.se>
@@ -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];
index e39163f..dc27d29 100644 (file)
@@ -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 <patrick@blueri.se>
@@ -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)
 {