Skip to contentSkip to conversation

net: usb: r8152: Set default WOL options

PATCH In review Kyle Pelton 2 participants 2 messages May 12, 2022 – May 13, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: usb: r8152: Set default WOL options

Set default wake-on-lan options on probe to avoid state from previous boot.

Fixes issue on some boots where wake-on-lan settings are incorrectly set due to previous runtime-suspend activity. This causes spurious wakeups while in suspend.

---
 drivers/net/usb/r8152.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/usb/r8152.c +5 -2
index ee41088c5251..a2b3c398beee 100644
@@ -3269,6 +3269,7 @@ static int rtl8152_set_features(struct net_device *dev,
 }
 
 #define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST)
+#define WAKE_DEFAULT (WAKE_PHY << 5)
 
 static u32 __rtl_get_wol(struct r8152 *tp)
 {
@@ -9717,10 +9718,12 @@ static int rtl8152_probe(struct usb_interface *intf,
 
 	intf->needs_remote_wakeup = 1;
 
-	if (!rtl_can_wakeup(tp))
+	if (!rtl_can_wakeup(tp)) {
 		__rtl_set_wol(tp, 0);
-	else
+	} else {
+		__rtl_set_wol(tp, WAKE_DEFAULT);
 		tp->saved_wolopts = __rtl_get_wol(tp);
+	}
 
 	tp->rtl_ops.init(tp);
 #if IS_BUILTIN(CONFIG_USB_RTL8152)
Signature · 1 line
2.25.1
#1 lore raw

Kyle Pelton <[email protected]>

Quoted 1 line

Sent: Friday, May 13, 2022 5:50 AM

[...]

Quoted 3 lines

#define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST |
WAKE_BCAST | WAKE_MCAST)
+#define WAKE_DEFAULT (WAKE_PHY << 5)

I think the (WAKE_PHY << 5) is equal to WAKE_MAGIC.

drivers/net/usb/r8152.c static int rtl8152_probe(struct usb_interface *intf, · line 9725

Quoted 13 lines

static u32 __rtl_get_wol(struct r8152 *tp)
{

drivers/net/usb/r8152.c +3 -2
@@ -9717,10 +9718,12 @@ static int rtl8152_probe(struct usb_interface *intf,
 
 	intf->needs_remote_wakeup = 1;
 
-	if (!rtl_can_wakeup(tp))
+	if (!rtl_can_wakeup(tp)) {
 		__rtl_set_wol(tp, 0);
-	else
+	} else {
+		__rtl_set_wol(tp, WAKE_DEFAULT);
 		tp->saved_wolopts = __rtl_get_wol(tp);

I think it is better to set tp->saved_wolopts = WAKE_MAGIC. Besides, add rtl_runtime_suspend_enable(tp, false) in r8152b_init() as same as r8153_init(), r8153b_init(), and so on. You don't need __rtl_set_wol() here.

drivers/net/usb/r8152.c static int rtl8152_probe(struct usb_interface *intf, · line 9729

Quoted 4 lines
drivers/net/usb/r8152.c +1 -0
+	}
 
 	tp->rtl_ops.init(tp);
 #if IS_BUILTIN(CONFIG_USB_RTL8152)

Best Regards,
Hayes