From: Andrew Lunn <andrew@lunn.ch>
To: Dejin Zheng <zhengdejin5@gmail.com>
Cc: f.fainelli@gmail.com, hkallweit1@gmail.com,
linux@armlinux.org.uk, davem@davemloft.net, kuba@kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Kevin Groeneveld <kgroeneveld@gmail.com>
Subject: Re: [PATCH net v1] net: phy: smsc: fix printing too many logs
Date: Wed, 17 Jun 2020 20:43:34 +0200 [thread overview]
Message-ID: <20200617184334.GA240559@lunn.ch> (raw)
In-Reply-To: <20200617175039.GA18631@nuc8i5>
On Thu, Jun 18, 2020 at 01:50:39AM +0800, Dejin Zheng wrote:
> On Wed, Jun 17, 2020 at 06:19:25PM +0200, Andrew Lunn wrote:
> > On Wed, Jun 17, 2020 at 11:33:40PM +0800, Dejin Zheng wrote:
> > > Commit 7ae7ad2f11ef47 ("net: phy: smsc: use phy_read_poll_timeout()
> > > to simplify the code") will print a lot of logs as follows when Ethernet
> > > cable is not connected:
> > >
> > > [ 4.473105] SMSC LAN8710/LAN8720 2188000.ethernet-1:00: lan87xx_read_status failed: -110
> > >
> > > So fix it by read_poll_timeout().
> >
> > Do you have a more detailed explanation of what is going on here?
> >
> > After a lot of thought, i think i can see how this happens. But the
> > commit message should really spell out why this is the correct fix.
> >
> Hi Andrew:
>
> Kevin report a bug for me in link[1], I check the Commit 7ae7ad2f11ef47
> ("net: phy: smsc: use phy_read_poll_timeout() to simplify the code") and
> found it change the original behavior in smsc driver. It does not has
> any error message whether it is timeout or phy_read fails, but this Commit
> will changed it and will print some error messages by
> phy_read_poll_timeout() when it is timeout or phy_read fails. so use the
> read_poll_timeout() to replace phy_read_poll_timeout() to fix this
> issue. the read_poll_timeout() does not print any log when it goes
> wrong.
>
> the original codes is that:
>
> /* Wait max 640 ms to detect energy */
> for (i = 0; i < 64; i++) {
> /* Sleep to allow link test pulses to be sent */
> msleep(10);
> rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
> if (rc < 0)
> return rc;
> if (rc & MII_LAN83C185_ENERGYON)
> break;
> }
>
> Commit 7ae7ad2f11ef47 modify it as this:
>
> phy_read_poll_timeout(phydev, MII_LAN83C185_CTRL_STATUS,
> rc & MII_LAN83C185_ENERGYON, 10000,
> 640000, true);
> if (rc < 0)
> return rc;
>
> the phy_read_poll_timeout() will print a error log by phydev_err()
> when timeout or rc < 0. read_poll_timeout() just return timeout
> error and does not print any error log.
>
> #define phy_read_poll_timeout(phydev, regnum, val, cond, sleep_us, \
> timeout_us, sleep_before_read) \
> ({ \
> int __ret = read_poll_timeout(phy_read, val, (cond) || val < 0, \
> sleep_us, timeout_us, sleep_before_read, phydev, regnum); \
> if (val < 0) \
> __ret = val; \
> if (__ret) \
> phydev_err(phydev, "%s failed: %d\n", __func__, __ret); \
> __ret; \
> })
>
> So use read_poll_timeout Use read_poll_timeout() to be consistent with the
> original code.
You have explained what the change does. But not why it is
needed. What exactly is happening. To me, the key thing is
understanding why we get -110, and why it is not an actual error we
should be reporting as an error. That is what needs explaining.
And once that is understood, i think we might be looking at a
different solution.
Andrew
next prev parent reply other threads:[~2020-06-17 18:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-17 15:33 [PATCH net v1] net: phy: smsc: fix printing too many logs Dejin Zheng
2020-06-17 16:19 ` Andrew Lunn
2020-06-17 17:50 ` Dejin Zheng
2020-06-17 18:43 ` Andrew Lunn [this message]
2020-06-17 20:24 ` Russell King - ARM Linux admin
2020-06-17 21:36 ` Andrew Lunn
2020-06-18 15:08 ` Dejin Zheng
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=20200617184334.GA240559@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=kgroeneveld@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=zhengdejin5@gmail.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).