From 9a5ce850414289c06a44e462bb43f20315169979 Mon Sep 17 00:00:00 2001 From: jmatthew Date: Wed, 10 Jan 2024 05:06:00 +0000 Subject: [PATCH] If bringing up a queue fails, only tear down the ones that we set up successfully, rather than trying to tear them all down and crashing. tested by hrvoje, who can make queue setup fail sometimes ok bluhm@ --- sys/dev/pci/if_bnxt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/dev/pci/if_bnxt.c b/sys/dev/pci/if_bnxt.c index 94b80f04000..fc1de6ddcca 100644 --- a/sys/dev/pci/if_bnxt.c +++ b/sys/dev/pci/if_bnxt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bnxt.c,v 1.42 2024/01/09 04:32:29 jmatthew Exp $ */ +/* $OpenBSD: if_bnxt.c,v 1.43 2024/01/10 05:06:00 jmatthew Exp $ */ /*- * Broadcom NetXtreme-C/E network driver. * @@ -1073,7 +1073,7 @@ bnxt_up(struct bnxt_softc *sc) if (bnxt_hwrm_vnic_ctx_alloc(sc, &sc->sc_vnic.rss_id) != 0) { printf("%s: failed to allocate vnic rss context\n", DEVNAME(sc)); - goto down_queues; + goto down_all_queues; } sc->sc_vnic.id = (uint16_t)HWRM_NA_SIGNATURE; @@ -1139,8 +1139,11 @@ dealloc_vnic: bnxt_hwrm_vnic_free(sc, &sc->sc_vnic); dealloc_vnic_ctx: bnxt_hwrm_vnic_ctx_free(sc, &sc->sc_vnic.rss_id); + +down_all_queues: + i = sc->sc_nqueues; down_queues: - for (i = 0; i < sc->sc_nqueues; i++) + while (i-- > 0) bnxt_queue_down(sc, &sc->sc_queues[i]); bnxt_dmamem_free(sc, sc->sc_rx_cfg); -- 2.20.1