From patchwork Mon Oct 11 04:16:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1539104 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=okxtgPoQ; 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 4HSQVf3bB3z9sPf for ; Mon, 11 Oct 2021 15:17:14 +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 1mZmkN-0003hD-GC; Mon, 11 Oct 2021 04:17:07 +0000 Received: from mail-pj1-f51.google.com ([209.85.216.51]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mZmkJ-0003WF-UH for kernel-team@lists.ubuntu.com; Mon, 11 Oct 2021 04:17:04 +0000 Received: by mail-pj1-f51.google.com with SMTP id kk10so12302261pjb.1 for ; Sun, 10 Oct 2021 21:16:59 -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=OY6NbkRVjAGlLTGXRhf6FPYUxsPw4+6pg7kjQchzpSo=; b=okxtgPoQjDMAC7MA+BL9STBwQuYtyj8BeknF1mWVGbFNG5jP910V4HixyubXmDcjrb 1SWQRrW5o5bE500zm/XYVNSOKIZjHeCkS38A36dkb+4dfC7Z70jhoJJL8/Bzy1YtORk7 aSVMu/Un9ghQhkF3KegY1QVLr1g8jXaOLWU5G6jZBPKIn+2BDxRYRvrn8fpszoDN/Ewt aAZu+afZOxtlCRv66hpjJ0r412jDpkOSbFOtvGgdRkYjitkM9Ovrh9IvyGnoezyPUbro 32Y9d9MBaaskpSQ+h9UDh5X62N2X+lpidlVOFC47wTS4Wl6WExHNj8WwR+yl7/O5nXn8 pylA== 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=OY6NbkRVjAGlLTGXRhf6FPYUxsPw4+6pg7kjQchzpSo=; b=mYsoPF8i0jkEM+se53eNSDjV1vN1fRPeFB7K6RBX608Uy+kD+aWcXMFzVZGRtlJYXH UKA0mol6xno/0+A5w5hFke+iYs5opiCairWiwMzqGYznJHxp8VDBXDv8jqHO8JcwpOZU 6YrtumWgYR8VhmE2nhZPLn9tYdyAdbC6J6gKTmiYu31qpyM9LuIJOdqhRhq51kRRxVQF izQKXjkt5sCO+y+mBJbkv+Kbwj/Cf085znlI2ACgd1V9kbwmA5/cnUtNns62vemOd2yp xI9GSHG08m7nddobMYshzOcf8d/PPKoZN33He1UjitqUezC3S8cSrPW9c1DckPeZJH13 pgZg== X-Gm-Message-State: AOAM532YiYXf2AUln5MscEFBE8pRIoYGKCYoYEygCPhy2lS7Q6qiZ+aH wyVoExOvap8+UUFkt7HHW/goNHOyvV4= X-Google-Smtp-Source: ABdhPJy2r8TBnQEREZtAqPp65fxwne8Sy9RFx636L1vqaAtTEqN6vlqE1fOxIgnpSSZc2UmCqtFUiw== X-Received: by 2002:a17:90b:314d:: with SMTP id ip13mr27771584pjb.13.1633925817242; Sun, 10 Oct 2021 21:16:57 -0700 (PDT) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id 130sm5812341pfz.77.2021.10.10.21.16.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Oct 2021 21:16:56 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/3][SRU][OEM-5.13][OEM-5.14] r8169: Enable chip-specific ASPM regardless of PCIe ASPM status Date: Mon, 11 Oct 2021 12:16:31 +0800 Message-Id: <20211011041632.52463-9-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.216.51; envelope-from=acelan@gmail.com; helo=mail-pj1-f51.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 5ef4d002bf1b1..19c92aeccce1c 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -623,7 +623,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; @@ -2675,8 +2674,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 { @@ -5296,8 +5300,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 | PCIE_LINK_STATE_L1_2); - 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);