Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4112484pxj; Tue, 8 Jun 2021 06:48:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxur6mQUJLw83vr+cVXEYV1tKJiQG14+n2Rdxp1c2HZjKVdIbje1PAxJXg6H8eg+CVKzZd6 X-Received: by 2002:a05:6402:2707:: with SMTP id y7mr7491643edd.0.1623160118710; Tue, 08 Jun 2021 06:48:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623160118; cv=none; d=google.com; s=arc-20160816; b=c6kBt9oC3nI6KiuDml8jieuJ/bHMX/Tl7L50Ir3S9Blxtj/H4FDtkv7OKigBpA9wek jWUA0AhjTyFRJCrKndJJTUu8V20u6GqXiIJ0lTByp30no7lDfPlqw95/9LVXP4ap0D6S EeoWrBJer8COfDvp9UisN8xLwwSH0jxUSQnytN+cvqPWLVLOttdLj8fVKmP1aQm2zeeI 9N9KXC3b2k15qQ+HKlxN6FTSgY6uOqIpS7gU+UXl4OueaChEIjiX//2Dcp6teyHAa9kI vEKNkH3OMLNIJ9IA7Z+YSipfKP5dHTLd4zmR7L5VyONFh6FoLSF7fN2Ej8TSyI076IK7 XQvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to:dkim-signature; bh=jzbvjE84lrtKUNpP24YP5MwbO6S+0YQcY8DpHibDnEs=; b=K1YZywkAR58R0b5WsIEDzU37DkGjgOzPk9uiLR3m9M4tyzGu5R/SIG4WHYLOafmhIV 4X3nrB+zXNCxKbDRnsjMqkm/PVjmk478q7AEHfeDSsIN3+6H4qcMoGcGr4YGXFoYcPZI QUZK3Cm87uezw5VburirwrmDjcjEeshMIIDFNvOEWLmqjCAn/NVI+ePareg1SrEU4w7Y fkf6qX9WMCE4TXB/Bl4R4ATLJQEuVr6At78NGJylBKD3+FdD4Op7e8pg2vtV4jSH4PqM xfSDKuc9XfYhGRKaf8Z9JpSC3Sow/IAuwJg/CItkd39Rn+2TizoFZgFGfNgP807D6Mvq dR7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dfmBFuMZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qo1si15043402ejb.590.2021.06.08.06.48.15; Tue, 08 Jun 2021 06:48:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dfmBFuMZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232841AbhFHNr6 (ORCPT + 99 others); Tue, 8 Jun 2021 09:47:58 -0400 Received: from mail-ej1-f43.google.com ([209.85.218.43]:36546 "EHLO mail-ej1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231162AbhFHNr5 (ORCPT ); Tue, 8 Jun 2021 09:47:57 -0400 Received: by mail-ej1-f43.google.com with SMTP id a11so32009613ejf.3; Tue, 08 Jun 2021 06:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:references:from:subject:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=jzbvjE84lrtKUNpP24YP5MwbO6S+0YQcY8DpHibDnEs=; b=dfmBFuMZMy9Bk8MgPYS2ibX39Ixwl2PGP1VKEwXVN6SOb12qEnkuOWWGpeLIPaaNTY zU5ltUD0VfvPCNcPSbR7+EIwF66ytYWZyE5I5SchNMfrpc93jHANa449W7vCqcjPBTyr endnbUyPhKkspnjz7RPCdOhuTIGJtGgExJIBN3u3ju1IvRo8I3jyijhx6NNlnLGgH19Y e2+8BF2KzPZxRAOGdloSD5yows0o0MBGX+XysPD7rJPBRIRE2gD4eaxLrTzMdd2TSrYy HAlJpyDOKjD7h7vRZYyCqLz2ZChPxYe0eVSnmBTiurcsPi2OugEwO+ahzwSLvAclfRnZ KS4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=jzbvjE84lrtKUNpP24YP5MwbO6S+0YQcY8DpHibDnEs=; b=UAFfMTGhovKzhHPI5wYoF16251mlZJ2IVZGfrLlE6jyCcUuLeft4CZ1HqqPcvYLjeS gUO4v57LLC31+6Cx2M2eFD/7MsfyMQL14MWXXyPicFS2IlSDMB5+r7un9wtFs4aKuDLU jX1wI6Ed+YdaGsxuQIo25TUsrXeM4onTs/Nc7DNLBJ7ki5499x29ig61tVj2Gnqdx7Rg D70m8Rr5FAnR5gjNSoHR3w4451eL2rEiC+sr6G/5oSUbC4X8ZJEwADDsOxDLmsmR83Ea rbvf2BOxeTMbovb/tHPyQQl6h8MyB2rSOCKzvFhgrD+otsgY6pzKiMt52LcfIp6YPj/I vt9Q== X-Gm-Message-State: AOAM533E24l++5A6g5S/ybQcfu8phtAnRBxhU33QHXidNpOcBGgkZF2/ 8bnDzTXRZ8vwrPtGGctvWwIAbTB+ajg= X-Received: by 2002:a17:906:1814:: with SMTP id v20mr22849444eje.152.1623159903585; Tue, 08 Jun 2021 06:45:03 -0700 (PDT) Received: from ?IPv6:2003:ea:8f29:3800:8cb5:6cf8:6fac:256f? (p200300ea8f2938008cb56cf86fac256f.dip0.t-ipconnect.de. [2003:ea:8f29:3800:8cb5:6cf8:6fac:256f]) by smtp.googlemail.com with ESMTPSA id v7sm8975040edx.38.2021.06.08.06.45.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Jun 2021 06:45:02 -0700 (PDT) To: Koba Ko Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, Linux Kernel Mailing List References: <20210608032207.2923574-1-koba.ko@canonical.com> <84eb168e-58ff-0350-74e2-c55249eb258c@gmail.com> From: Heiner Kallweit Subject: Re: [PATCH] [v2] r8169: Use PHY_POLL when RTL8106E enable ASPM Message-ID: <7a36c032-38fa-6aa6-fa0f-c3664850d8ea@gmail.com> Date: Tue, 8 Jun 2021 15:44:57 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08.06.2021 12:43, Koba Ko wrote: > On Tue, Jun 8, 2021 at 4:00 PM Heiner Kallweit wrote: >> >> On 08.06.2021 05:22, Koba Ko wrote: >>> For RTL8106E, it's a Fast-ethernet chip. >>> If ASPM is enabled, the link chang interrupt wouldn't be triggered >>> immediately and must wait a very long time to get link change interrupt. >>> Even the link change interrupt isn't triggered, the phy link is already >>> established. >>> >>> Use PHY_POLL to watch the status of phy link and disable >>> the link change interrupt when ASPM is enabled on RTL8106E. >>> >>> v2: Instead use PHY_POLL and identify 8106E by RTL_GIGA_MAC_VER_39. >>> >> >> Still the issue description doesn't convince me that it's a hw bug >> with the respective chip version. What has been stated so far: >> >> 1. (and most important) Issue doesn't occur in mainline because ASPM >> is disabled in mainline for r8169. Issue occurs only with a >> downstream kernel with ASPM enabled for r8169. > > mainline kernel and enable L1, the issue is also observed. > Yes, but enabling L1 via sysfs is at own risk. >> 2. Issue occurs only with ASPM L1.1 not disabled, even though this chip >> version doesn't support L1 sub-states. Just L0s/L1 don't trigger >> the issue. >> The NIC doesn't announce L1.1 support, therefore PCI core won't >> enable L1 sub-states on the PCIe link between NIC and upstream >> PCI bridge. > > More precisely, when L1 is enabled, the issue would be triggered. > For RTL8106E, > 1. Only disable L0s, pcie_aspm_enabled return 1, issue is triggered. > 2. Only disable L1_1, pcie_aspm_enabled return 1, issue is triggered. > > 3. Only disable L1, pcie_aspm_enabled return 0, issue is not triggered. > >> >> 3. Issue occurs only with a GBit-capable link partner. 100MBit link >> partners are fine. Not clear whether issue occurs with a specific >> Gbit link partner only or with GBit-capable link partners in general. >> >> 4. Only link-up interrupt is affected. Not link-down and not interrupts >> triggered by other interrupt sources. >> >> 5. Realtek couldn't confirm that there's such a hw bug on RTL8106e. >> >> One thing that hasn't been asked yet: >> Does issue occur always if you re-plug the cable? Or only on boot? >> I'm asking because in the dmesg log you attached to the bugzilla issue >> the following looks totally ok. >> >> [ 61.651643] r8169 0000:01:00.0 enp1s0: Link is Down >> [ 63.720015] r8169 0000:01:00.0 enp1s0: Link is Up - 100Mbps/Full - flow control rx/tx >> [ 66.685499] r8169 0000:01:00.0 enp1s0: Link is Down > > Once the link is up, > 1. If cable is unplug&plug immediately, you wouldn't see the issue. > 2. Unplug cable and wait a long time (~1Mins), then plug the cable, > the issue appears again. > This sounds runtime-pm-related. After 10s the NIC runtime-suspends, and once the cable is re-plugged a PME is triggered that lets the PCI core return the PCIe link from D3hot to D0. If you re-plug the cable after such a longer time, do you see the PCIe PME immediately in /proc/interrupts? And if you set /sys/class/net//power/control to "on", does the issue still occur? >> >>> Signed-off-by: Koba Ko >>> --- >>> drivers/net/ethernet/realtek/r8169_main.c | 21 +++++++++++++++++++-- >>> 1 file changed, 19 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c >>> index 2c89cde7da1e..a59cbaef2839 100644 >>> --- a/drivers/net/ethernet/realtek/r8169_main.c >>> +++ b/drivers/net/ethernet/realtek/r8169_main.c >>> @@ -4914,6 +4914,19 @@ static const struct dev_pm_ops rtl8169_pm_ops = { >>> >>> #endif /* CONFIG_PM */ >>> >>> +static int rtl_phy_poll_quirk(struct rtl8169_private *tp) >>> +{ >>> + struct pci_dev *pdev = tp->pci_dev; >>> + >>> + if (!pcie_aspm_enabled(pdev)) >> >> That's the wrong call. According to what you said earlier you want to >> check for L1 sub-states, not for ASPM in general. > > As per described above, that's why use pcie_aspm_enabled here. > >> >>> + return 0; >>> + >>> + if (tp->mac_version == RTL_GIGA_MAC_VER_39) >>> + return 1; >>> + >>> + return 0; >>> +} >>> + >>> static void rtl_wol_shutdown_quirk(struct rtl8169_private *tp) >>> { >>> /* WoL fails with 8168b when the receiver is disabled. */ >>> @@ -4991,7 +5004,10 @@ static const struct net_device_ops rtl_netdev_ops = { >>> >>> static void rtl_set_irq_mask(struct rtl8169_private *tp) >>> { >>> - tp->irq_mask = RxOK | RxErr | TxOK | TxErr | LinkChg; >>> + tp->irq_mask = RxOK | RxErr | TxOK | TxErr; >>> + >>> + if (!rtl_phy_poll_quirk(tp)) >>> + tp->irq_mask |= LinkChg; >>> >>> if (tp->mac_version <= RTL_GIGA_MAC_VER_06) >>> tp->irq_mask |= SYSErr | RxOverflow | RxFIFOOver; >>> @@ -5085,7 +5101,8 @@ static int r8169_mdio_register(struct rtl8169_private *tp) >>> new_bus->name = "r8169"; >>> new_bus->priv = tp; >>> new_bus->parent = &pdev->dev; >>> - new_bus->irq[0] = PHY_MAC_INTERRUPT; >>> + new_bus->irq[0] = >>> + (rtl_phy_poll_quirk(tp) ? PHY_POLL : PHY_MAC_INTERRUPT); >>> snprintf(new_bus->id, MII_BUS_ID_SIZE, "r8169-%x", pci_dev_id(pdev)); >>> >>> new_bus->read = r8169_mdio_read_reg; >>> >>