git: 48d70503bcae - main - pci: add tunable hw.pci.enable_mps_tune

From: Corvin Köhne <corvink_at_FreeBSD.org>
Date: Mon, 27 Mar 2023 09:28:33 UTC
The branch main has been updated by corvink:

URL: https://cgit.FreeBSD.org/src/commit/?id=48d70503bcae816eea6109c30ba79261eb47c9d0

commit 48d70503bcae816eea6109c30ba79261eb47c9d0
Author:     Corvin Köhne <corvink@FreeBSD.org>
AuthorDate: 2023-02-06 09:26:33 +0000
Commit:     Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2023-03-27 09:28:27 +0000

    pci: add tunable hw.pci.enable_mps_tune
    
    If the tunable is set to 0, the tuning of the MPS (maximum payload size)
    is disabled and the default MPS values set by the BIOS are used. In this
    case the system may use a lower speed or operate in a less optimized
    state, but it can resolve issues with stability and compatibility. With
    specific devices the tuning of the mps, can lead to a complete freeze of
    the system.
    
    Reviewed by:            manu
    MFC after:              1 week
    Sponsored by:           Beckhoff Automation GmbH & Co. KG
    Differential Revision:  https://reviews.freebsd.org/D38397
---
 sys/dev/pci/pci.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index 335c89423f24..92368f42608b 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -420,6 +420,11 @@ SYSCTL_INT(_hw_pci, OID_AUTO, clear_aer_on_attach, CTLFLAG_RWTUN,
     &pci_clear_aer_on_attach, 0,
     "Clear port and device AER state on driver attach");
 
+static bool pci_enable_mps_tune = true;
+SYSCTL_BOOL(_hw_pci, OID_AUTO, enable_mps_tune, CTLFLAG_RWTUN,
+    &pci_enable_mps_tune, 1,
+    "Enable tuning of MPS(maximum payload size)." );
+
 static int
 pci_has_quirk(uint32_t devid, int quirk)
 {
@@ -4452,7 +4457,8 @@ pci_add_child(device_t bus, struct pci_devinfo *dinfo)
 	pci_cfg_restore(dev, dinfo);
 	pci_print_verbose(dinfo);
 	pci_add_resources(bus, dev, 0, 0);
-	pcie_setup_mps(dev);
+	if (pci_enable_mps_tune)
+		pcie_setup_mps(dev);
 	pci_child_added(dinfo->cfg.dev);
 
 	if (pci_clear_aer_on_attach)