Ensure no device mutexes are left held on shut_down

Also, fix TestMutualExclusion and TestEvtNofifReadWrite.
Previously, some of the normal SetUp function was not
being done for this test. In some cases, no DRM
devices are being found on the test machine. Skip
those.

Change-Id: Iaa5a257841eb459aa57491ae9680c34a60d5ac2b
This commit is contained in:
Chris Freehill committed 2020-06-19 13:59:20 -05:00
1 parent 488bbb668a
commit 59394f3354
5 files changed
+82 -31

No files matched your search

+14
View File
@@ -588,6 +588,20 @@ rsmi_shut_down(void) {
return RSMI_STATUS_INIT_ERROR;
}
// Release any device mutexes that are being held
#if DEBUG
int ret = 0;
#endif
for (int i = 0; i < smi.monitor_devices().size(); ++i) {
#if DEBUG
ret = pthread_mutex_unlock(smi.monitor_devices()[i]->mutex());
std::cout << "pthread_mutex_unlock() returned " << ret <<
" for device " << i << " in rsmi_shut_down()" << std::endl;
#else
(void)pthread_mutex_unlock(smi.monitor_devices()[i]->mutex());
#endif
}
(void)smi.ref_count_dec();
if (smi.ref_count() == 0) {
+1
View File
@@ -91,6 +91,7 @@ shared_mutex_t shared_mutex_init(const char *name, mode_t mode) {
if (ret || (mutex.created == 0 &&
reinterpret_cast<shared_mutex_t *>(addr)->ptr == NULL)) {
// Something is out of sync.
fprintf(stderr, "pthread_mutex_timedlock() returned %d\n", ret);
perror("Failed to initialize RSMI device mutex after 5 seconds. Previous "
"execution may not have shutdown cleanly. To fix problem, stop all "
"rocm_smi programs, and then delete the rocm_smi* shared memory files in"