From patchwork Mon Sep 18 13:10:51 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: 141700 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3142603vqi; Mon, 18 Sep 2023 22:20:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF2+KgFwF1XSnO++GtxAyphFm4R2QpJKDpTakUb5qIuzLLwHSdEOlI2ojcsOJUxr9aeg1UA X-Received: by 2002:a17:902:e80a:b0:1b3:d4d5:beb2 with SMTP id u10-20020a170902e80a00b001b3d4d5beb2mr13304164plg.9.1695100816191; Mon, 18 Sep 2023 22:20:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695100816; cv=none; d=google.com; s=arc-20160816; b=iKt/B1EgijHVRBqu5q03v2ZFhR2B3UshzuAGqFW3QGLc/htfqByiCa6agA5v6arNqy zohl9uhTmZ3pkdFp/kB1ZsMZvhKlcnrKHh+retYxmzbN7hhwHwnAVVMfhI5XSi+Wq2mB c803hlDaqHbvQwbSITq9EG4ja0S683Lg7Ow04NDYFCqccclvpedJlGzO4e0th/orMVaW 5GLpIXmAmK6sif5sAyql9eNgW1a5VkLfyw9ETvbFBdKNHSMHEXZuJ+58/VtlBBChSWr8 oFNca9CUiqqEdN+2kEhT/CNxYNOwSbVgWSRmZJOiCp7zheZj2NE9cD+p/aXLSpmlHb3y Da/Q== 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=sYXkEBQuP4/oDlPbUhFIQI4g7N/jmvM0L8IIetaJY2I=; fh=/7kP9SYU25TB7qw7q6Es1nezDj4fMY9HgkSCMIyL4IU=; b=zk3wb5DW5lbfH35cGi08TLA1ZT5gDJAEwjVDA39u0tVakLZ3RcbGqjStLmW2jvyYGX HzN1aQxoAI8J5B+6Z73NdGJyQTNLQjzVJcPy9Qpd/bKzk30/JbCMVIzEEJLcvCXmmzHy MwpiWV/68zAOqhxK+h4ePGsoumSA6fAzpx9gjJ50erYrmJd2vO6VSaG7Fexrg5yxU+rI YWmgAMfetjVuC9XQxAqbirHyBQ0W2mU6gF/jAHBjyx9D0xJB5hEOvl+JxQGJqIT2fGjy D2wUum9smFxv6OzvnbPO1b0FroIEdLrGDKwrkAVx4TfNMYXJix8At8/luL36iOr+LY94 2gBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BiWQTkL2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id o6-20020a170902d4c600b001c3ce0922ecsi9608675plg.627.2023.09.18.22.20.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 22:20:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BiWQTkL2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id AE25F8126718; Mon, 18 Sep 2023 08:48:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229816AbjIRPrO (ORCPT + 25 others); Mon, 18 Sep 2023 11:47:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229804AbjIRPrL (ORCPT ); Mon, 18 Sep 2023 11:47:11 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98E5E121; Mon, 18 Sep 2023 08:44:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695051873; x=1726587873; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4RLnw7kq3hIGZLooWQrGpuOQSJqB/nglTVJsokARwac=; b=BiWQTkL2r5gcaOLpyGOle3AHlJbaiX8n15uOmFR6rgG6EuNjG1iSBNNf BYwweDF8M1m9tDk0I9htAdK//6v82UhVRHHj1o+g7kl37wJmCOP6yJyWG 2XgPzKx2620pR8vWx7XEbIVTHzBc6ftDn/FipSxZE//lFS4HH8lB0wxdg D7Z5d8Syxj7Mrl6ZjS19QGO1cEUhbVrfmM2BsbaaacdI05KrRrMCEEnsK 8ry5FL0UcrnM0DCvtk4uKBawt5t5iIMI5Hh89F1ICblxt0xau6qBCNahe 8Zqkfw8sBjA3fQWZyyyg6AOC6ImMuCC77b5unx05UrVSm5XHQdHsAZoBU g==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="446112692" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="446112692" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:11:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="811341426" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="811341426" Received: from nprotaso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.49.156]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:11:30 -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 , linux-kernel@vger.kernel.org, Nirmal Patel , Jonathan Derrick , Lorenzo Pieralisi , Bjorn Helgaas Cc: ath10k@lists.infradead.org, ath11k@lists.infradead.org, ath12k@lists.infradead.org, intel-wired-lan@lists.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-bluetooth@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rdma@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, =?utf-8?q?Ilpo_J?= =?utf-8?q?=C3=A4rvinen?= Subject: [PATCH v2 01/13] PCI/ASPM: Rename pci_enable_link_state() to pci_set_default_link_state() Date: Mon, 18 Sep 2023 16:10:51 +0300 Message-Id: <20230918131103.24119-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> References: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:48:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777442033141067295 X-GMAIL-MSGID: 1777442033141067295 pci_enable_link_state() and pci_disable_link_state() are not paired symmetrically despite their names suggesting otherwise. 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 function that pairs symmetrically with pci_disable_link_state() can be added later. 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 ad56df98b8e6..e424ce897d23 100644 --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -752,7 +752,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 1bf630059264..fc909e20365f 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1102,8 +1102,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. @@ -1111,7 +1111,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); @@ -1153,7 +1153,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 8c7c2c3c6c65..7df56988ff48 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1776,7 +1776,7 @@ extern bool pcie_ports_native; #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); -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); @@ -1785,7 +1785,7 @@ 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) +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 Mon Sep 18 13:10:52 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: 141583 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2968767vqi; Mon, 18 Sep 2023 14:39:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJT0w4PwBVBFDs52vDVrymzYd9BdmhY760UY1GBKGshI5PdIyPbFITSohCFzMgaBjw2vu4 X-Received: by 2002:a05:6a21:47c6:b0:148:6ebd:2834 with SMTP id as6-20020a056a2147c600b001486ebd2834mr8072358pzc.34.1695073157566; Mon, 18 Sep 2023 14:39:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695073157; cv=none; d=google.com; s=arc-20160816; b=O2jiF0B0XOjrqKUSKzQtyDSDAvhugQTE7Oe+dR8xCh0n+kxxxhx8aPtUdJilS9KyQ7 r/Si0KCWNW7NTtDn002dCGLDufK4Y6L5iNDTXeH2f0d0yBZhLARyBNZJ8i5kfTEBAUsc UGbrRGODQRXbYDWbrQ4xAGiEvuEIN0ImNh+5M+nf8tINkH756aQpavdamXdKUvGq1KlO lX9NmiH+LN4lEpXPoC7LQuz4AP1OsjrLFFIwZ8teHa4uj2N2qOQkQiTWKC/FVVBOVsRN I8YjlJBv+zlodqeb/zHgDW1SaOakK38Ai797akQ2NHgQCr1LiKoHTzWxVa2qwqS+r9aQ g8IQ== 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=srslaMf53cmqJmB/WU04epzua9/FTF59REZaS2Rz7b4=; fh=+5iD0Q8HSG3sWhOMH+VlKQPx3hsE19cSXpLHbIzVt94=; b=FDTnsn6av/+1LJfc870DwVqMHOyG5fI0wMAUmBbsWVtmRpINGh9LuNRIxIeyDY5ZrR 1YKsSqUDi7CHXuCUzyoveKFfggPwnUMQeI4BxfvfW6i/aIf5dgKMzy1rp/seO0UBIDHk ECMKfYrqpr6REswKw/UkNbgVV8Ruw8RXCX/6K2Fyz4ICmeuxW77FZonn6SEcq42eYSKR 0MoZ4wP2QSQPPWk9Y+ljpMut/cPGOHEd7J1AvuJ1BOSnJmrCXLdFAjir3X9/JOlPyExb fYeC7zb7ROMvMiY6l5Lg8hsBzT3UhXm5Qvuc7AdleP+4lzp6o8XAmcjToQPxKgYFu8kz hsrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CCyiFHOt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id o3-20020a056a001bc300b006826c8d5a31si8632389pfw.21.2023.09.18.14.39.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 14:39:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CCyiFHOt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 140DA80C7731; Mon, 18 Sep 2023 08:46:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229735AbjIRPqI (ORCPT + 25 others); Mon, 18 Sep 2023 11:46:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229473AbjIRPqG (ORCPT ); Mon, 18 Sep 2023 11:46:06 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92C2D10F5; Mon, 18 Sep 2023 08:44: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=1695051884; x=1726587884; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GntG1C/Of1kw8Cak4jvrKOjbZB9Dh17vQJmAQuf8VNA=; b=CCyiFHOtrnuecVM3tUjigHAESBKnrxnahyRn0XjQWC3ntsfOOcVy3zTe ZUo4VAeyvJGL9i56FHVU1nBnZusfKh+fZuO2HGz6ox47L1C1o/qP1FpPn dWeUS7321BZ8mw5qKZQMqFv4e+PVyT+jqVVeAONtCv6saErVeXUkaJIm0 6byhgORv/FfkuP3z6LF/MFouEpM+thDXfZp8HTyUcla1h7e2Y4XpQj0db YMu4e5DL6GM4J2AWf1shHC9kmJww9hPaV24TCFd6w2Z12voAbvujUZwXI IuqAyu/SvX2q4VkECCJplB0cSngtVNz6BDR0BejzgeGZS1MC5hEC+OBqu A==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="446112778" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="446112778" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:11:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="811341486" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="811341486" Received: from nprotaso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.49.156]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:11:37 -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 , linux-kernel@vger.kernel.org, Bjorn Helgaas Cc: ath10k@lists.infradead.org, ath11k@lists.infradead.org, ath12k@lists.infradead.org, intel-wired-lan@lists.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-bluetooth@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rdma@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, =?utf-8?q?Ilpo_J?= =?utf-8?q?=C3=A4rvinen?= Subject: [PATCH v2 02/13] PCI/ASPM: Improve pci_set_default_link_state() kerneldoc Date: Mon, 18 Sep 2023 16:10:52 +0300 Message-Id: <20230918131103.24119-3-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> References: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:46:33 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777413031179405171 X-GMAIL-MSGID: 1777413031179405171 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 fc909e20365f..860bc94974ec 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1102,14 +1102,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 + * + * 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 Mon Sep 18 13:10:53 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: 141533 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2908701vqi; Mon, 18 Sep 2023 12:42:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG6ltbGFF1UqAqCDvnHiySN6p8n4Vh/S8r6G7lWd+lrq9EinNByqFOWFhp/BEZDdAYZsx5a X-Received: by 2002:a17:90b:3103:b0:25d:eca9:1621 with SMTP id gc3-20020a17090b310300b0025deca91621mr7550637pjb.6.1695066166367; Mon, 18 Sep 2023 12:42:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695066166; cv=none; d=google.com; s=arc-20160816; b=QK7txWoU6crl/NY1BwQLNF+8zaIAJpUt8bLwjI/c42oMdRaSS53/2P+gNNc4VfRbg1 NWg3mWhQZApwRXZIEHo17TmNxlCsGfIUgCG+SWtnDUrd4OJ3r0DT9dqUq9JFojWbkssc eaRe3VLQPkHd9gkqAILiudgs7TSPzZi8jUvPKDwilo1qzaAKVTfIa4ENDjtwWolYB/Ih Wt7/de9aQ6GZ3H7QEhDUMqg9L+V7orhOehk4bc3f+n84eQl+mvb9GubM6nb62MIkWLrt Y/+El2GlUUMgkjsIjro/VQGTs6IcnP150Jl5/wDzTUcuPXhDzJEvkQdkM+uLgC5y/1HA y35A== 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=HPjduN6rlM0jX6Zy4R6TFW+pSLP6fULJP4bEmdfscv4=; fh=+5iD0Q8HSG3sWhOMH+VlKQPx3hsE19cSXpLHbIzVt94=; b=cZFpy4KMRg9TMPZFl6enzbvrPrYqc9f9uBvVtvxL4FFge4Snuq4IJq3u48PjTPNU1e Rt439XMw0ENgTKVhQrUKkRU8KpDpFnecVdFTymEiCOqEsbuQdfHRQny0yAmaWM++2l0N 8V2AZ3R5VUA4905mmxmVuvxHjKnLsF8FfI90TV9WYspT01Jyj7Y6qYPZC6FRW8VJvtqK vgtUdrnGICfA4JJZH9Am3sNUcR0XMsZDa3eNrCi04tm2pRNru04kJDrFUx44Vdtj7cB4 qwMODMrdgNJzsgCqYfdfFvKZfBW9G1iCoQ5J1dBwv9f5bIbYnkRooUP/npZpvQ/RKA61 WW0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LC1Rve02; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id e20-20020a170902f1d400b001bb377f8c8bsi8217155plc.2.2023.09.18.12.42.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 12:42:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LC1Rve02; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id CB1748120473; Mon, 18 Sep 2023 08:49:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229757AbjIRPrf (ORCPT + 25 others); Mon, 18 Sep 2023 11:47:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229826AbjIRPre (ORCPT ); Mon, 18 Sep 2023 11:47:34 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9264910F4; Mon, 18 Sep 2023 08:44: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=1695051884; x=1726587884; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4NBLfl/BS/3VShevYHOCVVW7LFobwQI1zr9aS+V1OKk=; b=LC1Rve02aHbu+3hf+GBKvgh2ENjuWXK20L0MB2ePq1jAQJT2QELkdNTz 19KtmZlDucq86OobQwsR8V7RsZapz8NFjLG1OHBWYfZ1izHeUS/GjRe8w MRY4WJ7Ye+EMsalUszYCAx48yQJZ+2Ljct4lM5mrRJFZS6XPwPBK4uuX3 DOBWWaCQlfWkd3+DCCE6wWQLU57cWBEKZrtEELlfPqdoE9iZbKKApdv5I 1mwqQk0PkTaAR4Zh8shfYbHZtc29q4nqOUMYwVjcpqr3eHY9w/PxXm+c4 C3zVTHVr1Kz8ISW2kpBlFsbwVkrmDxp3rBu0Dfl1lOqs5YWPb77sJqfXZ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="446112875" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="446112875" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:11:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="811341550" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="811341550" Received: from nprotaso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.49.156]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:11:43 -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 , linux-kernel@vger.kernel.org, Bjorn Helgaas Cc: ath10k@lists.infradead.org, ath11k@lists.infradead.org, ath12k@lists.infradead.org, intel-wired-lan@lists.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-bluetooth@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rdma@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, =?utf-8?q?Ilpo_J?= =?utf-8?q?=C3=A4rvinen?= Subject: [PATCH v2 03/13] PCI/ASPM: Disable ASPM when driver requests it Date: Mon, 18 Sep 2023 16:10:53 +0300 Message-Id: <20230918131103.24119-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> References: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:49:35 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777405700497325445 X-GMAIL-MSGID: 1777405700497325445 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 --- 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 860bc94974ec..ec6d7a092ac1 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1042,16 +1042,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); @@ -1087,13 +1094,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 7df56988ff48..3c24ca164104 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1773,18 +1773,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_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_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_set_default_link_state(struct pci_dev *pdev, int state) { return 0; } static inline void pcie_no_aspm(void) { } From patchwork Mon Sep 18 13:10:54 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: 141518 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2881608vqi; Mon, 18 Sep 2023 11:56:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHBoxX1jG/0e6ZijdR1KhP13+7LVTwToI4g51xQA/pALIaz0q3QdgB1Hv0tY3gAGGeo0m6f X-Received: by 2002:a05:6a00:2d83:b0:68a:586a:f62 with SMTP id fb3-20020a056a002d8300b0068a586a0f62mr9135498pfb.4.1695063375583; Mon, 18 Sep 2023 11:56:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695063375; cv=none; d=google.com; s=arc-20160816; b=YP5ViHW67yJjQsbEhkeH1OLyZIWMiw/llXzHDcaqKAk7jMIYXJELkkn/5IdRuFSQl4 ywuo64evYXyUFRwJBw4o3hn6iXwXA5RCF2pBSg2u/LcGrQauxuaX2HiypIpWLlQqssvH SeJson/9Qx9iQ7k/G7OYNBCzrH5ZwqWtIYGZUH2/o7xhHk5QS0GNHTEjNEhEGd47WVGU yI3DS+iEkVxjognIoZxAGw3kTU9WujYI44AVGgso2yeOa4kj6HQ7Bu5osQxrdDdA2TYT SnuB+35kUCWIS9RMS4wN5ofc6QPk310uJKqocTa2TyMUAxp9ImaYjML5WX3BoCWbnbzq ULIQ== 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=mdb2wMHdr8CoVjkzTANz2jRL1uIvbsjlwfgTQD9IR2o=; fh=+5iD0Q8HSG3sWhOMH+VlKQPx3hsE19cSXpLHbIzVt94=; b=BR9CTymSrLoylQdResvZ25UMLJgBOV0gacMVA8yAvIYE1UoowCUSuEkqikCxWlrm1l 9/tdmEqZ8CEUxzIzpEwEobrGbrbVofooDASkI/65a37gmhIvpU2dEyWMRcXxV9SVyGND dyhD/tG73iuLXOJLcElnVu7HHD9BKDSli9Nx5xmYZlwAHXijz64IKs+dZszKdy+LI9uA QmsQ7VkYKjhvwVQBygu7dkFiXlgcFXc5z/Qw9dbKEs1pAJje8Ye3TjeOAaFBR0L9w8j/ DooCT/t0TvpCn5QRSS8Pyp8Onu8rM22g8QmhhP5Aen2fnlAX45t0MIb8w3xMnBGdnt0L HmEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WyHkEmtr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id b9-20020a63d809000000b00565e386ff3esi8305784pgh.738.2023.09.18.11.56.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 11:56:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WyHkEmtr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 9AD0B803E9F1; Mon, 18 Sep 2023 08:49:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229845AbjIRPro (ORCPT + 25 others); Mon, 18 Sep 2023 11:47:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229846AbjIRPrl (ORCPT ); Mon, 18 Sep 2023 11:47:41 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8581419A7; Mon, 18 Sep 2023 08:44:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695051886; x=1726587886; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ymkN+p4ogpYhyDF99HjDp+8yFzsuK5k5J5zb7K9eDd0=; b=WyHkEmtrm5ATwt3VZF3xouUzV+1P0o1Dqg2HoOZ+BKYydtWtnXwtcaOP Xvpc94Gi/UaJdDQWqq+wUVoqq9d2JlN5k69AcrbEOJlT9rILhbVY3eaH9 /OhdDztnpucygMldh3EdBIYDX6kDyeoUDhF5Lr6URItuwzzMVqHPnkN6Q iBpXnvYJ55wdFfTniVQ/jwz1JvgOmhJVG5dDe2q/tEnAGDRHimNpGYaeC ruj5nZ55AfqTXfyetcpA3HD1yNJ5kDYm4Jt4blwHa2gt1S02jFE10+pPZ O9dRIWtX3p15gHgqKBk7IicaMXHM1uhTucg88Ix/woQVRpigZaoDz+6lN Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="446113130" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="446113130" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:12:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="811341856" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="811341856" Received: from nprotaso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.49.156]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:12:02 -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 , linux-kernel@vger.kernel.org, Bjorn Helgaas Cc: ath10k@lists.infradead.org, ath11k@lists.infradead.org, ath12k@lists.infradead.org, intel-wired-lan@lists.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-bluetooth@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rdma@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, =?utf-8?q?Ilpo_J?= =?utf-8?q?=C3=A4rvinen?= Subject: [PATCH v2 04/13] PCI/ASPM: Move L0S/L1/sub states mask calculation into a helper Date: Mon, 18 Sep 2023 16:10:54 +0300 Message-Id: <20230918131103.24119-5-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> References: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:49:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777402773882496687 X-GMAIL-MSGID: 1777402773882496687 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 | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index ec6d7a092ac1..91dc95aca90f 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1034,6 +1034,26 @@ 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) + result |= ASPM_STATE_L1; + 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); @@ -1063,18 +1083,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) - link->aspm_disable |= ASPM_STATE_L1; - 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) From patchwork Mon Sep 18 13:10:55 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: 141678 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3108543vqi; Mon, 18 Sep 2023 20:36:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYEquoWtqPP0QQKDsZJ+RwACCDw+aMRfuwGaqpGqaFtvTh3WcO/Q8G16Jsbms1hMjEx1fd X-Received: by 2002:a9d:768f:0:b0:6bb:1071:ea72 with SMTP id j15-20020a9d768f000000b006bb1071ea72mr10542318otl.36.1695094570771; Mon, 18 Sep 2023 20:36:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695094570; cv=none; d=google.com; s=arc-20160816; b=e/NdVQdnfZd2eVbGo4tPazrxgYOZW5a9VzZy2ADdCATPUfCLOGDq3JPoqa703qD+3X w8WskKokF5HqZguFeyowME/jJOLMVlLSU4CMsOG5s/6IWU/XUCzG6b2RnnBA400GtGk8 Mo/xCLquhq0OnruVYGiRc4FR07yQzHuy5D5M7uObkd0LSLZMOw+uNVujKBr013oD7WxD fOXVCmRDuWySjDXiZGlykdwUONFRKBJGH7bMGxOE5NLaoudZuNRqNp3m9zdO4OgHRH9Q foGVJ2GA+bzEPNm5D9p+UsKpwugW9SvpSXrmy0IaQmW0b7OmXA43u0QkcoCsIJvTKBMW oq5g== 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=+lpdCK5+VQs9sNEvDPk/c3GmQ6kipvNq7frsPNfmFLM=; fh=+5iD0Q8HSG3sWhOMH+VlKQPx3hsE19cSXpLHbIzVt94=; b=ZRAWQys+3Y1xwPwDhplH6hmaq3h1jH//XkeUEcMXgzaM1urpiiV52vmEx6r2Y6BY0E Aij09jXWOROUBR0h/qgWm9hHFghysBJ4QsHLvrnINODXjh1x0+duc0EO3t0PtCfExuCY ABf/sH20/2mkljVueZQyKS8nMRriZJRPfFrXjXdc+uXmoql3jIU0urDlJXccvUFIjoQ4 7EJOTXT0JI/ElERsrqKXdgFd9YrZdC3MgveoC9aI6N98w3g2NOCgLToW3SEsl6Ige+73 JWvepFrbc534efdPzAdvF0+GFym3wzNoXkNfXQfrKXvQTPkcgyNCkAEwqkdQ6bgxZopy OU7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fQjsiB6v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id e1-20020a636901000000b0056956177395si8800715pgc.512.2023.09.18.20.36.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 20:36:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fQjsiB6v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id CAD98815CDA8; Mon, 18 Sep 2023 08:47:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbjIRPqc (ORCPT + 25 others); Mon, 18 Sep 2023 11:46:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229725AbjIRPq1 (ORCPT ); Mon, 18 Sep 2023 11:46:27 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A0C0CF8; Mon, 18 Sep 2023 08:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695051920; x=1726587920; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uEKrgp0fS4TcV/kqj/T1ibXnz9U6nSS/hcSxBB6l/C0=; b=fQjsiB6vONTRlk5HZosldvkskKXZ2MTyw1KqGM3O3eFuh+jVIf6/8ul4 Rzi241HaWnxbMJgnRQya5Vf5HZBP40Y5/Jj4XJPboRdRKlTbqJ0qr0KOd nCbLZK7sWH5N93txZXAqS2jwkyz0Y8GoxizUBigNMg5QCESzbT+8Rj8Qv 4YBOb63OSFvCwj72KYi0Jj4Vw0D+W+P2od8ZDz/C7ghlZjHdP8TrGwjnD vm6PTGbzxAKuGfkYpabIXNG137gcRf/MI5I7SpYfdHbXbsnn5eCB+evOX q6Dk4OQs5qbi37fN5XaOTMg5h66s6jQeP0qCtpkaAkAWdIuseFiDPqdxX A==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="446113406" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="446113406" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:12:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="811342150" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="811342150" Received: from nprotaso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.49.156]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:12:30 -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 , linux-kernel@vger.kernel.org, Bjorn Helgaas Cc: ath10k@lists.infradead.org, ath11k@lists.infradead.org, ath12k@lists.infradead.org, intel-wired-lan@lists.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-bluetooth@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rdma@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, =?utf-8?q?Ilpo_J?= =?utf-8?q?=C3=A4rvinen?= Subject: [PATCH v2 05/13] PCI/ASPM: Add pci_enable_link_state() Date: Mon, 18 Sep 2023 16:10:55 +0300 Message-Id: <20230918131103.24119-6-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> References: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:47:05 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777435484527642098 X-GMAIL-MSGID: 1777435484527642098 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 | 42 +++++++++++++++++++++++++++++++++++++++++ include/linux/pci.h | 2 ++ 2 files changed, 44 insertions(+) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 91dc95aca90f..f45d18d47c20 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1117,6 +1117,48 @@ 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 enabled 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. + */ + 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 3c24ca164104..844d09230264 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1776,11 +1776,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 Mon Sep 18 13:10:56 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: 141666 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3090641vqi; Mon, 18 Sep 2023 19:42:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvvM5iEIQhZLmRJNFqM97z8bRIU0LHRb/22/grXuzt3PCs92UHsZpLZo1TDYLLysh0vrlv X-Received: by 2002:a05:6a20:7faa:b0:140:324c:124c with SMTP id d42-20020a056a207faa00b00140324c124cmr10433069pzj.62.1695091320263; Mon, 18 Sep 2023 19:42:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695091320; cv=none; d=google.com; s=arc-20160816; b=E9NTYAcXNAwgb6/JJeFDpQFW4GyQ1YcF/Kl8T9FBo1u2LF5WP3LITKKWVgItbcMr7M lSwdzsxFQEIKZedBpHF78LsuY1YEK6InD64VDjWTLh0hATM0x1M4ORqMCpKO7xYekA46 CL+QT/0YGEwxlfHHNtJPY4wSwiW/UsdcNt8vLe2EPMWmNIbVuXqqm2PlMvwcJuO7RsgR m5TgPXCBbglTGcoxbNL2DGq99B9s+KMUAlQHZTH8oMOKUGdE5ttYQ1nBQCYXB6uNYyyn PgD3S8ObeQz4dks6rCwIrbZ86v6nBk99MJ2m49KE8jwRQg4Cbek/l6X86musj8jzBc/+ VThg== 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=o/TC1u7gT8HKB4gXUtL/XOeGJcNwejVQ8csHh1ehEss=; fh=3Ln+o8s0YE7fD0O+S0ddIzZMr1lau7G1Zo21L0MX58s=; b=a0/VWova1kkny8hgLByKYY1ebPD0wCJVaVX8XBedjwTOQT8fuK0iBPzkv+cPxX3KVd dTsTWvCqpV7oHqsChATJw2kJX96Ut6BxWwmq6XLBGwqU+M12buW1QHGQP8bHERHa14Js OfeV8iz7dWnuOfGl/3MD7vaDpjdhBacTBxDjIPvB5ZDOAzpE+bgW3LderKtIq4lkIhC9 im+7+HKtx0an/Udl5h77TVE+Cbl5REVgfhuONSoNFxyjkimZ2FFFU6PAxhJypWtWjJHi MuUlw5UwBKUHtRgtupEA4JRkB4hYbG5GFaNz8AKnNAWtqd8nYWRFVlqm5xfHwbOKu+e9 p0rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Z3qX81iE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id s21-20020a63af55000000b00573fd75b486si9141106pgo.658.2023.09.18.19.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 19:42:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Z3qX81iE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 91DF9817ABDD; Mon, 18 Sep 2023 08:48:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229779AbjIRPql (ORCPT + 25 others); Mon, 18 Sep 2023 11:46:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229777AbjIRPqi (ORCPT ); Mon, 18 Sep 2023 11:46:38 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3E5910F9; Mon, 18 Sep 2023 08:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695051925; x=1726587925; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fG2lEBkT7mIaWcABDtYlaKTuVQodmkE/Rpx2qX2kUFA=; b=Z3qX81iEm9q3J3rZvsRGetWSeLIJEbSAEiGcre6HL+7VT6l2y2D0SOTQ KnsOVhDsc4F4FlN+i9Vov1ZfcXMrA9YLQEJczkHPuzsi2Vt5aDTsyxq/e KrgmklsmlT8x92tpnrLxHwacqKPZ5FJQYoZJ7QiAL+rYB5KVR0uIvRz43 Fv5hzirjgEQnjqNdHc5ApZhmTOAlNvkmQtKuwMN2BF3fOIdm+oz1PA+/K RfYTQQ5ur0vU5Hx8FvDJkxg5zYUhFDJ9MV2Un4zJ/tpLKPsQFWXRaI1UF VDXQ3Kucy2CXpT79mlT1rPQJFPawRUrFakbk2BLNxOc/AQd3t9W6XlW1o Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="446113432" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="446113432" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:12:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="811342282" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="811342282" Received: from nprotaso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.49.156]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:12:38 -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 , linux-kernel@vger.kernel.org, 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 Cc: ath10k@lists.infradead.org, ath11k@lists.infradead.org, ath12k@lists.infradead.org, intel-wired-lan@lists.osuosl.org, linux-mediatek@lists.infradead.org, linux-rdma@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, =?utf-8?q?Ilpo_J?= =?utf-8?q?=C3=A4rvinen?= Subject: [PATCH v2 06/13] Bluetooth: hci_bcm4377: Convert aspm disable to quirk Date: Mon, 18 Sep 2023 16:10:56 +0300 Message-Id: <20230918131103.24119-7-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> References: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:48:07 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777432075825840905 X-GMAIL-MSGID: 1777432075825840905 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 Acked-by: Sven Peter --- 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 eeec1d6f9023..d6ab0e98013f 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -2502,6 +2502,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 Mon Sep 18 13:10:57 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: 141603 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2995382vqi; Mon, 18 Sep 2023 15:35:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHthuNltGAXv8e1AoV4YV8RRd5SlGdjPNAhmwNbOMuA9uY6J7g6V/p1esEr8GNNpzpkFTYn X-Received: by 2002:a05:6a00:2491:b0:68f:efc2:ba3d with SMTP id c17-20020a056a00249100b0068fefc2ba3dmr10366679pfv.33.1695076557648; Mon, 18 Sep 2023 15:35:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695076557; cv=none; d=google.com; s=arc-20160816; b=hZJCJ1mHmUDq/6CHa7adWbZVd4jgpwF/n/PuPhQg/UlgKRBWPeHTGNS6xm+Pk7ZDYX T7TWP/mZF5zzYAIAOPGtD2vIS+lq4RHp7Say2PbRSBIqKIA1nVvupkzS7FIPMSUk8IKy RP99nai5C5d95GuNaKjhwhk+z7scjcAQMsr+perRYSDqjiile9qB2GPt0DFJbR85MZK7 EzXq7P12wTrwxD0cOR9mjA6shlHy4IDHsXDBIBkV0WBFm9Z4qaNdg6sDFZgNQkSsNUz2 iGMDm0qio02jNGbX1xbJPZSz3BgeZJgWIacUUh/0h+O4j0dXB6V7eEyTS+dIw/VDSgD2 UJyQ== 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=T2YrxzdblVoPuj3DWN5pSWbg6jEvr2tQ06PIRnyBZAE=; fh=2odfiKWo6rGGIz3pizDK0KAfc0SW+n372GSgOk9xKUI=; b=GwWQZDpGMQ7Ukfsxm8Qy4EjoLal11NhmufgabzDFUWV8WFZqH8Rb17FOrFJ7Ga1ogL 1fOwlfiTs7dQidrxp2rPZRa4JitJ3d05rl7Q6e6FxVWL9l6c4eFvapkVjVikjevZlB0d ZQlTgsZap1LkGl5Qlk/dDNwb4v1InxPgdy9AtdO4jq2PRptDlbAtDmtbTOCRDanV32Gm z81LO/tcTnFofSd77LfocF/nYBhf9Jv4s1rQHneEZhHiG6qOHFjM4L9PikuoEK1jdSvU mklrcpeeH4M7Iez+oz3et73KJ7PJaLveN3YPTlxWbwGnMbN39rrek2YuTSm2go47nbU6 UnhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Y7erHHU9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id o66-20020a634145000000b00563de199314si8535461pga.896.2023.09.18.15.35.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 15:35:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Y7erHHU9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0B74C81A9996; Mon, 18 Sep 2023 08:49:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229655AbjIRPsh (ORCPT + 25 others); Mon, 18 Sep 2023 11:48:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbjIRPse (ORCPT ); Mon, 18 Sep 2023 11:48:34 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A514171C; Mon, 18 Sep 2023 08:45:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695051927; x=1726587927; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cukenIapxUiEiCycbwYwBac+amF+ty4IZL1khZo/lv0=; b=Y7erHHU9t/meW7U1cozLNKU0FOvbS+GNWVZQuHqA5u6FYKVhkd4tfeet Iqe8v2kmNjzwHMjVSvHqr3UO87IErCLc4xUcF3C5tfjyXl8/OSWY+qGiL /lwzj5Kcptlwp91YQl1XOk5Y+aSyaHzLvp6bB3JDx6U0IhzIACYYuLn4d er/EbRVoMzj3pJ3Hxm3gHTGQk7SJopebXHC1bcGmEnnVhy7BczQOHHeEg pYnI8dNqbTpg1UMvyApp1jj4kWPP7Zul4Av2vZjxPlZ1QXxGq9Rhy/+/T iFF8bXx46A90shII1oKt/WzdSXsUW5E7DZ62EgfuNKDAz/ikxG5/pE140 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="446113469" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="446113469" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:12:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="811342373" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="811342373" Received: from nprotaso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.49.156]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:12:46 -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 , linux-kernel@vger.kernel.org, Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Kalle Valo , Matthias Brugger , AngeloGioacchino Del Regno , linux-wireless@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: ath10k@lists.infradead.org, ath11k@lists.infradead.org, ath12k@lists.infradead.org, intel-wired-lan@lists.osuosl.org, linux-bluetooth@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 07/13] mt76: Remove unreliable pci_disable_link_state() workaround Date: Mon, 18 Sep 2023 16:10:57 +0300 Message-Id: <20230918131103.24119-8-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> References: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:49:55 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777416596445893284 X-GMAIL-MSGID: 1777416596445893284 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 85c4799be954..cb28cef780a5 100644 --- a/drivers/net/wireless/mediatek/mt76/Makefile +++ b/drivers/net/wireless/mediatek/mt76/Makefile @@ -12,7 +12,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 e8757865a3d0..0869fe03e3d2 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -1038,7 +1038,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 3dda84a93717..45a861122926 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c @@ -294,7 +294,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 = mt792x_get_mac80211_ops(&pdev->dev, &mt7921_ops, (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 c5301050ff8b..1e84c1f37c37 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 Mon Sep 18 13:10:58 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: 141527 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2893111vqi; Mon, 18 Sep 2023 12:14:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtev1nT6IqCBEv+KF9Jgqafbszu5Ls4zk47yQ7x886n5/DP57/8gdMwHWNB34SDbqCzBwq X-Received: by 2002:a05:6a20:100c:b0:157:eb44:fd2e with SMTP id gs12-20020a056a20100c00b00157eb44fd2emr8264645pzc.19.1695064441728; Mon, 18 Sep 2023 12:14:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695064441; cv=none; d=google.com; s=arc-20160816; b=h703mgwll0hNGEteFb3GOX2dlk9Ufq4BIX7yLgKHs42hOvQclyz/yuAwSsDhNCxYuv mQL7gyk+1J3PXDfSe3JbFV44ll0tIyw++603AIL8FDomHX4JQQsZ0SrVDn1hZbhpGypp ukaiz22YhCYHcXCygBRrBRyBZpTF1Vl/BbHSnxsu3i+KcYbqJLWw/Lc3hD4jIZgrJIxc ZGaCmwmORxIzh1/CEAJVwr7YhkeMMTT3EkSCMgZ7vI06g5bWhjHyITPCpcov4JcH49cI 3GuSVvnqo8P7Bp8GIiflJjHPiKtiZsVDikOKnjGGeREIOJh5XV7qZhraaR3RsawVfVJd knDQ== 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=DtUvR2ykzGk+Iwv9BjnZvZG1qw5+70af/yHXrvzYB3o=; fh=kIPMZjgwkNNvu2EuAwvcGQ57i8gRc1LwFhRvGANfQdM=; b=mHDEzKSjaa4j+z8nmxMt+Xq4CemqIcLUB6WPoCG9IIH3D4kWLvaPETi2l1XoTAxshV 0H/6hx6pXVWuI2V1vkmXJigZFnX+zURR78wE4ZYZoyjWghRgaNVuPItaMBMxm/tOrW87 ksjRN9AQOAAFkmqvSVnaF+mwpusOVwK7Lm6M1axk/qzvgBbM49VBCgaGZym60W3gKvTp 78JK92GVFAO0HkuvJVsoCJqYrxkfaCH7vThjeXqreZfOFYUu+Wqh6Bsb0Jc8lqHSwARZ 4XLccSTQLUVwkSutuekcAlOm5z/9cGSaKsLUWJDuIeIp8mNDDE2wJNXvdC+Q35YizD4w e/HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZPQdPh0V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id a26-20020a056a001d1a00b0068e4661404asi8219825pfx.392.2023.09.18.12.14.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 12:14:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZPQdPh0V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id D79E2820BFFD; Mon, 18 Sep 2023 08:49:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229742AbjIRPtL (ORCPT + 25 others); Mon, 18 Sep 2023 11:49:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbjIRPtJ (ORCPT ); Mon, 18 Sep 2023 11:49:09 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 027B219B6; Mon, 18 Sep 2023 08:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695051962; x=1726587962; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zTpTCMfWjtWGKDy0jqcFW3mar26wQ+s3+v+7yTP0erY=; b=ZPQdPh0V60UWeaLLo6ePQfn6wSS3Fj+EQdbGY4YCnQRFrQmuFhPC6RCw qgWnDG4W4q1aF+pkm6H/iTgzKjiXWHepkegUx9/XXYT50gwWxT14Z360j xHHi/B+UJFRXpv1I+x6z5zBEqTTHgm1nU49h7E/u52VZShBe5c1Q2TQBe sAdrf065s7ZfjN3MYST2uRAb9BIeZzTLPWuiyXSPJBmmKaU2TRRpXw680 CMJ0qv777UJ84g+M3IQ60P0ul+kP3cUyupUSuD53cTw7W4IqW2nenVspd ny++0bRVkB9UqmQVLihlCjSnmSGHqa7r1MkMiIbcmBEnI4JhVa7RKJ90s w==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="446113490" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="446113490" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:13:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="811342491" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="811342491" Received: from nprotaso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.49.156]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:12:54 -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 , linux-kernel@vger.kernel.org, Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org Cc: ath10k@lists.infradead.org, ath11k@lists.infradead.org, ath12k@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-bluetooth@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rdma@vger.kernel.org, linux-wireless@vger.kernel.org, =?utf-8?q?Ilpo_?= =?utf-8?q?J=C3=A4rvinen?= Subject: [PATCH v2 08/13] e1000e: Remove unreliable pci_disable_link_state{,_locked}() workaround Date: Mon, 18 Sep 2023 16:10:58 +0300 Message-Id: <20230918131103.24119-9-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> References: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:49:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777403891927015515 X-GMAIL-MSGID: 1777403891927015515 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 f536c856727c..fbe468061591 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -6765,79 +6765,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 @@ -6848,7 +6775,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); } /** @@ -6861,7 +6788,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 Mon Sep 18 13:10:59 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: 141606 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2997190vqi; Mon, 18 Sep 2023 15:40:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEoGpdf7Hhbn7lY8E7jYct+czGEIi0kDrIlc3zY3CnJ5M2lmhswgxVbAJpa7x2bOCxX7WLp X-Received: by 2002:a17:903:41ca:b0:1bd:e258:a256 with SMTP id u10-20020a17090341ca00b001bde258a256mr992855ple.32.1695076811352; Mon, 18 Sep 2023 15:40:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695076811; cv=none; d=google.com; s=arc-20160816; b=pDZfV38l5dPwBWpTSIbSZnHkdchWBRkD3FIstgIQ7H3Rx2oqsicLRpjn0D7UgKbzHx 1WpM1oNFtEjr2lk0cy1U9QMUDOfQylYALjZA8fXWtATrAbart6BPqF3xrtE9/bP6V4rt LznhSZHDjXWpPdwwZX1t+CafAOiIwAYg9CzSEcFSoj2J+pp6f2+brlkRs1GS/RJqTh+Y 4n1mDH+sgWvZVoBw/cjmtJ0DZWPqzdxZxRKPOjQKDUdzM4ZCbsjmtCmig4IllYn3WSeN yWcfHXncAO+A/PmQjSQLeQGknorLUasitorq+sS03KioqRERK4PLakJ9/VWBXmy1tz5j 24XQ== 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=2zhdSzCh63cqyYevgFdjNtRFf3fnzFQ0lY4h4VWy3zs=; fh=DwV0dbg1evDUFBb0OZkIvpceGR2hltz0LUkG+Qg8PNA=; b=Nns6FnQGIrcR60gyih/sLqAOxbPQQQseLktQISsuWXYHi1Cand3k56x6bYIeV7SJmL P2Qh4dgK+ZJgtAkJy6ILsGJWxwqcH4MEKh9p+yFLCGU4b8PYcX8cLwiBsgl8Z0E4w2iT vMlr8XOU1PAbe9vgh061cYBhKvnOskf6iF1BhKla6vEjWZcODYHtgTC4UmXIBk0KsQLs xO8t7uYmqbNZELvNIbg8eoZBlGdokqkqD1ZhOA+lI05emXeVYYwoi/jhAImZ+h0LmNOP jiwZ5aXDIlKBm53VsTkNKDbLIIDx3GqjCFMKP5wI8r7Jzpvdyj2Zqww+dCHF0dYpEQ2v dScA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hAa1dTQq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id s9-20020a170903320900b001bf1973eaeasi8626321plh.577.2023.09.18.15.40.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 15:40:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hAa1dTQq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id D1EE1803BF2D; Mon, 18 Sep 2023 08:47:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229555AbjIRPrQ (ORCPT + 25 others); Mon, 18 Sep 2023 11:47:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229826AbjIRPrM (ORCPT ); Mon, 18 Sep 2023 11:47:12 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7281D10F7; Mon, 18 Sep 2023 08:46:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695051962; x=1726587962; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1z4zU2kddqvhSnJhYzQ+kzmt/kJVDZXOqL2l9VfDNaA=; b=hAa1dTQqLYgVzYD8Rwhgp2v/JxO04glOp4D9FsxFIn/c1i5ze8o1iQQL qKovhXbgSNde7JvZrjo1tLZcFBtKHAv+zG8lvrNEPEr3nADZnCxMWhoVk wrIUVx9tP8mKASbNubyQBpA1Rk05Eg4vD+hXbXu/pXLchOox3jga+NNli 63MtcMQBUOLmgx9likXbr8cjrlSb7BzYCPHTgJjxvpIBtIoMSh5hhtJUJ YoC3BJ9clOKvuMrELzAlDqjQVh/t7LXaPX2u4tV7jMYm3/+tQLD2F/4nl XyVS2IZkqr/+3UpZhbSpks7s1e+AK++BpmJ/Vy3M5asQ7Tcpvu2h8cUvg w==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="446113501" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="446113501" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:13:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="811342626" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="811342626" Received: from nprotaso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.49.156]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:13:01 -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 , linux-kernel@vger.kernel.org, Kalle Valo , Jeff Johnson , ath10k@lists.infradead.org, linux-wireless@vger.kernel.org Cc: ath11k@lists.infradead.org, ath12k@lists.infradead.org, intel-wired-lan@lists.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-bluetooth@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, =?utf-8?q?Ilpo_J=C3=A4r?= =?utf-8?q?vinen?= Subject: [PATCH v2 09/13] wifi: ath10k: Use pci_disable/enable_link_state() Date: Mon, 18 Sep 2023 16:10:59 +0300 Message-Id: <20230918131103.24119-10-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> References: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:47:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777416862906753081 X-GMAIL-MSGID: 1777416862906753081 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 Acked-by: Kalle Valo --- 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 23f366221939..64f7133ce122 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 Mon Sep 18 13:11:00 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: 141623 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3036102vqi; Mon, 18 Sep 2023 17:10:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHTB1pyaUIx8My3GINEOnEk68OdOiyj8Azi3pmqVI45qkLU5BtX4fbWbLPf99ybaogD+sih X-Received: by 2002:a05:6808:1909:b0:3a9:bc8d:42e9 with SMTP id bf9-20020a056808190900b003a9bc8d42e9mr15250663oib.21.1695082218855; Mon, 18 Sep 2023 17:10:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695082218; cv=none; d=google.com; s=arc-20160816; b=AC0v/plL6yEVhbuyZZjHohACkGdyMs6W3ygY+dPxhxFi1Ok47LPu4DINkymmJD6x/Y MIrfL44Bl52nKbsJhprl7pBIpPuaffuweyeIq5jISC1+5NWA8CPEmh1VZzZj0KsbHxxo qrsVKqRkwXz3h1+Lp5CQAwu5dklg9fgqICXWlMD79worBpFG4OJCw5cBqPFWqkwIISyW khc03VztGp07XahMTsznQaWy4f3htN2qPlgLlVjB8vQmj4WbYFkLlCvwjukaflCXjK3S 18Z4bHhEbOG6/ZkoqYjpiAOb9i4i8Avm3FEHK8KItOF0uPxmINjTfphj9dZmyg2XjfHh SR1w== 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=zpo5FuQxOugQWaoY9+OBNmDAsg+rqZ8zbp7l7RnXoOw=; fh=9Kk6YaHJfmT3496aAtzPBhBLucKpQIEBlVI6UT5q2dI=; b=DWKrFmXDcezCSeqioH3OAZCKmpb0YtIfLnxobaWA6lwHyRVraFmVSFNPChk3jVX4rz TBRmYaUQC88+np2WhsWzU+578VrwGjbRWgae813P79D3INxClBoFS64PZzmIuIox5plI S9nhE2RRpxMaNQToY6nZOvQZsSMGB8rwgeOgn4KAC3GTRfdAieYwfdgwYvDAGP0FupZW 6vRLZ3qOqPnDNYsLs0aVRNqR+lIysu5LdB5T6koDo3blFPC4uOl38CA713Br3YLCxRnF 8XxU06whG2Qc0h+7MbYP9T4dbB9owxhMBJAoBfzn68TUnxyP1iKSkUZCrWQ0df+r6C/E SD8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=S1NLiq1h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id m16-20020a63fd50000000b0056546b5fef4si840754pgj.232.2023.09.18.17.10.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 17:10:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=S1NLiq1h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 01E7C8328AE1; Mon, 18 Sep 2023 08:50:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229864AbjIRPt0 (ORCPT + 25 others); Mon, 18 Sep 2023 11:49:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229566AbjIRPtX (ORCPT ); Mon, 18 Sep 2023 11:49:23 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 333382737; Mon, 18 Sep 2023 08:46:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695051968; x=1726587968; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TVpIxZltjnz+Zaq4u2l7j7EaR5dq+4x3KCuX5f2+zQ8=; b=S1NLiq1hUmfP6XxF9L222FRPcsNvI5gUKnm/wgZ6n8U00mZp3boY0zn7 RdOauE9ivA8OCUDABPS7HYXc9bkSNcYOIdYlsV2o3XrQ/3NzW0jKETdy/ Ht6SYte4qOCbFazRAaOYYl2sJCiz6/DIhJ69WfdzCNSG4Eu96fTI96rpP 9Xi4TYqe0/+sLpr7X8hL3TA4wPBBDs3l5wsC1F3uAYwQ5ljYzSggIesAH 2nlDFViYkSeVshQtRyEmQCspYJzL9J/iKr8U18gYijTGrLBsMGfkbsGVV 7QJtdFx+aEfa3NJHOqwAG37bDdKmHF4svH7o2KJF4DAqmoXNdoNZuy/k/ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="446113535" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="446113535" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:13:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="811342781" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="811342781" Received: from nprotaso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.49.156]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:13: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 , linux-kernel@vger.kernel.org, Kalle Valo , Jeff Johnson , ath11k@lists.infradead.org, linux-wireless@vger.kernel.org Cc: ath10k@lists.infradead.org, ath12k@lists.infradead.org, intel-wired-lan@lists.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-bluetooth@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, =?utf-8?q?Ilpo_J=C3=A4r?= =?utf-8?q?vinen?= Subject: [PATCH v2 10/13] wifi: ath11k: Use pci_disable/enable_link_state() Date: Mon, 18 Sep 2023 16:11:00 +0300 Message-Id: <20230918131103.24119-11-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> References: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:50:15 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777422532441369595 X-GMAIL-MSGID: 1777422532441369595 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 Acked-by: Kalle Valo --- 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 a5aa1857ec14..764cdf74b0e9 100644 --- a/drivers/net/wireless/ath/ath11k/pci.c +++ b/drivers/net/wireless/ath/ath11k/pci.c @@ -582,19 +582,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 Mon Sep 18 13:11:01 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: 141595 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2983347vqi; Mon, 18 Sep 2023 15:10:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsjKbOER9/5Wz3teZgklPItVYG9xXvzmdHMqHCzxtzX6lALUpMytOELtWmJdQDtsZnLL4K X-Received: by 2002:a17:90a:bb03:b0:267:eefe:d0b5 with SMTP id u3-20020a17090abb0300b00267eefed0b5mr9191335pjr.46.1695075022788; Mon, 18 Sep 2023 15:10:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695075022; cv=none; d=google.com; s=arc-20160816; b=uZoWwhIyOVxgPmI+3Aq9UDq43CjFIEq757zO+/0xgfQK3mY+vK0kzgukDyTdt6LyTz ecjNn1kRI62/m669edXNc5TQsAjCJ8CKMeogeJPx81ZDfzie483dvSBsaYDfKMclsbYe pqZSsJq8Dd6qO/di4ifVAKmXDCJtHLd9ZTxfM5nLRDoIBocubkQTXP6eY4RcpjW15SgX JWPjDq6ckpAywzt1AvjXVSbLVtQiBbC2Q65Ul1S6wEUiAtEh0AC6SlYs76LqAZIJTOFz pCwFZKCr6U2jXqm0pVtFnF5honWghAJ2V5KFg4ZJMgqSKKuqHM9MdnvrLLvx13h1Hit8 vkgQ== 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=JEWlB+vb01n5HuMc8lzVnMTu2oDHzr5DfZ087w7HOPo=; fh=0XtxFfPJ0+h+th/1hGwweltSBJ4b8+b0QNNkHIMyCKE=; b=fhSNlvsUwJ2zng5bMDONy1H4VlbLmK/vcg61KBErAgR956Hd8gP9nIXfIOaXTj97nN CqSOcRllS9n3bWjCZZ7izHC6LjkLlD5m6EbK50nUuS+RCf72vBQ9pEVk7H5pabKcfkzb yAdZdoCiF0XkUAO9FwXALP8p8qe79fzXiE8wLcOmFmAypRvbMEmD7wxsrbkKGrQsijfM XqhKHTg2bqdf1ezdF+ckXju6vUa98fZTqDfjK3DYicg7o6y32zU9g2XoeqFSChYKNopl XYQL4FQRE/0Mw0GZuYXEYdV2exXrgoT8tTM0wHYHQGp0n7Rt1/6ygEpMZzkQaY9JlTQ8 f29Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=g2uLs8OA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id ng8-20020a17090b1a8800b0025eeb3cc4b2si9181037pjb.9.2023.09.18.15.10.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 15:10:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=g2uLs8OA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id B008481B4AF0; Mon, 18 Sep 2023 08:48:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229821AbjIRPsf (ORCPT + 25 others); Mon, 18 Sep 2023 11:48:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229751AbjIRPsc (ORCPT ); Mon, 18 Sep 2023 11:48:32 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93351CFC; Mon, 18 Sep 2023 08:46:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695051983; x=1726587983; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=s0vQPYCvTArOJ8UKcbPeJ71cltUHLof64ZzmndGbOp4=; b=g2uLs8OADS77SXqB3EuVJrEreMnzHFPTafxvzmdEL/C30iUp3zH7jq1d ABZ3Kgh5gdJWDrpY5cUPNAW0MC6MwehHgL8SJnJWsyivkRwisemiLfzRD JkRNPbicHlrpKkMhHoxPsPyTChaGYZWWo9+635t/DgCn0pxxUem/ScJGT 4SLlJpWs3qxKi0/KMeTdVUlZ787kIuyPnPSg8tREZhknRBZJx+ocIwy8D LwpMktM8zntgHLuDzWer72KmurJ5RX9+isF15HXWJoMsVjFIyeFEABBjp SRMTXuInJSNLU6fsVFUgEno8xmvLj+zQAa0qNs2pEZq25iAy6AzZxGniE Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="446113610" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="446113610" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:13:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="811343017" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="811343017" Received: from nprotaso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.49.156]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:13:39 -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 , linux-kernel@vger.kernel.org, Kalle Valo , Jeff Johnson , ath12k@lists.infradead.org, linux-wireless@vger.kernel.org Cc: ath10k@lists.infradead.org, ath11k@lists.infradead.org, intel-wired-lan@lists.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-bluetooth@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, =?utf-8?q?Ilpo_J=C3=A4r?= =?utf-8?q?vinen?= Subject: [PATCH v2 11/13] wifi: ath12k: Use pci_disable/enable_link_state() Date: Mon, 18 Sep 2023 16:11:01 +0300 Message-Id: <20230918131103.24119-12-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> References: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:48:52 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777414986633372343 X-GMAIL-MSGID: 1777414986633372343 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 Acked-by: Kalle Valo --- 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 fae5dfd6e9d7..9401f62476be 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 Mon Sep 18 13:11:02 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: 141682 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3116801vqi; Mon, 18 Sep 2023 21:03:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGXTy1cXWNZ4Q3dfnYrd87whmaWdUK1xTMag0OqtalJYbSF8v8P307UVF5GO3edIMP8kYw X-Received: by 2002:a17:90b:1193:b0:276:ae0f:57c0 with SMTP id gk19-20020a17090b119300b00276ae0f57c0mr44139pjb.19.1695096184341; Mon, 18 Sep 2023 21:03:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695096184; cv=none; d=google.com; s=arc-20160816; b=OJ+Dx4wc9L3qp/dDwGhSa6/t3i0e72R+KN18mq8fLsrqmLeILgiLkCzLWcsrPQA2zR tYo/Rmu13MjtNItaJ31ySlIkh4eih+puiBaki8qtmLjB0VUD5bDfWawJ4aUekwZ610QX sFc8JhzhIfzAaeersPOUn7anYbxBXrxpVFCdw9xidnPL8D/j6YgEfnNaSCdoJ5yCF5Eg qW/AKLVU5kZyVLUKtRb/ai+9GUyNODklk5vTt8IOTY8PEUwhtVTEowwUj8OSBjOf6Rph uzG4gIBKNnVF4WlyfXR0ogWE2LTbsH7V8alnpouGMV4oofuyzLium1Tk/51VeqTe1e1n iLQg== 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=qSGf2m7y21UFfyUOcYbqaO6jpD76DQ6RV61twHJZQNA=; fh=LxgcFpG5Hp/Lw8zxpggNFNRVoBPXT5GTsAbjG/Cq2eY=; b=HSHocLTbyN4s54l1cW+Jugd4sOZ+nV0tF6LPs/zTZ9ASSMaUyXilABYl/9PyZEvkqy FVtlM4GXmPETRVRZwLaXbe9NAytCGESsJwbQbp71fMm+TXV5rhN2sh6zQtXXnLdUbCWG JIt4QlKW623ya7FMscoOwk8W1Z0rORkpOKELdz7VVNd0YnOkSybbt0ToXrmKPodRSNAc wuaszHKdxIq5d0LUh0oHhiltjX9+M85SXtvx4ZlUbF3BNT2Ts96GcPqd66qt6Lkcd9I+ ALUdPzMuTB2lQUMnpnuvG52Y+eYvr4SBr3RnXHLrCP0WsMIYlbscRL8KFILWfr/Xci3/ M6dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JubL0SGD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id u5-20020a17090ae00500b0026806ed3fd8si9045794pjy.71.2023.09.18.21.03.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 21:03:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JubL0SGD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 8C6B6811F925; Mon, 18 Sep 2023 09:47:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230519AbjIRQqv (ORCPT + 25 others); Mon, 18 Sep 2023 12:46:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230310AbjIRQqb (ORCPT ); Mon, 18 Sep 2023 12:46:31 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D674A1FC9; Mon, 18 Sep 2023 09:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695053858; x=1726589858; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kDT+yWJAUHrBQ8ex5Uxk7tCrxharMirq80UQzoJeAvk=; b=JubL0SGD129feTlxJbpEtLUy5fAs6Exf+tYTFgooSXcczDpaAndTVc2O IF0Rux7dygTVLWBcC4nqidMxiFnC9c9tQTT7d/0L8LA6pH6wjY6QBCPt4 vfW9hx7c70IMqrxn6dvsW/jMsIbI77mMPrXEqzimjXBMRAH0wccmmY+b0 ljVmKf0zfF+ds94dkq8IEqhKersOT5Ic7MaP8L3ZF99+f5xWE8YLVQRQ2 mtUxcJiutcmG+YrkgBBt6b4bqxU2qPf0VtrarGrLJcyHzlajnCYICAAmf 4sOY5Oy5Ju7Rf1jzssP6IFHfna1L8EbF8G0neV4V4BgBdMppJOvGGBUfk A==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="446113624" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="446113624" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:13:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="811343130" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="811343130" Received: from nprotaso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.49.156]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:13:47 -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 , linux-kernel@vger.kernel.org, Dennis Dalessandro , Jason Gunthorpe , Leon Romanovsky , linux-rdma@vger.kernel.org Cc: ath10k@lists.infradead.org, ath11k@lists.infradead.org, ath12k@lists.infradead.org, intel-wired-lan@lists.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-bluetooth@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Dean Luick Subject: [PATCH v2 12/13] RDMA/hfi1: Use pci_disable/enable_link_state() Date: Mon, 18 Sep 2023 16:11:02 +0300 Message-Id: <20230918131103.24119-13-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> References: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 18 Sep 2023 09:47:01 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777437177050741465 X-GMAIL-MSGID: 1777437177050741465 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 Mon Sep 18 13:11:03 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: 141509 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2869114vqi; Mon, 18 Sep 2023 11:32:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGHoD9xHbM0x9m8qY1pqiaOvSE166aEM6S5anS5YvS4Mt/GH+M03exSJV8PYWFZ0jAa6wTn X-Received: by 2002:a17:902:ecc6:b0:1bd:c7e2:462 with SMTP id a6-20020a170902ecc600b001bdc7e20462mr8746045plh.11.1695061959688; Mon, 18 Sep 2023 11:32:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695061959; cv=none; d=google.com; s=arc-20160816; b=zMS6vtpfGbaHlmxRUNLc5C2tqZ0x+d9QUhZj4xpvQenAChkP8wgMsk2PzQPXotYQw7 2v5lsTCRQfSKJpbIOjEYABw5/DlhvoKNMasIaHxdTIdpIYwSiNsCMfOUijTosTbZdT5B eO4pYnkpFL+h+gahtVA/bi2EtLx00p4l4w8AeevzFzP5k2F7qWYgYzvTCyy4QttANWim LO+zGCdPDPUsbO9T5S1Km+VNEPuy0DUN+jC7aLFtqrjB641GMQ0BC/shCYvdzkV1MbT0 0wGIrVweeP75e2topdunNP5/ZSPUOz+3ZWkssUJSrfMxeElgTkpkh09hfRE0YBRI9NOR wcZw== 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=UCfLuylS5mlTJri5OrkWw39dG1L9JsgH5woxfhcXej4=; fh=V/jkFcPu7MmAy3MJPsn2heI/qTpS90GSlS8FQJiXILA=; b=TWkN15kaPii1ZyCe2ReQly6oJ3qHzZeVEKZPAeG9b082SUPtXXHuyIVpfsx2ORQpHQ TH0gKUjzNX14CJOrI4t1+JRdvDuthc1iago+xauMm/oRWrmbnI6n9WmannDbefTGPAbX Uwn9VTEyRbpFa0a8vyAMz/TB3u9Og6/J7q66l5NqJnhFN/3KHI1jyAmuoatNn59UEMBm 0rRG4FtwtOPSwQS1lW9HfK+lTYoGR0Dwng+nd5i5SN/xxzweMjrZFaCbVl2rHB+ta+PY vPJfUQGEMi8KZoJn6UK9urb7B8krpteJDq5dvfVutmpVaIgYlxaTPPPM0MfEsVPJKRfe fF7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NPsXbfSc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id q16-20020a170902dad000b001badbe8e441si2604856plx.106.2023.09.18.11.32.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 11:32:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NPsXbfSc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id C49DA81FADB3; Mon, 18 Sep 2023 09:32:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230230AbjIRQcf (ORCPT + 25 others); Mon, 18 Sep 2023 12:32:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230050AbjIRQcY (ORCPT ); Mon, 18 Sep 2023 12:32:24 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1236EF9; Mon, 18 Sep 2023 09:17:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695053862; x=1726589862; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/jlflr+zDO/ybJEIj9ZeNbSBAg1LjrmA0JjnTT6qqL0=; b=NPsXbfSc9IPT94hOIIrNw/67t2VR+JhPjuDVykOsCKaDlVXy2p+FMbTA GTb86C7h+BuEfgDYFoHleY31PYmFwn/JH8Z1iIw50IMRKQR1XxT7Sglow iO58ySRv3gMvX59UGQVNeZ+Lrwfv1wAJgTIAyuMJHMlJ+kDDHAXYTmBBR NLJh7geSMk+NKR69+b8rXsbggqJvVRD9Q4Wt3JQ0PtG6rj1NjBzMomEcZ xc3dogm5JFgKGATaztjOSUtj9IudJWsZFo5qGdP2p6+6QXGWpWWgYtBvc eBeG7AIRRca48GUX44UpUlqM7o9nm231xa//lVetXTgoWmsg+n4N4/B/F g==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="446113641" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="446113641" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:14:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="811343218" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="811343218" Received: from nprotaso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.49.156]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:13:54 -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 , linux-kernel@vger.kernel.org, Arnd Bergmann , Greg Kroah-Hartman Cc: ath10k@lists.infradead.org, ath11k@lists.infradead.org, ath12k@lists.infradead.org, intel-wired-lan@lists.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-bluetooth@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rdma@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, =?utf-8?q?Ilpo_J?= =?utf-8?q?=C3=A4rvinen?= Subject: [PATCH v2 13/13] misc: rtsx: Use pci_disable/enable_link_state() Date: Mon, 18 Sep 2023 16:11:03 +0300 Message-Id: <20230918131103.24119-14-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> References: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 18 Sep 2023 09:32:56 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777401289237477782 X-GMAIL-MSGID: 1777401289237477782 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 f4ab09439da7..8d3216c64ad1 100644 --- a/drivers/misc/cardreader/rts5228.c +++ b/drivers/misc/cardreader/rts5228.c @@ -497,8 +497,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; } @@ -509,8 +508,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 94af6bf8a25a..f1ef15683a2f 100644 --- a/drivers/misc/cardreader/rts5261.c +++ b/drivers/misc/cardreader/rts5261.c @@ -578,8 +578,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; } @@ -591,8 +590,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 a3f4b52bb159..6efb792152f2 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 |