From patchwork Thu Jan 31 18:52:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 1034444 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MhnZyp1Z"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43r8WF6q8Jz9s9G for ; Fri, 1 Feb 2019 05:52:57 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728370AbfAaSw4 (ORCPT ); Thu, 31 Jan 2019 13:52:56 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:41055 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727373AbfAaSwz (ORCPT ); Thu, 31 Jan 2019 13:52:55 -0500 Received: by mail-wr1-f65.google.com with SMTP id x10so4488634wrs.8 for ; Thu, 31 Jan 2019 10:52:54 -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=/yG71rPJxzFw/A/f+z0SAZ/bDrNUXvbgDESThfZpt3Q=; b=MhnZyp1ZRI8ikEq6ar7NQMKs7HBl8jbiZ+gDjRupehsFfTCkuA9mMH7Lr+w1hcSrI/ dlL6Y0w3XdlvP0FynTW5GdrRfU3RTPV3s+tGteUuBbNwq6iHwwPqNFDsme7fIDmGvTeO gJ7hNiosC/FoGdYLKCAzAVYwMdBR2/I6HDFvRfe7H0OFxvDbHAcozu9z8R/a1KeeBQKi wgvLD2urmayx/8f7eR4xklzquCvER+/UtVlh1Nna7wXWRBxsxza1hog9lroisqJyExt8 16IqFuMVBC6kOB2SqXbQwwDv6f0EB430t+DBBG7mRbYvqLDcCWytL3AO9KMVw3OKPEIu fdow== 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=/yG71rPJxzFw/A/f+z0SAZ/bDrNUXvbgDESThfZpt3Q=; b=llzm4I6bVZOydCi69xHAEYXTvIL0jbTngj0QW7F9OAbkE4W3L/eW2OxT/ueDkohuCd x7cT8fNa22+hHLFchBGbNXTi7xHZWCdzN0IhWtIwraw/Fgmxoy8PsSON+c1iVEDFHjuG VdJYIwCFRypfJhjqBBHmJ+2TPNJb4V6Yzcz2yXMOoa+i3YgvoQ8E7E68fcrO59cU8YjW 3agwygBJkGge05X5rqWgOAmO2TxmnRWboF7LXS7V4Su4T1pRyMCuWgix3bJ2WNIdj+W8 2eWLWu5tORQ6wvkmvfCPDX84BLuu7qjoRfDAWSRsl2VjYUu5jRQNOLRYVP5ZbVBX+eCN /7HQ== X-Gm-Message-State: AJcUukcvE8SqIkRJu4odWtGHiqhAek20eaLiC29ICk4+nPMfDiIxSsqK iPWxjeR+qNviVpGyXxbDUlGOL5v9 X-Google-Smtp-Source: ALg8bN6yMmrH/OuoyfLqwwsCv32gycFtK18+22C75VnPpVymV2H2KzG+UB4pw7xYmZyxMm2KrDJwuA== X-Received: by 2002:adf:fa90:: with SMTP id h16mr37627362wrr.326.1548960773075; Thu, 31 Jan 2019 10:52:53 -0800 (PST) Received: from ?IPv6:2003:ea:8bf1:e200:456f:ee03:474f:a529? (p200300EA8BF1E200456FEE03474FA529.dip0.t-ipconnect.de. [2003:ea:8bf1:e200:456f:ee03:474f:a529]) by smtp.googlemail.com with ESMTPSA id c1sm65577wmb.14.2019.01.31.10.52.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 10:52:52 -0800 (PST) From: Heiner Kallweit Subject: [PATCH v2 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 19:52:46 +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-Language: en-US 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. v2: - Don't just exclude __rtl8169_get_wol() from compiling, remove it. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169.c | 39 +--------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 3e650bd9e..9dc689817 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -1371,41 +1371,6 @@ static void rtl_link_chg_patch(struct rtl8169_private *tp) #define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST) -static u32 __rtl8169_get_wol(struct rtl8169_private *tp) -{ - u8 options; - u32 wolopts = 0; - - options = RTL_R8(tp, Config1); - if (!(options & PMEnable)) - return 0; - - options = RTL_R8(tp, Config3); - if (options & LinkUp) - wolopts |= WAKE_PHY; - switch (tp->mac_version) { - case RTL_GIGA_MAC_VER_34 ... RTL_GIGA_MAC_VER_38: - case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_51: - if (rtl_eri_read(tp, 0xdc, ERIAR_EXGMAC) & MagicPacket_v2) - wolopts |= WAKE_MAGIC; - break; - default: - if (options & MagicPacket) - wolopts |= WAKE_MAGIC; - break; - } - - options = RTL_R8(tp, Config5); - if (options & UWF) - wolopts |= WAKE_UCAST; - if (options & BWF) - wolopts |= WAKE_BCAST; - if (options & MWF) - wolopts |= WAKE_MCAST; - - return wolopts; -} - static void rtl8169_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) { struct rtl8169_private *tp = netdev_priv(dev); @@ -4284,7 +4249,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 +7406,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);