Add SubsystemVendor and SubsystemDevice fields to NvidiaPCIDevice - #90
Merged
karthikvetrivel merged 2 commits intoJun 29, 2026
Merged
Conversation
Signed-off-by: Karthik Vetrivel <kvetrivel@nvidia.com>
karthikvetrivel
marked this pull request as ready for review
June 22, 2026 13:53
JunAr7112
reviewed
Jun 25, 2026
JunAr7112
left a comment
Contributor
There was a problem hiding this comment.
LGTM Karthik. Is the device filter matching mentioned in the original issue part of the scope for this PR?
Signed-off-by: Karthik Vetrivel <kvetrivel@nvidia.com>
karthikvetrivel
force-pushed
the
nvpci-subsystem-ids
branch
from
June 25, 2026 16:29
daac03a to
e0f2e8c
Compare
Member
Author
|
@JunAr7112 Thanks! This PR needs to land before integrating this change in |
JunAr7112
approved these changes
Jun 25, 2026
tariq1890
reviewed
Jul 2, 2026
| case os.IsNotExist(err): | ||
| p.logger.Warningf("subsystem_device file not found for %s", address) | ||
| default: | ||
| return nil, fmt.Errorf("unable to read PCI subsystem device id for %s: %v", address, err) |
Contributor
There was a problem hiding this comment.
Suggested change
| return nil, fmt.Errorf("unable to read PCI subsystem device id for %s: %v", address, err) | |
| return nil, fmt.Errorf("unable to read PCI subsystem device id for %s: %w", address, err) |
| subsystemDeviceStr := strings.TrimSpace(string(subsystemDevice)) | ||
| subsystemDeviceID, err = strconv.ParseUint(subsystemDeviceStr, 0, 16) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("unable to convert subsystem device string to uint16: %v", subsystemDeviceStr) |
Contributor
There was a problem hiding this comment.
Suggested change
| return nil, fmt.Errorf("unable to convert subsystem device string to uint16: %v", subsystemDeviceStr) | |
| return nil, fmt.Errorf("unable to convert subsystem device string %s to uint16: %w", subsystemDeviceStr, err) |
| subsystemVendorStr := strings.TrimSpace(string(subsystemVendor)) | ||
| subsystemVendorID, err = strconv.ParseUint(subsystemVendorStr, 0, 16) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("unable to convert subsystem vendor string to uint16: %v", subsystemVendorStr) |
Contributor
There was a problem hiding this comment.
Suggested change
| return nil, fmt.Errorf("unable to convert subsystem vendor string to uint16: %v", subsystemVendorStr) | |
| return nil, fmt.Errorf("unable to convert subsystem vendor string %s to uint16: %w", subsystemVendorStr, err) |
| case os.IsNotExist(err): | ||
| p.logger.Warningf("subsystem_vendor file not found for %s", address) | ||
| default: | ||
| return nil, fmt.Errorf("unable to read PCI subsystem vendor id for %s: %v", address, err) |
Contributor
There was a problem hiding this comment.
Suggested change
| return nil, fmt.Errorf("unable to read PCI subsystem vendor id for %s: %v", address, err) | |
| return nil, fmt.Errorf("unable to read PCI subsystem vendor id for %s: %w", address, err) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
SubsystemVendorandSubsystemDevice(uint16) toNvidiaPCIDevice.These fields are populated during PCI discovery from:
/sys/bus/pci/devices/<addr>/subsystem_vendor/sys/bus/pci/devices/<addr>/subsystem_deviceProblem
Some NVIDIA devices share the same PCI vendor/device IDs but differ by subsystem IDs. Exposing these fields allows downstream consumers to disambiguate devices during matching/filtering.
Unblocks NVIDIA/mig-parted#343.
Tested
I added two new tests.
TestNvpciSubsystemcreates a mock A100 device at 0000:80:05.1, callsGetGPUs(), and verifies the new fields are populated from the mock sysfs files:TestNvpciSubsystemMissingcreates the same mock device, then removes the mocksubsystem_vendorandsubsystem_devicefiles. It callsGetGPUs()and verifies discovery still succeeds, with both new fields left at 0.