axgbe: move phy_stop to axgbe_if_detach()

Since the iflib interface needs axgbe_pci_init() and its phy starting capabilities, no data was passed in its absence.

With the NULL check of the axgbe_miibus we also resort back to an MDIO read as a module might be capable of both
clause 22 and clause 45 methods of communication.

with the move of phy_stop() to if_detach() in d50d4e8cd4, it's better to prevent reconfiguring the phy should the pci_init() callout trigger more than once.
This commit is contained in:
Ad Schellevis 2023-05-15 16:04:18 +02:00 committed by Franco Fichtner
parent d35993f92b
commit 7ffe076525
3 changed files with 13 additions and 4 deletions

View file

@ -1577,6 +1577,7 @@ axgbe_if_detach(if_ctx_t ctx)
mac_res[0] = pdata->xgmac_res;
mac_res[1] = pdata->xpcs_res;
phy_if->phy_stop(pdata);
phy_if->phy_exit(pdata);
/* Free Interrupts */
@ -1648,7 +1649,6 @@ axgbe_pci_stop(if_ctx_t ctx)
{
struct axgbe_if_softc *sc = iflib_get_softc(ctx);
struct xgbe_prv_data *pdata = &sc->pdata;
struct xgbe_phy_if *phy_if = &pdata->phy_if;
struct xgbe_hw_if *hw_if = &pdata->hw_if;
int ret;
@ -1663,8 +1663,6 @@ axgbe_pci_stop(if_ctx_t ctx)
hw_if->disable_tx(pdata);
hw_if->disable_rx(pdata);
phy_if->phy_stop(pdata);
ret = hw_if->exit(pdata);
if (ret)
axgbe_error("%s: exit error %d\n", __func__, ret);

View file

@ -1439,7 +1439,10 @@ xgbe_phy_stop(struct xgbe_prv_data *pdata)
static int
xgbe_phy_start(struct xgbe_prv_data *pdata)
{
int ret;
int ret = 0;
if (pdata->phy_started)
return (ret);
DBGPR("-->xgbe_phy_start\n");
@ -1584,6 +1587,7 @@ xgbe_phy_init(struct xgbe_prv_data *pdata)
pdata->phy.duplex = DUPLEX_FULL;
}
pdata->phy_started = 0;
pdata->phy.link = 0;
pdata->phy.pause_autoneg = pdata->pause_autoneg;

View file

@ -3178,6 +3178,11 @@ xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart)
}
if (phy_data->phydev || phy_data->port_mode != XGBE_PORT_MODE_SFP) {
if (pdata->axgbe_miibus == NULL) {
axgbe_printf(1, "%s: miibus not initialized", __func__);
goto mdio_read;
}
mii = device_get_softc(pdata->axgbe_miibus);
mii_tick(mii);
@ -3202,6 +3207,8 @@ xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart)
xgbe_rrc(pdata);
}
mdio_read:
/* Link status is latched low, so read once to clear
* and then read again to get current state
*/