From: Jakub Kicinski <kuba@kernel.org>
To: Raju Rangoju <Raju.Rangoju@amd.com>
Cc: <andrew+netdev@lunn.ch>, <davem@davemloft.net>,
<edumazet@google.com>, <pabeni@redhat.com>,
<netdev@vger.kernel.org>, <Shyam-sundar.S-k@amd.com>
Subject: Re: [PATCH net v2] amd-xgbe: do not double read link status
Date: Mon, 30 Jun 2025 18:12:25 -0700 [thread overview]
Message-ID: <20250630181225.38a67e11@kernel.org> (raw)
In-Reply-To: <20250625095315.232566-1-Raju.Rangoju@amd.com>
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
next prev parent reply other threads:[~2025-07-01 1:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-25 9:53 [PATCH net v2] amd-xgbe: do not double read link status Raju Rangoju
2025-07-01 1:12 ` Jakub Kicinski [this message]
2025-07-01 6:42 ` Rangoju, Raju
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=20250630181225.38a67e11@kernel.org \
--to=kuba@kernel.org \
--cc=Raju.Rangoju@amd.com \
--cc=Shyam-sundar.S-k@amd.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.