mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 00:08:11 +00:00
Simplify handling of custom firmware path
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
0a37f8798a
commit
d3d41a3e1d
@ -101,7 +101,7 @@ func NewDriverLibraryDiscoverer(logger logger.Interface, driverRoot string, nvid
|
|||||||
return d, nil
|
return d, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUTSRelease(logger logger.Interface) (string, error) {
|
func getUTSRelease() (string, error) {
|
||||||
utsname := &unix.Utsname{}
|
utsname := &unix.Utsname{}
|
||||||
if err := unix.Uname(utsname); err != nil {
|
if err := unix.Uname(utsname); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -110,7 +110,7 @@ func getUTSRelease(logger logger.Interface) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getFirmwareSearchPaths(logger logger.Interface) ([]string, error) {
|
func getFirmwareSearchPaths(logger logger.Interface) ([]string, error) {
|
||||||
utsRelease, err := getUTSRelease(logger)
|
utsRelease, err := getUTSRelease()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to get UTS_RELEASE: %v", err)
|
return nil, fmt.Errorf("failed to get UTS_RELEASE: %v", err)
|
||||||
}
|
}
|
||||||
@ -122,21 +122,29 @@ func getFirmwareSearchPaths(logger logger.Interface) ([]string, error) {
|
|||||||
filepath.Join("/lib/firmware/"),
|
filepath.Join("/lib/firmware/"),
|
||||||
}
|
}
|
||||||
|
|
||||||
customFirmwareClassPath, err := os.ReadFile("/sys/module/firmware_class/parameters/path")
|
if p := getCustomFirmwareClassPath(logger); p != "" {
|
||||||
if err != nil {
|
logger.Debugf("using custom firmware class path: %s", p)
|
||||||
return nil, fmt.Errorf("failed to get custom firmware class path for driver version: %v", err)
|
firmwarePaths = append(firmwarePaths, p)
|
||||||
}
|
|
||||||
if !(len(customFirmwareClassPath) == 1 && customFirmwareClassPath[0] == byte(10)) {
|
|
||||||
firmwarePaths = append(firmwarePaths, string(customFirmwareClassPath))
|
|
||||||
}
|
}
|
||||||
return firmwarePaths, nil
|
return firmwarePaths, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getCustomFirmwareClassPath returns the custom firmware class path if it exists.
|
||||||
|
func getCustomFirmwareClassPath(logger logger.Interface) string {
|
||||||
|
customFirmwareClassPath, err := os.ReadFile("/sys/module/firmware_class/parameters/path")
|
||||||
|
if err != nil {
|
||||||
|
logger.Warningf("failed to get custom firmware class path: %v", err)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.TrimSpace(string(customFirmwareClassPath))
|
||||||
|
}
|
||||||
|
|
||||||
// NewDriverFirmwareDiscoverer creates a discoverer for GSP firmware associated with the specified driver version.
|
// NewDriverFirmwareDiscoverer creates a discoverer for GSP firmware associated with the specified driver version.
|
||||||
func NewDriverFirmwareDiscoverer(logger logger.Interface, driverRoot string, version string) (discover.Discover, error) {
|
func NewDriverFirmwareDiscoverer(logger logger.Interface, driverRoot string, version string) (discover.Discover, error) {
|
||||||
gspFirmwareSearchPaths, err := getFirmwareSearchPaths(logger)
|
gspFirmwareSearchPaths, err := getFirmwareSearchPaths(logger)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to get libraries for driver version: %v", err)
|
return nil, fmt.Errorf("failed to get firmware search paths: %v", err)
|
||||||
}
|
}
|
||||||
gspFirmwarePaths := filepath.Join("nvidia", version, "gsp*.bin")
|
gspFirmwarePaths := filepath.Join("nvidia", version, "gsp*.bin")
|
||||||
return discover.NewMounts(
|
return discover.NewMounts(
|
||||||
|
Loading…
Reference in New Issue
Block a user