From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 471B8CDB47E for ; Thu, 12 Oct 2023 10:56:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:Message-ID:In-Reply-To:Subject:cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kmelHjV370btKzhShHD7UypycpYrAvbT3Onv+R38R3E=; b=Zy35d+lPcLA6ocwP6BxRRnDKt0 RAMNKqmNnhxVvq22Pm/hW/9bSPikL0/I+3X3fPrbWbTTTE3sdvxTKk1+sgwduJCXgx5bJKyhXB5hT cj1ZP/9F7V99K+wfcoS8CqSoNqSYZZwEh7pd16Ms0rVTU69Cd3qHNkW1QkZ+e4noyy0ntiJMyo8lN QuQ6pKjk0NmrW7BYCQjmXge3V08hBtsmd0jpwGJQk0NSG4qZ5hSJFsgXtRyUnb6894yjXASLpEVHv fNE2gxSzmps+24mgoqMfmy2vMBU3TF2IYDNdk8hFqi/m9p6E2vUeF3gMP5OGsRVyO7uJ1eNyCu5xo xFQ4XHIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qqtMi-000iJh-0L; Thu, 12 Oct 2023 10:56:28 +0000 Received: from mgamail.intel.com ([198.175.65.9]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qqtMf-000iIz-2V; Thu, 12 Oct 2023 10:56:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697108186; x=1728644186; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=ncUYHUPUudbeDBu1X+DbOYSPV06JH2dv47rcK32PQ+0=; b=XbQ5cHut39GU+sCjyTF1Uyy+KgtcMhRoY1HUoC9XZg3r12SlRW925fFy S1t7OwiuLk4TWK56G6Os1JYg9OdvD9N3UCwWnIZ1xH2jzDFQYlivXEBBt fB0AMwYiAyurcIiViHKoXzt7J8UGCnbVi6SzzEUTMcDRckPYmR+w/DyXk 9+LufoCXMoIy/yj/d6X5nA0G1xroQk/t2k65XWejEoSHhZTigRwnfyIMF nb4DbpA4/iq/AwOEpcfQ8fLY0KTbTwTuc6+9yVGLKIaOagJ14ADfHKOHc szZ8rsDSrWpexuHCfrZvjbXChKiG/QFdrQH35abmrlyqDZ5ekRdAbDJj9 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3483262" X-IronPort-AV: E=Sophos;i="6.03,218,1694761200"; d="scan'208";a="3483262" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 03:56:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="789349717" X-IronPort-AV: E=Sophos;i="6.03,218,1694761200"; d="scan'208";a="789349717" Received: from asroczyn-mobl.ger.corp.intel.com ([10.249.36.107]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 03:56:18 -0700 Date: Thu, 12 Oct 2023 13:56:16 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Bjorn Helgaas , "Rafael J . Wysocki" cc: linux-pci@vger.kernel.org, Lorenzo Pieralisi , Rob Herring , =?ISO-8859-2?Q?Krzysztof_Wilczy=F1ski?= , Lukas Wunner , Heiner Kallweit , Emmanuel Grumbach , LKML , Bjorn Helgaas , 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 Subject: Re: [PATCH v2 03/13] PCI/ASPM: Disable ASPM when driver requests it In-Reply-To: <20231011212206.GA1043224@bhelgaas> Message-ID: References: <20231011212206.GA1043224@bhelgaas> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1326969328-1697108183=:1692" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231012_035625_857241_2BEE7D57 X-CRM114-Status: GOOD ( 32.27 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "ath10k" Errors-To: ath10k-bounces+ath10k=archiver.kernel.org@lists.infradead.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1326969328-1697108183=:1692 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Wed, 11 Oct 2023, Bjorn Helgaas wrote: > On Mon, Sep 18, 2023 at 04:10:53PM +0300, Ilpo Järvinen wrote: > > 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. > > ... > > > +#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; > > P.S. I think this should look the same to the user (same dmesg log and > same taint, if we do that) as the CONFIG_PCIEASPM=y case. Okay. > > + 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); > > This disables *all* ASPM states, unlike the version when > CONFIG_PCIEASPM is enabled. I suppose there's a reason, and maybe a > comment could elaborate on it? > > When CONFIG_PCIEASPM is not enabled, I don't think we actively > *disable* ASPM in the hardware; we just leave it as-is, so firmware > might have left it enabled. This whole trickery is intended for drivers that do not want to have ASPM because the devices are broken with it. So leaving it as-is is not really an option (as demonstrated by the custom workarounds). > > + > > + return 0; > > +} > > Conceptually it seems like the LNKCTL updates here should be the same > whether CONFIG_PCIEASPM is enabled or not (subject to the question > above). > > When CONFIG_PCIEASPM is enabled, we might need to do more stuff, but > it seems like the core should be the same. So you think it's safer to partially disable ASPM (as per driver's request) rather than disable it completely? I got the impression that the latter might be safer from what Rafael said earlier but I suppose I might have misinterpreted him since he didn't exactly say that it might be safer to _completely_ disable it. -- i. --8323329-1326969328-1697108183=:1692 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ath10k mailing list ath10k@lists.infradead.org http://lists.infradead.org/mailman/listinfo/ath10k --8323329-1326969328-1697108183=:1692-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 29A8CCDB46E for ; Thu, 12 Oct 2023 10:56:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:Message-ID:In-Reply-To:Subject:cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=x5eJBLHYFlYo9z/YmcgniU/xpzhGLzPajjzLIs28x4s=; b=z2Ckipympc705FIMsiSsXlKkA9 0Wu4qRA5KkTgHKbU8k8nluLDP7hPl2fS1JALksv1hrbkcIa6Ztw5V8zFqVET97726Qbs7rwYLcH/2 82DFCzUjKfeX9PB510eZ+BX6ewWgX3h8hhmDf/x5jINuPZe3qKF8gpYl0B0/wPWswdCoNltp/5vdI w6jieLjDlsGjDXr+z0UxlFUQAUUXzvSQVFtzLg+2FhqtBBtyNR7dkTmleewoqvzB/4zyRm5hcwT9R mhrG1XE1lyJu8MonEhIbzdhNE9Pc9kramtUjRZkTTadTP7AvUVqUwIdJmj+KenNh3rlpdPaUiI4qs Es59vYLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qqtMk-000iKU-0D; Thu, 12 Oct 2023 10:56:30 +0000 Received: from mgamail.intel.com ([198.175.65.9]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qqtMf-000iIz-2V; Thu, 12 Oct 2023 10:56:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697108186; x=1728644186; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=ncUYHUPUudbeDBu1X+DbOYSPV06JH2dv47rcK32PQ+0=; b=XbQ5cHut39GU+sCjyTF1Uyy+KgtcMhRoY1HUoC9XZg3r12SlRW925fFy S1t7OwiuLk4TWK56G6Os1JYg9OdvD9N3UCwWnIZ1xH2jzDFQYlivXEBBt fB0AMwYiAyurcIiViHKoXzt7J8UGCnbVi6SzzEUTMcDRckPYmR+w/DyXk 9+LufoCXMoIy/yj/d6X5nA0G1xroQk/t2k65XWejEoSHhZTigRwnfyIMF nb4DbpA4/iq/AwOEpcfQ8fLY0KTbTwTuc6+9yVGLKIaOagJ14ADfHKOHc szZ8rsDSrWpexuHCfrZvjbXChKiG/QFdrQH35abmrlyqDZ5ekRdAbDJj9 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3483262" X-IronPort-AV: E=Sophos;i="6.03,218,1694761200"; d="scan'208";a="3483262" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 03:56:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="789349717" X-IronPort-AV: E=Sophos;i="6.03,218,1694761200"; d="scan'208";a="789349717" Received: from asroczyn-mobl.ger.corp.intel.com ([10.249.36.107]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 03:56:18 -0700 Date: Thu, 12 Oct 2023 13:56:16 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Bjorn Helgaas , "Rafael J . Wysocki" cc: linux-pci@vger.kernel.org, Lorenzo Pieralisi , Rob Herring , =?ISO-8859-2?Q?Krzysztof_Wilczy=F1ski?= , Lukas Wunner , Heiner Kallweit , Emmanuel Grumbach , LKML , Bjorn Helgaas , 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 Subject: Re: [PATCH v2 03/13] PCI/ASPM: Disable ASPM when driver requests it In-Reply-To: <20231011212206.GA1043224@bhelgaas> Message-ID: References: <20231011212206.GA1043224@bhelgaas> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1326969328-1697108183=:1692" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231012_035625_857241_2BEE7D57 X-CRM114-Status: GOOD ( 32.27 ) X-BeenThere: ath11k@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "ath11k" Errors-To: ath11k-bounces+ath11k=archiver.kernel.org@lists.infradead.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1326969328-1697108183=:1692 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Wed, 11 Oct 2023, Bjorn Helgaas wrote: > On Mon, Sep 18, 2023 at 04:10:53PM +0300, Ilpo Järvinen wrote: > > 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. > > ... > > > +#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; > > P.S. I think this should look the same to the user (same dmesg log and > same taint, if we do that) as the CONFIG_PCIEASPM=y case. Okay. > > + 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); > > This disables *all* ASPM states, unlike the version when > CONFIG_PCIEASPM is enabled. I suppose there's a reason, and maybe a > comment could elaborate on it? > > When CONFIG_PCIEASPM is not enabled, I don't think we actively > *disable* ASPM in the hardware; we just leave it as-is, so firmware > might have left it enabled. This whole trickery is intended for drivers that do not want to have ASPM because the devices are broken with it. So leaving it as-is is not really an option (as demonstrated by the custom workarounds). > > + > > + return 0; > > +} > > Conceptually it seems like the LNKCTL updates here should be the same > whether CONFIG_PCIEASPM is enabled or not (subject to the question > above). > > When CONFIG_PCIEASPM is enabled, we might need to do more stuff, but > it seems like the core should be the same. So you think it's safer to partially disable ASPM (as per driver's request) rather than disable it completely? I got the impression that the latter might be safer from what Rafael said earlier but I suppose I might have misinterpreted him since he didn't exactly say that it might be safer to _completely_ disable it. -- i. --8323329-1326969328-1697108183=:1692 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- ath11k mailing list ath11k@lists.infradead.org http://lists.infradead.org/mailman/listinfo/ath11k --8323329-1326969328-1697108183=:1692-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 051EACDB46E for ; Thu, 12 Oct 2023 10:56:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:Message-ID:In-Reply-To:Subject:cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=J4ZJLqdPsxXUpBQU5XMvfCGOzwGP0j+sY0P+HaEA1YI=; b=v86hBHsPWzYP3LNOg6BQpclpeI aQeWnEP5eLjo7PMwJa7XCb5lzcvQWauwO1e/UQKHlXt4W8J71EGjgDXTAGQ5P9pf/hasHmWESNUfO ONZsw/EPjBpjru6S1+papJJwz1cYY2u1pNI+qrbz7hoMdfCWV5dmW1x55TaZw//h8nTem/rC8wz7v Drzfa3LvoXBLNcjt4i+7QOta0i4EwPLrrlh3+7B0ujMQ9kTfNts4hf3rTo0TyGQEFzC6dCtu3KL5I mZpJ7yO146oUri58x5dnHQk2fkCk7Dl+QkXChnDt7e1CPIQnwMx0N3w2Sah+nYvwDVJJzPB0Tw/aY P9WatJZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qqtMi-000iJq-1y for ath12k@archiver.kernel.org; Thu, 12 Oct 2023 10:56:28 +0000 Received: from mgamail.intel.com ([198.175.65.9]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qqtMf-000iIz-2V; Thu, 12 Oct 2023 10:56:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697108186; x=1728644186; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=ncUYHUPUudbeDBu1X+DbOYSPV06JH2dv47rcK32PQ+0=; b=XbQ5cHut39GU+sCjyTF1Uyy+KgtcMhRoY1HUoC9XZg3r12SlRW925fFy S1t7OwiuLk4TWK56G6Os1JYg9OdvD9N3UCwWnIZ1xH2jzDFQYlivXEBBt fB0AMwYiAyurcIiViHKoXzt7J8UGCnbVi6SzzEUTMcDRckPYmR+w/DyXk 9+LufoCXMoIy/yj/d6X5nA0G1xroQk/t2k65XWejEoSHhZTigRwnfyIMF nb4DbpA4/iq/AwOEpcfQ8fLY0KTbTwTuc6+9yVGLKIaOagJ14ADfHKOHc szZ8rsDSrWpexuHCfrZvjbXChKiG/QFdrQH35abmrlyqDZ5ekRdAbDJj9 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3483262" X-IronPort-AV: E=Sophos;i="6.03,218,1694761200"; d="scan'208";a="3483262" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 03:56:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="789349717" X-IronPort-AV: E=Sophos;i="6.03,218,1694761200"; d="scan'208";a="789349717" Received: from asroczyn-mobl.ger.corp.intel.com ([10.249.36.107]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 03:56:18 -0700 Date: Thu, 12 Oct 2023 13:56:16 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Bjorn Helgaas , "Rafael J . Wysocki" cc: linux-pci@vger.kernel.org, Lorenzo Pieralisi , Rob Herring , =?ISO-8859-2?Q?Krzysztof_Wilczy=F1ski?= , Lukas Wunner , Heiner Kallweit , Emmanuel Grumbach , LKML , Bjorn Helgaas , 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 Subject: Re: [PATCH v2 03/13] PCI/ASPM: Disable ASPM when driver requests it In-Reply-To: <20231011212206.GA1043224@bhelgaas> Message-ID: References: <20231011212206.GA1043224@bhelgaas> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1326969328-1697108183=:1692" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231012_035625_857241_2BEE7D57 X-CRM114-Status: GOOD ( 32.27 ) X-BeenThere: ath12k@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "ath12k" Errors-To: ath12k-bounces+ath12k=archiver.kernel.org@lists.infradead.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1326969328-1697108183=:1692 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Wed, 11 Oct 2023, Bjorn Helgaas wrote: > On Mon, Sep 18, 2023 at 04:10:53PM +0300, Ilpo Järvinen wrote: > > 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. > > ... > > > +#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; > > P.S. I think this should look the same to the user (same dmesg log and > same taint, if we do that) as the CONFIG_PCIEASPM=y case. Okay. > > + 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); > > This disables *all* ASPM states, unlike the version when > CONFIG_PCIEASPM is enabled. I suppose there's a reason, and maybe a > comment could elaborate on it? > > When CONFIG_PCIEASPM is not enabled, I don't think we actively > *disable* ASPM in the hardware; we just leave it as-is, so firmware > might have left it enabled. This whole trickery is intended for drivers that do not want to have ASPM because the devices are broken with it. So leaving it as-is is not really an option (as demonstrated by the custom workarounds). > > + > > + return 0; > > +} > > Conceptually it seems like the LNKCTL updates here should be the same > whether CONFIG_PCIEASPM is enabled or not (subject to the question > above). > > When CONFIG_PCIEASPM is enabled, we might need to do more stuff, but > it seems like the core should be the same. So you think it's safer to partially disable ASPM (as per driver's request) rather than disable it completely? I got the impression that the latter might be safer from what Rafael said earlier but I suppose I might have misinterpreted him since he didn't exactly say that it might be safer to _completely_ disable it. -- i. --8323329-1326969328-1697108183=:1692 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- ath12k mailing list ath12k@lists.infradead.org https://lists.infradead.org/mailman/listinfo/ath12k --8323329-1326969328-1697108183=:1692-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 48B9DCDB46E for ; Thu, 12 Oct 2023 19:09:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 0A6436133C; Thu, 12 Oct 2023 19:09:07 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 0A6436133C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1697137747; bh=AtmMTWEEE9/TjsHVJ+mts8acOpITqsMyD+NiGZZj5HM=; h=Date:From:To:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=Re/9b+icnyMZ0PL05fOyYrIzJucVuSwJzOjVp7kyHoKvURhH6MbZUJczKpD/C7rWQ aKJVJMAFVG02RV2GDG3ujuI5X699CnKT5I2BJH+39CuZBIiIxfGAeytlxiZ6XrOhQB YZRLvrxwNTkZAtZfOI2b4v4R+vaVNwG+xaiYe8sDoliqJeIUxZvrCULCJa+lp9O1dA mpUq5P2s5j3ov1KUwvf8dSSzZRJC6ek9YuXdTxLQd68o4HosPrTo/Fd/ub1fcs/Qcs WyTv+S3Lle4wN7JWgpgYQT2Ax2CuKKrc2Ku2NqTfls8McLas85ssUdFHicd3Oh/vrE BfsnhxWODmGrQ== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P4LC0p-9jcIY; Thu, 12 Oct 2023 19:09:05 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id C424B61341; Thu, 12 Oct 2023 19:09:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org C424B61341 Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 627F41BF2B9 for ; Thu, 12 Oct 2023 10:56:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 39BD5405FA for ; Thu, 12 Oct 2023 10:56:25 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 39BD5405FA X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Qqc-S3NfW2j8 for ; Thu, 12 Oct 2023 10:56:24 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by smtp2.osuosl.org (Postfix) with ESMTPS id 727D7404B9 for ; Thu, 12 Oct 2023 10:56:24 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 727D7404B9 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3483258" X-IronPort-AV: E=Sophos;i="6.03,218,1694761200"; d="scan'208";a="3483258" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 03:56:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="789349717" X-IronPort-AV: E=Sophos;i="6.03,218,1694761200"; d="scan'208";a="789349717" Received: from asroczyn-mobl.ger.corp.intel.com ([10.249.36.107]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 03:56:18 -0700 Date: Thu, 12 Oct 2023 13:56:16 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Bjorn Helgaas , "Rafael J . Wysocki" In-Reply-To: <20231011212206.GA1043224@bhelgaas> Message-ID: References: <20231011212206.GA1043224@bhelgaas> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1326969328-1697108183=:1692" X-Mailman-Approved-At: Thu, 12 Oct 2023 19:06:39 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697108185; x=1728644185; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=ncUYHUPUudbeDBu1X+DbOYSPV06JH2dv47rcK32PQ+0=; b=CYclsOvOPtH3Q8m1wMMmDYUHx/L6vQrIQRlGlDiTpobaSJ/SD8nZa1yQ lmY9YqnctCNWpDlmbqOQfO8u3cwjxe1sBLbcfgWfX7nJ+ZrNDZ4y23gAX HbkMANv6j4C80UF4fY2QznF81/dmYLkDw/KG2IiTPs7jbdaRuZ4TdQFxh wlLZwCWV8LmydShMWfIj8HsKLUGGxyKHhIL2h8Yd4USZuVsQsWxWUShau izP+1118O9PObYimo3ulINXAXq9pIBJWoqzKEwS/rGrv3vJAdEgdjHiSQ VeVAmvpuDHBN7XAu6gEJd7JD4Cb/HMGDGmdPiPIXwKpyDJUTvWKLeg2qw g==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=CYclsOvO Subject: Re: [Intel-wired-lan] [PATCH v2 03/13] PCI/ASPM: Disable ASPM when driver requests it X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?ISO-8859-2?Q?Krzysztof_Wilczy=F1ski?= , linux-rdma@vger.kernel.org, Lorenzo Pieralisi , Rob Herring , ath12k@lists.infradead.org, linux-pci@vger.kernel.org, linux-wireless@vger.kernel.org, LKML , ath10k@lists.infradead.org, Emmanuel Grumbach , linux-bluetooth@vger.kernel.org, Lukas Wunner , intel-wired-lan@lists.osuosl.org, Netdev , Bjorn Helgaas , linux-mediatek@lists.infradead.org, ath11k@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Heiner Kallweit Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1326969328-1697108183=:1692 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Wed, 11 Oct 2023, Bjorn Helgaas wrote: > On Mon, Sep 18, 2023 at 04:10:53PM +0300, Ilpo Järvinen wrote: > > 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. > > ... > > > +#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; > > P.S. I think this should look the same to the user (same dmesg log and > same taint, if we do that) as the CONFIG_PCIEASPM=y case. Okay. > > + 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); > > This disables *all* ASPM states, unlike the version when > CONFIG_PCIEASPM is enabled. I suppose there's a reason, and maybe a > comment could elaborate on it? > > When CONFIG_PCIEASPM is not enabled, I don't think we actively > *disable* ASPM in the hardware; we just leave it as-is, so firmware > might have left it enabled. This whole trickery is intended for drivers that do not want to have ASPM because the devices are broken with it. So leaving it as-is is not really an option (as demonstrated by the custom workarounds). > > + > > + return 0; > > +} > > Conceptually it seems like the LNKCTL updates here should be the same > whether CONFIG_PCIEASPM is enabled or not (subject to the question > above). > > When CONFIG_PCIEASPM is enabled, we might need to do more stuff, but > it seems like the core should be the same. So you think it's safer to partially disable ASPM (as per driver's request) rather than disable it completely? I got the impression that the latter might be safer from what Rafael said earlier but I suppose I might have misinterpreted him since he didn't exactly say that it might be safer to _completely_ disable it. -- i. --8323329-1326969328-1697108183=:1692 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan --8323329-1326969328-1697108183=:1692-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B67D7C41513 for ; Thu, 12 Oct 2023 10:56:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343649AbjJLK4b (ORCPT ); Thu, 12 Oct 2023 06:56:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235696AbjJLK40 (ORCPT ); Thu, 12 Oct 2023 06:56:26 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E182CF; Thu, 12 Oct 2023 03:56: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=1697108185; x=1728644185; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=ncUYHUPUudbeDBu1X+DbOYSPV06JH2dv47rcK32PQ+0=; b=CYclsOvOPtH3Q8m1wMMmDYUHx/L6vQrIQRlGlDiTpobaSJ/SD8nZa1yQ lmY9YqnctCNWpDlmbqOQfO8u3cwjxe1sBLbcfgWfX7nJ+ZrNDZ4y23gAX HbkMANv6j4C80UF4fY2QznF81/dmYLkDw/KG2IiTPs7jbdaRuZ4TdQFxh wlLZwCWV8LmydShMWfIj8HsKLUGGxyKHhIL2h8Yd4USZuVsQsWxWUShau izP+1118O9PObYimo3ulINXAXq9pIBJWoqzKEwS/rGrv3vJAdEgdjHiSQ VeVAmvpuDHBN7XAu6gEJd7JD4Cb/HMGDGmdPiPIXwKpyDJUTvWKLeg2qw g==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3483256" X-IronPort-AV: E=Sophos;i="6.03,218,1694761200"; d="scan'208";a="3483256" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 03:56:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="789349717" X-IronPort-AV: E=Sophos;i="6.03,218,1694761200"; d="scan'208";a="789349717" Received: from asroczyn-mobl.ger.corp.intel.com ([10.249.36.107]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 03:56:18 -0700 Date: Thu, 12 Oct 2023 13:56:16 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Bjorn Helgaas , "Rafael J . Wysocki" cc: linux-pci@vger.kernel.org, Lorenzo Pieralisi , Rob Herring , =?ISO-8859-2?Q?Krzysztof_Wilczy=F1ski?= , Lukas Wunner , Heiner Kallweit , Emmanuel Grumbach , LKML , Bjorn Helgaas , 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 Subject: Re: [PATCH v2 03/13] PCI/ASPM: Disable ASPM when driver requests it In-Reply-To: <20231011212206.GA1043224@bhelgaas> Message-ID: References: <20231011212206.GA1043224@bhelgaas> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1326969328-1697108183=:1692" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1326969328-1697108183=:1692 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Wed, 11 Oct 2023, Bjorn Helgaas wrote: > On Mon, Sep 18, 2023 at 04:10:53PM +0300, Ilpo Järvinen wrote: > > 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. > > ... > > > +#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; > > P.S. I think this should look the same to the user (same dmesg log and > same taint, if we do that) as the CONFIG_PCIEASPM=y case. Okay. > > + 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); > > This disables *all* ASPM states, unlike the version when > CONFIG_PCIEASPM is enabled. I suppose there's a reason, and maybe a > comment could elaborate on it? > > When CONFIG_PCIEASPM is not enabled, I don't think we actively > *disable* ASPM in the hardware; we just leave it as-is, so firmware > might have left it enabled. This whole trickery is intended for drivers that do not want to have ASPM because the devices are broken with it. So leaving it as-is is not really an option (as demonstrated by the custom workarounds). > > + > > + return 0; > > +} > > Conceptually it seems like the LNKCTL updates here should be the same > whether CONFIG_PCIEASPM is enabled or not (subject to the question > above). > > When CONFIG_PCIEASPM is enabled, we might need to do more stuff, but > it seems like the core should be the same. So you think it's safer to partially disable ASPM (as per driver's request) rather than disable it completely? I got the impression that the latter might be safer from what Rafael said earlier but I suppose I might have misinterpreted him since he didn't exactly say that it might be safer to _completely_ disable it. -- i. --8323329-1326969328-1697108183=:1692-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 12B87CDB47E for ; Thu, 12 Oct 2023 10:56:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:Message-ID:In-Reply-To:Subject:cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CuSx4n4TI3AXSppt91DtRy2kdHLdrD5rtb3gui73cvg=; b=uAdysgT7ZTGkVN0uwV108cX9t8 oDM/Z1bImygabKmu19aUji3CtPEfhWFT/c6lV5gg7fsvyub+cNsy241ggp9I/bTEYl2KKSbDT3CJ7 rEI8TK4lPhUCfve+7K/g6vKQ2fd9gSinhVJDW9JTgvHlQqtIOaoAF35zopsdbMWE0VgdBuyksAfsj kiJ3PbUpKE6AhUkkJ+Eb7zUt6eIDpLZUx9XPc2VLTqDDfhi0dBpZTCagyVNL4hRTnbYU7mfF1xSQE vRCBz0WFrBGYNRz0/gJseASAa0BO8dhX3lzRpiwwLwbt8YoOyfY1zeM9oimWLvOCKqxqDxo3z4EnU JkPqoDLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qqtMj-000iK0-0B; Thu, 12 Oct 2023 10:56:29 +0000 Received: from mgamail.intel.com ([198.175.65.9]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qqtMf-000iIz-2V; Thu, 12 Oct 2023 10:56:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697108186; x=1728644186; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=ncUYHUPUudbeDBu1X+DbOYSPV06JH2dv47rcK32PQ+0=; b=XbQ5cHut39GU+sCjyTF1Uyy+KgtcMhRoY1HUoC9XZg3r12SlRW925fFy S1t7OwiuLk4TWK56G6Os1JYg9OdvD9N3UCwWnIZ1xH2jzDFQYlivXEBBt fB0AMwYiAyurcIiViHKoXzt7J8UGCnbVi6SzzEUTMcDRckPYmR+w/DyXk 9+LufoCXMoIy/yj/d6X5nA0G1xroQk/t2k65XWejEoSHhZTigRwnfyIMF nb4DbpA4/iq/AwOEpcfQ8fLY0KTbTwTuc6+9yVGLKIaOagJ14ADfHKOHc szZ8rsDSrWpexuHCfrZvjbXChKiG/QFdrQH35abmrlyqDZ5ekRdAbDJj9 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3483262" X-IronPort-AV: E=Sophos;i="6.03,218,1694761200"; d="scan'208";a="3483262" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 03:56:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="789349717" X-IronPort-AV: E=Sophos;i="6.03,218,1694761200"; d="scan'208";a="789349717" Received: from asroczyn-mobl.ger.corp.intel.com ([10.249.36.107]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 03:56:18 -0700 Date: Thu, 12 Oct 2023 13:56:16 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Bjorn Helgaas , "Rafael J . Wysocki" cc: linux-pci@vger.kernel.org, Lorenzo Pieralisi , Rob Herring , =?ISO-8859-2?Q?Krzysztof_Wilczy=F1ski?= , Lukas Wunner , Heiner Kallweit , Emmanuel Grumbach , LKML , Bjorn Helgaas , 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 Subject: Re: [PATCH v2 03/13] PCI/ASPM: Disable ASPM when driver requests it In-Reply-To: <20231011212206.GA1043224@bhelgaas> Message-ID: References: <20231011212206.GA1043224@bhelgaas> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1326969328-1697108183=:1692" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231012_035625_857241_2BEE7D57 X-CRM114-Status: GOOD ( 32.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1326969328-1697108183=:1692 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Wed, 11 Oct 2023, Bjorn Helgaas wrote: > On Mon, Sep 18, 2023 at 04:10:53PM +0300, Ilpo Järvinen wrote: > > 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. > > ... > > > +#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; > > P.S. I think this should look the same to the user (same dmesg log and > same taint, if we do that) as the CONFIG_PCIEASPM=y case. Okay. > > + 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); > > This disables *all* ASPM states, unlike the version when > CONFIG_PCIEASPM is enabled. I suppose there's a reason, and maybe a > comment could elaborate on it? > > When CONFIG_PCIEASPM is not enabled, I don't think we actively > *disable* ASPM in the hardware; we just leave it as-is, so firmware > might have left it enabled. This whole trickery is intended for drivers that do not want to have ASPM because the devices are broken with it. So leaving it as-is is not really an option (as demonstrated by the custom workarounds). > > + > > + return 0; > > +} > > Conceptually it seems like the LNKCTL updates here should be the same > whether CONFIG_PCIEASPM is enabled or not (subject to the question > above). > > When CONFIG_PCIEASPM is enabled, we might need to do more stuff, but > it seems like the core should be the same. So you think it's safer to partially disable ASPM (as per driver's request) rather than disable it completely? I got the impression that the latter might be safer from what Rafael said earlier but I suppose I might have misinterpreted him since he didn't exactly say that it might be safer to _completely_ disable it. -- i. --8323329-1326969328-1697108183=:1692 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --8323329-1326969328-1697108183=:1692--