Re: [PATCH net-next v5 4/5] net: phy: mediatek: Extend 1G TX/RX link pulse time

From: SkyLake Huang (黃啟澤)
Date: Thu May 30 2024 - 12:01:41 EST


On Thu, 2024-05-30 at 11:23 +0100, Russell King (Oracle) wrote:
>
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> Hi,
>
> A few suggestions:
>
> On Thu, May 30, 2024 at 11:48:43AM +0800, Sky Huang wrote:
> > +static int extend_an_new_lp_cnt_limit(struct phy_device *phydev)
> > +{
> > +int mmd_read_ret;
> > +u32 reg_val;
> > +int timeout;
> > +
> > +timeout = read_poll_timeout(mmd_read_ret = phy_read_mmd, reg_val,
> > + (mmd_read_ret < 0) || reg_val & MTK_PHY_FINAL_SPEED_1000,
> > + 10000, 1000000, false, phydev,
> > + MDIO_MMD_VEND1, MTK_PHY_LINK_STATUS_MISC);
>
> timeout = phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1,
> MTK_PHY_LINK_STATUS_MISC,
> reg_val,
> reg_val & MTK_PHY_FINAL_SPEED_1000,
> 10000, 1000000, false);
>
> > +if (mmd_read_ret < 0)
> > +return mmd_read_ret;
>
> So, what if the poll times out (timeout == -ETIMEDOUT) ? If you want
> to
> ignore that, then:
>
> if (timeout < 0 && timeout != -ETIMEDOUT)
> return timeout;
>
I'm not going to handle timeout case here. If we can't detect
MTK_PHY_FINAL_SPEED_1000 in 1 second, let it go and we'll detect it
next round.

> > +int mtk_gphy_cl22_read_status(struct phy_device *phydev)
> > +{
> > +int ret;
> > +
> > +ret = genphy_read_status(phydev);
> > +if (ret)
> > +return ret;
> > +
> > +if (phydev->autoneg == AUTONEG_ENABLE && !phydev-
> >autoneg_complete) {
> > +ret = phy_read(phydev, MII_CTRL1000);
> > +if ((ret & ADVERTISE_1000FULL) || (ret & ADVERTISE_1000HALF)) {
>
> This is equivalent to:
>
> if (ret & (ADVERTISE_1000FULL | ADVERTISE_1000HALF)) {
>
> which is easier to read.
>
> Thanks.
>
> --
> RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
> FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

Agree. I'll modify this in next version.

Sky