Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Guixin Liu <kanie@linux.alibaba.com>
To: "Bjorn Helgaas" <bhelgaas@google.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Lukas Wunner" <lukas@wunner.de>, "Kees Cook" <kees@kernel.org>
Cc: linux-pci@vger.kernel.org, xlpang@linux.alibaba.com,
	oliver.yang@linux.alibaba.com
Subject: [PATCH v1 1/2] PCI/bwctrl: Add pci_bwctrl_available()
Date: Wed, 29 Jul 2026 11:45:04 +0800	[thread overview]
Message-ID: <20260729034505.469107-2-kanie@linux.alibaba.com> (raw)
In-Reply-To: <20260729034505.469107-1-kanie@linux.alibaba.com>

Enabling the PCIe bandwidth controller sets the Link Bandwidth Management
Interrupt Enable (LBMIE) and Link Autonomous Bandwidth Interrupt Enable
(LABIE) bits.  On some (typically old) platforms this has been observed to
cause boot hangs, e.g. commit 46a9f70e93ef ("PCI/bwctrl: Disable BW
controller on Intel P45 using a quirk") works around one such case with a
per-device quirk.

In preparation for a system-wide switch to turn the bandwidth controller
off, add pci_bwctrl_available() and pci_no_bwctrl(), mirroring
pci_aer_available()/pci_no_aer(), and consult the former when deciding
whether to enable PCIE_PORT_SERVICE_BWCTRL.

No functional change intended: the controller stays available by default.

Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
---
 drivers/pci/pci.h          |  4 ++++
 drivers/pci/pcie/bwctrl.c  | 12 ++++++++++++
 drivers/pci/pcie/portdrv.c |  3 ++-
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 4469e1a77f3c..7a1d4f624ed8 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -1121,8 +1121,12 @@ static inline void pcie_ecrc_get_policy(char *str) { }
 
 #ifdef CONFIG_PCIEPORTBUS
 void pcie_reset_lbms(struct pci_dev *port);
+void pci_no_bwctrl(void);
+bool pci_bwctrl_available(void);
 #else
 static inline void pcie_reset_lbms(struct pci_dev *port) {}
+static inline void pci_no_bwctrl(void) {}
+static inline bool pci_bwctrl_available(void) { return false; }
 #endif
 
 struct pci_dev_reset_methods {
diff --git a/drivers/pci/pcie/bwctrl.c b/drivers/pci/pcie/bwctrl.c
index c4c8d260bf96..947cb4b8697b 100644
--- a/drivers/pci/pcie/bwctrl.c
+++ b/drivers/pci/pcie/bwctrl.c
@@ -48,6 +48,18 @@ struct pcie_bwctrl_data {
 /* Prevent port removal during Link Speed changes. */
 static DECLARE_RWSEM(pcie_bwctrl_setspeed_rwsem);
 
+static bool pcie_bwctrl_disable;
+
+void pci_no_bwctrl(void)
+{
+	pcie_bwctrl_disable = true;
+}
+
+bool pci_bwctrl_available(void)
+{
+	return !pcie_bwctrl_disable;
+}
+
 static bool pcie_valid_speed(enum pci_bus_speed speed)
 {
 	return (speed >= PCIE_SPEED_2_5GT) && (speed <= PCIE_SPEED_64_0GT);
diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c
index 2d6aa488fe7b..e212c34f7f4a 100644
--- a/drivers/pci/pcie/portdrv.c
+++ b/drivers/pci/pcie/portdrv.c
@@ -274,7 +274,8 @@ static int get_port_device_capability(struct pci_dev *dev)
 
 		pcie_capability_read_dword(dev, PCI_EXP_LNKCAP, &linkcap);
 		if (linkcap & PCI_EXP_LNKCAP_LBNC &&
-		    hweight8(dev->supported_speeds) > 1)
+		    hweight8(dev->supported_speeds) > 1 &&
+		    pci_bwctrl_available())
 			services |= PCIE_PORT_SERVICE_BWCTRL;
 	}
 
-- 
2.43.7


  reply	other threads:[~2026-07-29  3:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29  3:45 [PATCH v1 0/2] PCI: Add pci=nobwctrl to disable the PCIe bandwidth controller Guixin Liu
2026-07-29  3:45 ` Guixin Liu [this message]
2026-07-29  3:52   ` [PATCH v1 1/2] PCI/bwctrl: Add pci_bwctrl_available() sashiko-bot
2026-07-29  3:45 ` [PATCH v1 2/2] PCI: Add pci=nobwctrl parameter to disable the PCIe bandwidth controller Guixin Liu
2026-07-29  3:50   ` sashiko-bot
2026-07-29  7:01 ` [PATCH v1 0/2] PCI: Add pci=nobwctrl " Lukas Wunner
2026-07-29  8:28   ` Guixin Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260729034505.469107-2-kanie@linux.alibaba.com \
    --to=kanie@linux.alibaba.com \
    --cc=bhelgaas@google.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jic23@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=oliver.yang@linux.alibaba.com \
    --cc=u.kleine-koenig@baylibre.com \
    --cc=xlpang@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox