From patchwork Thu Dec 23 09:24:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1572556 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=H8m6kJpC; 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 4JKPtP5SDWz9t5G for ; Thu, 23 Dec 2021 20:25:16 +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 1n0KLP-0007ty-Pj; Thu, 23 Dec 2021 09:25:03 +0000 Received: from mail-pg1-f174.google.com ([209.85.215.174]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1n0KLN-0007sv-Vz for kernel-team@lists.ubuntu.com; Thu, 23 Dec 2021 09:25:02 +0000 Received: by mail-pg1-f174.google.com with SMTP id k4so4440507pgb.8 for ; Thu, 23 Dec 2021 01:25:01 -0800 (PST) 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=wBT52OOIW07ha5xDOzJj3smbLmLKTfGX08F83VSjX6M=; b=H8m6kJpC6ML8x7thLx8F80QxxP7lk9BnC1oIAEe6Ud/hBW/l7F6fFZQQpBGi+fvVos rH6AYpRGzakuIMCkH4G5ZiDtYM/VK63QO9G9aIYQs7p7xoRkIhPHPOSX2/WDNSoFs8dL ElDiJz8NGn+m0IbHrl2ryZxFym/jhMaE+bdGwz43SLZE63jJoM43gezYkNOXWOs+w1Lx 36Oyl9QbZz+Ao/RxwFj47tP04Fkrsmu7eZkx031DO64XX8B3mbeAPn6TZkgBCInDXI68 90iVXTBLjcTR0Xa8qiqPom+S5RuOkMqD57pq+/hHNh/TqST65MLxjfmjGn1TsHzdQyt8 JXGg== 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=wBT52OOIW07ha5xDOzJj3smbLmLKTfGX08F83VSjX6M=; b=YunkM2LnU5saMPOmVR6+RCoZ3Rnb5/TFrR3b+sqqaJpZPv2NQo9c3OUYSy6175Rr6Q g1O1lDqYzqwc2WZdA2EDvYEGP+AzQww5GlQjaSD+OYjyHHelUGLxiCmMEhDABVZ4AI1l uO0Lb8M+TsPOg9o0nTtp+M1CgAJ4MBt5crAuoTySwP86IMHlcBU9djpr3Lz5+vcctdLf d2xe61LRHjKX6GrYtgZPzWrtSkjEt/BIwTXV2yZ7kkDURyfkrrt6tMROXuo3jYnqWcF9 2gtyWT3bUO5k+J4arrVy2dErYdJq29xFG92PtWAwss5gd0KCbKUJ8LpxoNiQfo3kqbhe hmrA== X-Gm-Message-State: AOAM531Cl20NB4RmHSoDOo7Vd6l2huLpRHmI1jMDOCNjGsGIR9FCgG3z P9GPEQM1d27i+PbtXXWlaX/iDuTLBKA= X-Google-Smtp-Source: ABdhPJzvjdeEFcWv1kBouhSESxPnNEFcnev/DPH/Iobbb8Ty660YLPi+Nfhl+QT06IqYAX3E/Steiw== X-Received: by 2002:a63:9:: with SMTP id 9mr1428604pga.136.1640251499357; Thu, 23 Dec 2021 01:24:59 -0800 (PST) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id 6sm4063082pgc.90.2021.12.23.01.24.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 01:24:58 -0800 (PST) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/1][SRU][OEM-5.13] rtw88: Disable PCIe ASPM while doing NAPI poll on 8821CE Date: Thu, 23 Dec 2021 17:24:56 +0800 Message-Id: <20211223092456.1544132-1-acelan.kao@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211222063758.153688-1-kai.heng.feng@canonical.com> References: <20211222063758.153688-1-kai.heng.feng@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.215.174; envelope-from=acelan@gmail.com; helo=mail-pg1-f174.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/1927808 Many Intel based platforms face system random freeze after commit 9e2fd29864c5 ("rtw88: add napi support"). The commit itself shouldn't be the culprit. My guess is that the 8821CE only leaves ASPM L1 for a short period when IRQ is raised. Since IRQ is masked during NAPI polling, the PCIe link stays at L1 and makes RX DMA extremely slow. Eventually the RX ring becomes messed up: [ 1133.194697] rtw_8821ce 0000:02:00.0: pci bus timeout, check dma status Since the 8821CE hardware may fail to leave ASPM L1, manually do it in the driver to resolve the issue. Fixes: 9e2fd29864c5 ("rtw88: add napi support") Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=215131 BugLink: https://bugs.launchpad.net/bugs/1927808 Signed-off-by: Kai-Heng Feng Acked-by: Jian-Hong Pan (backported from commit 24f5e38a13b5ae2b6105cda8bb47c19108e62a9a linux-next) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/net/wireless/realtek/rtw88/pci.c | 52 +++++++++--------------- drivers/net/wireless/realtek/rtw88/pci.h | 2 + 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c index e7d17ab8f113b..029bd7de9db2a 100644 --- a/drivers/net/wireless/realtek/rtw88/pci.c +++ b/drivers/net/wireless/realtek/rtw88/pci.c @@ -2,7 +2,6 @@ /* Copyright(c) 2018-2019 Realtek Corporation */ -#include #include #include #include "main.h" @@ -1395,7 +1394,11 @@ static void rtw_pci_link_ps(struct rtw_dev *rtwdev, bool enter) * throughput. This is probably because the ASPM behavior slightly * varies from different SOC. */ - if (rtwpci->link_ctrl & PCI_EXP_LNKCTL_ASPM_L1) + if (!(rtwpci->link_ctrl & PCI_EXP_LNKCTL_ASPM_L1)) + return; + + if ((enter && atomic_dec_if_positive(&rtwpci->link_usage) == 0) || + (!enter && atomic_inc_return(&rtwpci->link_usage) == 1)) rtw_pci_aspm_set(rtwdev, enter); } @@ -1630,6 +1633,9 @@ static int rtw_pci_napi_poll(struct napi_struct *napi, int budget) priv); int work_done = 0; + if (rtwpci->rx_no_aspm) + rtw_pci_link_ps(rtwdev, false); + while (work_done < budget) { u32 work_done_once; @@ -1653,6 +1659,8 @@ static int rtw_pci_napi_poll(struct napi_struct *napi, int budget) if (rtw_pci_get_hw_rx_ring_nr(rtwdev, rtwpci)) napi_schedule(napi); } + if (rtwpci->rx_no_aspm) + rtw_pci_link_ps(rtwdev, true); return work_done; } @@ -1674,41 +1682,13 @@ static void rtw_pci_napi_deinit(struct rtw_dev *rtwdev) netif_napi_del(&rtwpci->napi); } -enum rtw88_quirk_dis_pci_caps { - QUIRK_DIS_PCI_CAP_MSI, - QUIRK_DIS_PCI_CAP_ASPM, -}; - -static int disable_pci_caps(const struct dmi_system_id *dmi) -{ - uintptr_t dis_caps = (uintptr_t)dmi->driver_data; - - if (dis_caps & BIT(QUIRK_DIS_PCI_CAP_MSI)) - rtw_disable_msi = true; - if (dis_caps & BIT(QUIRK_DIS_PCI_CAP_ASPM)) - rtw_pci_disable_aspm = true; - - return 1; -} - -static const struct dmi_system_id rtw88_pci_quirks[] = { - { - .callback = disable_pci_caps, - .ident = "Protempo Ltd L116HTN6SPW", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Protempo Ltd"), - DMI_MATCH(DMI_PRODUCT_NAME, "L116HTN6SPW"), - }, - .driver_data = (void *)BIT(QUIRK_DIS_PCI_CAP_ASPM), - }, - {} -}; - int rtw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { + struct pci_dev *bridge = pci_upstream_bridge(pdev); struct ieee80211_hw *hw; struct rtw_dev *rtwdev; + struct rtw_pci *rtwpci; int drv_data_size; int ret; @@ -1726,6 +1706,9 @@ int rtw_pci_probe(struct pci_dev *pdev, rtwdev->hci.ops = &rtw_pci_ops; rtwdev->hci.type = RTW_HCI_TYPE_PCIE; + rtwpci = (struct rtw_pci *)rtwdev->priv; + atomic_set(&rtwpci->link_usage, 1); + ret = rtw_core_init(rtwdev); if (ret) goto err_release_hw; @@ -1754,7 +1737,10 @@ int rtw_pci_probe(struct pci_dev *pdev, goto err_destroy_pci; } - dmi_check_system(rtw88_pci_quirks); + /* Disable PCIe ASPM L1 while doing NAPI poll for 8821CE */ + if (pdev->device == 0xc821 && bridge->vendor == PCI_VENDOR_ID_INTEL) + rtwpci->rx_no_aspm = true; + rtw_pci_phy_cfg(rtwdev); ret = rtw_register_hw(rtwdev, hw); diff --git a/drivers/net/wireless/realtek/rtw88/pci.h b/drivers/net/wireless/realtek/rtw88/pci.h index 0ffae887527a2..cbbae130e620b 100644 --- a/drivers/net/wireless/realtek/rtw88/pci.h +++ b/drivers/net/wireless/realtek/rtw88/pci.h @@ -222,6 +222,8 @@ struct rtw_pci { struct rtw_pci_tx_ring tx_rings[RTK_MAX_TX_QUEUE_NUM]; struct rtw_pci_rx_ring rx_rings[RTK_MAX_RX_QUEUE_NUM]; u16 link_ctrl; + atomic_t link_usage; + bool rx_no_aspm; DECLARE_BITMAP(flags, NUM_OF_RTW_PCI_FLAGS); void __iomem *mmap;