From: Andrew Lunn <andrew@lunn.ch>
To: Qiang Ma <maqianga@uniontech.com>
Cc: f.fainelli@gmail.com, davem@davemloft.net,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Ming Wang <wangming01@loongson.cn>
Subject: Re: [PATCH] net: phy: fix autoneg invalid error state of GBSR register.
Date: Wed, 1 Sep 2021 14:43:26 +0200 [thread overview]
Message-ID: <YS91biZov3jE+Lrd@lunn.ch> (raw)
In-Reply-To: <20210901105608.29776-1-maqianga@uniontech.com>
On Wed, Sep 01, 2021 at 06:56:08PM +0800, Qiang Ma wrote:
> When the PHY is not link and working in polling mode, PHY state
> machine will periodically read GBSR register. Normally, the GBSR
> register value is 0. But as the log show, in very small cases the
> value is 0x8640. The value 0x8640 means Master/Slave resolution
> failed. The PHY state machine will enter PHY_HALTED state and the
> PHY will never be able to link.
>
> [49176.903012] [debug]: lpagb:0x0 adv:0x300
> [49177.927025] [debug]: lpagb:0x8640 adv:0x300
> [49177.927034] Generic PHY stmmac-18:00: Master/Slave resolution failed
> [49177.927241] [debug]: lpagb:0x0 adv:0x300
>
> According to the RTL8211E PHY chip datasheet, the contents of GBSR register
> are valid only when auto negotiation is completed(BMSR[5]: Auto-
> Negotiation Complete = 1). This patch adds the condition before
> reading GBSR register to fix this error state.
>
> Signed-off-by: Ming Wang <wangming01@loongson.cn>
> Signed-off-by: Qiang Ma <maqianga@uniontech.com>
> ---
> drivers/net/phy/phy_device.c | 10 ++++------
> include/linux/phy.h | 1 +
> 2 files changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index b884b681d5c5..b77ed5ec31c6 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -1532,10 +1532,8 @@ int genphy_update_link(struct phy_device *phydev)
> if (status < 0)
> return status;
>
> - if ((status & BMSR_LSTATUS) == 0)
> - phydev->link = 0;
> - else
> - phydev->link = 1;
> + phydev->link = status & BMSR_LSTATUS ? 1 : 0;
> + phydev->autoneg_complete = status & BMSR_ANEGCOMPLETE ? 1 : 0;
>
> return 0;
> }
What tree is this against? Both net-next/master and net/master have:
if (status < 0)
return status;
done:
phydev->link = status & BMSR_LSTATUS ? 1 : 0;
phydev->autoneg_complete = status & BMSR_ANEGCOMPLETE ? 1 : 0;
/* Consider the case that autoneg was started and "aneg complete"
* bit has been reset, but "link up" bit not yet.
*/
if (phydev->autoneg == AUTONEG_ENABLE && !phydev->autoneg_complete)
phydev->link = 0;
return 0;
}
It looks like you are using an old tree.
Andrew
next parent reply other threads:[~2021-09-01 12:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210901105608.29776-1-maqianga@uniontech.com>
2021-09-01 12:43 ` Andrew Lunn [this message]
[not found] ` <tencent_405C539D1A6BA06876B7AC05@qq.com>
2021-09-01 13:01 ` [PATCH] net: phy: fix autoneg invalid error state of GBSR register Andrew Lunn
2021-09-01 14:39 ` Jakub Kicinski
[not found] ` <tencent_312431A93CE3F240692EF111@qq.com>
2021-09-01 14:55 ` Florian Fainelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YS91biZov3jE+Lrd@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maqianga@uniontech.com \
--cc=netdev@vger.kernel.org \
--cc=wangming01@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).