[PATCH] r8169: Don't claim WoL works if LanWake flag is not set

Subsystems: 8169 10/100/1000 gigabit ethernet driver, networking drivers, the rest

STALE3904d

8 messages, 2 authors, 2015-12-11 · open the first message on its own page

[PATCH] r8169: Don't claim WoL works if LanWake flag is not set

From: Corinna Vinschen <hidden>
Date: 2015-12-09 10:28:05

The __rtl8169_get_wol function returns the state of the various WoL
method bits (MagicPaket, Unicast, etc.).  While the PMEnable bit is
tested at entry, the function doesn't check the LanWake flag.  Even if
any one of the WoL bits is set, WoL is deactivated as a whole if LanWake
isn't set.  The return value from __rtl8169_get_wol doesn't reflect
that.

Unfortunately BIOS exist (HP T620) which set the MagicPaket bit to 1 but
the LanWake flag to 0 when switching on WoL in the BIOS.  On those
machines, ethtool wrongly claims that WoL via MagicPaket is activated
while in fact it isn't, unless you explicitely called

This patch is supposed to fix this behaviour.  If LanWake is 0, the
function now returns 0.  Thus ethtool correctly reports "Wake-on: d".

The patch is against Dave's net-next tree.


Signed-off-by: Corinna Vinschen <redacted>
---
 drivers/net/ethernet/realtek/r8169.c | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 79ef799..813ad2b 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -1705,6 +1705,10 @@ static u32 __rtl8169_get_wol(struct rtl8169_private *tp)
 	if (!(options & PMEnable))
 		return 0;
 
+	options = RTL_R8(Config5);
+	if (!(options & LanWake))
+		return 0;
+
 	options = RTL_R8(Config3);
 	if (options & LinkUp)
 		wolopts |= WAKE_PHY;
-- 
2.1.0

[PATCH v2] r8169: Don't claim WoL works if LanWake flag is not set

From: Corinna Vinschen <hidden>
Date: 2015-12-09 10:43:50

[v2 adds missing text to the patch comment]

The __rtl8169_get_wol function returns the state of the various WoL
method bits (MagicPaket, Unicast, etc.).  While the PMEnable bit is
tested at entry, the function doesn't check the LanWake flag.  Even if
any one of the WoL bits is set, WoL is deactivated as a whole if LanWake
isn't set.  The return value from __rtl8169_get_wol doesn't reflect
that.

Unfortunately BIOS exist (HP T620) which set the MagicPaket bit to 1 but
the LanWake flag to 0 when switching on WoL in the BIOS.  On those machines,
ethtool wrongly claims that WoL via MagicPaket is activated while in fact
it isn't, unless you explicitely called, e.g, `ethtool -s <IF> wol g'.

This patch is supposed to fix this behaviour.  If LanWake is 0, the
function now returns 0.  Thus ethtool correctly reports "Wake-on: d".

The patch is against Dave's net-next tree.


Signed-off-by: Corinna Vinschen <redacted>
---
 drivers/net/ethernet/realtek/r8169.c | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 79ef799..813ad2b 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -1705,6 +1705,10 @@ static u32 __rtl8169_get_wol(struct rtl8169_private *tp)
 	if (!(options & PMEnable))
 		return 0;
 
+	options = RTL_R8(Config5);
+	if (!(options & LanWake))
+		return 0;
+
 	options = RTL_R8(Config3);
 	if (options & LinkUp)
 		wolopts |= WAKE_PHY;
-- 
2.1.0

Re: [PATCH v2] r8169: Don't claim WoL works if LanWake flag is not set

From: Francois Romieu <romieu@fr.zoreil.com>
Date: 2015-12-09 22:43:17

Corinna Vinschen [off-list ref] :
[...]
This patch is supposed to fix this behaviour.  If LanWake is 0, the
function now returns 0.  Thus ethtool correctly reports "Wake-on: d".
Can you turn it into a DMI controlled one (something like
drivers/net/ethernet/marvell/skge.c use of dmi_check_system) in order to
avoid a global change of behavior ?

Btw it's probably time to emit some warning during driver probe if wol
bits are not consistent with LanWake.

-- 
Ueimor

Re: [PATCH v2] r8169: Don't claim WoL works if LanWake flag is not set

From: Corinna Vinschen <hidden>
Date: 2015-12-10 09:51:39

On Dec  9 23:43, Francois Romieu wrote:
Corinna Vinschen [off-list ref] :
[...]
quoted
This patch is supposed to fix this behaviour.  If LanWake is 0, the
function now returns 0.  Thus ethtool correctly reports "Wake-on: d".
Can you turn it into a DMI controlled one (something like
drivers/net/ethernet/marvell/skge.c use of dmi_check_system)
I could do this (after I could lay my hands on such a board, that is),
but I'm not convinced that this makes a lot of sense for two reasons.
in order to
avoid a global change of behavior ?
1.  There is no global change in behaviour.  The usual way to handle the
    WoL flags is to set the affected method flags and additionally set
    LanWake if any of the method flags is set.  The fact that the method
    flags don't enable WoL without also settting the LanWake flag is
    documented.

    __rtl8169_get_wol not reflecting this is a bug.  The code lazily
    assumes that checking the WoL method flags is sufficient while in
    fact it isn't.  __rtl8169_set_wol sets the LanWake flag accordingly,
    but that doesn't mean the driver may assume that the flags haven't
    been set differently.  I can easily hack the driver to set LanWake
    to 0 and ethtool would still happily report WoL is active.  That's
    plain wrong.

2. While we now know a single board which neglects to set the LanWake
   flag, that doesn't mean there aren't other boards out there doing the
   same.
   
   On top of that, the state of the NIC registers in terms of WoL are
   *not* board-specific.  They are regular NIC registers which are just
   set in a combination which the driver in it's current state evaluates
   wrongly.  It doesn't matter who and why the flags have been set that
   way.  The driver should reflect the actual state, and that requires
   to check for LanWake.

For those reasons I think that my fix is the right thing to do.
Btw it's probably time to emit some warning during driver probe if wol
bits are not consistent with LanWake.
That's a good idea.  I'll propose a followup patch with this addition.


Thanks,
Corinna

Re: [PATCH v2] r8169: Don't claim WoL works if LanWake flag is not set

From: Francois Romieu <romieu@fr.zoreil.com>
Date: 2015-12-10 20:41:07

Corinna Vinschen [off-list ref] :
[...]
I could do this (after I could lay my hands on such a board, that is),
but I'm not convinced that this makes a lot of sense for two reasons.
Ok, let's get this change applied. Whatever happens should not be
hard to manage (I'm thinking about other boards or BIOSes relying on the
current - broken as it can be - behavior to work correctly).

[...]
1.  There is no global change in behaviour.  The usual way to handle the
    WoL flags is to set the affected method flags and additionally set
    LanWake if any of the method flags is set.  The fact that the method
    flags don't enable WoL without also settting the LanWake flag is
    documented.
I see no such thing in "7.5 Power Management Function" of the 8168c
registers datasheet. While Config3 states Magic Packet and Link Up
dependencies on Config1.PMEn, it says nothing about Config5.LanWake.

On old 8169 chipsets LanWake is autoloaded from EEPROM.

Plausible for Config5.{B, M, U}WF ? Ok.

Documented ? I am genuinely curious to know where.

-- 
Ueimor

Re: [PATCH v2] r8169: Don't claim WoL works if LanWake flag is not set

From: Corinna Vinschen <hidden>
Date: 2015-12-10 22:02:58

On Dec 10 21:40, Francois Romieu wrote:
Corinna Vinschen [off-list ref] :
[...]
quoted
I could do this (after I could lay my hands on such a board, that is),
but I'm not convinced that this makes a lot of sense for two reasons.
Ok, let's get this change applied. Whatever happens should not be
hard to manage (I'm thinking about other boards or BIOSes relying on the
current - broken as it can be - behavior to work correctly).

[...]
quoted
1.  There is no global change in behaviour.  The usual way to handle the
    WoL flags is to set the affected method flags and additionally set
    LanWake if any of the method flags is set.  The fact that the method
    flags don't enable WoL without also settting the LanWake flag is
    documented.
I see no such thing in "7.5 Power Management Function" of the 8168c
registers datasheet. While Config3 states Magic Packet and Link Up
dependencies on Config1.PMEn, it says nothing about Config5.LanWake.

On old 8169 chipsets LanWake is autoloaded from EEPROM.

Plausible for Config5.{B, M, U}WF ? Ok.

Documented ? I am genuinely curious to know where.
Ok, I reread the documentation I have, and I got that wrong it seems.
Apparently the LanWake flag enables or disables the LANWAKE/LANWAKEB pin
only but not the other possible PM events.

So, self-NACKed.

It's still a bit weird.  On the machines I tested this on, if I disable
LanWake and shutdown the machine, I can send, e.g., MagicPackets as much
as I like, the machined don't come up.  Isn't it a bit misleading then
if ethtool reports that some WoL method is enabled but it doesn't work?


Corinna

Re: [PATCH v2] r8169: Don't claim WoL works if LanWake flag is not set

From: Francois Romieu <romieu@fr.zoreil.com>
Date: 2015-12-11 00:06:39

Corinna Vinschen [off-list ref] :
[...]
It's still a bit weird.  On the machines I tested this on, if I disable
LanWake and shutdown the machine, I can send, e.g., MagicPackets as much
as I like, the machined don't come up.  Isn't it a bit misleading then
if ethtool reports that some WoL method is enabled but it doesn't work?
Of course it is. :o(

I'm fine with Config5.LanWake changes if you have empirical evidences that
it helps.

We have terse - outdated ? - documentation and some hint from
http://marc.info/?l=linux-netdev&m=137654699802446. I'm unable to figure
what an/the adequate change could be, especially a low level chance of
regression one.

-- 
Ueimor

Re: [PATCH v2] r8169: Don't claim WoL works if LanWake flag is not set

From: Corinna Vinschen <hidden>
Date: 2015-12-11 09:42:33

On Dec 11 01:06, Francois Romieu wrote:
Corinna Vinschen [off-list ref] :
[...]
quoted
It's still a bit weird.  On the machines I tested this on, if I disable
LanWake and shutdown the machine, I can send, e.g., MagicPackets as much
as I like, the machined don't come up.  Isn't it a bit misleading then
if ethtool reports that some WoL method is enabled but it doesn't work?
Of course it is. :o(

I'm fine with Config5.LanWake changes if you have empirical evidences that
it helps.

We have terse - outdated ? - documentation and some hint from
http://marc.info/?l=linux-netdev&m=137654699802446. I'm unable to figure
what an/the adequate change could be, especially a low level chance of
regression one.
I think the problem here is that LanWake only switches off aspects of
the WoL capability which can't be reflected in a reliable way to the
kernel.  That's certainly one reason for the driver to enable/disable
LanWake always in lock-step with PMEnable.

So I wonder if we shouldn't just add some code to rtl_init_one (or
create a new function called from rtl_init_one) which checks the WoL
flags and if the PmConfig and LanWake flags are set inconsistently
(aka "differently") then set them to an equal value, either 0 (no WoL
method enabled) or 1 (any WoL method enabled).

Does that make sense?


Thanks,
Corinna
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help