From nobody Sat Aug 22 00:42:59 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hRdgr58tZz6pr7m for ; Sat, 22 Aug 2026 00:43:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hRdgr2DyWz3K6G for ; Sat, 22 Aug 2026 00:43:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787359384; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/BXQzDSyH+V52/NWTB2as9sxbsTpizSxmLqof4VdVgw=; b=JXS9mNjye+EGA+RVRKnyOeJQ6hy2b5+paHLQ8atDH+WrgYEsJSrCdHXQfn7kuz5LnTo0qw LHw4gki8jkwW40vbRdE2M2L7c7gZhNCEw+QdpZT+cmzqDhWMUgHa+NMcOeiHQuSE5ggqkv Zw2Mh7pTjL9T4QA/IXmtNAJ0xKyXQ3J5tE/dxYXNouRIidp+ar3KZsmtjbYAv/CVO1WbZX vUpk8irZa6vJT9+uDdWMGL6b9oeYDI0MoFbmhwO7olKXR/QxwJJUkVj8tyFPlUB34NEzFo FvrrArQPPmBt2pxA7iQfVxiUvYQ/CZ2Hs3rPnj8VNVogQCpdWUxmpyjvR8ZMjA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1787359384; a=rsa-sha256; cv=none; b=KxWLQUKHiDXTA80/c5PmrXcyySbo9rKh7IADIEFM0AaagDDG7ZjRz2II6fvxYNH43RkRWA ktOdLWYBXxvlvyb7XtprqcqxU+mg220dDpFKOnZUkCG4GGqBrGMHeYBjXmmYbMAAMcBYEw BvMXOSkHv9UhN3lKesDxCAsWnoT6qhf/GXxBN/GmVWjhvA3BpetGgbvSXZRHV0qQCa57mb NuRfUhOCD/bL01TTT4Q+B6YSD68opgzfpGHAflHXDBtBKoKaB8ABsWC53iqtIZxqQYm7qP 4m3FoBv7Dm6NXaJDykyb9HlrmOfMb0TiJIK206OyqgtwpUqPhim4tjZmk6IFrA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787359384; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/BXQzDSyH+V52/NWTB2as9sxbsTpizSxmLqof4VdVgw=; b=MPloBgPK4FBnltmyMfPU5FhPjbXEkPu/Z8WIXTAxm/C9xVGQa6YjxrkncnRSgiLWQMQVR7 VqYGann4RG4WJWXGpExHHyu4gzpld2P+6uv2rosQ6OuuQo/GoCpIyU0zsul4tkcvdY+Lwx ndWt82VjQHlZsso8AlhbTtbWokuGgnbXjAFej8EpI97ly+EKfnEwEuaCnD5LefTdV9g1NC KDLMKD97Mspn7RnhvOaj3R+IxavW4G8ULzCrCLBS1sBp0vBc55bpLb/5zgJqebMedeVeL8 mp15U5vpA39+H3MPBY7giNlOvcyC96dVNUpG+zeGYla5bFPtkuFvvGt4XoTLQA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hRdgr1JwVzBWs for ; Sat, 22 Aug 2026 00:43:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 256f3 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 22 Aug 2026 00:42:59 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 522e73a8d345 - stable/14 - axgbe: Align channel lifetime with queue allocation List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 522e73a8d345272ffc45bd65363bc9d9d1749f35 Auto-Submitted: auto-generated Date: Sat, 22 Aug 2026 00:42:59 +0000 Message-Id: <6a88f093.256f3.d71cf87@gitrepo.freebsd.org> The branch stable/14 has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=522e73a8d345272ffc45bd65363bc9d9d1749f35 commit 522e73a8d345272ffc45bd65363bc9d9d1749f35 Author: Kevin Bowling AuthorDate: 2026-08-08 04:14:53 +0000 Commit: Kevin Bowling CommitDate: 2026-08-22 00:42:15 +0000 axgbe: Align channel lifetime with queue allocation DMA channels are allocated by attach_pre but released by queues_free. When iflib fails after attach_pre and before queue allocation, neither the old detach nor queues_free path releases them. Allocate channels with the TX queue state and make queues_free tolerate partially allocated rings. Use it to unwind allocation failures so TX rings are also released when RX allocation fails. An early detach can also precede PHY initialization and interrupt assignment. Skip absent PHY and channel state, and release the locks owned by attach_pre on both failure and detach. (cherry picked from commit 65228a835267191ba692c2699b18913a388b4d20) --- sys/dev/axgbe/if_axgbe_pci.c | 78 +++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 41 deletions(-) diff --git a/sys/dev/axgbe/if_axgbe_pci.c b/sys/dev/axgbe/if_axgbe_pci.c index ee800011ff24..1cdab7d22fd3 100644 --- a/sys/dev/axgbe/if_axgbe_pci.c +++ b/sys/dev/axgbe/if_axgbe_pci.c @@ -528,13 +528,6 @@ axgbe_if_attach_pre(if_ctx_t ctx) /* Initialize IFLIB if_softc_ctx_t */ axgbe_init_iflib_softc_ctx(sc); - /* Alloc channels */ - if (axgbe_alloc_channels(ctx)) { - axgbe_error("Unable to allocate channel memory\n"); - ret = ENOMEM; - goto release_bus_resource; - } - TASK_INIT(&pdata->service_work, 0, xgbe_service, pdata); /* create the workqueue */ @@ -555,13 +548,16 @@ axgbe_if_attach_pre(if_ctx_t ctx) free_task_queue: taskqueue_free(pdata->dev_workqueue); - axgbe_free_channels(sc); release_bus_resource: bus_release_resources(dev, axgbe_pci_mac_spec, mac_res); free_vlans: free(pdata->active_vlans, M_AXGBE); + pdata->active_vlans = NULL; + mtx_destroy(&pdata->xpcs_lock); + mtx_destroy(&pdata->rss_mutex); + mtx_destroy(&pdata->mdio_mutex); return (ret); } /* axgbe_if_attach_pre */ @@ -1500,6 +1496,8 @@ axgbe_interrupts_free(if_ctx_t ctx) for (i = 0; i < scctx->isc_nrxqsets; i++) { channel = pdata->channel[i]; + if (channel == NULL) + continue; axgbe_printf(2, "%s: rid %d\n", __func__, channel->dma_irq_rid); irq.ii_res = channel->dma_irq_res; irq.ii_tag = channel->dma_irq_tag; @@ -1518,21 +1516,31 @@ axgbe_if_detach(if_ctx_t ctx) mac_res[0] = pdata->xgmac_res; mac_res[1] = pdata->xpcs_res; - phy_if->phy_exit(pdata); + if (pdata->phy_data != NULL) { + phy_if->phy_stop(pdata); + phy_if->phy_exit(pdata); + pdata->phy_data = NULL; + } /* Free Interrupts */ axgbe_interrupts_free(ctx); /* Free workqueues */ taskqueue_free(pdata->dev_workqueue); + pdata->dev_workqueue = NULL; /* Release bus resources */ bus_release_resources(iflib_get_dev(ctx), axgbe_pci_mac_spec, mac_res); /* Free VLAN bitmap */ free(pdata->active_vlans, M_AXGBE); + pdata->active_vlans = NULL; axgbe_sysctl_exit(pdata); + pdata->sys_op = NULL; + mtx_destroy(&pdata->xpcs_lock); + mtx_destroy(&pdata->rss_mutex); + mtx_destroy(&pdata->mdio_mutex); return (0); } /* axgbe_if_detach */ @@ -1640,7 +1648,7 @@ axgbe_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *va, uint64_t *pa, int ntxqs, if_softc_ctx_t scctx = sc->scctx; struct xgbe_channel *channel; struct xgbe_ring *tx_ring; - int i, j, k; + int i, j; MPASS(scctx->isc_ntxqsets > 0); MPASS(scctx->isc_ntxqsets == ntxqsets); @@ -1648,6 +1656,10 @@ axgbe_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *va, uint64_t *pa, int ntxqs, axgbe_printf(1, "%s: txqsets %d/%d txqs %d\n", __func__, scctx->isc_ntxqsets, ntxqsets, ntxqs); + if (axgbe_alloc_channels(ctx) != 0) { + axgbe_error("Unable to allocate channel memory\n"); + return (ENOMEM); + } for (i = 0 ; i < ntxqsets; i++) { @@ -1667,6 +1679,10 @@ axgbe_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *va, uint64_t *pa, int ntxqs, tx_ring->rdata = (struct xgbe_ring_data*)malloc(scctx->isc_ntxd[j] * sizeof(struct xgbe_ring_data), M_AXGBE, M_NOWAIT); + if (tx_ring->rdata == NULL) { + axgbe_error("Unable to allocate TX ring data\n"); + goto tx_ring_fail; + } /* Get the virtual & physical address of hw queues */ tx_ring->rdesc = (struct xgbe_ring_desc *)va[i*ntxqs + j]; @@ -1681,21 +1697,7 @@ axgbe_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *va, uint64_t *pa, int ntxqs, return (0); tx_ring_fail: - - for (j = 0; j < i ; j++) { - - channel = pdata->channel[j]; - - tx_ring = channel->tx_ring; - for (k = 0; k < ntxqs ; k++, tx_ring++) { - if (tx_ring && tx_ring->rdata) - free(tx_ring->rdata, M_AXGBE); - } - free(channel->tx_ring, M_AXGBE); - - channel->tx_ring = NULL; - } - + axgbe_if_queues_free(ctx); return (ENOMEM); } /* axgbe_if_tx_queues_alloc */ @@ -1709,7 +1711,7 @@ axgbe_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *va, uint64_t *pa, int nrxqs, if_softc_ctx_t scctx = sc->scctx; struct xgbe_channel *channel; struct xgbe_ring *rx_ring; - int i, j, k; + int i, j; MPASS(scctx->isc_nrxqsets > 0); MPASS(scctx->isc_nrxqsets == nrxqsets); @@ -1740,6 +1742,10 @@ axgbe_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *va, uint64_t *pa, int nrxqs, rx_ring->rdata = (struct xgbe_ring_data*)malloc(scctx->isc_nrxd[j] * sizeof(struct xgbe_ring_data), M_AXGBE, M_NOWAIT); + if (rx_ring->rdata == NULL) { + axgbe_error("Unable to allocate RX ring data\n"); + goto rx_ring_fail; + } /* Get the virtual and physical address of the hw queues */ rx_ring->rdesc = (struct xgbe_ring_desc *)va[i*nrxqs + j]; @@ -1754,21 +1760,7 @@ axgbe_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *va, uint64_t *pa, int nrxqs, return (0); rx_ring_fail: - - for (j = 0 ; j < i ; j++) { - - channel = pdata->channel[j]; - - rx_ring = channel->rx_ring; - for (k = 0; k < nrxqs ; k++, rx_ring++) { - if (rx_ring && rx_ring->rdata) - free(rx_ring->rdata, M_AXGBE); - } - free(channel->rx_ring, M_AXGBE); - - channel->rx_ring = NULL; - } - + axgbe_if_queues_free(ctx); return (ENOMEM); } /* axgbe_if_rx_queues_alloc */ @@ -1788,6 +1780,8 @@ axgbe_if_queues_free(if_ctx_t ctx) for (i = 0 ; i < scctx->isc_ntxqsets; i++) { channel = pdata->channel[i]; + if (channel == NULL || channel->tx_ring == NULL) + continue; tx_ring = channel->tx_ring; for (j = 0; j < sctx->isc_ntxqs ; j++, tx_ring++) { @@ -1801,6 +1795,8 @@ axgbe_if_queues_free(if_ctx_t ctx) for (i = 0 ; i < scctx->isc_nrxqsets; i++) { channel = pdata->channel[i]; + if (channel == NULL || channel->rx_ring == NULL) + continue; rx_ring = channel->rx_ring; for (j = 0; j < sctx->isc_nrxqs ; j++, rx_ring++) {