Skip to content

Commit 433f9d0

Browse files
hkallweitdavem330
authored andcommitted
r8169: improve saved_wolopts handling
Let's make saved_wolopts a shadow copy of the WoL options. This allows to simplify the code and get rid of calls to now unneeded function __rtl8169_get_wol(). However don't remove __rtl8169_get_wol() completely to be prepared for the case that we can respect BIOS WOL settings again. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 92bad85 commit 433f9d0

File tree

1 file changed

+14
-20
lines changed
  • drivers/net/ethernet/realtek

1 file changed

+14
-20
lines changed

drivers/net/ethernet/realtek/r8169.c

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,6 +1587,12 @@ static void rtl8169_check_link_status(struct net_device *dev,
15871587

15881588
#define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST)
15891589

1590+
/* Currently we only enable WoL if explicitly told by userspace to circumvent
1591+
* issues on certain platforms, see commit bde135a672bf ("r8169: only enable
1592+
* PCI wakeups when WOL is active"). Let's keep __rtl8169_get_wol() for the
1593+
* case that we want to respect BIOS settings again.
1594+
*/
1595+
#if 0
15901596
static u32 __rtl8169_get_wol(struct rtl8169_private *tp)
15911597
{
15921598
u8 options;
@@ -1621,25 +1627,16 @@ static u32 __rtl8169_get_wol(struct rtl8169_private *tp)
16211627

16221628
return wolopts;
16231629
}
1630+
#endif
16241631

16251632
static void rtl8169_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
16261633
{
16271634
struct rtl8169_private *tp = netdev_priv(dev);
1628-
struct device *d = tp_to_dev(tp);
1629-
1630-
pm_runtime_get_noresume(d);
16311635

16321636
rtl_lock_work(tp);
1633-
16341637
wol->supported = WAKE_ANY;
1635-
if (pm_runtime_active(d))
1636-
wol->wolopts = __rtl8169_get_wol(tp);
1637-
else
1638-
wol->wolopts = tp->saved_wolopts;
1639-
1638+
wol->wolopts = tp->saved_wolopts;
16401639
rtl_unlock_work(tp);
1641-
1642-
pm_runtime_put_noidle(d);
16431640
}
16441641

16451642
static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
@@ -1719,14 +1716,14 @@ static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
17191716

17201717
rtl_lock_work(tp);
17211718

1719+
tp->saved_wolopts = wol->wolopts & WAKE_ANY;
1720+
17221721
if (pm_runtime_active(d))
1723-
__rtl8169_set_wol(tp, wol->wolopts);
1724-
else
1725-
tp->saved_wolopts = wol->wolopts;
1722+
__rtl8169_set_wol(tp, tp->saved_wolopts);
17261723

17271724
rtl_unlock_work(tp);
17281725

1729-
device_set_wakeup_enable(d, wol->wolopts);
1726+
device_set_wakeup_enable(d, tp->saved_wolopts);
17301727

17311728
pm_runtime_put_noidle(d);
17321729

@@ -4638,7 +4635,7 @@ static void rtl_wol_suspend_quirk(struct rtl8169_private *tp)
46384635

46394636
static bool rtl_wol_pll_power_down(struct rtl8169_private *tp)
46404637
{
4641-
if (!(__rtl8169_get_wol(tp) & WAKE_ANY))
4638+
if (!tp->saved_wolopts)
46424639
return false;
46434640

46444641
rtl_speed_down(tp);
@@ -7219,7 +7216,6 @@ static int rtl_open(struct net_device *dev)
72197216

72207217
rtl_unlock_work(tp);
72217218

7222-
tp->saved_wolopts = 0;
72237219
pm_runtime_put_sync(&pdev->dev);
72247220

72257221
rtl8169_check_link_status(dev, tp);
@@ -7367,7 +7363,6 @@ static int rtl8169_runtime_suspend(struct device *device)
73677363
}
73687364

73697365
rtl_lock_work(tp);
7370-
tp->saved_wolopts = __rtl8169_get_wol(tp);
73717366
__rtl8169_set_wol(tp, WAKE_ANY);
73727367
rtl_unlock_work(tp);
73737368

@@ -7392,7 +7387,6 @@ static int rtl8169_runtime_resume(struct device *device)
73927387

73937388
rtl_lock_work(tp);
73947389
__rtl8169_set_wol(tp, tp->saved_wolopts);
7395-
tp->saved_wolopts = 0;
73967390
rtl_unlock_work(tp);
73977391

73987392
__rtl8169_resume(dev);
@@ -7462,7 +7456,7 @@ static void rtl_shutdown(struct pci_dev *pdev)
74627456
rtl8169_hw_reset(tp);
74637457

74647458
if (system_state == SYSTEM_POWER_OFF) {
7465-
if (__rtl8169_get_wol(tp) & WAKE_ANY) {
7459+
if (tp->saved_wolopts) {
74667460
rtl_wol_suspend_quirk(tp);
74677461
rtl_wol_shutdown_quirk(tp);
74687462
}

0 commit comments

Comments
 (0)