Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0013C169C4 for ; Thu, 31 Jan 2019 06:43:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 79E8D20881 for ; Thu, 31 Jan 2019 06:43:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NRgeKS1Z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726852AbfAaGnj (ORCPT ); Thu, 31 Jan 2019 01:43:39 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:46095 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725867AbfAaGni (ORCPT ); Thu, 31 Jan 2019 01:43:38 -0500 Received: by mail-wr1-f68.google.com with SMTP id l9so1911032wrt.13 for ; Wed, 30 Jan 2019 22:43:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=DHdJaCDf2koLJUgT6h5T9hyNsHgV5OHNF91nRZxp0XI=; b=NRgeKS1Z+/urvTi7ubaKERvaJbbCqnf5cESPFP4X3/exj/++EQpsRhBNt1gnWv0CGl qrAGIwzs60IOp3pjYA43yOEBmiqjSoR3OgLX2qrnIVqbTQmA2r/tgz70fmSaK5GL/07f EE/LoOFyNgR8iyUbuPlHvOkjQoTjKJGS6GdLfgo6SzhUbMAvqjiIEpPEXwns14cG57as V0wnjVkJL+yo4BcTgT8S90mvZLvJEMDD33qawwJ2fj0HziITfLa0G/OyNhhAVya+3f5e l/Kzndr6FV8beuh0fAtNOGNJt5MuDmNHwHxyq26oJJjbLtBdCydYXL+SjhpUsI9NIpGR jM6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=DHdJaCDf2koLJUgT6h5T9hyNsHgV5OHNF91nRZxp0XI=; b=hSoyb4mJ+7UwqmPww455HXW068zZQTGk9d/Pd1DTTR4zWM6b9NhXQEZDohGR3/E8JN eUmsvHy1JyxG/Wd6ocf6yuCFN3jMSM80DMf9NfM/V2ahVfuMkAFMWHiMpuLRacB1IdEy N8zD8AkX2RPlgrszQhuk1jn9pSH6P116QYSJLfIqUEcXx3S4WuV39vfi6wpuCWUPiPFX 3zku3+Ao+LAvsASP4TGRPk8kmgyxmOmSVk88a3BeqRNXQ1w8+MbK9KSSrQG/w6hla20H kmOc2uHhom9oicsdNwynO7x/QMocS3aYu6T0jHMNT2y71xeG3sE5QboWJG0vCWpCLdAq xxdw== X-Gm-Message-State: AJcUukd7tzLtDFHkzgHGwGXHjXwdlZxSHg0bymRDXo+g25Ldifr4hRxS 9vwOvVjtLi5QQSrdK7+c5lgg4DeW X-Google-Smtp-Source: ALg8bN7wXnKEHjcF3PU+kSgdknEirjkgcsYGVzi2ef5ZewdBm44xgLiwhdmhdSvkreD4iUgzBdqZpQ== X-Received: by 2002:adf:9f10:: with SMTP id l16mr34359470wrf.206.1548917016500; Wed, 30 Jan 2019 22:43:36 -0800 (PST) Received: from ?IPv6:2003:ea:8bf1:e200:e020:9b53:e4ee:67d3? (p200300EA8BF1E200E0209B53E4EE67D3.dip0.t-ipconnect.de. [2003:ea:8bf1:e200:e020:9b53:e4ee:67d3]) by smtp.googlemail.com with ESMTPSA id 127sm8334569wmm.45.2019.01.30.22.43.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jan 2019 22:43:35 -0800 (PST) From: Heiner Kallweit Subject: [PATCH net-next] r8169: improve WoL handling To: Realtek linux nic maintainers , David Miller Cc: "netdev@vger.kernel.org" Message-ID: Date: Thu, 31 Jan 2019 07:43:30 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org WoL handling for the RTL8168 family is a little bit tricky because of different types of broken BIOS and/or chip quirks. Two known issues: 1. Network properly resumes from suspend only if WoL is enabled in the chip. 2. Some notebooks wake up immediately if system is suspended and network device is wakeup-enabled. Few patches tried to deal with this: 7edf6d314cd0 ("r8169: disable WOL per default") 18041b523692 ("r8169: restore previous behavior to accept BIOS WoL settings") Currently we have the situation that the chip WoL settings as set by the BIOS are respected (to prevent issue 1), but the device doesn't get wakeup-enabled (to prevent issue 2). This leads to another issue: If systemd is told to set WoL it first checks whether the requested settings are active already (and does nothing if yes). Due to the chip WoL flags being set properly systemd assumes that WoL is configured properly in our case. Result is that device doesn't get wakeup-enabled and WoL doesn't work (until it's set e.g. by ethtool). This patch now: - leaves the chip WoL settings as is (to prevent issue 1) - keeps the behavior to not wakeup-enable the device initially (to prevent issue 2) - In addition we report WoL as being disabled in get_wol, matching that device isn't wakeup-enabled. If systemd is told to enable WoL, it will therefore detect that it has to do something and will call set_wol. Of course the user still has the option to override this with e.g. ethtool. Because there are lots of consumer mainboards with members of the RTL8168 family as onboard network, there's a certain chance that also the new approach may trigger a BIOS bug and cause issues. Therefore don't remove __rtl8169_get_wol() completely. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 3e650bd9e..2dab28115 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -1371,6 +1371,8 @@ static void rtl_link_chg_patch(struct rtl8169_private *tp) #define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST) +/* Don't delete it completely, in case we need to re-enable it */ +#if 0 static u32 __rtl8169_get_wol(struct rtl8169_private *tp) { u8 options; @@ -1405,6 +1407,7 @@ 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) { @@ -4284,7 +4287,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)) + if (!device_may_wakeup(tp_to_dev(tp))) return false; phy_speed_down(tp->phydev, false); @@ -7441,8 +7444,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) return rc; } - tp->saved_wolopts = __rtl8169_get_wol(tp); - mutex_init(&tp->wk.mutex); INIT_WORK(&tp->wk.work, rtl_task); u64_stats_init(&tp->rx_stats.syncp); -- 2.20.1