From: "Rangoju, Raju" <raju.rangoju@amd.com>
To: Jakub Kicinski <kuba@kernel.org>
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: Tue, 1 Jul 2025 12:12:21 +0530 [thread overview]
Message-ID: <ef471e23-e0e2-4e7b-91a7-c56569e526dd@amd.com> (raw)
In-Reply-To: <20250630181225.38a67e11@kernel.org>
On 7/1/2025 6:42 AM, Jakub Kicinski wrote:
> 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.
Sounds good, I'll update commit message accordingly.
>
>> - 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 :/
Sure. I'll re-spin v3 with the suggested changes.
>
> 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,
prev parent reply other threads:[~2025-07-01 6:42 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
2025-07-01 6:42 ` Rangoju, Raju [this message]
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=ef471e23-e0e2-4e7b-91a7-c56569e526dd@amd.com \
--to=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=kuba@kernel.org \
--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 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).