Commit 34eea5ac authored by Matt Carlson's avatar Matt Carlson Committed by David S. Miller

tg3: Only allow phy ioctls while netif_running

When tg3 was new, phy accesses through ioctl were allowable at any time.
Then, the driver started shutting down the phy when the device was
closed.  Phy accesses would be allowed when the driver first attached to
the device, but then would be forbidden after the device had been up'd
and down'd.  After that, management firmware made it illegal to access
the phy unless the driver "owned" the device.  Now that most firmware
is being moved over to the APE, it is less clear when phy accesses are
safe.

While it is possible to attempt to identify these conditions and code
the driver to navigate through the pitfalls, it could be perplexing to
the admin why phy accesses work in some cases and not others.  This
patch brings some uniformity to the problem by only allowing phy
accesses while the driver has control of the device.
Signed-off-by: default avatarMatt Carlson <mcarlson@broadcom.com>
Reviewed-by: default avatarMichael Chan <mchan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4a85f098
...@@ -11444,9 +11444,7 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -11444,9 +11444,7 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES) if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES)
break; /* We have no PHY */ break; /* We have no PHY */
if ((tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) || if (!netif_running(dev))
((tp->tg3_flags & TG3_FLAG_ENABLE_ASF) &&
!netif_running(dev)))
return -EAGAIN; return -EAGAIN;
spin_lock_bh(&tp->lock); spin_lock_bh(&tp->lock);
...@@ -11462,9 +11460,7 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -11462,9 +11460,7 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES) if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES)
break; /* We have no PHY */ break; /* We have no PHY */
if ((tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) || if (!netif_running(dev))
((tp->tg3_flags & TG3_FLAG_ENABLE_ASF) &&
!netif_running(dev)))
return -EAGAIN; return -EAGAIN;
spin_lock_bh(&tp->lock); spin_lock_bh(&tp->lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment