From patchwork Fri Jun 2 11:47:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 102520 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp978838vqr; Fri, 2 Jun 2023 05:10:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7nd2JAtLUgSMSrvL5+Le8lwCykeQC9oxSQJiy1rMCcq/WcwlMCVq6MD3700ubWCfoSa3a5 X-Received: by 2002:a17:903:442:b0:1b0:6a10:1ba0 with SMTP id iw2-20020a170903044200b001b06a101ba0mr2102797plb.44.1685707835034; Fri, 02 Jun 2023 05:10:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685707835; cv=none; d=google.com; s=arc-20160816; b=q+/hjL1xmH1unTFmSDdNjrjvUaY90WfU+aHaMJB/84JINOY4E7WGARe1YxY/oJDEhc kZLKsLM3CpG+wPNyLShRh+hyIq7cakUuVH+R3R07Y0mQR+IPzowLPw3c+gW7afLCSj2Z 2XR2kI0oGYxVqXWV1SVDG4RYBIxWRrGPs82SkjdIrDNhyEO+4AShgzY+K7Mv4Fiu1bBu QaRSpt6iVJJbB5APhKy400gCQHZh6+GLFKM0H1sYCPiX5wFU2l5pHQ84ogKX8cLnhohQ EHclFfqk0/U6EKzWxvqRkiZ5k4O+2z66Zyn8ObNoywR126ebu/jNnYmo0fS10JAf1281 XsnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=s1/tSz4InN6r2f8Pw+NTKf4RR79ZSvHkyZuDw4zta9k=; b=bnuEUzGl1ECr3kiavT0Fr8rsND48obXIHpT1wGH8Xp9PNpaYz9bWf4V0O5KDVuvD+7 o3jP+uD39C4isGiHQYuB5F6Tld7F+X9re5AWGAd9MZ71cZsJWkoqwznPxLuN+HV9fuqp C8syK7SIKsOwGhD1O+0XgHSc2ao6N6het7yiF+skuPy/5BL8gLrPlT7Aa1eBp9D9vfo8 FgH25s1xSRcWlm3xY29Oiroo1zlZ+B4/00xUFskcbhDrWVsJYpxezBCdHMCGKBNxvs1u c3utdKWHXyYl0xd2ovYJIRuzzTrSSyEwcM2gnCtoDvJGdujuefhlQi+Jx696/i9Ozkyn Exjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=X1XxXcjU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b3-20020a170903228300b001b061dcdb78si890196plh.92.2023.06.02.05.10.22; Fri, 02 Jun 2023 05:10:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=X1XxXcjU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234687AbjFBLsP (ORCPT + 99 others); Fri, 2 Jun 2023 07:48:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234206AbjFBLsM (ORCPT ); Fri, 2 Jun 2023 07:48:12 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DC991AD; Fri, 2 Jun 2023 04:48:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685706490; x=1717242490; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zLpbqNZWijW0FovPyYDarY5V8t0U65hdE+v9Mv8XiYk=; b=X1XxXcjU7egS+YWoz7sL/9P3HdTzrgx0rc/ZVlmaWMQUZ53+yom0Y/X3 Tn9uGOYucPt9h+8GvwTvWlAWqyFBBLgR98sjMvbXPzvcEKo4Mf2bfebCU g1rGBkF8dBSoZ1bijTPttdYx98ysSFxr6qCd1jwpSfkcgCU4oeC0n8Xa3 i1TFBT2GygOLebtua70VFXo05Hus2mQNuE238M1jj6XiEe0oejlveyqGT 2jP2NI4SUoej5Ig3tg5g1Z3I8ZRC0GrZHL9aeddfbw6zdiOrjidumLDyG jzPxjMF8FK2ThDpxVZ8x5cRKK+dchEGY0uZTSfdFSh/dsk1zFXe5XTc3I A==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="358279601" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="358279601" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="707819412" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="707819412" Received: from rspatil-mobl3.gar.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.208.112]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:05 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , Bjorn Helgaas , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [RFC PATCH v1 01/13] PCI/ASPM: Disable ASPM when driver requests it Date: Fri, 2 Jun 2023 14:47:38 +0300 Message-Id: <20230602114751.19671-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> References: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767592779142907172?= X-GMAIL-MSGID: =?utf-8?q?1767592779142907172?= PCI core/ASPM service driver allows controlling ASPM state through pci_disable_link_state() and pci_enable_link_state() API. It was decided earlier (see the Link below), to not allow ASPM changes when OS does not have control over it but only log a warning about the problem (commit 2add0ec14c25 ("PCI/ASPM: Warn when driver asks to disable ASPM, but we can't do it")). Similarly, if ASPM is not enabled through config, ASPM cannot be disabled. A number of drivers have added workarounds to force ASPM off with own writes into the Link Control Register (some even with comments explaining why PCI core does not disable it under some circumstances). According to the comments, some drivers require ASPM to be off for reliable operation. Having custom ASPM handling in drivers is problematic because the state kept in the ASPM service driver is not updated by the changes made outside the link state management API. As the first step to address this issue, make pci_disable_link_state() to unconditionally disable ASPM so the motivation for drivers to come up with custom ASPM handling code is eliminated. Place the minimal ASPM disable handling into own file as it is too complicated to fit into a header as static inline and it has almost no overlap with the existing, more complicated ASPM code in drivers/pci/pce/aspm.c. Make pci_disable_link_state() function comment to comply kerneldoc formatting while changing the description. Link: https://lore.kernel.org/all/CANUX_P3F5YhbZX3WGU-j1AGpbXb_T9Bis2ErhvKkFMtDvzatVQ@mail.gmail.com/ Link: https://lore.kernel.org/all/20230511131441.45704-1-ilpo.jarvinen@linux.intel.com/ Signed-off-by: Ilpo Järvinen --- A few open questions: - If somebody has better suggestion for where to place the code, please let me know? - When OS does not have control, should all states be disabled (instead of the ones the driver requested)? drivers/pci/pcie/Makefile | 1 + drivers/pci/pcie/aspm.c | 33 ++++++++++------- drivers/pci/pcie/aspm_minimal.c | 66 +++++++++++++++++++++++++++++++++ include/linux/pci.h | 6 +-- 4 files changed, 88 insertions(+), 18 deletions(-) create mode 100644 drivers/pci/pcie/aspm_minimal.c diff --git a/drivers/pci/pcie/Makefile b/drivers/pci/pcie/Makefile index 8de4ed5f98f1..ec7f04037b01 100644 --- a/drivers/pci/pcie/Makefile +++ b/drivers/pci/pcie/Makefile @@ -6,6 +6,7 @@ pcieportdrv-y := portdrv.o rcec.o obj-$(CONFIG_PCIEPORTBUS) += pcieportdrv.o +obj-y += aspm_minimal.o obj-$(CONFIG_PCIEASPM) += aspm.o obj-$(CONFIG_PCIEAER) += aer.o err.o obj-$(CONFIG_PCIEAER_INJECT) += aer_inject.o diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 02b47e2cc774..51d6693d7171 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1089,16 +1089,23 @@ static int __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem) return -EINVAL; /* * A driver requested that ASPM be disabled on this device, but - * if we don't have permission to manage ASPM (e.g., on ACPI + * if we might not have permission to manage ASPM (e.g., on ACPI * systems we have to observe the FADT ACPI_FADT_NO_ASPM bit and - * the _OSC method), we can't honor that request. Windows has - * a similar mechanism using "PciASPMOptOut", which is also - * ignored in this situation. + * the _OSC method), previously we chose to not honor disable + * request in that case. Windows has a similar mechanism using + * "PciASPMOptOut", which is also ignored in this situation. + * + * Not honoring the requests to disable ASPM, however, led to + * drivers forcing ASPM off on their own. As such changes of ASPM + * state are not tracked by this service driver, the state kept here + * became out of sync. + * + * Therefore, honor ASPM disable requests even when OS does not have + * ASPM control. Plain disable for ASPM is assumed to be slightly + * safer than fully managing it. */ - if (aspm_disabled) { - pci_warn(pdev, "can't disable ASPM; OS doesn't have ASPM control\n"); - return -EPERM; - } + if (aspm_disabled) + pci_warn(pdev, "OS doesn't have ASPM control, disabling ASPM anyway\n"); if (sem) down_read(&pci_bus_sem); @@ -1135,13 +1142,13 @@ int pci_disable_link_state_locked(struct pci_dev *pdev, int state) EXPORT_SYMBOL(pci_disable_link_state_locked); /** - * pci_disable_link_state - Disable device's link state, so the link will - * never enter specific states. Note that if the BIOS didn't grant ASPM - * control to the OS, this does nothing because we can't touch the LNKCTL - * register. Returns 0 or a negative errno. - * + * pci_disable_link_state - Disable device's link state * @pdev: PCI device * @state: ASPM link state to disable + * + * Disable device's link state so the link will never enter specific states. + * + * Return: 0 or a negative errno */ int pci_disable_link_state(struct pci_dev *pdev, int state) { diff --git a/drivers/pci/pcie/aspm_minimal.c b/drivers/pci/pcie/aspm_minimal.c new file mode 100644 index 000000000000..4e4f63e51b21 --- /dev/null +++ b/drivers/pci/pcie/aspm_minimal.c @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Minimal PCIe ASPM handling when CONFIG_PCIEASPM is not set. + * + * Copyright (C) 2023 Intel Corporation. + */ + +#include + +#include "../pci.h" + +#ifndef CONFIG_PCIEASPM +/* + * Always disable ASPM when requested, even when CONFIG_PCIEASPM is + * not build to avoid drivers adding code to do it on their own + * which caused issues when core does not know about the out-of-band + * ASPM state changes. + */ +int pci_disable_link_state_locked(struct pci_dev *pdev, int state) +{ + struct pci_dev *parent = pdev->bus->self; + struct pci_bus *linkbus = pdev->bus; + struct pci_dev *child; + u16 aspm_enabled, linkctl; + int ret; + + if (!parent) + return -ENODEV; + + ret = pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &linkctl); + if (ret != PCIBIOS_SUCCESSFUL) + return pcibios_err_to_errno(ret); + aspm_enabled = linkctl & PCI_EXP_LNKCTL_ASPMC; + + ret = pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &linkctl); + if (ret != PCIBIOS_SUCCESSFUL) + return pcibios_err_to_errno(ret); + aspm_enabled |= linkctl & PCI_EXP_LNKCTL_ASPMC; + + /* If no states need to be disabled, don't touch LNKCTL */ + if (state & aspm_enabled) + return 0; + + ret = pcie_capability_clear_word(parent, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_ASPMC); + if (ret != PCIBIOS_SUCCESSFUL) + return pcibios_err_to_errno(ret); + list_for_each_entry(child, &linkbus->devices, bus_list) + pcie_capability_clear_word(child, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_ASPMC); + + return 0; +} +EXPORT_SYMBOL(pci_disable_link_state_locked); + +int pci_disable_link_state(struct pci_dev *pdev, int state) +{ + int ret; + + down_read(&pci_bus_sem); + ret = pci_disable_link_state_locked(pdev, state); + up_read(&pci_bus_sem); + + return ret; +} +EXPORT_SYMBOL(pci_disable_link_state); + +#endif diff --git a/include/linux/pci.h b/include/linux/pci.h index ab7682ed172f..1878f55b2aa6 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1774,18 +1774,14 @@ extern bool pcie_ports_native; PCIE_LINK_STATE_L1_2 | PCIE_LINK_STATE_L1_1_PCIPM |\ PCIE_LINK_STATE_L1_2_PCIPM) -#ifdef CONFIG_PCIEASPM int pci_disable_link_state(struct pci_dev *pdev, int state); int pci_disable_link_state_locked(struct pci_dev *pdev, int state); +#ifdef CONFIG_PCIEASPM int pci_enable_link_state(struct pci_dev *pdev, int state); void pcie_no_aspm(void); bool pcie_aspm_support_enabled(void); bool pcie_aspm_enabled(struct pci_dev *pdev); #else -static inline int pci_disable_link_state(struct pci_dev *pdev, int state) -{ return 0; } -static inline int pci_disable_link_state_locked(struct pci_dev *pdev, int state) -{ return 0; } static inline int pci_enable_link_state(struct pci_dev *pdev, int state) { return 0; } static inline void pcie_no_aspm(void) { } From patchwork Fri Jun 2 11:47:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 102510 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp968601vqr; Fri, 2 Jun 2023 04:55:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6PfYB0cXvRjbmQqhigJ7WPWlewGzW+9Lq+g+yccFj44vlLqIFVcl3ZWMHaURkg4GdSnjNF X-Received: by 2002:a17:90a:1b0e:b0:256:9b5c:2aa2 with SMTP id q14-20020a17090a1b0e00b002569b5c2aa2mr2203141pjq.6.1685706939137; Fri, 02 Jun 2023 04:55:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685706939; cv=none; d=google.com; s=arc-20160816; b=mcXmF1dt1sthysu/DU8aY7+zIuXehXPWzWHruLO0/YnUtxMJlH4KcTZyAQSTLhn1On vTpEBDwhG0vtzg2OigoTFb03YogMWX8yfTTru3Soz4Qbc9EvOVJybyZYk/FlRVbQwZlE 5FemDCAtG29BfupE6Bjy9/BCbA1ZTQ0gSWz3yCO/WndKSsiaV0YiEnJdLYIezIYTzrM5 gqoopYb6CPp59o86+zmVJTdWun2qZ6ISkYUifSI1zIfvJBT2aYd03iD6o6QsGhIxi7NR 1quvJdqNvZL3ek2QZybvMDyKFxB7Do4KfO5xTTXVh3hcqty2rTtekk2ECY7WmhNXQcIx UVrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OAZww5YC9cda/1jXY4rsdB2Qa0tKUWky9lMc7kvTIA8=; b=HSznFK7YAL8/J7NFEVqACtMWDrjpgdV3gg7bwmtb8kTIpo549yquSM7vzELLFiYwF+ aKbhcYU4jFz3gFtQXQgDi8dr/CLDVPLFxrrXNd+8CBG50SKgh9wpbkOEnA3fSl7jQI1I qpni0Eu97WTe+j8iXQO+xADFXavEeVvIa/qozDnzR5oU8oZZEZBJJrsYGmVyHh1TVupI j519BCv7LNVSSJ1RtA8L9NAJvVgOKzwzuOIS37zk90BjYYeruxyyxiaIBeEfxBh7Omkf 4i8UcSGuzGEz/8dIzz0mDnwZCexOT12l9jLjhn6MnCmNOiZLggshmsLBo/GXtiwNtAaa UZYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dRsl7VQb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q8-20020a656a88000000b0053ef5432117si879115pgu.461.2023.06.02.04.55.27; Fri, 02 Jun 2023 04:55:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dRsl7VQb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235109AbjFBLtF (ORCPT + 99 others); Fri, 2 Jun 2023 07:49:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229452AbjFBLs7 (ORCPT ); Fri, 2 Jun 2023 07:48:59 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44FF9E7B; Fri, 2 Jun 2023 04:48:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685706510; x=1717242510; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GYiQUacdfpCaOUMOuUUbytp5bgtwqkFXs7jFdgIpGa0=; b=dRsl7VQbR4RXL1A4hSial9N8vJkzkcA55oEl8FPUocQyK+hEiREgigfk kNZ09UpBWK5hj39bvkdXT+oqmSF3nx/s/9qoUUJLTIPwllcgWEZNwAclf sO9TnFP5eW3uQhnvH1Exx+M/IuQF7svCWlhOiyR5h34QeUPHYpRqGnvyf 8Ks9r4/d0uzpShCKgPElWCe5buKQfxnjxWDirffQeRxFKrjUbrENdfgHy qWA+ix9I0aaWS3KuHlh2gDhfMfMfybP4L24xsbahIlcyeo05f0OK+ocyx MelNiouvPkxbu4llGVWyDbW4D3hHDwa1mTVX0xP8pkcKqn5rbvtjsmszb A==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="358279620" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="358279620" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="707819419" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="707819419" Received: from rspatil-mobl3.gar.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.208.112]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:10 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , Nirmal Patel , Jonathan Derrick , Lorenzo Pieralisi , Bjorn Helgaas , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [RFC PATCH v1 02/13] PCI/ASPM: Rename pci_enable_link_state() to pci_set_default_link_state() Date: Fri, 2 Jun 2023 14:47:39 +0300 Message-Id: <20230602114751.19671-3-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> References: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767591839542456950?= X-GMAIL-MSGID: =?utf-8?q?1767591839542456950?= pci_enable_link_state() and pci_disable_link_state() are not paired symmetrically despite their names suggesting otherwise. Also, pci_enable_link_state() tweaks link state when the "default" policy is in use rather than exactly "enabling" some link states. Obviously, when the default policy is in use and the default link state is changed, some link states may get enabled but that is a secondary effect. Thus, rename pci_enable_link_state() to pci_set_default_link_state() to better match what it does. The rename also frees pci_enable_link_state() name so that a later commit can add a function that pairs symmetrically with pci_disable_link_state(). Signed-off-by: Ilpo Järvinen --- drivers/pci/controller/vmd.c | 2 +- drivers/pci/pcie/aspm.c | 8 ++++---- include/linux/pci.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c index 990630ec57c6..0e62f4cd5a5f 100644 --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -737,7 +737,7 @@ static int vmd_pm_enable_quirk(struct pci_dev *pdev, void *userdata) if (!(features & VMD_FEAT_BIOS_PM_QUIRK)) return 0; - pci_enable_link_state(pdev, PCIE_LINK_STATE_ALL); + pci_set_default_link_state(pdev, PCIE_LINK_STATE_ALL); pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_LTR); if (!pos) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 51d6693d7171..9fa8ab6eb7a4 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1157,8 +1157,8 @@ int pci_disable_link_state(struct pci_dev *pdev, int state) EXPORT_SYMBOL(pci_disable_link_state); /** - * pci_enable_link_state - Clear and set the default device link state so that - * the link may be allowed to enter the specified states. Note that if the + * pci_set_default_link_state - Clear and set the default device link state so + * that the link may be allowed to enter the specified states. Note that if the * BIOS didn't grant ASPM control to the OS, this does nothing because we can't * touch the LNKCTL register. Also note that this does not enable states * disabled by pci_disable_link_state(). Return 0 or a negative errno. @@ -1166,7 +1166,7 @@ EXPORT_SYMBOL(pci_disable_link_state); * @pdev: PCI device * @state: Mask of ASPM link states to enable */ -int pci_enable_link_state(struct pci_dev *pdev, int state) +int pci_set_default_link_state(struct pci_dev *pdev, int state) { struct pcie_link_state *link = pcie_aspm_get_link(pdev); @@ -1208,7 +1208,7 @@ int pci_enable_link_state(struct pci_dev *pdev, int state) return 0; } -EXPORT_SYMBOL(pci_enable_link_state); +EXPORT_SYMBOL(pci_set_default_link_state); static int pcie_aspm_set_policy(const char *val, const struct kernel_param *kp) diff --git a/include/linux/pci.h b/include/linux/pci.h index 1878f55b2aa6..5597e97a086d 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1777,12 +1777,12 @@ extern bool pcie_ports_native; int pci_disable_link_state(struct pci_dev *pdev, int state); int pci_disable_link_state_locked(struct pci_dev *pdev, int state); #ifdef CONFIG_PCIEASPM -int pci_enable_link_state(struct pci_dev *pdev, int state); +int pci_set_default_link_state(struct pci_dev *pdev, int state); void pcie_no_aspm(void); bool pcie_aspm_support_enabled(void); bool pcie_aspm_enabled(struct pci_dev *pdev); #else -static inline int pci_enable_link_state(struct pci_dev *pdev, int state) +static inline int pci_set_default_link_state(struct pci_dev *pdev, int state) { return 0; } static inline void pcie_no_aspm(void) { } static inline bool pcie_aspm_support_enabled(void) { return false; } From patchwork Fri Jun 2 11:47:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 102512 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp969550vqr; Fri, 2 Jun 2023 04:57:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ehuuPX4z/0mah0VgUumtNYG0xcc82RnezeTOJkWZOYYUZav8ZQXkACK3cRiFEZ20OLybB X-Received: by 2002:a17:903:249:b0:1af:a2a4:8379 with SMTP id j9-20020a170903024900b001afa2a48379mr1468030plh.17.1685707052442; Fri, 02 Jun 2023 04:57:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685707052; cv=none; d=google.com; s=arc-20160816; b=pV1pXhnXiyZIth0jEcgSRi4pttzAn6ATiW5oNFA+3OaS9rU168Xno5XKhTMBZxiRc5 d3XOXex98l/B/l0ktuFQfgnPhui41V1ZSm/HzC1w0e4CmNJ/MYvLWpjr6DucweKQ4Wds 7JwZxBbmoiOK6wjz/0H4WSIrA8NZCM/ceIaJjoTM/I+/wgjAbNRAvdA4+mgXPpy7rP+w 851NJPKqccfFsRV4VX+HLOcynkAwG2xAt+QwE/U+spTUf7RVZh/ouopZHSo+7tmCy0wf w0fs/zVr1tDOvH947i8wu46MA+YorF88Z5CEUvySOTZiK8KryQLYJeUMfd+Kio70mUss EF+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6m8xHyEGGA88+lDtKUiqyWPtDh/0RscvNA7OWO0+YS0=; b=a6UUdbtGCv5LKTq+CXkxzdc8uzfp4G7YLV42/P0Ikx2QNVXUyf3okb23L1zb68Yepg tC+Rw8ZRsSEN5JpbYbPOf4Aye/U1DJZDv7Dbaylb7zhxQsw21SmK5qHj6tvIQD1iskOv XKmEFhmPjCUl6tkUMkRJg5E59K8nX9m/39O90O8tQoVtfOORvTouQD0yf/rLlqW+vNfP 7xNT5WpLqlzaPrdjg9Bx0mQtpJfqNpimhdFc0desaxXEwY2L6UAHeUoMrsnr8tpmDg3i jOjNMNZ7tIR4eN3/Wq3u3Svrs/b+LjdtW61iU/IkrTRJu7bC+jm7YqCDftQXJp0ct2Ek v5zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DgcC+AbP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e23-20020a170902ed9700b001b04c773ce2si753723plj.541.2023.06.02.04.57.17; Fri, 02 Jun 2023 04:57:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DgcC+AbP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235231AbjFBLtI (ORCPT + 99 others); Fri, 2 Jun 2023 07:49:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235184AbjFBLtB (ORCPT ); Fri, 2 Jun 2023 07:49:01 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9236F10C4; Fri, 2 Jun 2023 04:48:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685706511; x=1717242511; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wuhMVA9R70dv8zCl7j+RyC0Woig16drv2hvDBVun3EM=; b=DgcC+AbPeVQgxvi1LkAlD+MrTdAIzshgbqVGX7aFN2aqv3DrgPCjEKnS M6D67aevqPUVi/4whyqDxL1u65kOfFZzxFUo2a57AjTzE5pkaDEbmkRJl xco3Mvyg3gu0XcCQfiQn9S3mWOfzmkYHJrSnWva+Mn/9acx/9XEaNfj88 dmSYf/0VRwkd3tx5H8mKkggf+BRenPR2o7OKX68/dev4n8h1IRsotwB7U dmDh8seUY6sqxZNidcxl3Ib3evxKqQrrrJaEDn5QEghDLF+JZuhbmrbtV 8j5gDlkAApxmge748cAvI2JCdLmqvrkB1NvflJiwGZmn5ewJSh3yKNcv6 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="358279642" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="358279642" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="707819423" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="707819423" Received: from rspatil-mobl3.gar.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.208.112]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:15 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , Bjorn Helgaas , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [RFC PATCH v1 03/13] PCI/ASPM: Improve pci_set_default_link_state() kerneldoc Date: Fri, 2 Jun 2023 14:47:40 +0300 Message-Id: <20230602114751.19671-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> References: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767591957953328931?= X-GMAIL-MSGID: =?utf-8?q?1767591957953328931?= Improve pci_set_default_link_state() documentation: - Note the link state may get changed if the default policy is in use - Better follow kerneldoc formatting guidelines (separate description block and return entries) Signed-off-by: Ilpo Järvinen --- drivers/pci/pcie/aspm.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 9fa8ab6eb7a4..33ee2b563a39 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1157,14 +1157,18 @@ int pci_disable_link_state(struct pci_dev *pdev, int state) EXPORT_SYMBOL(pci_disable_link_state); /** - * pci_set_default_link_state - Clear and set the default device link state so - * that the link may be allowed to enter the specified states. Note that if the - * BIOS didn't grant ASPM control to the OS, this does nothing because we can't - * touch the LNKCTL register. Also note that this does not enable states - * disabled by pci_disable_link_state(). Return 0 or a negative errno. - * + * pci_set_default_link_state - Set the default device link state * @pdev: PCI device * @state: Mask of ASPM link states to enable + * + * Clear and set the default device link state so that the link may be + * allowed to enter the specified states. If the default policy is in use, + * the link state may also be updated to reflect the new default link state. + * Note that if the BIOS didn't grant ASPM control to the OS, this does + * nothing because we can't touch the LNKCTL register. Also note that this + * does not enable states disabled by pci_disable_link_state(). + * + * Return: 0 or a negative errno. */ int pci_set_default_link_state(struct pci_dev *pdev, int state) { From patchwork Fri Jun 2 11:47:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 102508 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp968486vqr; Fri, 2 Jun 2023 04:55:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4rQsGf+iCQaDxZSl/YMo4SBhslPoQTYsH4PPmd9VNt1ybzzTzhiaq6+jZhKaQKr+hbqyyz X-Received: by 2002:a17:90a:8d04:b0:253:3eb5:3ade with SMTP id c4-20020a17090a8d0400b002533eb53ademr2118763pjo.8.1685706926616; Fri, 02 Jun 2023 04:55:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685706926; cv=none; d=google.com; s=arc-20160816; b=KcIZrNDWIh7iI7IzvdgI+lF5zkddmYd55j85SfsMzM7KtSjVnMWPdLD2MridkD9G09 kwWz+C5ymH4aJPVYemMFpmcJm0zIeL2prP0kspAYP2ojIdbmjr+s1PPoOaiYqMdCzVnd Oqtf4k51N5i3AwNyTPP/UKAScgmaVp2cqQNUWBrGAwhhnSmL/rWc/CPOzi39inX87r83 qsFC1EZcO5680/GEcW7KCPaP9jIhq+RmdHxgOd9oMBkZKOvPAllM9UWzjVEJQ+hEXwbO AKtpnSLIHDNNqH/iCkFMgTlInJbhdo26ZY+AMDs83TvUdkoORal4/YnTMp9SW0tZepfi XqLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pnop3ojBvT0npjhiQ3zcSp/jwIb7Gl+wT7FiBT4b72o=; b=mX2QsNh9PJLLivDEz1IGU3U4fmEyQw8G4Efclbm/KWEbqorDAaC75ZTPUW+hUr77US Cf3sWJ0Il8XUS4zpd/yP+XRrOvTb6/PCcQRNDD+/wM8JrEJQ5apktD82MJZ2Y3REYiqR k+/xfdNb+fWQ3SOyiFRJGqPSb7Z5/iQ2q/Lnjj4OJ8xW+quMLHRdGInpoudp4FZJEe27 WEQPXL8D3DCL8zDrTG6Ur1sF8r5uhV6keshHhYE2kmbhYCUIZE0pKuRrvHdPFjw89V6f SRu5Y9S44Ppj4kpkH2B8oICVatX/JxXgfkFhHKiVFluxrfu129UCPU7seFQNnSKjyHal Z3dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=A0Gy3gEw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 26-20020a17090a031a00b002536b553afdsi2643337pje.98.2023.06.02.04.55.11; Fri, 02 Jun 2023 04:55:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=A0Gy3gEw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235208AbjFBLtX (ORCPT + 99 others); Fri, 2 Jun 2023 07:49:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235041AbjFBLtP (ORCPT ); Fri, 2 Jun 2023 07:49:15 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC61110D8; Fri, 2 Jun 2023 04:48:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685706522; x=1717242522; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/DLIxgNO8D6hBvJ4nGLI25s1QAbvWbyDz0yc5as0DVI=; b=A0Gy3gEwcSC9kGijvpU/AQI1PjGVIGNUrM6Y4M+hUsvvgwdTPXcF8KTn 2w3AlqmRYjD04RzGFy6wJLsJuLaTtFcChUAkkBSsAOJciZjYNwp8uk529 OY7hVGkKeiO8ivR5dRbPv9jvFjaOYB95zdyWDKjTSnLsxqOkaBSi+LH9v XnVfdw/lU0N+XjKPPltRSL+GlAx/Q2XiVi5VMNae8Cuj5it03Bht/6Q81 rOoMylmzI+xKrbcFeFonQjf+NFHy+roqnO3n34dgfeqBgmytnuuE19ITA mu1Lw59ZKsQwfBIwGg5ncSsQd8rK73XbafVQU+5FIbNphUb21qs8wQrLK A==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="358279655" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="358279655" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="707819428" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="707819428" Received: from rspatil-mobl3.gar.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.208.112]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:20 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , Bjorn Helgaas , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [RFC PATCH v1 04/13] PCI/ASPM: Move L0S/L1/sub states mask calculation into a helper Date: Fri, 2 Jun 2023 14:47:41 +0300 Message-Id: <20230602114751.19671-5-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> References: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767591826429172465?= X-GMAIL-MSGID: =?utf-8?q?1767591826429172465?= ASPM service driver does the same L0S / L1S / sub states allowed calculation in __pci_disable_link_state() and pci_set_default_link_state(). Create a helper to calculate the mask for the allowed states. Signed-off-by: Ilpo Järvinen --- drivers/pci/pcie/aspm.c | 50 +++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 33ee2b563a39..4727f73a2d0d 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1081,6 +1081,27 @@ static struct pcie_link_state *pcie_aspm_get_link(struct pci_dev *pdev) return bridge->link_state; } +static u8 pci_link_state_mask(int state) +{ + u8 result = 0; + + if (state & PCIE_LINK_STATE_L0S) + result |= ASPM_STATE_L0S; + if (state & PCIE_LINK_STATE_L1) + /* L1 PM substates require L1 */ + result |= ASPM_STATE_L1 | ASPM_STATE_L1SS; + if (state & PCIE_LINK_STATE_L1_1) + result |= ASPM_STATE_L1_1; + if (state & PCIE_LINK_STATE_L1_2) + result |= ASPM_STATE_L1_2; + if (state & PCIE_LINK_STATE_L1_1_PCIPM) + result |= ASPM_STATE_L1_1_PCIPM; + if (state & PCIE_LINK_STATE_L1_2_PCIPM) + result |= ASPM_STATE_L1_2_PCIPM; + + return result; +} + static int __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem) { struct pcie_link_state *link = pcie_aspm_get_link(pdev); @@ -1110,19 +1131,7 @@ static int __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem) if (sem) down_read(&pci_bus_sem); mutex_lock(&aspm_lock); - if (state & PCIE_LINK_STATE_L0S) - link->aspm_disable |= ASPM_STATE_L0S; - if (state & PCIE_LINK_STATE_L1) - /* L1 PM substates require L1 */ - link->aspm_disable |= ASPM_STATE_L1 | ASPM_STATE_L1SS; - if (state & PCIE_LINK_STATE_L1_1) - link->aspm_disable |= ASPM_STATE_L1_1; - if (state & PCIE_LINK_STATE_L1_2) - link->aspm_disable |= ASPM_STATE_L1_2; - if (state & PCIE_LINK_STATE_L1_1_PCIPM) - link->aspm_disable |= ASPM_STATE_L1_1_PCIPM; - if (state & PCIE_LINK_STATE_L1_2_PCIPM) - link->aspm_disable |= ASPM_STATE_L1_2_PCIPM; + link->aspm_disable |= pci_link_state_mask(state); pcie_config_aspm_link(link, policy_to_aspm_state(link)); if (state & PCIE_LINK_STATE_CLKPM) @@ -1189,20 +1198,7 @@ int pci_set_default_link_state(struct pci_dev *pdev, int state) down_read(&pci_bus_sem); mutex_lock(&aspm_lock); - link->aspm_default = 0; - if (state & PCIE_LINK_STATE_L0S) - link->aspm_default |= ASPM_STATE_L0S; - if (state & PCIE_LINK_STATE_L1) - /* L1 PM substates require L1 */ - link->aspm_default |= ASPM_STATE_L1 | ASPM_STATE_L1SS; - if (state & PCIE_LINK_STATE_L1_1) - link->aspm_default |= ASPM_STATE_L1_1; - if (state & PCIE_LINK_STATE_L1_2) - link->aspm_default |= ASPM_STATE_L1_2; - if (state & PCIE_LINK_STATE_L1_1_PCIPM) - link->aspm_default |= ASPM_STATE_L1_1_PCIPM; - if (state & PCIE_LINK_STATE_L1_2_PCIPM) - link->aspm_default |= ASPM_STATE_L1_2_PCIPM; + link->aspm_default = pci_link_state_mask(state); pcie_config_aspm_link(link, policy_to_aspm_state(link)); link->clkpm_default = (state & PCIE_LINK_STATE_CLKPM) ? 1 : 0; From patchwork Fri Jun 2 11:47:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 102530 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp983774vqr; Fri, 2 Jun 2023 05:18:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6vbDmA1S2RhRKPbVLSYd7MnI3XjmMCut5UOCKDT3HRR8bGKEpWZNMjidrtDlDqEZCywOeh X-Received: by 2002:a05:6a20:7da5:b0:10c:6dbc:2810 with SMTP id v37-20020a056a207da500b0010c6dbc2810mr14748732pzj.62.1685708290652; Fri, 02 Jun 2023 05:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685708290; cv=none; d=google.com; s=arc-20160816; b=i0GgNHRb3qvwZ4dcgmexl9u8cA8xYIXvIAcT31MJL1kY+ifc7zy/9mlXT+7J1yBRad ieqx1BL6YkNDnow4C8FUyPXiGjLNBWkFcTIQd1/sheNm9Oypj7b7ZwEjZEvpfqfLtfnh XV43NtWBFnJFwChYBLsrtoCdmI4lc3E+JFIAQXi+l0kZOBBCzLXlbfOZYjepMkkTuNJL 6jNbtYCJIQWUQFqUxi79KD3FpecQX+DU8fZuaohebQL58zY5BiC2/uQTYoKoEOllcSQ1 0fuXczFTVs5sOwncOgo89lHtZrJWbCf/tuaWu5lc30gJXtdY1r8hMxyt+sV1P3ntozhx iVjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YnTXxUylb8kRaazZgaLukCN4B78DAd+/6DpkatBR/bI=; b=wfCYbi87NVFuaZeXBUZP6CFWcB/C3k/NdS6+nKavB0oSyX0afXTFgl3x275oWQ8sP9 0/c1fNGT2rVuzkOxgnnwYyr1sIlpMP35Kc+cdai0NPfJhLeBCitBJW2lPw3FtkaSXG5C VjNbDU478RutAp2AtTZHXARfrrvuADAnoOT/0reD9LnHeFuNBRLfIHpAJh0UzzwxD9RL 30oPEfWG4RXgVYG5nEROVRKwbqdRQd76DOQPafZyUXoj19PSc4dULiFavZkWkkgCJqm8 Kq9YEWg/Emrxpb2j9kS5GHBNUWya1GoeC4bFSe1zM7xjxVfkS5cWPyZOiD1BNu3+KULZ 9Wjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Dif17jcG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g129-20020a636b87000000b0053b8f80c65esi908896pgc.730.2023.06.02.05.17.56; Fri, 02 Jun 2023 05:18:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Dif17jcG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235228AbjFBLtb (ORCPT + 99 others); Fri, 2 Jun 2023 07:49:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235014AbjFBLt0 (ORCPT ); Fri, 2 Jun 2023 07:49:26 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A548310E7; Fri, 2 Jun 2023 04:48:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685706534; x=1717242534; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BtruzGycmKqs9ry1ncyoa7VfbvISx5ML/zzcyrdoo7U=; b=Dif17jcG+INVFOdVOZPq6DTykGF3oT/7onDc4tC50jjBvtYh3axKZRE0 wngS+63tHSYUwRzxGX2VCRzP/WzNMwb2jgCc05rYmZJpvVlaIaV2x/yxd b8cJFCUPUygBdqqiFpy9wOFP5AgTZNy486aIUn3u4fqm/dZMm1mAIj562 Ir+fe3b3NW5GRBBM1hMtIWiGDWbmhRL1IbHqZMK6fZeSyWfjGwB/ZR3O2 yaTC2CLIjCAft2xCpFpa8/ZM5aHOeopFt3a+s2bstyc3wRJoabZKZK/Sb VZjw4U9aoiqyD7584gMOfh0OaWwb9tn4hGtZeO1Hlj4LGQ0B9xXLuwlaq Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="358279663" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="358279663" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="707819437" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="707819437" Received: from rspatil-mobl3.gar.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.208.112]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:24 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , Bjorn Helgaas , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [RFC PATCH v1 05/13] PCI/ASPM: Add pci_enable_link_state() Date: Fri, 2 Jun 2023 14:47:42 +0300 Message-Id: <20230602114751.19671-6-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> References: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767593256692335848?= X-GMAIL-MSGID: =?utf-8?q?1767593256692335848?= pci_disable_link_state() lacks a symmetric pair. Some drivers want to disable ASPM during certain phases of their operation but then re-enable it later on. If pci_disable_link_state() is made for the device, there is currently no way to re-enable the states that were disabled. Add pci_enable_link_state() to remove ASPM states from the state disable mask. Signed-off-by: Ilpo Järvinen --- drivers/pci/pcie/aspm.c | 44 +++++++++++++++++++++++++++++++++++++++++ include/linux/pci.h | 2 ++ 2 files changed, 46 insertions(+) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 4727f73a2d0d..aed59ab13c46 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1165,6 +1165,50 @@ int pci_disable_link_state(struct pci_dev *pdev, int state) } EXPORT_SYMBOL(pci_disable_link_state); +/** + * pci_enable_link_state - Re-enable device's link state + * @pdev: PCI device + * @state: ASPM link states to re-enable + * + * Enable device's link state that were previously disable so the link is + * allowed to enter the specific states. Note that if the BIOS didn't grant + * ASPM control to the OS, this does nothing because we can't touch the + * LNKCTL register. + * + * Return: 0 or a negative errno. + */ +int pci_enable_link_state(struct pci_dev *pdev, int state) +{ + struct pcie_link_state *link = pcie_aspm_get_link(pdev); + + if (!link) + return -EINVAL; + /* + * A driver requested that ASPM be disabled on this device, but + * if we don't have permission to manage ASPM (e.g., on ACPI + * systems we have to observe the FADT ACPI_FADT_NO_ASPM bit and + * the _OSC method), we can't honor that request. Windows has + * a similar mechanism using "PciASPMOptOut", which is also + * ignored in this situation. + */ + if (aspm_disabled) { + pci_warn(pdev, "can't enable ASPM; OS doesn't have ASPM control\n"); + return -EPERM; + } + + mutex_lock(&aspm_lock); + link->aspm_disable &= ~pci_link_state_mask(state); + pcie_config_aspm_link(link, policy_to_aspm_state(link)); + + if (state & PCIE_LINK_STATE_CLKPM) + link->clkpm_disable = 0; + pcie_set_clkpm(link, policy_to_clkpm_state(link)); + mutex_unlock(&aspm_lock); + + return 0; +} +EXPORT_SYMBOL(pci_enable_link_state); + /** * pci_set_default_link_state - Set the default device link state * @pdev: PCI device diff --git a/include/linux/pci.h b/include/linux/pci.h index 5597e97a086d..aec259d12ca0 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1777,11 +1777,13 @@ extern bool pcie_ports_native; int pci_disable_link_state(struct pci_dev *pdev, int state); int pci_disable_link_state_locked(struct pci_dev *pdev, int state); #ifdef CONFIG_PCIEASPM +int pci_enable_link_state(struct pci_dev *pdev, int state); int pci_set_default_link_state(struct pci_dev *pdev, int state); void pcie_no_aspm(void); bool pcie_aspm_support_enabled(void); bool pcie_aspm_enabled(struct pci_dev *pdev); #else +static inline int pci_enable_link_state(struct pci_dev *pdev, int state) { return -EOPNOTSUPP; } static inline int pci_set_default_link_state(struct pci_dev *pdev, int state) { return 0; } static inline void pcie_no_aspm(void) { } From patchwork Fri Jun 2 11:47:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 102524 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp982236vqr; Fri, 2 Jun 2023 05:15:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ57xIZgXDRKR7sUd188B4WOnHq/YDcUWRtH5TREaPymkoET4lIC2DA4Ro3Tvz8xnyP+wOVl X-Received: by 2002:a05:6a00:aca:b0:644:d775:60bb with SMTP id c10-20020a056a000aca00b00644d77560bbmr10250982pfl.20.1685708155490; Fri, 02 Jun 2023 05:15:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685708155; cv=none; d=google.com; s=arc-20160816; b=fX65WNPsV940G58MOivwYzDC7rw+WyfXhTrGXbVPhBTNR1NQ/tvk9uphGa8/Fj0a2n GqZBmxnOdD5AXVnqagVNQ614MSp184b/846y67UL0unzAE9XMOvVrKu/OtY1xQDMPMEz iLgdYUvWqa6vvk6NqV90W561Lw/1gm0EDsl0OkmQgl5Q9cNTulPd+MvJUAbphsN9iE9Y S+r9D+e1kU7FgoncVCfmFO7frUCtCREvGJOPxQU2d6JtcNoETFLNj0XPrJ7YLzdWpBKQ H5KvaSixVSH+1bEuHXVJfzPUya52v8nK9XXH9e6UMcwvBPZJJmL6MC3Qm1TJYCn8Xrvc mhgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Eg0PEozLHnFjkWuMghdAqax0e4/Dlg1eAKkdw5VoWTg=; b=QPRiSWxks5JJ3RTmQcEUK1HEv18Pyscj1njrG+J/g4kJObAu5BrSyyiUrXQc1xOzAg Hvd0dDJo2byPJd5CbhLIwlpDfRZU/8k7iclG657SnX/CwvlScGCWk+eiXcFA08aW0fZT Sul+kQKdUWUHOgVuhMwH0uTz3TLT57Ga7jW1MCDZ+FA9kaet8AKGJ9PFx46Dy1cosV9U KfSbSVFQHTvmjF+vnFSBOi5LzTNzqf9k2VG0Y/cJ1L/qNoR+Jr/GeBH+cNhk81UJDC1I 4dqeQjA2/x/goRvnHZ+J+7OvUtzK4fpVLLbVTLohBvdyrG8wJicPv52pKaWpj3KPfi+t ZW7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BemgC809; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t127-20020a637885000000b0052c7ad564e2si926082pgc.707.2023.06.02.05.15.36; Fri, 02 Jun 2023 05:15:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BemgC809; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235195AbjFBLte (ORCPT + 99 others); Fri, 2 Jun 2023 07:49:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235236AbjFBLt2 (ORCPT ); Fri, 2 Jun 2023 07:49:28 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D000610EF; Fri, 2 Jun 2023 04:48:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685706538; x=1717242538; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9QPnZYdorgxm2tG/6TS44yuCtoro1PqrgtUx93Xiu78=; b=BemgC80972E9OTSM/YDZfiSp1yK4rX6yaztWmgXZ1zRtXNa5YqK1zVrx gGwRFnWC/+TDutQFzQCSWYu9Nh6ygVjgozKZ7q6MmZB6QETSNAaVvTx0O XHytvj9ytyn98TEgWyJGMz3LzvYQSJF28tfdiGmEeml22BnOJw8TvIIGe 2iNnTZWYNftxR0uXiRleNxbMXCet1zhFUrQY2buDHeyI5rq3Yb7iR2q+t khisMk85QVIHb7DhWHbFtufjSH37c1lv6NC5pNUSyEntSlYUKre9AFGmt /eq0QIOoM6h9xjoH+bKvgfMwumG7f3qVMAWQny7z13H3vqG60XgA/IjTC w==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="358279676" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="358279676" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="707819452" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="707819452" Received: from rspatil-mobl3.gar.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.208.112]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:29 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , Hector Martin , Sven Peter , Alyssa Rosenzweig , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , Bjorn Helgaas , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [RFC PATCH v1 06/13] Bluetooth: hci_bcm4377: Convert aspm disable to quirk Date: Fri, 2 Jun 2023 14:47:43 +0300 Message-Id: <20230602114751.19671-7-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> References: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767593115148798880?= X-GMAIL-MSGID: =?utf-8?q?1767593115148798880?= pci_disable_link_state() was made reliable regardless of ASPM CONFIG and OS being disallowed to change ASPM states to allow drivers to rely on pci_disable_link_state() working. Remove driver working around unreliable pci_disable_link_state() from hci_bcm4377 driver and add a PCI quirk to disable ASPM. Signed-off-by: Ilpo Järvinen --- drivers/bluetooth/hci_bcm4377.c | 20 -------------------- drivers/pci/quirks.c | 3 +++ 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/drivers/bluetooth/hci_bcm4377.c b/drivers/bluetooth/hci_bcm4377.c index 19ad0e788646..2348ee2380db 100644 --- a/drivers/bluetooth/hci_bcm4377.c +++ b/drivers/bluetooth/hci_bcm4377.c @@ -490,7 +490,6 @@ struct bcm4377_data; * clear_pciecfg_subsystem_ctrl_bit19: Set to true if bit 19 in the * vendor-specific subsystem control * register has to be cleared - * disable_aspm: Set to true if ASPM must be disabled due to hardware errata * broken_ext_scan: Set to true if the chip erroneously claims to support * extended scanning * broken_mws_transport_config: Set to true if the chip erroneously claims to @@ -509,7 +508,6 @@ struct bcm4377_hw { unsigned long has_bar0_core2_window2 : 1; unsigned long clear_pciecfg_subsystem_ctrl_bit19 : 1; - unsigned long disable_aspm : 1; unsigned long broken_ext_scan : 1; unsigned long broken_mws_transport_config : 1; @@ -2222,20 +2220,6 @@ static int bcm4377_probe_of(struct bcm4377_data *bcm4377) return 0; } -static void bcm4377_disable_aspm(struct bcm4377_data *bcm4377) -{ - pci_disable_link_state(bcm4377->pdev, - PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); - - /* - * pci_disable_link_state can fail if either CONFIG_PCIEASPM is disabled - * or if the BIOS hasn't handed over control to us. We must *always* - * disable ASPM for this device due to hardware errata though. - */ - pcie_capability_clear_word(bcm4377->pdev, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC); -} - static void bcm4377_pci_free_irq_vectors(void *data) { pci_free_irq_vectors(data); @@ -2288,9 +2272,6 @@ static int bcm4377_probe(struct pci_dev *pdev, const struct pci_device_id *id) return -ENODEV; } - if (bcm4377->hw->disable_aspm) - bcm4377_disable_aspm(bcm4377); - ret = pci_reset_function_locked(pdev); if (ret) dev_warn( @@ -2448,7 +2429,6 @@ static const struct bcm4377_hw bcm4377_hw_variants[] = { .otp_offset = 0x4120, .bar0_window1 = 0x1800b000, .bar0_window2 = 0x1810c000, - .disable_aspm = true, .broken_ext_scan = true, .send_ptb = bcm4377_send_ptb, }, diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index f4e2a88729fd..25b7d7bcb279 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -2407,6 +2407,9 @@ static void quirk_disable_aspm_l0s_l1(struct pci_dev *dev) */ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ASMEDIA, 0x1080, quirk_disable_aspm_l0s_l1); +/* BCM4377 must always disable ASPM due to hardware errata. */ +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM, 0x5fa0, quirk_disable_aspm_l0s_l1); + /* * Some Pericom PCIe-to-PCI bridges in reverse mode need the PCIe Retrain * Link bit cleared after starting the link retrain process to allow this From patchwork Fri Jun 2 11:47:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 102506 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp966222vqr; Fri, 2 Jun 2023 04:50:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6DRgt1RiOkYgx8pozueOy6Itv9hS0AcP/TFnrqmO+3zsLeko2PUFAqSEb2BAqBQ1zxIAhZ X-Received: by 2002:a05:6a20:3d85:b0:10b:60c1:2999 with SMTP id s5-20020a056a203d8500b0010b60c12999mr5937586pzi.22.1685706655101; Fri, 02 Jun 2023 04:50:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685706655; cv=none; d=google.com; s=arc-20160816; b=nQ0FZxnu6Jhtwljjvl9u09kkSts2C9A5SLe14Nkd7JteuwTdp4b5B+yiwN3wRgIkfb wlFCnhuJ4cbMVmhqBv5jKVApu3CA9ZcVLGQ4m52mkDaAeVqrDN93fN+JIBjBy1ydHlMw uQz6fqJlAJNN/kpIwulmhtzXIyVGdJqWgmRjnjaQyJ2OKItt8dpP4vBvrCRi9UNX0rrs DlHcB7HKLkZ2VrmVM06DpNI48GdhToY9KwfNuykPagVNlCyZjSN3xPsWMtOEIkDHSxwO s7veJk9PekN2hBeKe1CXpq0gei801E1OT2b7csZpp5PEq2AX1xSBFWruV2NB8LrzC4No 5G6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kUOBB+TNQjUJUkcVxMIwxG8p+H21R6sCSWyhJE+VjYY=; b=Kd38g2DVLjoKln+sRE9Qv5UxVrUqdA+2/7glLdk6rvaJh9cRTCa1+XcFmE+URDSBqX eAOe9Ve83tMEAzoBkvQco/z+yXH5z36sS5g9pBxCfGdNvpIgyLBJmSAAaXGuKPzZf9hF KlsRkqcpuzUUrfEhGl12OaavdTE1hdab5qxpU49H7YIDKC8oADF+8yKOSIQVi57HWYDT 9izzPcJE2jlI1E+R43cAlvvLM9sldU65vwPLqLrXDbT2LSnNkZGNrxMrwupKAD6f684g FshyvmZwk8Ir4GEig4L3hw0Cu55QoK776nU1ed3qlNtB1PD4WTazmRxZ8wkgum3hC+5v Q1Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AZDRAmVI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u62-20020a638541000000b0053b8874cee1si898467pgd.418.2023.06.02.04.50.42; Fri, 02 Jun 2023 04:50:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AZDRAmVI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235525AbjFBLuC (ORCPT + 99 others); Fri, 2 Jun 2023 07:50:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235325AbjFBLto (ORCPT ); Fri, 2 Jun 2023 07:49:44 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B62CE10C2; Fri, 2 Jun 2023 04:49:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685706554; x=1717242554; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=i8q5tBCE9Tvk3bz/ntyQFinJphOO7qsaUk4tCQhQBX0=; b=AZDRAmVIKqpCeni0Z3J7CQXu8HAzscyaJy+OVLjGWO8sjPTsTnirHxnU ivhGUCgnJx3ZlkgsqxaAjno3SaiX8Ar/yNsMatad+Hpsx901A5pjl9l4l cOcaM29UR1ZObS3LfbOX6/RwwXuGjbRT2Fw++InWO8Z5cttQoLSVdN+96 SJkketjcnTTCseH/F7qulT06AGAQMpISKPb6ojcWuZVaUCPWmEyCKTpzj hWGrWE7aip8uYOCOnQT3xMevpiEKqpIDa6MMMhsE2UFOKcGodPuF6ehr2 U9QbkzosORy0qN/xMM5y5toGox6UoVZa/SLeXXzUZNoGZtyVdiZR5fjpQ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="358279705" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="358279705" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="707819498" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="707819498" Received: from rspatil-mobl3.gar.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.208.112]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:36 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [RFC PATCH v1 07/13] mt76: Remove unreliable pci_disable_link_state() workaround Date: Fri, 2 Jun 2023 14:47:44 +0300 Message-Id: <20230602114751.19671-8-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> References: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767591541654797190?= X-GMAIL-MSGID: =?utf-8?q?1767591541654797190?= pci_disable_link_state() was made reliable regardless of ASPM CONFIG and OS being disallowed to change ASPM states to allow drivers to rely on pci_disable_link_state() working. Remove driver working around unreliable pci_disable_link_state() from mt76 driver and just call pci_disable_link_state() directly. Signed-off-by: Ilpo Järvinen --- It's a bit unclear which of these devices really need ASPM disabled. Probably all 76xx given the commit messages that added their disabling but 79xx seems a lot more uncertain and handwavy. mt7915 was done without observing any issue in commit 03b3dedc5de1 ("mt76: mt7915: disable ASPM"). mt7921 re-enabled aspm in bf3747ae2e25 ("mt76: mt7921: enable aspm by default"). mt7996 was added with aspm disabled. I didn't convert these to quirk due to how unclear the situation currently is (but for 76xx quirk would seem justified as there is actually some evidence to back aspm being harmful). --- drivers/net/wireless/mediatek/mt76/Makefile | 1 - drivers/net/wireless/mediatek/mt76/mt76.h | 1 - .../net/wireless/mediatek/mt76/mt7615/pci.c | 2 +- .../net/wireless/mediatek/mt76/mt76x0/pci.c | 2 +- .../net/wireless/mediatek/mt76/mt76x2/pci.c | 2 +- .../net/wireless/mediatek/mt76/mt7915/pci.c | 2 +- .../net/wireless/mediatek/mt76/mt7921/pci.c | 2 +- .../net/wireless/mediatek/mt76/mt7996/pci.c | 2 +- drivers/net/wireless/mediatek/mt76/pci.c | 47 ------------------- 9 files changed, 6 insertions(+), 55 deletions(-) delete mode 100644 drivers/net/wireless/mediatek/mt76/pci.c diff --git a/drivers/net/wireless/mediatek/mt76/Makefile b/drivers/net/wireless/mediatek/mt76/Makefile index 84c99b7e57f9..220e711840d3 100644 --- a/drivers/net/wireless/mediatek/mt76/Makefile +++ b/drivers/net/wireless/mediatek/mt76/Makefile @@ -10,7 +10,6 @@ mt76-y := \ mmio.o util.o trace.o dma.o mac80211.o debugfs.o eeprom.o \ tx.o agg-rx.o mcu.o -mt76-$(CONFIG_PCI) += pci.o mt76-$(CONFIG_NL80211_TESTMODE) += testmode.o mt76-usb-y := usb.o usb_trace.o diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 6b07b8fafec2..9beee339782e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -933,7 +933,6 @@ bool ____mt76_poll_msec(struct mt76_dev *dev, u32 offset, u32 mask, u32 val, #define mt76_poll_msec_tick(dev, ...) ____mt76_poll_msec(&((dev)->mt76), __VA_ARGS__) void mt76_mmio_init(struct mt76_dev *dev, void __iomem *regs); -void mt76_pci_disable_aspm(struct pci_dev *pdev); static inline u16 mt76_chip(struct mt76_dev *dev) { diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/pci.c b/drivers/net/wireless/mediatek/mt76/mt7615/pci.c index 9f43e673518b..d43efe4bf9e3 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/pci.c @@ -43,7 +43,7 @@ static int mt7615_pci_probe(struct pci_dev *pdev, if (ret) goto error; - mt76_pci_disable_aspm(pdev); + pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); map = id->device == 0x7663 ? mt7663e_reg_map : mt7615e_reg_map; ret = mt7615_mmio_probe(&pdev->dev, pcim_iomap_table(pdev)[0], diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c index 9277ff38b7a2..49c7a63cb1f6 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c @@ -181,7 +181,7 @@ mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (ret) return ret; - mt76_pci_disable_aspm(pdev); + pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), &mt76x0e_ops, &drv_ops); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c index df85ebc6e1df..de6eb593ab59 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c @@ -85,7 +85,7 @@ mt76x2e_probe(struct pci_dev *pdev, const struct pci_device_id *id) /* RG_SSUSB_CDR_BR_PE1D = 0x3 */ mt76_rmw_field(dev, 0x15c58, 0x3 << 6, 0x3); - mt76_pci_disable_aspm(pdev); + pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); return 0; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/pci.c b/drivers/net/wireless/mediatek/mt76/mt7915/pci.c index 39132894e8ea..8cf9a1a6d851 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/pci.c @@ -122,7 +122,7 @@ static int mt7915_pci_probe(struct pci_dev *pdev, if (ret) return ret; - mt76_pci_disable_aspm(pdev); + pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); if (id->device == 0x7916 || id->device == 0x790a) return mt7915_pci_hif2_probe(pdev); diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c index ddb1fa4ee01d..c9862e808cbb 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c @@ -286,7 +286,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev, goto err_free_pci_vec; if (mt7921_disable_aspm) - mt76_pci_disable_aspm(pdev); + pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); ops = mt7921_get_mac80211_ops(&pdev->dev, (void *)id->driver_data, &features); diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/pci.c b/drivers/net/wireless/mediatek/mt76/mt7996/pci.c index 64aee3fb5445..273b72c58878 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/pci.c @@ -111,7 +111,7 @@ static int mt7996_pci_probe(struct pci_dev *pdev, if (ret) return ret; - mt76_pci_disable_aspm(pdev); + pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); if (id->device == 0x7991) return mt7996_pci_hif2_probe(pdev); diff --git a/drivers/net/wireless/mediatek/mt76/pci.c b/drivers/net/wireless/mediatek/mt76/pci.c deleted file mode 100644 index 4c1c159fbb62..000000000000 --- a/drivers/net/wireless/mediatek/mt76/pci.c +++ /dev/null @@ -1,47 +0,0 @@ -// SPDX-License-Identifier: ISC -/* - * Copyright (C) 2019 Lorenzo Bianconi - */ - -#include "mt76.h" -#include - -void mt76_pci_disable_aspm(struct pci_dev *pdev) -{ - struct pci_dev *parent = pdev->bus->self; - u16 aspm_conf, parent_aspm_conf = 0; - - pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &aspm_conf); - aspm_conf &= PCI_EXP_LNKCTL_ASPMC; - if (parent) { - pcie_capability_read_word(parent, PCI_EXP_LNKCTL, - &parent_aspm_conf); - parent_aspm_conf &= PCI_EXP_LNKCTL_ASPMC; - } - - if (!aspm_conf && (!parent || !parent_aspm_conf)) { - /* aspm already disabled */ - return; - } - - dev_info(&pdev->dev, "disabling ASPM %s %s\n", - (aspm_conf & PCI_EXP_LNKCTL_ASPM_L0S) ? "L0s" : "", - (aspm_conf & PCI_EXP_LNKCTL_ASPM_L1) ? "L1" : ""); - - if (IS_ENABLED(CONFIG_PCIEASPM)) { - int err; - - err = pci_disable_link_state(pdev, aspm_conf); - if (!err) - return; - } - - /* both device and parent should have the same ASPM setting. - * disable ASPM in downstream component first and then upstream. - */ - pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL, aspm_conf); - if (parent) - pcie_capability_clear_word(parent, PCI_EXP_LNKCTL, - aspm_conf); -} -EXPORT_SYMBOL_GPL(mt76_pci_disable_aspm); From patchwork Fri Jun 2 11:47:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 102521 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp979007vqr; Fri, 2 Jun 2023 05:10:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ464LeYzm0xaPL5hdoWfiJO1BYAAb5JAcKmWrGuFH+AajhvZOVJJcoCfhIEstnP6vPWiykk X-Received: by 2002:a17:902:e801:b0:1a5:22a:165c with SMTP id u1-20020a170902e80100b001a5022a165cmr1698062plg.0.1685707849615; Fri, 02 Jun 2023 05:10:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685707849; cv=none; d=google.com; s=arc-20160816; b=SgbuYwWUD5BpgvcLonAiZxAz9NCP140yO+5sKeWy7o8Q9fS9TZGdiOz5FgZIXUHsku /czSIaYulgEU81mF3yquJacOvjJQdcQciYVZNCnNmyefCa3ovym+hE0DfqI4bVPkVOq+ bw6gfladZv5bIVOiAb0idq8DrRKX31MjFYrEXruSAR/DZezNTWPSRtYiY6An+AtYFoo1 KL4tA4ElUt6PqYnmzb5wYfUiclF3iv5JsRZ+ATH92c+SNRpQ/3RHanZCgEHAgRpcUnz2 rjCLExwWJ9ENCkTi/VekwvMwzR37rPKqDLcALHDEafIpkPYQ+ME4ZokQpreoLVKKxkOI W1xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4j8KViiPpieJIwzx/HkMOnLfHIY+6oaSvv/q7uA8YAk=; b=AyRuKzoUmY2etOr2IFmZJzTWHGAh8YO1WdPTx8ktgKk4AyEQcYmHEVvzF8gdaR429r gIvGwRdViqs4Par8Xyc897btRDeB80E+EOgI89ZnMNV9tTJLvn0wZU+Wmqd4JHlzKlss 8RnN5aT/yK+PAr1y6EgGdliSLMFTqWsFZjRZqymnkBDJwOpjJlj64Bp488efuGXwWU/b +tL1SITXyjtqOSWRbGZBHbyDO3PgtvHfeUN+UPnD3ljG59ZxslEUgCdCECK2oHIUnskQ /tU2mU/v/rgaA+IkFGjE45hxMmWGKNYii0sccc6/gyC2ostHODDV52fyEVy0V6mjdCUw di0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nVjj+tS4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b17-20020a170902d51100b001ae4a01a7e0si859586plg.236.2023.06.02.05.10.36; Fri, 02 Jun 2023 05:10:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nVjj+tS4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235615AbjFBLuU (ORCPT + 99 others); Fri, 2 Jun 2023 07:50:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235589AbjFBLty (ORCPT ); Fri, 2 Jun 2023 07:49:54 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C46EE63; Fri, 2 Jun 2023 04:49:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685706566; x=1717242566; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jGXAxasqLUJNCCsewqKuozH1mOZUvPCSOeFXiURbrcI=; b=nVjj+tS4Mx7xe20SIiFMGmTsVujt3v+aQDoe/N3sAoHZSPPWDu2HHWFO BbZpDf49xgCg6G51JyizgJ+Jt3xNziAf5Hjd+6//LL5TPE+DNzqmm3c0f WzdilcyIag8fxY25rbiN7wkEieh4AMw4SqBZO9aXKZgPhGbCfBM7vAZdF kmfZPH4X73EUAyIxMbMjW6+toMAvWaCUOb2p6bYqWOxL1YCF8XmUyDu/C cFXhOT+RbQv5VXyFgvtOB4UQSkDzMQyIVnJ3W9Yr23WH+neNFWq0ynhcn T9Bmcy7Z1vCrGldhX+OeoBBGSlpQ1j/x4LXDQ02T4EwClwYxK9ZEGKOBn w==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="358279726" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="358279726" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="707819513" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="707819513" Received: from rspatil-mobl3.gar.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.208.112]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:44 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [RFC PATCH v1 08/13] e1000e: Remove unreliable pci_disable_link_state{,_locked}() workaround Date: Fri, 2 Jun 2023 14:47:45 +0300 Message-Id: <20230602114751.19671-9-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> References: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767592793733552933?= X-GMAIL-MSGID: =?utf-8?q?1767592793733552933?= pci_disable_link_state() and pci_disable_link_state_locked() were made reliable regardless of ASPM CONFIG and OS being disallowed to change ASPM states to allow drivers to rely on them working. Remove driver working around unreliable pci_disable_link_state{,_locked}() from e1000e driver and just call the functions directly. Signed-off-by: Ilpo Järvinen --- drivers/net/ethernet/intel/e1000e/netdev.c | 77 +--------------------- 1 file changed, 2 insertions(+), 75 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index bd7ef59b1f2e..d680d059a681 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -6763,79 +6763,6 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime) return 0; } -/** - * __e1000e_disable_aspm - Disable ASPM states - * @pdev: pointer to PCI device struct - * @state: bit-mask of ASPM states to disable - * @locked: indication if this context holds pci_bus_sem locked. - * - * Some devices *must* have certain ASPM states disabled per hardware errata. - **/ -static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state, int locked) -{ - struct pci_dev *parent = pdev->bus->self; - u16 aspm_dis_mask = 0; - u16 pdev_aspmc, parent_aspmc; - - switch (state) { - case PCIE_LINK_STATE_L0S: - case PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1: - aspm_dis_mask |= PCI_EXP_LNKCTL_ASPM_L0S; - fallthrough; /* can't have L1 without L0s */ - case PCIE_LINK_STATE_L1: - aspm_dis_mask |= PCI_EXP_LNKCTL_ASPM_L1; - break; - default: - return; - } - - pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &pdev_aspmc); - pdev_aspmc &= PCI_EXP_LNKCTL_ASPMC; - - if (parent) { - pcie_capability_read_word(parent, PCI_EXP_LNKCTL, - &parent_aspmc); - parent_aspmc &= PCI_EXP_LNKCTL_ASPMC; - } - - /* Nothing to do if the ASPM states to be disabled already are */ - if (!(pdev_aspmc & aspm_dis_mask) && - (!parent || !(parent_aspmc & aspm_dis_mask))) - return; - - dev_info(&pdev->dev, "Disabling ASPM %s %s\n", - (aspm_dis_mask & pdev_aspmc & PCI_EXP_LNKCTL_ASPM_L0S) ? - "L0s" : "", - (aspm_dis_mask & pdev_aspmc & PCI_EXP_LNKCTL_ASPM_L1) ? - "L1" : ""); - -#ifdef CONFIG_PCIEASPM - if (locked) - pci_disable_link_state_locked(pdev, state); - else - pci_disable_link_state(pdev, state); - - /* Double-check ASPM control. If not disabled by the above, the - * BIOS is preventing that from happening (or CONFIG_PCIEASPM is - * not enabled); override by writing PCI config space directly. - */ - pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &pdev_aspmc); - pdev_aspmc &= PCI_EXP_LNKCTL_ASPMC; - - if (!(aspm_dis_mask & pdev_aspmc)) - return; -#endif - - /* Both device and parent should have the same ASPM setting. - * Disable ASPM in downstream component first and then upstream. - */ - pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL, aspm_dis_mask); - - if (parent) - pcie_capability_clear_word(parent, PCI_EXP_LNKCTL, - aspm_dis_mask); -} - /** * e1000e_disable_aspm - Disable ASPM states. * @pdev: pointer to PCI device struct @@ -6846,7 +6773,7 @@ static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state, int locked) **/ static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state) { - __e1000e_disable_aspm(pdev, state, 0); + pci_disable_link_state(pdev, state); } /** @@ -6859,7 +6786,7 @@ static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state) **/ static void e1000e_disable_aspm_locked(struct pci_dev *pdev, u16 state) { - __e1000e_disable_aspm(pdev, state, 1); + pci_disable_link_state_locked(pdev, state); } static int e1000e_pm_thaw(struct device *dev) From patchwork Fri Jun 2 11:47:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 102522 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp979613vqr; Fri, 2 Jun 2023 05:11:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4O4vi0gU2plJTHxQTnAA+A5ttxqR+KK7FHyp8k56RpAGDs34SDzL/RgOUZ8j7xrjmqotZC X-Received: by 2002:a05:6a21:339a:b0:110:d78f:813e with SMTP id yy26-20020a056a21339a00b00110d78f813emr14337274pzb.40.1685707905592; Fri, 02 Jun 2023 05:11:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685707905; cv=none; d=google.com; s=arc-20160816; b=yzh9WXfGvPsKhTNbqI62BFEXcXTD6vFHa4LXVjfu67ivShCRB5jUzyqeH5AbBYuK6V rnZDXYQ+mkMRK26k/Gafg9dNrf/RgTtKhcoP+PqE8CiKIWNx5yiOZwDLQdjEMpEhv2CX AxuCEvbXx9K5JmDO1G0aopTkAgcSv5G/ayMUmOFjd/UPI32S2lPsMfnOvW9yb+U4I3Mj whJ2U6d01xBHyowswvYDKKpy8pFSWYh1ziK5ko47TmbedV770bGtAIBMcL0JqpjfaALH S53gzbFBjwvTJM4SewsmV6m5+jDQGv6mmuSVNp8bErm2vUh3m5WU65t4yX1rUgYy+J+M KaZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dvtHwfXvMjPMP6MJHc6TiHmBZlW0u+078U93FRiYX1g=; b=FA1MicTG9WT4FuM2q7p7c6An8TkJpbN9Rn19pJptorjClXEvLnpaHgow/efYhq2Ex0 z69BggCEkKNOzI2u1CbdybVppFLn45UY5hPnM9viWP88Ba2zygJuK2KFHX7NP3/kVIEV Jl6p2Prx8jo40BQeCabkg/Tki5gdznkRW1wNPhxrq9AS5VhMiLXGhQbYSKA8djcRndT7 20JeVNxBvt8gjuwDkL1si8CMWUmWHHcousmgpNiHbThXIHlGcPd+n1gdcdWVN8l43QYA 2l8TEXJIuXCQEVOJh99p1pVDy4lJrjMLeVWVEL7nTXN/96oY/2JtwHnrlJYyON4bA3nm Pwrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jGcB3oSy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e13-20020a63500d000000b0053fc4ada0d5si875216pgb.836.2023.06.02.05.11.31; Fri, 02 Jun 2023 05:11:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jGcB3oSy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235581AbjFBLuO (ORCPT + 99 others); Fri, 2 Jun 2023 07:50:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235384AbjFBLt5 (ORCPT ); Fri, 2 Jun 2023 07:49:57 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 992E8E6E; Fri, 2 Jun 2023 04:49:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685706571; x=1717242571; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dBosWhrvI2xKSJwVt6rV8Xi3asJ1Qc/KI8E1WYfbsR4=; b=jGcB3oSyvAQmAwkbr4botjuRC6Ib2ZCthKaLRwY91YeuEEFtMxehjFnF bAfvpS+V1fdvkj5BRgx3wp8Wm1oNJ4OfyZVq/iPT/w0A3hyzHy5MuSThY j190nw4HdPTdCrYRU+FSq2TQtHuGk2Gf1BF23is74jaoNc++lg7viouQy 1zxF+7XMfyPdflm4PI3WYH8zwW7u/gCmTg2kd2Ml78xwEHHDeehV9EI+8 G0sZ1DnXLj0kg00IZVjNZgon4qyoCVvoxn665UkDOK9BfYaCR4A9ajp2J KEaYrHb0dwBmc826VXrWAMpbvlt5wu145JfpIgasYW5nwKr4RLRrGI8Sp Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="358279741" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="358279741" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="707819519" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="707819519" Received: from rspatil-mobl3.gar.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.208.112]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:51 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [RFC PATCH v1 09/13] wifi: ath10k: Use pci_disable/enable_link_state() Date: Fri, 2 Jun 2023 14:47:46 +0300 Message-Id: <20230602114751.19671-10-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> References: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767592852849721805?= X-GMAIL-MSGID: =?utf-8?q?1767592852849721805?= ath10k driver adjusts ASPM state itself which leaves ASPM service driver in PCI core unaware of the link state changes the driver implemented. Call pci_disable_link_state() and pci_enable_link_state() instead of adjusting ASPMC field in LNKCTL directly in the driver and let PCI core handle the ASPM state management. Signed-off-by: Ilpo Järvinen --- drivers/net/wireless/ath/ath10k/pci.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index 9275a672f90c..ec2b17e73b0e 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -1963,9 +1963,8 @@ static int ath10k_pci_hif_start(struct ath10k *ar) ath10k_pci_irq_enable(ar); ath10k_pci_rx_post(ar); - pcie_capability_clear_and_set_word(ar_pci->pdev, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC, - ar_pci->link_ctl & PCI_EXP_LNKCTL_ASPMC); + pci_enable_link_state(ar_pci->pdev, ar_pci->link_ctl & + (PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1)); return 0; } @@ -2822,8 +2821,7 @@ static int ath10k_pci_hif_power_up(struct ath10k *ar, pcie_capability_read_word(ar_pci->pdev, PCI_EXP_LNKCTL, &ar_pci->link_ctl); - pcie_capability_clear_word(ar_pci->pdev, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC); + pci_disable_link_state(ar_pci->pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); /* * Bring the target up cleanly. From patchwork Fri Jun 2 11:47:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 102515 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp969741vqr; Fri, 2 Jun 2023 04:57:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4i19OjR1YdO8PumwasaS1Dh0DKNMGKucNTFpCz4G5xVbEwSLs6nwEXzinLRCPknW7PcB0K X-Received: by 2002:a17:90a:bb81:b0:253:86ed:9b0e with SMTP id v1-20020a17090abb8100b0025386ed9b0emr1882214pjr.42.1685707073339; Fri, 02 Jun 2023 04:57:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685707073; cv=none; d=google.com; s=arc-20160816; b=iscrlv4lOsXEn00XG6Q1TU2lO1ylLLiOR3hLBZrr7FCObCaDlwLboK+nQ60JMWp2Ii Gc3zc/c+A9Wkzrjh70980sJ8MC/aw+EJvINJ7VzpZ4PIo10sQ9m2UxIP5FAMArRLbDoe m8p6row5k5nPSJJbvkGHz/x+28BLu0qKeecugb5RBAeFCWns+MQD6+MEqsQq+x7o/oam NpMGSmwOsmLEB8gpMGA5hHa4B2fKcvzmSIkPtMDjQDoResjjBZUVKLVTl8l823i1jtg+ LYzZFzdbUjZ8/SOWQYVMe5uYxgAcT5vUzTkOhn3zOlOLU3NCt8f6bFBrhicdSDQ8Duuu WyiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZR6u8Bab7VSmLp1IHD9IcQWKVgkb4mctcEQ5fCgDOLc=; b=Lyoq04edH/kMI6wp+8O75EolMknNzfHpqro04tm79FgyIUhO1N2kDHdRkYRszOS7Pn MAWtmYqPzwfZ4FvRla0m7QQqdDCpOzKix8oHvvptssqEizlRl0hPYtaFf16e8F+gOQYS wipAnCjgZieWPh/zwgP+nWPV8keIKeBhgMx2m8Cn0CMgKpa3equ6hCWiYmrVurXKWE03 eLrGnpwiKYQXx9S0g2xfXQPkXcXfgVcwBn6IUZruaYbVtVopxOXpzQFmIRH7GJecywPj u6pBvXC1WAkLpwZ8GoEj99YTdy+aZKqHjxJeEekTOgmUR1vu1pf9OxYJ5mFlPsB6DGbs jMOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CWjNt+1x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 15-20020a17090a190f00b00252ad7ab4a5si2754646pjg.5.2023.06.02.04.57.41; Fri, 02 Jun 2023 04:57:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CWjNt+1x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235551AbjFBLub (ORCPT + 99 others); Fri, 2 Jun 2023 07:50:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235542AbjFBLuJ (ORCPT ); Fri, 2 Jun 2023 07:50:09 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 653CB10DB; Fri, 2 Jun 2023 04:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685706584; x=1717242584; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=56pRsAda1UvobTeyQtWYC5Q58IjfGAVi8hUctvKnaUY=; b=CWjNt+1xptJdZAsjp4Ws4nBXWrPdN8N+UHyxzTr6KmLPHyFRdo9O6/DR 5R0FQpOO1MgiCe+mlF7TZ9Qs229/cMQ+J1XrkaLZIc2VU/h3feWIxTzJh tgUuLhU/n3bEM6rUwzkEyIb8WUGyd9A6Ch6kNZm+4eY1efdxRhQ5O0BIk VbCJfXshWLApQXPoYnE9JOn5MJWxSsH3Tf7wTJ48tulLtL7+iwbfGAgcz zjAVWqhp1Q3/MVmMWy1uc3Bg3/EcGESCztuHZYgZ9YjFl84iju6wQ2eay fzTicixa4XRlkBqknSfYJqH5KJGzExJ5TfH3tciKZ0Cuq4IH3MxUYfw54 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="358279760" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="358279760" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:49:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="707819534" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="707819534" Received: from rspatil-mobl3.gar.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.208.112]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:57 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [RFC PATCH v1 10/13] wifi: ath11k: Use pci_disable/enable_link_state() Date: Fri, 2 Jun 2023 14:47:47 +0300 Message-Id: <20230602114751.19671-11-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> References: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767591979917951669?= X-GMAIL-MSGID: =?utf-8?q?1767591979917951669?= ath11k driver adjusts ASPM state itself which leaves ASPM service driver in PCI core unaware of the link state changes the driver implemented. Call pci_disable_link_state() and pci_enable_link_state() instead of adjusting ASPMC field in LNKCTL directly in the driver and let PCI core handle the ASPM state management. Signed-off-by: Ilpo Järvinen --- drivers/net/wireless/ath/ath11k/pci.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/pci.c b/drivers/net/wireless/ath/ath11k/pci.c index 6ba4cef6b1c7..a9eac51658f6 100644 --- a/drivers/net/wireless/ath/ath11k/pci.c +++ b/drivers/net/wireless/ath/ath11k/pci.c @@ -581,19 +581,15 @@ static void ath11k_pci_aspm_disable(struct ath11k_pci *ab_pci) u16_get_bits(ab_pci->link_ctl, PCI_EXP_LNKCTL_ASPM_L1)); /* disable L0s and L1 */ - pcie_capability_clear_word(ab_pci->pdev, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC); - + pci_disable_link_state(ab_pci->pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); set_bit(ATH11K_PCI_ASPM_RESTORE, &ab_pci->flags); } static void ath11k_pci_aspm_restore(struct ath11k_pci *ab_pci) { if (test_and_clear_bit(ATH11K_PCI_ASPM_RESTORE, &ab_pci->flags)) - pcie_capability_clear_and_set_word(ab_pci->pdev, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC, - ab_pci->link_ctl & - PCI_EXP_LNKCTL_ASPMC); + pci_enable_link_state(ab_pci->pdev, ab_pci->link_ctl & + (PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1)); } static int ath11k_pci_power_up(struct ath11k_base *ab) From patchwork Fri Jun 2 11:47:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 102507 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp966954vqr; Fri, 2 Jun 2023 04:52:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Yv06Qp1Hyph7/19hUQpvIXd7CyzYoYt4b/FcAIcyD3eV6As9PPC3gQ9wu6I8V4KXRO2Oc X-Received: by 2002:a17:902:c64a:b0:1b1:bcea:c8f7 with SMTP id s10-20020a170902c64a00b001b1bceac8f7mr1665178pls.15.1685706742762; Fri, 02 Jun 2023 04:52:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685706742; cv=none; d=google.com; s=arc-20160816; b=AC4kaN/EjpxhhBh1aMl4fTTEgcAAq8xQ372pp0ob2CaTgT9e+2Bwg2FEpaHhFaGYVj 4peyCVSK0oyj7ahemYIbYfSIPSrw59kKG7zEQ8Yqb9XRJErx07ROofahL+B39oHh+9yp XMe+lVfeqtw/N/u1SYkKdL8fEK3Yl560D3OgtZ2TVEyO2AzB3puh6NQRMhK+XfYxymcs J2izCTOvstdLwvxpdrotDGBE8RhIXOpXKYr/0V1V5K9RTT/IAtAdJ7Ulg52wwVGAAy4G Mq/eDr3LyoCAmy+GsUBkXn+rz47rhyYKcaQ7zt3RaWNu9T4gtzh7zks17pQ8UPdhEuDn Rx6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=j0hvaURfip7U9Ahc8hs1FgnLAh2+bXf31w/EXmJCEFc=; b=WdEm5jCql0f05Ajq+IxTNyBlMB/n/8cZgVVdgNOds5+Y4NzKFFUvC0n0EkWV2gRW+2 ESfrQbp0/qDRrmnxMtdUeP+MZtvl1r6eNrrbI5fnUcxYHlzhB7ZLViB5E5wtlYw1vWqF UHvfqncgkH1IiNeczNKksewgf1Ur26Qnh9GmevCi/LXTHLln64dGojxtDETArUA5cymx +nNhvQoEEQC+DEsHJSTL/JZlX7Ost4Qeu9liii43sEn6rkYCEFXuzMupdU4tx5X2xzvp w6M0fk5tm/yQvbOXnAqSkvIxxg1Nebod42WR+lXsEtfvQAqewdDvNbhZSEJtIhy3o2xt FOBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YCcF9ckG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020a170902834900b0019ccffb3fd3si752099pln.509.2023.06.02.04.52.09; Fri, 02 Jun 2023 04:52:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YCcF9ckG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235510AbjFBLuk (ORCPT + 99 others); Fri, 2 Jun 2023 07:50:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235452AbjFBLu0 (ORCPT ); Fri, 2 Jun 2023 07:50:26 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5946D1B1; Fri, 2 Jun 2023 04:49:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685706594; x=1717242594; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aQjPDwWRzWzs+gV1YQG6XJoskPW79jaEO1/n4+Mecro=; b=YCcF9ckGCFmme+E/oo6pqRPjpNNHOJiZISecjFrgI3kFtY7Yypjxn0Dq 6FhGKxfceWnJNxisWjY8wD8rZ0q5p23Kl1xpBeZK4yGhoRnUaWIxZMwuv xl3pKxlOKI3tkXYf36C8EAp6Q0D/Lt925BHM9uKAynlxOwqfOtlgG1J7G g9YoMhSVgwpt96hXpmdly/0bLEjeQ4qAYvjPIqN4GVkllc3Js7lrvrlR9 2Wat1bewPaLp12jMSMEo7SUzytMCO0UXssltWbg7KCyNUF/N5KobHuHvw Cc1XfjXWt0+F35on64HNnpnPZRRW6Il4OKwDBVseUbdCWsuJNeN1QihCw w==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="358279775" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="358279775" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:49:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="707819546" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="707819546" Received: from rspatil-mobl3.gar.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.208.112]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:49:03 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , ath12k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [RFC PATCH v1 11/13] wifi: ath12k: Use pci_disable/enable_link_state() Date: Fri, 2 Jun 2023 14:47:48 +0300 Message-Id: <20230602114751.19671-12-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> References: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767591633471805692?= X-GMAIL-MSGID: =?utf-8?q?1767591633471805692?= ath12k driver adjusts ASPM state itself which leaves ASPM service driver in PCI core unaware of the link state changes the driver implemented. Call pci_disable_link_state() and pci_enable_link_state() instead of adjusting ASPMC field in LNKCTL directly in the driver and let PCI core handle the ASPM state management. Signed-off-by: Ilpo Järvinen --- drivers/net/wireless/ath/ath12k/pci.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/pci.c b/drivers/net/wireless/ath/ath12k/pci.c index e1e45eb50f3e..c072026d6699 100644 --- a/drivers/net/wireless/ath/ath12k/pci.c +++ b/drivers/net/wireless/ath/ath12k/pci.c @@ -794,19 +794,15 @@ static void ath12k_pci_aspm_disable(struct ath12k_pci *ab_pci) u16_get_bits(ab_pci->link_ctl, PCI_EXP_LNKCTL_ASPM_L1)); /* disable L0s and L1 */ - pcie_capability_clear_word(ab_pci->pdev, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC); - + pci_disable_link_state(ab_pci->pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); set_bit(ATH12K_PCI_ASPM_RESTORE, &ab_pci->flags); } static void ath12k_pci_aspm_restore(struct ath12k_pci *ab_pci) { if (test_and_clear_bit(ATH12K_PCI_ASPM_RESTORE, &ab_pci->flags)) - pcie_capability_clear_and_set_word(ab_pci->pdev, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC, - ab_pci->link_ctl & - PCI_EXP_LNKCTL_ASPMC); + pci_enable_link_state(ab_pci->pdev, ab_pci->link_ctl & + (PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1)); } static void ath12k_pci_kill_tasklets(struct ath12k_base *ab) From patchwork Fri Jun 2 11:47:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 102511 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp968757vqr; Fri, 2 Jun 2023 04:56:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5YJmEWWay/YjjI/qtICqqZrNmnTJv339SIAeXlUGfqI4STYVk4t1b/eyB7Ns4grMr/Hw4K X-Received: by 2002:a17:90a:5e48:b0:258:71e6:1c24 with SMTP id u8-20020a17090a5e4800b0025871e61c24mr1347824pji.12.1685706960956; Fri, 02 Jun 2023 04:56:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685706960; cv=none; d=google.com; s=arc-20160816; b=el6cB4ocXSEUQnFx/fokeIUEZJPe6QFVKEOLg5xraOoTV98EiZ+nAhnXX6qsHiFzWZ L1XOq1wCITGN7PNR/rG2Tp7YJrKbAJPjPHTXKM/A89Clh60c075lBxhPSc5yP5nKmVlQ XZ8759rulaH4I5kVN+BIdIGWAzv03g1KQAZm5tqgo6ODLNBv6W51O7F6EBTYYNr0RWtz fvOWMP7NWe2PmZTiJSJjR6b/QtWzUGLDyDW4Cg/xAT03TIKP+AmE0X4y974FJOBc6+tZ jWoaUG5SR5eUxePBsOCKPwhKs41bUiI6O3bFhCMI7O+O2u4IAm3wBfFd+dXzpdugVdWw 7hfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=j4jQSPx2IDLwxhYbemT2YA0+h/PhVlHGWApivRlHVNw=; b=GOGtKdevJfFcdfJtUE3f/DPat6FcBAA73B0pymHnavOjlKZXlxCuaAz/rkFoG+8HSK 74yiXjMDK8zaNXo6frbj8qQRNTcP5BxDCR2hT+77RzWoX4TnimqoHaFG/+iZyLOLaBsO KnjFY24T4m1dGkUd8ox8DeTnyjwIcFdGy14VWTb+sBVKFu7nCfgHz9Sn3miy899x7KKR q0AF8edfQZXi0p8FOzNYVz+rdlUYknQvUgqlTYw4LdiYKZONM+HeMH9Y8VuWcBjss/R+ vaxP6j/WnaiNjKN+x6MgRMEdDzSUQidAOfas8ZP4QeZhd3xL2vJwRbPa2YsJqK8Y+9gz MSxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dhOY6WwD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b13-20020a17090aa58d00b002470ea7f67fsi2710573pjq.3.2023.06.02.04.55.48; Fri, 02 Jun 2023 04:56:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dhOY6WwD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235515AbjFBLuq (ORCPT + 99 others); Fri, 2 Jun 2023 07:50:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235498AbjFBLu1 (ORCPT ); Fri, 2 Jun 2023 07:50:27 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A46AE5E; Fri, 2 Jun 2023 04:49:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685706597; x=1717242597; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dtcnuM+2TdnbsCijUckC327W0mtKyRtASd4omSZHYjg=; b=dhOY6WwD9tFuCuNpuke6q6ieXvkiWB1ka421N2iGJyH3t11c/dO3Ave3 uyUjL8e54Ujg+zQDU3jo1J4Q+IfkMn0axTp/MwrpP4+M8IZL24fARlFCm xNY0pBSFachRkmOSfzExXpZdwCroT+BmNhYuymJziAOrtOLLVj+72wJG5 HWVL5IALGh1McnNLAPzt7W27CmP2lyTl2xSdTc/en9YIAFh08RJdKEi6z /JCRZV7LK92B/atT0xoeTI6QCjcWb4pFsRl6xub+Tkfwel/h8lOq7vW6H ye6Es4NDwLnKTFqBxSP1Bo3V0sYYtYNWL2sWcwP0m6I2QiNMj40e/jRI5 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="358279796" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="358279796" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:49:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="707819552" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="707819552" Received: from rspatil-mobl3.gar.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.208.112]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:49:11 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , Dennis Dalessandro , Jason Gunthorpe , Leon Romanovsky , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [RFC PATCH v1 12/13] IB/hfi1: Use pci_disable/enable_link_state() Date: Fri, 2 Jun 2023 14:47:49 +0300 Message-Id: <20230602114751.19671-13-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> References: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767591862620424973?= X-GMAIL-MSGID: =?utf-8?q?1767591862620424973?= IB/hfi1 driver adjusts ASPM state itself which leaves ASPM service driver in PCI core unaware of the link state changes the driver implemented. Call pci_disable_link_state() and pci_enable_link_state() instead of adjusting ASPMC field in LNKCTL directly in the driver and let PCI core handle the ASPM state management. Remove the functions that handled the ASPM changes that are now unnecessary. Signed-off-by: Ilpo Järvinen Reviewed-by: Dean Luick --- drivers/infiniband/hw/hfi1/aspm.c | 38 +++---------------------------- drivers/infiniband/hw/hfi1/pcie.c | 2 +- 2 files changed, 4 insertions(+), 36 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/aspm.c b/drivers/infiniband/hw/hfi1/aspm.c index a3c53be4072c..8e3fc1d4c9c6 100644 --- a/drivers/infiniband/hw/hfi1/aspm.c +++ b/drivers/infiniband/hw/hfi1/aspm.c @@ -54,45 +54,13 @@ static void aspm_hw_set_l1_ent_latency(struct hfi1_devdata *dd) pci_write_config_dword(dd->pcidev, PCIE_CFG_REG_PL3, reg32); } -static void aspm_hw_enable_l1(struct hfi1_devdata *dd) -{ - struct pci_dev *parent = dd->pcidev->bus->self; - - /* - * If the driver does not have access to the upstream component, - * it cannot support ASPM L1 at all. - */ - if (!parent) - return; - - /* Enable ASPM L1 first in upstream component and then downstream */ - pcie_capability_clear_and_set_word(parent, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC, - PCI_EXP_LNKCTL_ASPM_L1); - pcie_capability_clear_and_set_word(dd->pcidev, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC, - PCI_EXP_LNKCTL_ASPM_L1); -} - -void aspm_hw_disable_l1(struct hfi1_devdata *dd) -{ - struct pci_dev *parent = dd->pcidev->bus->self; - - /* Disable ASPM L1 first in downstream component and then upstream */ - pcie_capability_clear_and_set_word(dd->pcidev, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC, 0x0); - if (parent) - pcie_capability_clear_and_set_word(parent, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC, 0x0); -} - static void aspm_enable(struct hfi1_devdata *dd) { if (dd->aspm_enabled || aspm_mode == ASPM_MODE_DISABLED || !dd->aspm_supported) return; - aspm_hw_enable_l1(dd); + pci_enable_link_state(dd->pcidev, PCI_EXP_LNKCTL_ASPM_L1); dd->aspm_enabled = true; } @@ -101,7 +69,7 @@ static void aspm_disable(struct hfi1_devdata *dd) if (!dd->aspm_enabled || aspm_mode == ASPM_MODE_ENABLED) return; - aspm_hw_disable_l1(dd); + pci_disable_link_state(dd->pcidev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); dd->aspm_enabled = false; } @@ -254,7 +222,7 @@ void aspm_init(struct hfi1_devdata *dd) /* Start with ASPM disabled */ aspm_hw_set_l1_ent_latency(dd); dd->aspm_enabled = false; - aspm_hw_disable_l1(dd); + pci_disable_link_state(dd->pcidev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); /* Now turn on ASPM if configured */ aspm_enable_all(dd); diff --git a/drivers/infiniband/hw/hfi1/pcie.c b/drivers/infiniband/hw/hfi1/pcie.c index 08732e1ac966..767f6cb770b6 100644 --- a/drivers/infiniband/hw/hfi1/pcie.c +++ b/drivers/infiniband/hw/hfi1/pcie.c @@ -1182,7 +1182,7 @@ int do_pcie_gen3_transition(struct hfi1_devdata *dd) * will be enabled if required later */ dd_dev_info(dd, "%s: clearing ASPM\n", __func__); - aspm_hw_disable_l1(dd); + pci_disable_link_state(dd->pcidev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); /* * step 5f: clear DirectSpeedChange From patchwork Fri Jun 2 11:47:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 102529 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp982897vqr; Fri, 2 Jun 2023 05:16:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Qkx9VO7cg2KA8mxohUN4Y+14F/Ep3wBs/H9F1Sz+UeBp69y0LnZLdartIeVOuDtGiJFUh X-Received: by 2002:a05:6a21:3983:b0:10b:8a3b:1680 with SMTP id ad3-20020a056a21398300b0010b8a3b1680mr12424891pzc.29.1685708217712; Fri, 02 Jun 2023 05:16:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685708217; cv=none; d=google.com; s=arc-20160816; b=uuFKS7SIuPgVr2QpLkIxbjBJayHNnT+Uoxq2A6lFSWDw3buwORcUKl6zBU33Da1Fa5 3HsUMMHKMRQqWesTUuWXZbgChAgTyb1NAyPCMxGmJQA8EtmeuxjTdk2ulbguaG3OZjVI E2VDgCIHw8zV3M6Rp5kwzUOy3Hjyh+Ul33uQ6z6bzqIV1AYSTOKb3SwzHHFqgYFpyawv ep1vS8zeHFlz7ZeU12tXn9R7Lsj8eP36yoRzlljZxwbeti71lxlFFs5ZuwuN5PU5rxb9 IsdSeaKyNVHjo6v3sttmJE4wQGcO4NgTnYx9+lyMLjfhvF+BkZ0/koLVPH7vwdKrkZTT X+tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RjV+ShvzarKfdotwHsCQYVc2bBMCuqw9AgNNUUP85jY=; b=hZyWBWna/x2aY7/Zn7onhlJfNp9BRaBwXXm5FwGz+aRt5a+7VKZrCIzh+K3RO0/+hs /UTCerrCK3mpZSFxbNbyVTyTPtLzLxrjrx7BC/D8prOztuwyCCAHzwaPjQ2p4LavWeoK 9+St2GjNrxfd+SGwS6am87vvBvmpTEBs2elsW3mhKcr895Ae7zp0eBFHFYAT9vjMV8pn qYnJj00reo3n5k8hzlpt36fNJw0C+iSiET7LFtHMlZUTzNcBfhCkIZHbk+BFpZXNHsu9 tDup9fPMdmniNGNq5amWVuNOvMgENWT+uYhzpdFjXwEx8MaMcsFjYE8In0/BYIZGypmd thzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BYzsTCrH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v135-20020a63618d000000b0053efd7561e1si829037pgb.287.2023.06.02.05.16.43; Fri, 02 Jun 2023 05:16:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BYzsTCrH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235651AbjFBLu7 (ORCPT + 99 others); Fri, 2 Jun 2023 07:50:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235637AbjFBLuj (ORCPT ); Fri, 2 Jun 2023 07:50:39 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4CF310CE; Fri, 2 Jun 2023 04:50:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685706609; x=1717242609; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1epCMyqe0p5e2ZAw49HzHho1aAoWMp3axRI3i6r+rD4=; b=BYzsTCrHWnr/7WA7k8em/tkgw0bq6uhUzMgJSF/FSFjb8ZFUds7E/1Cn z6hn0Y0YcVJD4HPgMTze/yDE5UmK9XvHrukUtR8dWDnnbCL3Mpq8kxv8Q gj0mIXtIPpfutmQJwcU84bElHzf/od45QI6nzd70AT3p6wVzVsCE05Ury G5/jo2bCZFQfXDDgq1PxHNBNDqmgRGMCcbgMPhcDomCcivbPbPauQDJJA 857v65hExapQPErpXpct/Rv0jxhxqO927FTcD9B7BqWlrEcqTzwvT8nDT 1M135Xf556FgmPqRTYgfXsxxUIfE8UosZNWCW7BBS/dGh9sAQwF+jfkTb A==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="358279807" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="358279807" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:49:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="707819560" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="707819560" Received: from rspatil-mobl3.gar.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.208.112]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:49:17 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [RFC PATCH v1 13/13] misc: rtsx: Use pci_disable/enable_link_state() Date: Fri, 2 Jun 2023 14:47:50 +0300 Message-Id: <20230602114751.19671-14-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> References: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767593179956681791?= X-GMAIL-MSGID: =?utf-8?q?1767593179956681791?= rtsx driver adjusts ASPM state itself which leaves ASPM service driver in PCI core unaware of the link state changes the driver implemented. Call pci_disable_link_state() and pci_enable_link_state() instead of adjusting ASPMC field in LNKCTL directly in the driver and let PCI core handle the ASPM state management. Signed-off-by: Ilpo Järvinen --- drivers/misc/cardreader/rts5228.c | 6 ++---- drivers/misc/cardreader/rts5261.c | 6 ++---- drivers/misc/cardreader/rtsx_pcr.c | 8 +++++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/misc/cardreader/rts5228.c b/drivers/misc/cardreader/rts5228.c index cfebad51d1d8..74a2651b5550 100644 --- a/drivers/misc/cardreader/rts5228.c +++ b/drivers/misc/cardreader/rts5228.c @@ -515,8 +515,7 @@ static void rts5228_enable_aspm(struct rtsx_pcr *pcr, bool enable) val = FORCE_ASPM_CTL0 | FORCE_ASPM_CTL1; val |= (pcr->aspm_en & 0x02); rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, mask, val); - pcie_capability_clear_and_set_word(pcr->pci, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC, pcr->aspm_en); + pci_enable_link_state(pcr->pci, pcr->aspm_en); pcr->aspm_enabled = enable; } @@ -527,8 +526,7 @@ static void rts5228_disable_aspm(struct rtsx_pcr *pcr, bool enable) if (pcr->aspm_enabled == enable) return; - pcie_capability_clear_and_set_word(pcr->pci, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC, 0); + pci_disable_link_state(pcr->pci, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); mask = FORCE_ASPM_VAL_MASK | FORCE_ASPM_CTL0 | FORCE_ASPM_CTL1; val = FORCE_ASPM_CTL0 | FORCE_ASPM_CTL1; rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, mask, val); diff --git a/drivers/misc/cardreader/rts5261.c b/drivers/misc/cardreader/rts5261.c index b1e76030cafd..03221db00b86 100644 --- a/drivers/misc/cardreader/rts5261.c +++ b/drivers/misc/cardreader/rts5261.c @@ -596,8 +596,7 @@ static void rts5261_enable_aspm(struct rtsx_pcr *pcr, bool enable) val |= (pcr->aspm_en & 0x02); rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, mask, val); - pcie_capability_clear_and_set_word(pcr->pci, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC, pcr->aspm_en); + pci_enable_link_state(pcr->pci, pcr->aspm_en); pcr->aspm_enabled = enable; } @@ -609,8 +608,7 @@ static void rts5261_disable_aspm(struct rtsx_pcr *pcr, bool enable) if (pcr->aspm_enabled == enable) return; - pcie_capability_clear_and_set_word(pcr->pci, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC, 0); + pci_disable_link_state(pcr->pci, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, mask, val); rtsx_pci_write_register(pcr, SD_CFG1, SD_ASYNC_FIFO_NOT_RST, 0); udelay(10); diff --git a/drivers/misc/cardreader/rtsx_pcr.c b/drivers/misc/cardreader/rtsx_pcr.c index 32b7783e9d4f..3c3edbb9c837 100644 --- a/drivers/misc/cardreader/rtsx_pcr.c +++ b/drivers/misc/cardreader/rtsx_pcr.c @@ -86,9 +86,11 @@ static void rtsx_comm_set_aspm(struct rtsx_pcr *pcr, bool enable) return; if (pcr->aspm_mode == ASPM_MODE_CFG) { - pcie_capability_clear_and_set_word(pcr->pci, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC, - enable ? pcr->aspm_en : 0); + if (enable) + pci_enable_link_state(pcr->pci, pcr->aspm_en); + else + pci_disable_link_state(pcr->pci, PCIE_LINK_STATE_L0S | + PCIE_LINK_STATE_L1); } else if (pcr->aspm_mode == ASPM_MODE_REG) { if (pcr->aspm_en & 0x02) rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, FORCE_ASPM_CTL0 |