[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250630181225.38a67e11@kernel.org>
Date: Mon, 30 Jun 2025 18:12:25 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Raju Rangoju <Raju.Rangoju@....com>
Cc: <andrew+netdev@...n.ch>, <davem@...emloft.net>, <edumazet@...gle.com>,
<pabeni@...hat.com>, <netdev@...r.kernel.org>, <Shyam-sundar.S-k@....com>
Subject: Re: [PATCH net v2] amd-xgbe: do not double read link status
On Wed, 25 Jun 2025 15:23:15 +0530 Raju Rangoju wrote:
> The link status is latched low so that momentary link drops
> can be detected. Avoid double-reading the status to identify
> short link interruptions, unless the link was already down.
Took me a minute to understand this. How about:
The link status is latched low so that momentary link drops
can be detected. Always double-reading the status defeats this
design feature. Only double read if link was already down.
> - reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1);
> - reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1);
> + if (!pdata->phy.link) {
> + reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1);
> + if (reg < 0)
> + return reg;
> +
> + if (reg & MDIO_STAT1_LSTATUS)
> + goto skip_read;
> + }
>
> + reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1);
> + if (reg < 0)
> + return reg;
> +skip_read:
> if (pdata->en_rx_adap) {
> /* if the link is available and adaptation is done,
> * declare link up
Don't use gotos for normal function control flow :/
reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1);
if (reg < 0)
return reg;
/* Link status is latched low so that momentary link drops
* can be detected. If link was already down read again
* to get the latest state.
*/
if (!pdata->phy.link && !(reg & MDIO_STAT1_LSTATUS)) {
reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1);
if (reg < 0)
return reg;
}
if (pdata->en_rx_adap) {
/* if the link is available and adaptation is done,
--
pw-bot: cr
Powered by blists - more mailing lists