From patchwork Mon Oct 11 04:16:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1539096 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=HMUuEjYc; 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 4HSQVG2Zt4z9sWJ for ; Mon, 11 Oct 2021 15:16:53 +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 1mZmk2-0003Ne-Jv; Mon, 11 Oct 2021 04:16:46 +0000 Received: from mail-pj1-f42.google.com ([209.85.216.42]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mZmk0-0003MQ-1M for kernel-team@lists.ubuntu.com; Mon, 11 Oct 2021 04:16:44 +0000 Received: by mail-pj1-f42.google.com with SMTP id k23so12322451pji.0 for ; Sun, 10 Oct 2021 21:16:43 -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=/usZTPkBZt6DfECkkm8NqXtnZaO/etFjNOLS5ID9Ew8=; b=HMUuEjYcdCf8Zk/p9pZURgO4JHIX6MJzuKkDFPJ3ECmsxoApSpj1BTecbfXkE1eD/S FYGAtw+jfyeo7N1Ip7WnJclfdsrrE84Dgh8y1yrJt94+5HO1PI9cWzQu70WivnAPhix9 8O8BJhCW7ub2p9IXxXM4Cn+TSP4rh7buz7/3xhK6CRa2z1/oKeMS/faukksG6dROLkJ4 +tb2io+9wUs6aav+uWSgiJ5+flVBts7bMp03BqYVslttTrjvLhXl3tKXgwjxznl1krcx +aAk95KL1YAtUAI6927wd9tgJYMEqcL1R991SpphzDVTdtqn7Ytsn/9R6wOPxKpYC51n IyHQ== 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=/usZTPkBZt6DfECkkm8NqXtnZaO/etFjNOLS5ID9Ew8=; b=TYZgKDH1VsFrGyUtnq86JSNmUTYxm2j4DleR/nG68Yd0t5r+VigYcsoAywqNAKMaL7 NXjuAyy5jrGUhuNqcmo0nlPcvib5Yjahg0fTgClAhdMIIrl2JkfA/LpjZ8JknhxFtp3B D4hAxpp+kHh4BeX3u7HacnsF1cqJhNw7cfh2OrY421kqS6Q9TeAeoUjOtiDSO37FCLFU bcXXmFls13Ms1Ne9MLAsz32ENQz/o7zhOc6/K0T0oetouku/IVwiaPxbeRZ2lvkfpLRw /Pp1FA9LonI45DF2GMSCx5IIQkD/vzV/qui/9vMBOXvhYdGS+WPjVVwviAQJZRbuX7Jy CudA== X-Gm-Message-State: AOAM532l9AylzX1dBzapdYUhJDkRfwm8n7LuW0+SDV3xwuHUFbOkpkuD bdL7C46c2+zjyuEmUaRI6Ewx8PNxbhM= X-Google-Smtp-Source: ABdhPJyzRVoBS0bfPvb2cV/SYa0tZ+7K627EU5yrYwrWhk+aVCur94EkIJbt+X4ZLyrccVB0VIFbvw== X-Received: by 2002:a17:90a:16:: with SMTP id 22mr28505711pja.25.1633925801760; Sun, 10 Oct 2021 21:16:41 -0700 (PDT) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id d5sm5664688pjs.53.2021.10.10.21.16.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Oct 2021 21:16:41 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/3][SRU][Unstable] r8169: Enable chip-specific ASPM regardless of PCIe ASPM status Date: Mon, 11 Oct 2021 12:16:25 +0800 Message-Id: <20211011041632.52463-3-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.42; envelope-from=acelan@gmail.com; helo=mail-pj1-f42.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 (cherry picked from https://patchwork.ozlabs.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 66d26d71bafc..08dd74e3f796 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; @@ -2699,8 +2698,13 @@ static void rtl_enable_exit_l1(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 { @@ -5310,8 +5314,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) /* Disable ASPM L1 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); - 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);