Fail gracefully if drm directory is not found

Change-Id: I0f3ab2721108355752caf0280124469b98af4967
This commit is contained in:
Chris Freehill
2020-10-05 16:45:46 -05:00
parent 946bf93dfb
commit c6f02b4d62
+9 -3
Vedi File
@@ -259,9 +259,13 @@ RocmSMI::Initialize(uint64_t flags) {
++i;
}
// DiscoverAmdgpuDevices() will seach for devices and monitors and update
// DiscoverAmdgpuDevices() will search for devices and monitors and update
// internal data structures.
DiscoverAmdgpuDevices();
ret = DiscoverAmdgpuDevices();
if (ret != 0) {
throw amd::smi::rsmi_exception(RSMI_INITIALIZATION_ERROR,
"DiscoverAmdgpuDevices() failed.");
}
// IterateSMIDevices will iterate through all the known devices and apply
// the provided call-back to each device found.
@@ -462,7 +466,9 @@ uint32_t RocmSMI::DiscoverAmdgpuDevices(void) {
}
auto drm_dir = opendir(kPathDRMRoot);
assert(drm_dir != nullptr);
if (drm_dir == nullptr) {
return 1;
}
auto dentry = readdir(drm_dir);