From 48d70503bcae816eea6109c30ba79261eb47c9d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corvin=20K=C3=B6hne?= Date: Mon, 6 Feb 2023 09:26:33 +0000 Subject: [PATCH] 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 335c89423f2..92368f42608 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)