From: Francois Romieu <romieu@fr.zoreil.com>
To: Marc Ballarin <ballarin.marc@gmx.de>
Cc: hayeswang@realtek.com, netdev@vger.kernel.org
Subject: Re: [PATCH] r8169: Fix WOL in power down case
Date: Sun, 9 Oct 2011 13:54:38 +0200 [thread overview]
Message-ID: <20111009115438.GA12343@electric-eye.fr.zoreil.com> (raw)
In-Reply-To: <20111009104907.0c6cd439900ca5eb7789295f@gmx.de>
Marc Ballarin <ballarin.marc@gmx.de> :
> Commit 92fc43b4159b518f5baae57301f26d770b0834c9 ("r8169: modify the flow of the
> hw reset.") breaks WOL on some versions of the hardware.
>
> Commit 106633897e086e1b47126996aac1a427eb80eb1b ("r8169: fix WOL setting for
> 8105 and 8111evl") tries to fix this, but only does so in the standby case.
>
> This patch applies an analogous fix to the shutdown path.
Nonononono, you must dig for similar occurrences of this bug. Take a look at
r810x_pll_power_down and you will realize that RTL_GIGA_MAC_VER_{29, 30} have
the exact same problem.
Moreover, the patch duplicates a chunk of conditional code:
1) it bloats the driver (ok, we have seen worse...).
2) you can bet that both instances won't be updated if / when
RTL_GIGA_MAC_VER_xy appears.
The patch below should fix it.
It looks like PM savings needs some love when WoL is enabled but this is a
different topic.
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index c236670..b53c83d 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -3328,22 +3328,36 @@ static void r810x_phy_power_up(struct rtl8169_private *tp)
rtl_writephy(tp, MII_BMCR, BMCR_ANENABLE);
}
-static void r810x_pll_power_down(struct rtl8169_private *tp)
+static bool rtl_test_wol_and_enable_packets_receive(struct rtl8169_private *tp)
{
void __iomem *ioaddr = tp->mmio_addr;
- if (__rtl8169_get_wol(tp) & WAKE_ANY) {
- rtl_writephy(tp, 0x1f, 0x0000);
- rtl_writephy(tp, MII_BMCR, 0x0000);
+ if (!(__rtl8169_get_wol(tp) & WAKE_ANY))
+ return false;
- if (tp->mac_version == RTL_GIGA_MAC_VER_29 ||
- tp->mac_version == RTL_GIGA_MAC_VER_30)
- RTL_W32(RxConfig, RTL_R32(RxConfig) | AcceptBroadcast |
- AcceptMulticast | AcceptMyPhys);
- return;
+ rtl_writephy(tp, 0x1f, 0x0000);
+ rtl_writephy(tp, MII_BMCR, 0x0000);
+
+ switch (tp->mac_version) {
+ case RTL_GIGA_MAC_VER_29:
+ case RTL_GIGA_MAC_VER_30:
+ case RTL_GIGA_MAC_VER_32:
+ case RTL_GIGA_MAC_VER_33:
+ case RTL_GIGA_MAC_VER_34:
+ RTL_W32(RxConfig, RTL_R32(RxConfig) |
+ AcceptBroadcast | AcceptMulticast | AcceptMyPhys);
+ break;
+ default:
+ break;
}
- r810x_phy_power_down(tp);
+ return true;
+}
+
+static void r810x_pll_power_down(struct rtl8169_private *tp)
+{
+ if (!rtl_test_wol_and_enable_packets_receive(tp))
+ r810x_phy_power_down(tp);
}
static void r810x_pll_power_up(struct rtl8169_private *tp)
@@ -3430,17 +3444,8 @@ static void r8168_pll_power_down(struct rtl8169_private *tp)
tp->mac_version == RTL_GIGA_MAC_VER_33)
rtl_ephy_write(ioaddr, 0x19, 0xff64);
- if (__rtl8169_get_wol(tp) & WAKE_ANY) {
- rtl_writephy(tp, 0x1f, 0x0000);
- rtl_writephy(tp, MII_BMCR, 0x0000);
-
- if (tp->mac_version == RTL_GIGA_MAC_VER_32 ||
- tp->mac_version == RTL_GIGA_MAC_VER_33 ||
- tp->mac_version == RTL_GIGA_MAC_VER_34)
- RTL_W32(RxConfig, RTL_R32(RxConfig) | AcceptBroadcast |
- AcceptMulticast | AcceptMyPhys);
+ if (rtl_test_wol_and_enable_packets_receive(tp))
return;
- }
r8168_phy_power_down(tp);
@@ -5807,10 +5812,10 @@ static void rtl_shutdown(struct pci_dev *pdev)
if (system_state == SYSTEM_POWER_OFF) {
/* WoL fails with 8168b when the receiver is disabled. */
- if ((tp->mac_version == RTL_GIGA_MAC_VER_11 ||
+ if (rtl_test_wol_and_enable_packets_receive(tp) &&
+ (tp->mac_version == RTL_GIGA_MAC_VER_11 ||
tp->mac_version == RTL_GIGA_MAC_VER_12 ||
- tp->mac_version == RTL_GIGA_MAC_VER_17) &&
- (tp->features & RTL_FEATURE_WOL)) {
+ tp->mac_version == RTL_GIGA_MAC_VER_17)) {
pci_clear_master(pdev);
RTL_W8(ChipCmd, CmdRxEnb);
next prev parent reply other threads:[~2011-10-09 11:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-07 20:19 Regression: non-working WOL with r8169 Marc Ballarin
2011-10-07 21:00 ` Francois Romieu
2011-10-07 21:33 ` Marc Ballarin
2011-10-07 21:42 ` Francois Romieu
2011-10-07 22:31 ` Marc Ballarin
2011-10-07 23:28 ` Francois Romieu
2011-10-09 8:49 ` [PATCH] r8169: Fix WOL in power down case Marc Ballarin
2011-10-09 11:54 ` Francois Romieu [this message]
2011-10-09 17:13 ` Marc Ballarin
2011-11-01 17:28 ` Stefan Becker
2011-11-02 23:08 ` Francois Romieu
2011-11-03 17:27 ` Stefan Becker
[not found] ` <CAOJ2eMcFbt9zkA9-uq20OUs1r3Ee6jo=jbEJ7RP87OCxu5XJjA@mail.gmail.com>
2011-11-03 18:12 ` Francois Romieu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111009115438.GA12343@electric-eye.fr.zoreil.com \
--to=romieu@fr.zoreil.com \
--cc=ballarin.marc@gmx.de \
--cc=hayeswang@realtek.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox