From 0645e675ef9f33ff95f3dd6f2a94ce620e607bf8 Mon Sep 17 00:00:00 2001 From: MakiseKurisu Date: Tue, 11 Mar 2025 13:36:15 +0800 Subject: [PATCH 1/2] nixos/nvidia: update busIDType to correctly handle PCI bus domain There are real devices with 32-bit domain ID 0x10000, which needs 10 digits to represent at the worst case (0xffffffff): open-mpi/hwloc#354 Current test will deny those devices since the field was expecting a Bus ID, which is only 8-bit wide. Format: https://gitlab.freedesktop.org/xorg/xserver/-/blob/master/hw/xfree86/common/xf86pciBus.c#L263 Fixes: ce2e4707b782657e077a0ef072cbd67756cae673 --- nixos/modules/hardware/video/nvidia.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/hardware/video/nvidia.nix b/nixos/modules/hardware/video/nvidia.nix index eb2db48d6fcd..2d52d1e8b28f 100644 --- a/nixos/modules/hardware/video/nvidia.nix +++ b/nixos/modules/hardware/video/nvidia.nix @@ -17,7 +17,7 @@ let offloadCfg = pCfg.offload; reverseSyncCfg = pCfg.reverseSync; primeEnabled = syncCfg.enable || reverseSyncCfg.enable || offloadCfg.enable; - busIDType = lib.types.strMatching "([[:print:]]+[:@][0-9]{1,3}:[0-9]{1,2}:[0-9])?"; + busIDType = lib.types.strMatching "([[:print:]]+:[0-9]{1,3}(@[0-9]{1,10})?:[0-9]{1,2}:[0-9])?"; ibtSupport = useOpenModules || (nvidia_x11.ibtSupport or false); settingsFormat = pkgs.formats.keyValue { }; in From 72ffdcd4a6c11c44403318c6a60f7ebf519a68bb Mon Sep 17 00:00:00 2001 From: MakiseKurisu Date: Tue, 11 Mar 2025 13:41:34 +0800 Subject: [PATCH 2/2] nixos/nvidia: update description of BusIds for caveats --- nixos/modules/hardware/video/nvidia.nix | 30 ++++++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/nixos/modules/hardware/video/nvidia.nix b/nixos/modules/hardware/video/nvidia.nix index 2d52d1e8b28f..068e23aa3347 100644 --- a/nixos/modules/hardware/video/nvidia.nix +++ b/nixos/modules/hardware/video/nvidia.nix @@ -120,30 +120,48 @@ in prime.nvidiaBusId = lib.mkOption { type = busIDType; default = ""; - example = "PCI:1:0:0"; + example = "PCI:1@0:0:0"; description = '' Bus ID of the NVIDIA GPU. You can find it using lspci; for example if lspci - shows the NVIDIA GPU at "01:00.0", set this option to "PCI:1:0:0". + shows the NVIDIA GPU at "0001:02:03.4", set this option to "PCI:2@1:3:4". + + lspci might omit the PCI domain (0001 in above example) if it is zero. + In which case, use "@0" instead. + + Please be aware that this option takes decimal address while lspci reports + hexadecimal address. So for device at domain "10000", use "@65536". ''; }; prime.intelBusId = lib.mkOption { type = busIDType; default = ""; - example = "PCI:0:2:0"; + example = "PCI:0@0:2:0"; description = '' Bus ID of the Intel GPU. You can find it using lspci; for example if lspci - shows the Intel GPU at "00:02.0", set this option to "PCI:0:2:0". + shows the Intel GPU at "0001:02:03.4", set this option to "PCI:2@1:3:4". + + lspci might omit the PCI domain (0001 in above example) if it is zero. + In which case, use "@0" instead. + + Please be aware that this option takes decimal address while lspci reports + hexadecimal address. So for device at domain "10000", use "@65536". ''; }; prime.amdgpuBusId = lib.mkOption { type = busIDType; default = ""; - example = "PCI:4:0:0"; + example = "PCI:4@0:0:0"; description = '' Bus ID of the AMD APU. You can find it using lspci; for example if lspci - shows the AMD APU at "04:00.0", set this option to "PCI:4:0:0". + shows the AMD APU at "0001:02:03.4", set this option to "PCI:2@1:3:4". + + lspci might omit the PCI domain (0001 in above example) if it is zero. + In which case, use "@0" instead. + + Please be aware that this option takes decimal address while lspci reports + hexadecimal address. So for device at domain "10000", use "@65536". ''; };