mirror of
https://github.com/clearml/go-nvlib
synced 2025-02-25 13:33:10 +00:00
[nvmdev] fix bug in construction of parent PCI device
When constructing NvidiaPCIDevice objects for each 'parent' device in the
'/sys/class/mdev_bus' directory, use the default PCI devices root
'/sys/bus/pci/devices'. All devices in '/sys/class/mdev_bus' will have
a corresponding directory at '/sys/bus/pci/devices'.
Starting with bf3f431fc8
the construction of the NvidiaPCIDevice object will fail when attempting to detect the physfn.
When SRIOV is used, all the VFs will show up under '/sys/class/mdev_bus', but the physfn will
only show up under '/sys/bus/pci/devices'.
Signed-off-by: Christopher Desiniotis <cdesiniotis@nvidia.com>
This commit is contained in:
parent
167d4d5546
commit
44a5440a0a
@ -242,7 +242,8 @@ func (m mdev) iommuGroup() (int, error) {
|
|||||||
|
|
||||||
// NewParentDevice constructs a ParentDevice.
|
// NewParentDevice constructs a ParentDevice.
|
||||||
func NewParentDevice(devicePath string) (*ParentDevice, error) {
|
func NewParentDevice(devicePath string) (*ParentDevice, error) {
|
||||||
nvdevice, err := newNvidiaPCIDeviceFromPath(devicePath)
|
address := filepath.Base(devicePath)
|
||||||
|
nvdevice, err := nvpci.New().GetGPUByPciBusID(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to construct NVIDIA PCI device: %v", err)
|
return nil, fmt.Errorf("failed to construct NVIDIA PCI device: %v", err)
|
||||||
}
|
}
|
||||||
@ -370,12 +371,3 @@ func (p *ParentDevice) GetAvailableMDEVInstances(mdevType string) (int, error) {
|
|||||||
|
|
||||||
return availableInstances, nil
|
return availableInstances, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// newNvidiaPCIDeviceFromPath constructs an NvidiaPCIDevice for the specified device path.
|
|
||||||
func newNvidiaPCIDeviceFromPath(devicePath string) (*nvpci.NvidiaPCIDevice, error) {
|
|
||||||
root := filepath.Dir(devicePath)
|
|
||||||
address := filepath.Base(devicePath)
|
|
||||||
return nvpci.New(
|
|
||||||
nvpci.WithPCIDevicesRoot(root),
|
|
||||||
).GetGPUByPciBusID(address)
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user