Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions kernel-open/conftest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4067,6 +4067,23 @@ compile_test() {
compile_check_conftest "$CODE" "NV_PCI_REBAR_GET_POSSIBLE_SIZES_PRESENT" "" "functions"
;;

pci_is_thunderbolt_attached)
#
# Determine if the pci_is_thunderbolt_attached() function is
# present.
#
# Added by commit 0d4ef7ce7e78 ("PCI: Identify Thunderbolt
# devices") in v4.15.
#
CODE="
#include <linux/pci.h>
void conftest_pci_is_thunderbolt_attached(void) {
pci_is_thunderbolt_attached();
}"

compile_check_conftest "$CODE" "NV_PCI_IS_THUNDERBOLT_ATTACHED_PRESENT" "" "functions"
;;

pci_resize_resource_has_exclude_bars_arg)
#
# Determine if pci_resize_resource() has exclude_bars argument.
Expand Down
34 changes: 31 additions & 3 deletions kernel-open/nvidia/nv-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,25 @@ static int nv_resize_pcie_bars(struct pci_dev *pci_dev) {
return 0;
}

#if defined(NV_PCI_IS_THUNDERBOLT_ATTACHED_PRESENT)
/*
* Thunderbolt / USB4 hotplug bridges have a small prefetchable MMIO
* window that cannot accommodate a GiB-scale resized BAR. Skip
* the resize attempt proactively rather than trying and failing,
* which avoids an uninformative -ENOENT in the kernel log and
* sidesteps the failure path entirely.
*/
if (pci_is_thunderbolt_attached(pci_dev))
{
nv_printf(NV_DBG_INFO,
"NVRM: %04x:%02x:%02x.%x: device is downstream of Thunderbolt, "
"skipping BAR1 resize\n",
NV_PCI_DOMAIN_NUMBER(pci_dev), NV_PCI_BUS_NUMBER(pci_dev),
NV_PCI_SLOT_NUMBER(pci_dev), PCI_FUNC(pci_dev->devfn));
return 0;
}
#endif

// Check if BAR1 has PCIe rebar capabilities
sizes = pci_rebar_get_possible_sizes(pci_dev, NV_GPU_BAR1);
if (sizes == 0) {
Expand Down Expand Up @@ -1949,9 +1968,18 @@ nv_pci_probe
goto err_zero_dev;

if (nv_resize_pcie_bars(pci_dev)) {
nv_printf(NV_DBG_ERRORS,
"NVRM: Fatal Error while attempting to resize PCIe BARs.\n");
goto err_zero_dev;
/*
* Resizable BAR is an enhancement, not a requirement. When
* the resize fails (commonly because the upstream bridge
* prefetchable window is too small to accommodate a GiB-scale
* BAR, as seen with Thunderbolt/USB4 hotplug bridges), the
* device is still functional with its existing BAR
* allocation. Do not turn a minor performance degradation
* into a hard probe failure -- log a warning and continue.
*/
nv_printf(NV_DBG_WARNINGS,
"NVRM: PCIe BAR resize failed; continuing with the existing "
"BAR allocation.\n");
}

nvl->all_mappings_revoked = NV_TRUE;
Expand Down
1 change: 1 addition & 0 deletions kernel-open/nvidia/nvidia.Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += pde_data
NV_CONFTEST_FUNCTION_COMPILE_TESTS += xen_ioemu_inject_msi
NV_CONFTEST_FUNCTION_COMPILE_TESTS += phys_to_dma
NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_rebar_get_possible_sizes
NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_is_thunderbolt_attached
NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_backlight_device_by_name
NV_CONFTEST_FUNCTION_COMPILE_TESTS += dma_direct_map_resource
NV_CONFTEST_FUNCTION_COMPILE_TESTS += flush_cache_all
Expand Down