[SWDEV-499029] Fix unable to change memory partition modes

Changes:
  * [API] Removed checking board name, fixes for other MI ASICs
  * [API] Fixed unable to restart AMD GPU, libdrm blocked
    doing this operation
  * [API] Added ability to unload/reload libdrm
    from within AMD SMI APIs
  * [CLI] Increased progress bar to change memory partition modes
    to 140 seconds, since driver reload is variable per system

Change-Id: I52f227f2ab850c4a6332ff3ecdc899903b1080f1
Signed-off-by: Charis Poag <Charis.Poag@amd.com>
This commit is contained in:
Charis Poag
2024-11-21 22:35:43 -06:00
والد 35d8e827b9
کامیت 7d061f9ae4
8فایلهای تغییر یافته به همراه207 افزوده شده و 92 حذف شده
@@ -33,18 +33,24 @@ amdsmi_status_t AMDSmiLibraryLoader::load(const char* filename) {
if (filename == nullptr) {
return AMDSMI_STATUS_FAIL_LOAD_MODULE;
}
if (libHandler_) {
if (libHandler_ || library_loaded_) {
unload();
}
std::lock_guard<std::mutex> guard(library_mutex_);
libHandler_ = dlopen(filename, RTLD_LAZY);
if (!libHandler_) {
char* error = dlerror();
std::cerr << "Fail to open " << filename <<": " << error
<< std::endl;
return AMDSMI_STATUS_FAIL_LOAD_MODULE;
// check if already loaded, return success if it is
// dlopen(filename, RTLD_NOLOAD) == null only IFF library is not loaded
void* isLibOpen = dlopen(filename, RTLD_NOLOAD);
if (isLibOpen == nullptr) {
libHandler_ = dlopen(filename, RTLD_LAZY);
if (!libHandler_) {
char* error = dlerror();
std::cerr << "Fail to open " << filename <<": " << error
<< std::endl;
return AMDSMI_STATUS_FAIL_LOAD_MODULE;
}
}
library_loaded_ = true;
return AMDSMI_STATUS_SUCCESS;
}
@@ -54,6 +60,7 @@ amdsmi_status_t AMDSmiLibraryLoader::unload() {
if (libHandler_) {
dlclose(libHandler_);
libHandler_ = nullptr;
library_loaded_ = false;
}
return AMDSMI_STATUS_SUCCESS;
}