Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix PCI address in filepath for graphics cards #408

Merged
merged 1 commit into from
Mar 11, 2025
Merged

fix PCI address in filepath for graphics cards #408

merged 1 commit into from
Mar 11, 2025

Conversation

jaypipes
Copy link
Owner

@jaypipes jaypipes commented Mar 9, 2025

Ensure we take only the last PCI address in the /sys/class/drm sysfs output as the PCI Address of the graphics card. For some graphics cards, they are on a PCI bridge or host bus adapter that was erroneously being identified as the PCI Address of the graphics card itself.

Consider this ll /sys/class/drm output on one of my workstations:

lrwxrwxrwx 1 root root    0 Mar  9 17:57 card0 -> ../../devices/pci0000:00/0000:00:02.0/drm/card0
lrwxrwxrwx 1 root root    0 Mar  9 17:57 card0-DP-1 -> ../../devices/pci0000:00/0000:00:02.0/drm/card0/card0-DP-1
lrwxrwxrwx 1 root root    0 Mar  9 17:57 card0-HDMI-A-1 -> ../../devices/pci0000:00/0000:00:02.0/drm/card0/card0-HDMI-A-1
lrwxrwxrwx 1 root root    0 Mar  9 17:57 card0-HDMI-A-2 -> ../../devices/pci0000:00/0000:00:02.0/drm/card0/card0-HDMI-A-2
lrwxrwxrwx 1 root root    0 Mar  9 17:57 card1 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1
lrwxrwxrwx 1 root root    0 Mar  9 17:57 card1-DP-2 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1/card1-DP-2
lrwxrwxrwx 1 root root    0 Mar  9 17:57 card1-DP-3 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1/card1-DP-3
lrwxrwxrwx 1 root root    0 Mar  9 17:57 card1-DP-4 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1/card1-DP-4
lrwxrwxrwx 1 root root    0 Mar  9 17:57 card1-HDMI-A-3 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1/card1-HDMI-A-3
lrwxrwxrwx 1 root root    0 Mar  9 17:57 renderD128 -> ../../devices/pci0000:00/0000:00:02.0/drm/renderD128
lrwxrwxrwx 1 root root    0 Mar  9 17:57 renderD129 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/renderD129

Before this fix, card1 was getting the PCI Address of 0000.:00:01.0 which was incorrect. After this fix, the PCI Address for card is the correct 000:01:00.0 which is the NVIDIA GPU itself not the Intel PCI bridge.

Fixes Issue #407

Ensure we take only the last PCI address in the `/sys/class/drm` sysfs
output as the PCI Address of the graphics card. For some graphics cards,
they are on a PCI bridge or host bus adapter that was erroneously being
identified as the PCI Address of the graphics card itself.

Consider this `ll /sys/class/drm` output on one of my workstations:

```
lrwxrwxrwx 1 root root    0 Mar  9 17:57 card0 -> ../../devices/pci0000:00/0000:00:02.0/drm/card0
lrwxrwxrwx 1 root root    0 Mar  9 17:57 card0-DP-1 -> ../../devices/pci0000:00/0000:00:02.0/drm/card0/card0-DP-1
lrwxrwxrwx 1 root root    0 Mar  9 17:57 card0-HDMI-A-1 -> ../../devices/pci0000:00/0000:00:02.0/drm/card0/card0-HDMI-A-1
lrwxrwxrwx 1 root root    0 Mar  9 17:57 card0-HDMI-A-2 -> ../../devices/pci0000:00/0000:00:02.0/drm/card0/card0-HDMI-A-2
lrwxrwxrwx 1 root root    0 Mar  9 17:57 card1 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1
lrwxrwxrwx 1 root root    0 Mar  9 17:57 card1-DP-2 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1/card1-DP-2
lrwxrwxrwx 1 root root    0 Mar  9 17:57 card1-DP-3 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1/card1-DP-3
lrwxrwxrwx 1 root root    0 Mar  9 17:57 card1-DP-4 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1/card1-DP-4
lrwxrwxrwx 1 root root    0 Mar  9 17:57 card1-HDMI-A-3 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1/card1-HDMI-A-3
lrwxrwxrwx 1 root root    0 Mar  9 17:57 renderD128 -> ../../devices/pci0000:00/0000:00:02.0/drm/renderD128
lrwxrwxrwx 1 root root    0 Mar  9 17:57 renderD129 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/renderD129
```

Before this fix, `card1` was getting the PCI Address of `0000.:00:01.0`
which was incorrect. After this fix, the PCI Address for `card` is the
correct `000:01:00.0` which is the NVIDIA GPU itself not the Intel PCI
bridge.

Fixes Issue #407

Signed-off-by: Jay Pipes <[email protected]>
@jaypipes jaypipes merged commit 3773bc3 into main Mar 11, 2025
14 checks passed
@jaypipes jaypipes deleted the issue407 branch March 11, 2025 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant