The branch main has been updated by kbowling:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=b263545980f44c0318afcc26188046ad7e559ceb

commit b263545980f44c0318afcc26188046ad7e559ceb
Author:     Kevin Bowling <[email protected]>
AuthorDate: 2026-09-07 11:00:55 +0000
Commit:     Kevin Bowling <[email protected]>
CommitDate: 2026-09-17 06:09:30 +0000

    axgbe: Propagate hardware and PHY initialization failures
    
    Check hardware initialization instead of discarding its result, and
    preserve the original initialization error across cleanup. Report a failed
    init to iflib rather than publishing a running datapath. Return normalized
    FreeBSD errors from attach_post.  Reuse the existing native reset cleanup
    on failure.
    
    MFC after:      2 weeks
    Sponsored by:   BBOX.io
---
 sys/dev/axgbe/if_axgbe_pci.c | 40 ++++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/sys/dev/axgbe/if_axgbe_pci.c b/sys/dev/axgbe/if_axgbe_pci.c
index 0153247495e3..7cf74b49e339 100644
--- a/sys/dev/axgbe/if_axgbe_pci.c
+++ b/sys/dev/axgbe/if_axgbe_pci.c
@@ -93,7 +93,7 @@ static int axgbe_if_msix_intr_assign(if_ctx_t, int);
 static void xgbe_free_intr(struct xgbe_prv_data *, struct resource *, void *, 
int);
 
 /* Init and Iflib routines */
-static void axgbe_pci_init(struct xgbe_prv_data *);
+static int axgbe_pci_init(struct xgbe_prv_data *);
 static void axgbe_pci_stop(if_ctx_t);
 static void xgbe_disable_rx_tx_int(struct xgbe_prv_data *, struct xgbe_channel 
*);
 static void xgbe_disable_rx_tx_ints(struct xgbe_prv_data *);
@@ -1500,9 +1500,8 @@ axgbe_if_attach_post(if_ctx_t ctx)
        scctx->isc_max_frame_size = if_getmtu(ifp) + 18;
        scctx->isc_min_frame_size = XGMAC_MIN_PACKET;
 
-       axgbe_pci_init(pdata);
-
-       return (0);
+       ret = axgbe_pci_init(pdata);
+       return (ret < 0 ? -ret : ret);
 } /* axgbe_if_attach_post */
 
 static void
@@ -1595,27 +1594,28 @@ axgbe_if_detach(if_ctx_t ctx)
        return (0);
 } /* axgbe_if_detach */
 
-static void
+static int
 axgbe_pci_init(struct xgbe_prv_data *pdata)
 {
        struct xgbe_phy_if      *phy_if = &pdata->phy_if;
        struct xgbe_hw_if       *hw_if = &pdata->hw_if;
-       int ret = 0;
+       int ret, reset_ret;
 
        if (!__predict_false((test_bit(XGBE_DOWN, &pdata->dev_state)))) {
                axgbe_printf(1, "%s: Starting when XGBE_UP\n", __func__);
-               return;
+               return (0);
        }
 
-       hw_if->init(pdata);
+       ret = hw_if->init(pdata);
+       if (ret != 0) {
+               axgbe_error("%s: hardware init error %d\n", __func__, ret);
+               goto fail;
+       }
 
-        ret = phy_if->phy_start(pdata);
-        if (ret) {
-               axgbe_error("%s:  phy start %d\n", __func__, ret);
-               ret = hw_if->exit(pdata);
-               if (ret)
-                       axgbe_error("%s: exit error %d\n", __func__, ret);
-               return;
+       ret = phy_if->phy_start(pdata);
+       if (ret != 0) {
+               axgbe_error("%s: phy start error %d\n", __func__, ret);
+               goto fail;
        }
 
        hw_if->enable_tx(pdata);
@@ -1631,6 +1631,13 @@ axgbe_pci_init(struct xgbe_prv_data *pdata)
        xgbe_dump_mtl_registers(pdata);
        xgbe_dump_mac_registers(pdata);
        xgbe_dump_rmon_counters(pdata);
+       return (0);
+
+fail:
+       reset_ret = hw_if->exit(pdata);
+       if (reset_ret != 0)
+               axgbe_error("%s: cleanup reset error %d\n", __func__, 
reset_ret);
+       return (ret);
 }
 
 static void
@@ -1639,7 +1646,8 @@ axgbe_if_init(if_ctx_t ctx)
        struct axgbe_if_softc   *sc = iflib_get_softc(ctx);
        struct xgbe_prv_data    *pdata = &sc->pdata;    
 
-       axgbe_pci_init(pdata);
+       if (axgbe_pci_init(pdata) != 0)
+               iflib_init_failed(ctx);
 }
 
 static void

Reply via email to