netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] r8169: Enable WOL from Magic Packet by default
@ 2012-02-14 18:27 Sameer Nanda
  2012-02-14 18:33 ` Sameer Nanda
  2012-02-15  0:13 ` Francois Romieu
  0 siblings, 2 replies; 7+ messages in thread
From: Sameer Nanda @ 2012-02-14 18:27 UTC (permalink / raw)
  To: omieu, jw, hayeswang; +Cc: netdev, linux-pm, Sameer Nanda

Set the WOL config registers to only enable WOL from magic packet by
default. Without this change in place, the WOL config register
settings on warm reboot come up in an inconsistent state since these
registers don't get reset on a warm reboot.

Signed-off-by: Sameer Nanda <snanda@chromium.org>
---
 drivers/net/ethernet/realtek/r8169.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 7a0c800..a6921b7 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -4073,12 +4073,13 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	tp->txd_version = rtl_chip_infos[chipset].txd_version;
 
 	RTL_W8(Cfg9346, Cfg9346_Unlock);
+
+	/* Enable WOL from Magic Packet by default */
 	RTL_W8(Config1, RTL_R8(Config1) | PMEnable);
-	RTL_W8(Config5, RTL_R8(Config5) & PMEStatus);
-	if ((RTL_R8(Config3) & (LinkUp | MagicPacket)) != 0)
-		tp->features |= RTL_FEATURE_WOL;
-	if ((RTL_R8(Config5) & (UWF | BWF | MWF)) != 0)
-		tp->features |= RTL_FEATURE_WOL;
+	RTL_W8(Config3, MagicPacket);
+	RTL_W8(Config5, PMEStatus);
+	tp->features |= RTL_FEATURE_WOL;
+
 	tp->features |= rtl_try_msi(tp, cfg);
 	RTL_W8(Cfg9346, Cfg9346_Lock);
 
-- 
1.7.7.3

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

* Re: [PATCH 1/2] r8169: Enable WOL from Magic Packet by default
  2012-02-14 18:27 [PATCH 1/2] r8169: Enable WOL from Magic Packet by default Sameer Nanda
@ 2012-02-14 18:33 ` Sameer Nanda
  2012-02-14 18:38   ` Sameer Nanda
  2012-02-15  0:13 ` Francois Romieu
  1 sibling, 1 reply; 7+ messages in thread
From: Sameer Nanda @ 2012-02-14 18:33 UTC (permalink / raw)
  To: romieu, jw, hayeswang; +Cc: netdev, linux-pm, Sameer Nanda

Fixed Francois Romieu email address.

On Tue, Feb 14, 2012 at 10:27 AM, Sameer Nanda <snanda@chromium.org> wrote:
>
> Set the WOL config registers to only enable WOL from magic packet by
> default. Without this change in place, the WOL config register
> settings on warm reboot come up in an inconsistent state since these
> registers don't get reset on a warm reboot.
>
> Signed-off-by: Sameer Nanda <snanda@chromium.org>
> ---
>  drivers/net/ethernet/realtek/r8169.c |   11 ++++++-----
>  1 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
> index 7a0c800..a6921b7 100644
> --- a/drivers/net/ethernet/realtek/r8169.c
> +++ b/drivers/net/ethernet/realtek/r8169.c
> @@ -4073,12 +4073,13 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
>        tp->txd_version = rtl_chip_infos[chipset].txd_version;
>
>        RTL_W8(Cfg9346, Cfg9346_Unlock);
> +
> +       /* Enable WOL from Magic Packet by default */
>        RTL_W8(Config1, RTL_R8(Config1) | PMEnable);
> -       RTL_W8(Config5, RTL_R8(Config5) & PMEStatus);
> -       if ((RTL_R8(Config3) & (LinkUp | MagicPacket)) != 0)
> -               tp->features |= RTL_FEATURE_WOL;
> -       if ((RTL_R8(Config5) & (UWF | BWF | MWF)) != 0)
> -               tp->features |= RTL_FEATURE_WOL;
> +       RTL_W8(Config3, MagicPacket);
> +       RTL_W8(Config5, PMEStatus);
> +       tp->features |= RTL_FEATURE_WOL;
> +
>        tp->features |= rtl_try_msi(tp, cfg);
>        RTL_W8(Cfg9346, Cfg9346_Lock);
>
> --
> 1.7.7.3
>



--
Sameer

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

* Re: [PATCH 1/2] r8169: Enable WOL from Magic Packet by default
  2012-02-14 18:33 ` Sameer Nanda
@ 2012-02-14 18:38   ` Sameer Nanda
  0 siblings, 0 replies; 7+ messages in thread
From: Sameer Nanda @ 2012-02-14 18:38 UTC (permalink / raw)
  To: romieu, Rafael J. Wysocki, hayeswang; +Cc: netdev, linux-pm, Sameer Nanda

Fixed Rafael's email address.  Sorry about the dupe emails.

On Tue, Feb 14, 2012 at 10:33 AM, Sameer Nanda <snanda@chromium.org> wrote:
> Fixed Francois Romieu email address.
>
> On Tue, Feb 14, 2012 at 10:27 AM, Sameer Nanda <snanda@chromium.org> wrote:
>>
>> Set the WOL config registers to only enable WOL from magic packet by
>> default. Without this change in place, the WOL config register
>> settings on warm reboot come up in an inconsistent state since these
>> registers don't get reset on a warm reboot.
>>
>> Signed-off-by: Sameer Nanda <snanda@chromium.org>
>> ---
>>  drivers/net/ethernet/realtek/r8169.c |   11 ++++++-----
>>  1 files changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
>> index 7a0c800..a6921b7 100644
>> --- a/drivers/net/ethernet/realtek/r8169.c
>> +++ b/drivers/net/ethernet/realtek/r8169.c
>> @@ -4073,12 +4073,13 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
>>        tp->txd_version = rtl_chip_infos[chipset].txd_version;
>>
>>        RTL_W8(Cfg9346, Cfg9346_Unlock);
>> +
>> +       /* Enable WOL from Magic Packet by default */
>>        RTL_W8(Config1, RTL_R8(Config1) | PMEnable);
>> -       RTL_W8(Config5, RTL_R8(Config5) & PMEStatus);
>> -       if ((RTL_R8(Config3) & (LinkUp | MagicPacket)) != 0)
>> -               tp->features |= RTL_FEATURE_WOL;
>> -       if ((RTL_R8(Config5) & (UWF | BWF | MWF)) != 0)
>> -               tp->features |= RTL_FEATURE_WOL;
>> +       RTL_W8(Config3, MagicPacket);
>> +       RTL_W8(Config5, PMEStatus);
>> +       tp->features |= RTL_FEATURE_WOL;
>> +
>>        tp->features |= rtl_try_msi(tp, cfg);
>>        RTL_W8(Cfg9346, Cfg9346_Lock);
>>
>> --
>> 1.7.7.3
>>
>
>
>
> --
> Sameer



-- 
Sameer
_______________________________________________
linux-pm mailing list
linux-pm@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-pm

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

* Re: [PATCH 1/2] r8169: Enable WOL from Magic Packet by default
  2012-02-14 18:27 [PATCH 1/2] r8169: Enable WOL from Magic Packet by default Sameer Nanda
  2012-02-14 18:33 ` Sameer Nanda
@ 2012-02-15  0:13 ` Francois Romieu
  2012-02-15  1:00   ` Sameer Nanda
  1 sibling, 1 reply; 7+ messages in thread
From: Francois Romieu @ 2012-02-15  0:13 UTC (permalink / raw)
  To: Sameer Nanda; +Cc: netdev, linux-pm, hayeswang

Sameer Nanda <snanda@chromium.org> :
> Set the WOL config registers to only enable WOL from magic packet by
> default. Without this change in place, the WOL config register
> settings on warm reboot come up in an inconsistent state since these
> registers don't get reset on a warm reboot.

I am not completely convinced, especially as the change of behavior
could be noticed.

Can you elaborate why the previous WoL settings should be ignored ?

-- 
Ueimor

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

* Re: [PATCH 1/2] r8169: Enable WOL from Magic Packet by default
  2012-02-15  0:13 ` Francois Romieu
@ 2012-02-15  1:00   ` Sameer Nanda
  2012-02-15  3:37     ` David Miller
  0 siblings, 1 reply; 7+ messages in thread
From: Sameer Nanda @ 2012-02-15  1:00 UTC (permalink / raw)
  To: Francois Romieu; +Cc: netdev, linux-pm, hayeswang

On Tue, Feb 14, 2012 at 4:13 PM, Francois Romieu <romieu@fr.zoreil.com> wrote:
> Sameer Nanda <snanda@chromium.org> :
>> Set the WOL config registers to only enable WOL from magic packet by
>> default. Without this change in place, the WOL config register
>> settings on warm reboot come up in an inconsistent state since these
>> registers don't get reset on a warm reboot.
>
> I am not completely convinced, especially as the change of behavior
> could be noticed.

Agreed that this change could be noticed.  Maybe a module parameter
might be a better way to handle this?

>
> Can you elaborate why the previous WoL settings should be ignored ?

With runtime PM, the "previous" settings may not be what the user had
set up since runtime PM mucks around with WOL settings.  Therefore,
the user could see inconsistent WOL settings upon booting up.

My second patch in this series mitigates this to a large extent by
restoring the saved WOL options in rtl_shutdown.  One case it doesn't
handle is non-graceful shutdown since rtl_shutdown may not be invoked.

The issue we ran into is this: disconnect network cable, reboot
system.  This will cause WOL on PHY to be enabled on next boot.  If
you connect the cable and then transition the system to S3 state or
halt the system, the system wakes right back up since the PHY state
changes.  Not good.

>
> --
> Ueimor



-- 
Sameer

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

* Re: [PATCH 1/2] r8169: Enable WOL from Magic Packet by default
  2012-02-15  1:00   ` Sameer Nanda
@ 2012-02-15  3:37     ` David Miller
  2012-02-16 20:47       ` Sameer Nanda
  0 siblings, 1 reply; 7+ messages in thread
From: David Miller @ 2012-02-15  3:37 UTC (permalink / raw)
  To: snanda; +Cc: netdev, linux-pm, hayeswang, romieu

From: Sameer Nanda <snanda@chromium.org>
Date: Tue, 14 Feb 2012 17:00:04 -0800

> On Tue, Feb 14, 2012 at 4:13 PM, Francois Romieu <romieu@fr.zoreil.com> wrote:
>> Sameer Nanda <snanda@chromium.org> :
>>> Set the WOL config registers to only enable WOL from magic packet by
>>> default. Without this change in place, the WOL config register
>>> settings on warm reboot come up in an inconsistent state since these
>>> registers don't get reset on a warm reboot.
>>
>> I am not completely convinced, especially as the change of behavior
>> could be noticed.
> 
> Agreed that this change could be noticed.  Maybe a module parameter
> might be a better way to handle this?

Please no random module parameters, something ethtool based is
what you should shoot for.

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

* Re: [PATCH 1/2] r8169: Enable WOL from Magic Packet by default
  2012-02-15  3:37     ` David Miller
@ 2012-02-16 20:47       ` Sameer Nanda
  0 siblings, 0 replies; 7+ messages in thread
From: Sameer Nanda @ 2012-02-16 20:47 UTC (permalink / raw)
  To: David Miller; +Cc: romieu, rjw, hayeswang, netdev, linux-pm

On Tue, Feb 14, 2012 at 7:37 PM, David Miller <davem@davemloft.net> wrote:
> From: Sameer Nanda <snanda@chromium.org>
> Date: Tue, 14 Feb 2012 17:00:04 -0800
>
>> On Tue, Feb 14, 2012 at 4:13 PM, Francois Romieu <romieu@fr.zoreil.com> wrote:
>>> Sameer Nanda <snanda@chromium.org> :
>>>> Set the WOL config registers to only enable WOL from magic packet by
>>>> default. Without this change in place, the WOL config register
>>>> settings on warm reboot come up in an inconsistent state since these
>>>> registers don't get reset on a warm reboot.
>>>
>>> I am not completely convinced, especially as the change of behavior
>>> could be noticed.
>>
>> Agreed that this change could be noticed.  Maybe a module parameter
>> might be a better way to handle this?
>
> Please no random module parameters, something ethtool based is
> what you should shoot for.

With the existing code, WOL from PHY, unicast, multicast and broadcast
packets may get accidentally enabled.  The probability of seeing such
packets/events in the wild is quite high and this can cause unintended
wakes from S3 or reboots.

The probability of seeing matching MagicPackets in the wild is
vanishingly small.  Therefore, setting MagicPacket as the only default
WOL mechanism seems like the safer option.

Since ethtool already supports setting of WOL options from userland, I
guess we don't need a new module parameter as the user can set WOL
options according to his own desires.

-- 
Sameer

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

end of thread, other threads:[~2012-02-16 20:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-14 18:27 [PATCH 1/2] r8169: Enable WOL from Magic Packet by default Sameer Nanda
2012-02-14 18:33 ` Sameer Nanda
2012-02-14 18:38   ` Sameer Nanda
2012-02-15  0:13 ` Francois Romieu
2012-02-15  1:00   ` Sameer Nanda
2012-02-15  3:37     ` David Miller
2012-02-16 20:47       ` Sameer Nanda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).