All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] r8169: improve PHY initialization and WoL handling
@ 2018-06-24 16:35 Heiner Kallweit
  2018-06-24 16:37 ` [PATCH net-next 1/3] r8169: improve phy initialization when resuming Heiner Kallweit
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Heiner Kallweit @ 2018-06-24 16:35 UTC (permalink / raw)
  To: Realtek linux nic maintainers, David Miller; +Cc: netdev

Series with smaller improvements regarding PHY initialization and
WoL handling.

Heiner Kallweit (3):
  r8169: improve phy inititalization when resuming
  r8169: improve saved_wolopts handling
  r8169: don't check WoL when powering down PHY and interface is down

 drivers/net/ethernet/realtek/r8169.c | 40 +++++++++++-----------------
 1 file changed, 15 insertions(+), 25 deletions(-)

-- 
2.18.0

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net-next 1/3] r8169: improve phy initialization when resuming
  2018-06-24 16:35 [PATCH net-next 0/3] r8169: improve PHY initialization and WoL handling Heiner Kallweit
@ 2018-06-24 16:37 ` Heiner Kallweit
  2018-06-24 16:39 ` [PATCH net-next 2/3] r8169: improve saved_wolopts handling Heiner Kallweit
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2018-06-24 16:37 UTC (permalink / raw)
  To: Realtek linux nic maintainers, David Miller; +Cc: netdev

Let's move calling rtl8169_init_phy() to __rtl8169_resume().
It simplifies the code and avoids rtl8169_init_phy() being called
when resuming whilst interface is down. rtl_open() will initialize
the PHY when the interface is brought up.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/ethernet/realtek/r8169.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 44715958..480fb141 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -7334,6 +7334,7 @@ static void __rtl8169_resume(struct net_device *dev)
 	netif_device_attach(dev);
 
 	rtl_pll_power_up(tp);
+	rtl8169_init_phy(dev, tp);
 
 	rtl_lock_work(tp);
 	napi_enable(&tp->napi);
@@ -7347,9 +7348,6 @@ static int rtl8169_resume(struct device *device)
 {
 	struct pci_dev *pdev = to_pci_dev(device);
 	struct net_device *dev = pci_get_drvdata(pdev);
-	struct rtl8169_private *tp = netdev_priv(dev);
-
-	rtl8169_init_phy(dev, tp);
 
 	if (netif_running(dev))
 		__rtl8169_resume(dev);
@@ -7397,8 +7395,6 @@ static int rtl8169_runtime_resume(struct device *device)
 	tp->saved_wolopts = 0;
 	rtl_unlock_work(tp);
 
-	rtl8169_init_phy(dev, tp);
-
 	__rtl8169_resume(dev);
 
 	return 0;
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next 2/3] r8169: improve saved_wolopts handling
  2018-06-24 16:35 [PATCH net-next 0/3] r8169: improve PHY initialization and WoL handling Heiner Kallweit
  2018-06-24 16:37 ` [PATCH net-next 1/3] r8169: improve phy initialization when resuming Heiner Kallweit
@ 2018-06-24 16:39 ` Heiner Kallweit
  2018-06-24 16:40 ` [PATCH net-next 3/3] r8169: don't check WoL when powering down PHY and interface is down Heiner Kallweit
  2018-06-25  7:22 ` [PATCH net-next 0/3] r8169: improve PHY initialization and WoL handling David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2018-06-24 16:39 UTC (permalink / raw)
  To: Realtek linux nic maintainers, David Miller; +Cc: netdev

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>
---
 drivers/net/ethernet/realtek/r8169.c | 34 ++++++++++++----------------
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 480fb141..f8a1309a 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -1587,6 +1587,12 @@ static void rtl8169_check_link_status(struct net_device *dev,
 
 #define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST)
 
+/* Currently we only enable WoL if explicitly told by userspace to circumvent
+ * issues on certain platforms, see commit bde135a672bf ("r8169: only enable
+ * PCI wakeups when WOL is active"). Let's keep __rtl8169_get_wol() for the
+ * case that we want to respect BIOS settings again.
+ */
+#if 0
 static u32 __rtl8169_get_wol(struct rtl8169_private *tp)
 {
 	u8 options;
@@ -1621,25 +1627,16 @@ static u32 __rtl8169_get_wol(struct rtl8169_private *tp)
 
 	return wolopts;
 }
+#endif
 
 static void rtl8169_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 {
 	struct rtl8169_private *tp = netdev_priv(dev);
-	struct device *d = tp_to_dev(tp);
-
-	pm_runtime_get_noresume(d);
 
 	rtl_lock_work(tp);
-
 	wol->supported = WAKE_ANY;
-	if (pm_runtime_active(d))
-		wol->wolopts = __rtl8169_get_wol(tp);
-	else
-		wol->wolopts = tp->saved_wolopts;
-
+	wol->wolopts = tp->saved_wolopts;
 	rtl_unlock_work(tp);
-
-	pm_runtime_put_noidle(d);
 }
 
 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)
 
 	rtl_lock_work(tp);
 
+	tp->saved_wolopts = wol->wolopts & WAKE_ANY;
+
 	if (pm_runtime_active(d))
-		__rtl8169_set_wol(tp, wol->wolopts);
-	else
-		tp->saved_wolopts = wol->wolopts;
+		__rtl8169_set_wol(tp, tp->saved_wolopts);
 
 	rtl_unlock_work(tp);
 
-	device_set_wakeup_enable(d, wol->wolopts);
+	device_set_wakeup_enable(d, tp->saved_wolopts);
 
 	pm_runtime_put_noidle(d);
 
@@ -4638,7 +4635,7 @@ static void rtl_wol_suspend_quirk(struct rtl8169_private *tp)
 
 static bool rtl_wol_pll_power_down(struct rtl8169_private *tp)
 {
-	if (!(__rtl8169_get_wol(tp) & WAKE_ANY))
+	if (!tp->saved_wolopts)
 		return false;
 
 	rtl_speed_down(tp);
@@ -7219,7 +7216,6 @@ static int rtl_open(struct net_device *dev)
 
 	rtl_unlock_work(tp);
 
-	tp->saved_wolopts = 0;
 	pm_runtime_put_sync(&pdev->dev);
 
 	rtl8169_check_link_status(dev, tp);
@@ -7367,7 +7363,6 @@ static int rtl8169_runtime_suspend(struct device *device)
 	}
 
 	rtl_lock_work(tp);
-	tp->saved_wolopts = __rtl8169_get_wol(tp);
 	__rtl8169_set_wol(tp, WAKE_ANY);
 	rtl_unlock_work(tp);
 
@@ -7392,7 +7387,6 @@ static int rtl8169_runtime_resume(struct device *device)
 
 	rtl_lock_work(tp);
 	__rtl8169_set_wol(tp, tp->saved_wolopts);
-	tp->saved_wolopts = 0;
 	rtl_unlock_work(tp);
 
 	__rtl8169_resume(dev);
@@ -7462,7 +7456,7 @@ static void rtl_shutdown(struct pci_dev *pdev)
 	rtl8169_hw_reset(tp);
 
 	if (system_state == SYSTEM_POWER_OFF) {
-		if (__rtl8169_get_wol(tp) & WAKE_ANY) {
+		if (tp->saved_wolopts) {
 			rtl_wol_suspend_quirk(tp);
 			rtl_wol_shutdown_quirk(tp);
 		}
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next 3/3] r8169: don't check WoL when powering down PHY and interface is down
  2018-06-24 16:35 [PATCH net-next 0/3] r8169: improve PHY initialization and WoL handling Heiner Kallweit
  2018-06-24 16:37 ` [PATCH net-next 1/3] r8169: improve phy initialization when resuming Heiner Kallweit
  2018-06-24 16:39 ` [PATCH net-next 2/3] r8169: improve saved_wolopts handling Heiner Kallweit
@ 2018-06-24 16:40 ` Heiner Kallweit
  2018-06-25  7:22 ` [PATCH net-next 0/3] r8169: improve PHY initialization and WoL handling David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2018-06-24 16:40 UTC (permalink / raw)
  To: Realtek linux nic maintainers, David Miller; +Cc: netdev

We can power down the PHY irregardless of WOL settings if interface
is down. So far we would have left the PHY enabled if WOL options
are set and the interface is brought down.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/ethernet/realtek/r8169.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index f8a1309a..1d33672c 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -4635,7 +4635,7 @@ static void rtl_wol_suspend_quirk(struct rtl8169_private *tp)
 
 static bool rtl_wol_pll_power_down(struct rtl8169_private *tp)
 {
-	if (!tp->saved_wolopts)
+	if (!netif_running(tp->dev) || !tp->saved_wolopts)
 		return false;
 
 	rtl_speed_down(tp);
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next 0/3] r8169: improve PHY initialization and WoL handling
  2018-06-24 16:35 [PATCH net-next 0/3] r8169: improve PHY initialization and WoL handling Heiner Kallweit
                   ` (2 preceding siblings ...)
  2018-06-24 16:40 ` [PATCH net-next 3/3] r8169: don't check WoL when powering down PHY and interface is down Heiner Kallweit
@ 2018-06-25  7:22 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2018-06-25  7:22 UTC (permalink / raw)
  To: hkallweit1; +Cc: nic_swsd, netdev

From: Heiner Kallweit <hkallweit1@gmail.com>
Date: Sun, 24 Jun 2018 18:35:48 +0200

> Series with smaller improvements regarding PHY initialization and
> WoL handling.

Series applied, thank you.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-06-25  7:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-24 16:35 [PATCH net-next 0/3] r8169: improve PHY initialization and WoL handling Heiner Kallweit
2018-06-24 16:37 ` [PATCH net-next 1/3] r8169: improve phy initialization when resuming Heiner Kallweit
2018-06-24 16:39 ` [PATCH net-next 2/3] r8169: improve saved_wolopts handling Heiner Kallweit
2018-06-24 16:40 ` [PATCH net-next 3/3] r8169: don't check WoL when powering down PHY and interface is down Heiner Kallweit
2018-06-25  7:22 ` [PATCH net-next 0/3] r8169: improve PHY initialization and WoL handling David Miller

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.