netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Woojung.Huh@microchip.com
Cc: dmurphy@ti.com, f.fainelli@gmail.com, netdev@vger.kernel.org, afd@ti.com
Subject: Re: [PATCH 2/3 v2] net: phy: DP83822 initial driver submission
Date: Thu, 5 Oct 2017 01:53:07 +0200	[thread overview]
Message-ID: <20171004235307.GD16612@lunn.ch> (raw)
In-Reply-To: <9235D6609DB808459E95D78E17F2E43D40B3F9A9@CHN-SV-EXMX02.mchp-main.com>

On Wed, Oct 04, 2017 at 10:44:36PM +0000, Woojung.Huh@microchip.com wrote:
> > +static int dp83822_suspend(struct phy_device *phydev)
> > +{
> > +	int value;
> > +
> > +	mutex_lock(&phydev->lock);
> > +	value = phy_read_mmd(phydev, DP83822_DEVADDR,
> > MII_DP83822_WOL_CFG);
> > +	mutex_unlock(&phydev->lock);

> Would we need mutex to access phy_read_mmd()?
> phy_read_mmd() has mdio_lock for indirect access.

Hi Woojung

The mdio lock is not sufficient. It protects against two mdio
accesses. But here we need to protect against two phy operations.
There is a danger something else tries to access the phy during
suspend.

> > +	if (!(value & DP83822_WOL_EN))
> > +		genphy_suspend(phydev);

Releasing the lock before calling genphy_suspend() is not so nice.
Maybe add a version which assumes the lock has already been taken?

      Andrew

  reply	other threads:[~2017-10-04 23:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-04 18:20 [PATCH 1/3 v2] net: phy: Remove TI DP83822 from DP83848 driver Dan Murphy
2017-10-04 18:20 ` [PATCH 2/3 v2] net: phy: DP83822 initial driver submission Dan Murphy
2017-10-04 22:44   ` Woojung.Huh
2017-10-04 23:53     ` Andrew Lunn [this message]
2017-10-05 20:06       ` Dan Murphy
2017-10-05 22:16       ` Woojung.Huh
2017-10-06 12:00       ` Dan Murphy
2017-10-04 18:20 ` [PATCH 3/3 v2] net: phy: Change error to EINVAL for invalid MAC Dan Murphy

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=20171004235307.GD16612@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=Woojung.Huh@microchip.com \
    --cc=afd@ti.com \
    --cc=dmurphy@ti.com \
    --cc=f.fainelli@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 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).