* Re: [PATCH] net: phy: add locking to phy_read_mmd_indirect()/phy_write_mmd_indirect()
[not found] <E1ZU9vP-0004nN-LW@rmk-PC.arm.linux.org.uk>
@ 2015-08-25 14:08 ` Florian Fainelli
2015-08-25 14:18 ` Russell King - ARM Linux
2015-08-25 23:31 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Florian Fainelli @ 2015-08-25 14:08 UTC (permalink / raw)
To: Russell King, David S. Miller; +Cc: netdev
Le 08/25/15 01:49, Russell King a écrit :
> The phy layer is missing locking for the above two functions - it
> has been observed that two threads (userspace and the phy worker
> thread) can race, entering the bus ->write or ->read functions
> simultaneously.
>
> This causes the FEC driver to initialise a completion while another
> thread is waiting on it or while the interrupt is calling complete()
> on it, which causes spinlock unlock-without-lock, spinlock lockups,
> and completion timeouts.
>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Fixes: a59a4d192 ("phy: add the EEE support and the way to access to the
MMD registers.")
Fixes: 0c1d77dfb ("net: libphy: Add phy specific function to access mmd
phy registers")
Thanks!
> ---
> drivers/net/phy/phy.c | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 1e1fbb049ec6..34fe339f4e80 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -1038,10 +1038,14 @@ int phy_read_mmd_indirect(struct phy_device *phydev, int prtad,
> int value = -1;
>
> if (phydrv->read_mmd_indirect == NULL) {
> - mmd_phy_indirect(phydev->bus, prtad, devad, addr);
> + struct mii_bus *bus = phydev->bus;
> +
> + mutex_lock(&bus->mdio_lock);
> + mmd_phy_indirect(bus, prtad, devad, addr);
>
> /* Read the content of the MMD's selected register */
> - value = phydev->bus->read(phydev->bus, addr, MII_MMD_DATA);
> + value = bus->read(bus, addr, MII_MMD_DATA);
> + mutex_unlock(&bus->mdio_lock);
> } else {
> value = phydrv->read_mmd_indirect(phydev, prtad, devad, addr);
> }
> @@ -1071,10 +1075,14 @@ void phy_write_mmd_indirect(struct phy_device *phydev, int prtad,
> struct phy_driver *phydrv = phydev->drv;
>
> if (phydrv->write_mmd_indirect == NULL) {
> - mmd_phy_indirect(phydev->bus, prtad, devad, addr);
> + struct mii_bus *bus = phydev->bus;
> +
> + mutex_lock(&bus->mdio_lock);
> + mmd_phy_indirect(bus, prtad, devad, addr);
>
> /* Write the data into MMD's selected register */
> - phydev->bus->write(phydev->bus, addr, MII_MMD_DATA, data);
> + bus->write(bus, addr, MII_MMD_DATA, data);
> + mutex_unlock(&bus->mdio_lock);
> } else {
> phydrv->write_mmd_indirect(phydev, prtad, devad, addr, data);
> }
>
--
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: phy: add locking to phy_read_mmd_indirect()/phy_write_mmd_indirect()
2015-08-25 14:08 ` [PATCH] net: phy: add locking to phy_read_mmd_indirect()/phy_write_mmd_indirect() Florian Fainelli
@ 2015-08-25 14:18 ` Russell King - ARM Linux
2015-08-25 23:31 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Russell King - ARM Linux @ 2015-08-25 14:18 UTC (permalink / raw)
To: Florian Fainelli; +Cc: David S. Miller, netdev
On Tue, Aug 25, 2015 at 07:08:24AM -0700, Florian Fainelli wrote:
> Le 08/25/15 01:49, Russell King a écrit :
> > The phy layer is missing locking for the above two functions - it
> > has been observed that two threads (userspace and the phy worker
> > thread) can race, entering the bus ->write or ->read functions
> > simultaneously.
> >
> > This causes the FEC driver to initialise a completion while another
> > thread is waiting on it or while the interrupt is calling complete()
> > on it, which causes spinlock unlock-without-lock, spinlock lockups,
> > and completion timeouts.
> >
> > Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
>
> Acked-by: Florian Fainelli <f.fainelli@gmail.com>
> Fixes: a59a4d192 ("phy: add the EEE support and the way to access to the
> MMD registers.")
> Fixes: 0c1d77dfb ("net: libphy: Add phy specific function to access mmd
> phy registers")
Thanks. I'm assuming that davem will take the patch?
> Thanks!
>
> > ---
> > drivers/net/phy/phy.c | 16 ++++++++++++----
> > 1 file changed, 12 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> > index 1e1fbb049ec6..34fe339f4e80 100644
> > --- a/drivers/net/phy/phy.c
> > +++ b/drivers/net/phy/phy.c
> > @@ -1038,10 +1038,14 @@ int phy_read_mmd_indirect(struct phy_device *phydev, int prtad,
> > int value = -1;
> >
> > if (phydrv->read_mmd_indirect == NULL) {
> > - mmd_phy_indirect(phydev->bus, prtad, devad, addr);
> > + struct mii_bus *bus = phydev->bus;
> > +
> > + mutex_lock(&bus->mdio_lock);
> > + mmd_phy_indirect(bus, prtad, devad, addr);
> >
> > /* Read the content of the MMD's selected register */
> > - value = phydev->bus->read(phydev->bus, addr, MII_MMD_DATA);
> > + value = bus->read(bus, addr, MII_MMD_DATA);
> > + mutex_unlock(&bus->mdio_lock);
> > } else {
> > value = phydrv->read_mmd_indirect(phydev, prtad, devad, addr);
> > }
> > @@ -1071,10 +1075,14 @@ void phy_write_mmd_indirect(struct phy_device *phydev, int prtad,
> > struct phy_driver *phydrv = phydev->drv;
> >
> > if (phydrv->write_mmd_indirect == NULL) {
> > - mmd_phy_indirect(phydev->bus, prtad, devad, addr);
> > + struct mii_bus *bus = phydev->bus;
> > +
> > + mutex_lock(&bus->mdio_lock);
> > + mmd_phy_indirect(bus, prtad, devad, addr);
> >
> > /* Write the data into MMD's selected register */
> > - phydev->bus->write(phydev->bus, addr, MII_MMD_DATA, data);
> > + bus->write(bus, addr, MII_MMD_DATA, data);
> > + mutex_unlock(&bus->mdio_lock);
> > } else {
> > phydrv->write_mmd_indirect(phydev, prtad, devad, addr, data);
> > }
> >
>
>
> --
> Florian
--
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: phy: add locking to phy_read_mmd_indirect()/phy_write_mmd_indirect()
2015-08-25 14:08 ` [PATCH] net: phy: add locking to phy_read_mmd_indirect()/phy_write_mmd_indirect() Florian Fainelli
2015-08-25 14:18 ` Russell King - ARM Linux
@ 2015-08-25 23:31 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2015-08-25 23:31 UTC (permalink / raw)
To: f.fainelli; +Cc: rmk+kernel, netdev
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Tue, 25 Aug 2015 07:08:24 -0700
> Le 08/25/15 01:49, Russell King a écrit :
>> The phy layer is missing locking for the above two functions - it
>> has been observed that two threads (userspace and the phy worker
>> thread) can race, entering the bus ->write or ->read functions
>> simultaneously.
>>
>> This causes the FEC driver to initialise a completion while another
>> thread is waiting on it or while the interrupt is calling complete()
>> on it, which causes spinlock unlock-without-lock, spinlock lockups,
>> and completion timeouts.
>>
>> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
>
> Acked-by: Florian Fainelli <f.fainelli@gmail.com>
> Fixes: a59a4d192 ("phy: add the EEE support and the way to access to the
> MMD registers.")
> Fixes: 0c1d77dfb ("net: libphy: Add phy specific function to access mmd
> phy registers")
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-08-25 23:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <E1ZU9vP-0004nN-LW@rmk-PC.arm.linux.org.uk>
2015-08-25 14:08 ` [PATCH] net: phy: add locking to phy_read_mmd_indirect()/phy_write_mmd_indirect() Florian Fainelli
2015-08-25 14:18 ` Russell King - ARM Linux
2015-08-25 23:31 ` David Miller
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).