[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:
@@ -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;
|
||||
}
|
||||
|
||||
مرجع در شماره جدید
Block a user