[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <05af1645-9355-4d1d-9aa2-fd5e42e8fad4@lunn.ch>
Date: Sat, 23 Nov 2024 00:10:10 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Frank Sae <Frank.Sae@...or-comm.com>
Cc: davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, xiaogang.fan@...or-comm.com,
fei.zhang@...or-comm.com, hua.sun@...or-comm.com
Subject: Re: [PATCH net-next v2 15/21] motorcomm:yt6801: Implement pci_driver
suspend and resume
> +static int fxgmac_pre_powerdown(struct fxgmac_pdata *pdata)
> +{
> + u32 val = 0;
> + int ret;
> +
> + fxgmac_disable_rx(pdata);
> +
> + yt_dbg(pdata, "%s, phy and mac status update\n", __func__);
> +
> + if (device_may_wakeup(pdata->dev)) {
> + val = rd32_mem(pdata, EPHY_CTRL);
> + if (val & EPHY_CTRL_STA_LINKUP) {
> + ret = phy_speed_down(pdata->phydev, true);
> + if (ret < 0) {
> + yt_err(pdata, "%s, phy_speed_down err:%d\n", __func__, ret);
> + return ret;
> + }
> +
> + ret = phy_read_status(pdata->phydev);
> + if (ret < 0) {
> + yt_err(pdata, "%s, phy_read_status err:%d\n",
> + __func__, ret);
> + return ret;
> + }
> +
> + pdata->phy_speed = pdata->phydev->speed;
> + pdata->phy_duplex = pdata->phydev->duplex;
> + yt_dbg(pdata, "%s, speed :%d, duplex :%d\n", __func__,
> + pdata->phy_speed, pdata->phy_duplex);
> +
> + fxgmac_config_mac_speed(pdata);
phy_speed_down() will trigger an autoneg cycle. Once the link has
established the adjust_link callback will be called telling you the
new speed and duplex. The only time you can safely access
phydev->speed and phydev->duplex is during that callback. At other
times the values can be inconsistent.
Andrew
Powered by blists - more mailing lists