From patchwork Mon Oct 11 04:16:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1539101 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=XM531Lm8; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HSQVR6Tm1z9sPf for ; Mon, 11 Oct 2021 15:17:03 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1mZmkC-0003Ud-Nm; Mon, 11 Oct 2021 04:16:56 +0000 Received: from mail-pl1-f178.google.com ([209.85.214.178]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mZmk7-0003Pp-S3 for kernel-team@lists.ubuntu.com; Mon, 11 Oct 2021 04:16:52 +0000 Received: by mail-pl1-f178.google.com with SMTP id x4so10439615pln.5 for ; Sun, 10 Oct 2021 21:16:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dz/1JHMqigS+VqmAQgV/dhhHx2EvUfaTDbvwukZNWYs=; b=XM531Lm8h11moPEPO44oiMj/AUv38dNmc3sxiL2YQIh9sXzXOeDBtNvk4b1a1Src8o iYfqArf34njF5Lg4Ixakz2UM5l8cVbp9qab6toA0ohPwUSFzqN+22goINgPznR7bR7Q/ 6LvPBLfNCr7X353iYkaTWIpm59ij1OKUbG9SFoBObDE14vgbnogO2Et11gUnfjNIGXYL WtiIO3cR/vlP9iByorvyKw4esMZ3hZKV7itQy5XlMAbuCh/UDhfbt4jgpAgmPuSgc85y Y/tZiO6bWbE0TJSVbwWTjKn1fwqYdfEzpdQ8Cs+Hck6pQyirVZL2XZ6dHUyn+V3y0iIS Muig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=dz/1JHMqigS+VqmAQgV/dhhHx2EvUfaTDbvwukZNWYs=; b=imc+OFTVg/C3UXHgZ5iOSJt4CpW+2Bmy1R9iTjH0QwFD/hiCup3fhA7CH0nxYo/4Dz 9y0AE6wUoPrh9NdngVmNs9V8YIAxy93gObXIiZH1b+9GQIaisOaxTGq+6dIPy8wjH+Ki yOrtSV/ptah0oTKsUvqMRLyIe8TL9tHSjEalONhNoiOrJOv53hsusaPdyT9Hd8djme9o KfjzusDpbq6gA5+P8bj0752GrncE5Vac6hr/yyqhAd3S+XLOQUZhKm7kDVZ5+13t3nPq qxIy2o8KHjTriicQTsib780PA0i2diXxc8S8Wxt2Qj3FdZ7/VvlDG6U0CQl4sAKH1nqk 7Ldg== X-Gm-Message-State: AOAM533hnykT3NURKdn5PipWxBLpPess/xXaAxeruVi3x0ohz3lxSP5e D+UCQTrwVKobBp0Flp5pM+MoztoFsiM= X-Google-Smtp-Source: ABdhPJyvEFL3Vu8HMFyP/iY18DurW7o9yR44bKK2CPyUO0S6UmB/Ckdfe3JVIPVAIhNqejaZTArxUQ== X-Received: by 2002:a17:90a:c08d:: with SMTP id o13mr11280117pjs.181.1633925809548; Sun, 10 Oct 2021 21:16:49 -0700 (PDT) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id ls7sm5823317pjb.16.2021.10.10.21.16.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Oct 2021 21:16:48 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/3][SRU][I] r8169: Enable chip-specific ASPM regardless of PCIe ASPM status Date: Mon, 11 Oct 2021 12:16:28 +0800 Message-Id: <20211011041632.52463-6-acelan.kao@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211011041632.52463-1-acelan.kao@canonical.com> References: <20211011041632.52463-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.214.178; envelope-from=acelan@gmail.com; helo=mail-pl1-f178.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Kai-Heng Feng BugLink: https://bugs.launchpad.net/bugs/1946433 To really enable ASPM on r8169 NICs, both standard PCIe ASPM and chip-specific ASPM have to be enabled at the same time. Since PCIe ASPM can be enabled or disabled vis sysfs and there's no mechanism to notify driver about ASPM change, unconditionally enable chip-specific ASPM to make ASPM really take into effect. Signed-off-by: Kai-Heng Feng (backported from https://patchwork.kernel.org/project/linux-pci/patch/20211007161552.272771-3-kai.heng.feng@canonical.com/) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/net/ethernet/realtek/r8169_main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index ea837093a176..fc8aebbd3544 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -625,7 +625,6 @@ struct rtl8169_private { } wk; unsigned supports_gmii:1; - unsigned aspm_manageable:1; dma_addr_t counters_phys_addr; struct rtl8169_counters *counters; struct rtl8169_tc_offsets tc_offset; @@ -2664,8 +2663,13 @@ static void rtl_pcie_state_l2l3_disable(struct rtl8169_private *tp) static void rtl_hw_aspm_clkreq_enable(struct rtl8169_private *tp, bool enable) { - /* Don't enable ASPM in the chip if OS can't control ASPM */ - if (enable && tp->aspm_manageable) { + struct pci_dev *pdev = tp->pci_dev; + + /* Skip if PCIe ASPM isn't possible */ + if (!pcie_aspm_support_enabled() || !pcie_aspm_capable(pdev)) + return; + + if (enable) { RTL_W8(tp, Config5, RTL_R8(tp, Config5) | ASPM_en); RTL_W8(tp, Config2, RTL_R8(tp, Config2) | ClkReqEn); } else { @@ -5279,8 +5283,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) /* Disable ASPM completely as that cause random device stop working * problems as well as full system hangs for some PCIe devices users. */ - rc = pci_disable_link_state(pdev, PCIE_LINK_STATE_L1_1); - tp->aspm_manageable = !rc; + pci_disable_link_state(pdev, PCIE_LINK_STATE_L1); /* enable device (incl. PCI PM wakeup and hotplug setup) */ rc = pcim_enable_device(pdev);