All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Antoine Tenart <antoine.tenart@bootlin.com>,
	"David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next v2 1/3] net: phy: marvell10g: add mdix control
Date: Tue, 3 Mar 2020 19:06:01 +0000	[thread overview]
Message-ID: <20200303190601.GU25745@shell.armlinux.org.uk> (raw)
In-Reply-To: <20200303170316.GJ24912@lunn.ch>

On Tue, Mar 03, 2020 at 06:03:16PM +0100, Andrew Lunn wrote:
> > +static int mv3310_reset(struct phy_device *phydev, u32 unit)
> > +{
> > +	int retries, val, err;
> > +
> > +	err = phy_modify_mmd(phydev, MDIO_MMD_PCS, unit + MDIO_CTRL1,
> > +			     MDIO_CTRL1_RESET, MDIO_CTRL1_RESET);
> > +	if (err < 0)
> > +		return err;
> > +
> > +	retries = 20;
> > +	do {
> > +		msleep(5);
> > +		val = phy_read_mmd(phydev, MDIO_MMD_PCS, unit + MDIO_CTRL1);
> > +		if (val < 0)
> > +			return val;
> > +	} while (val & MDIO_CTRL1_RESET && --retries);
> > +
> > +	return val & MDIO_CTRL1_RESET ? -ETIMEDOUT : 0;
> 
> Hi Russell
> 
> I've often seen people get this sort of polling loop wrong. So i
> generally point people towards include/linux/iopoll.h.

The above comes from phy_poll_reset().

> I wonder if it would be helpful to add phy_read_mmd_poll_timeout()
> and maybe phy_read_poll_timeout() to phy-core.c?

Maybe, if it becomes more prevalent.

We do have one version in aquantia_main.c which does the wrong
test-register, sleep, timeout sequence, which looks to be the only
case that is wrong.

So, if we want to do this, it should be a separate series, fixing
all locations at the same time.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

  reply	other threads:[~2020-03-03 19:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-03 15:53 [PATCH net-next v2 0/3] marvell10g tunable and power saving support Russell King - ARM Linux admin
2020-03-03 15:54 ` [PATCH net-next v2 1/3] net: phy: marvell10g: add mdix control Russell King
2020-03-03 17:03   ` Andrew Lunn
2020-03-03 19:06     ` Russell King - ARM Linux admin [this message]
2020-03-03 19:51       ` Andrew Lunn
2020-03-03 15:54 ` [PATCH net-next v2 2/3] net: phy: marvell10g: add energy detect power down tunable Russell King
2020-03-03 17:08   ` Andrew Lunn
2020-03-03 15:54 ` [PATCH net-next v2 3/3] net: phy: marvell10g: place in powersave mode at probe Russell King
2020-03-03 17:09   ` Andrew Lunn
2020-04-10 13:48   ` Matteo Croce
2020-04-10 14:19     ` Russell King - ARM Linux admin
2020-04-10 14:36       ` Russell King - ARM Linux admin
2020-04-10 14:39         ` Matteo Croce
2020-04-10 14:44           ` Russell King - ARM Linux admin
2020-04-10 14:50           ` Russell King - ARM Linux admin
2020-04-10 14:59             ` Matteo Croce
2020-04-10 15:16               ` Russell King - ARM Linux admin
2020-04-10 15:18                 ` Matteo Croce
2020-04-10 16:04                   ` Russell King - ARM Linux admin
2020-04-10 16:07                     ` Matteo Croce
2020-04-10 16:23                       ` Russell King - ARM Linux admin
2020-04-10 16:30                         ` Matteo Croce
2020-04-10 17:10                           ` Matteo Croce
2020-04-11  8:36                           ` Russell King - ARM Linux admin
2020-04-14 16:30     ` Russell King - ARM Linux admin

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=20200303190601.GU25745@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=antoine.tenart@bootlin.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=netdev@vger.kernel.org \
    /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.