libhsakmt: Don't close kfd_fd

When hsa is closed, it would close open fds for /dev/kfd but
not for /dev/dri/renderD*. This caused issues with CRIU
checkpoint, which expects that /dev/kfd will be open if
/dev/dri/renderD* is.

As a workaround for the CRIU behaviour, leave /dev/kfd open
when closing hsa.

Signed-off-by: David Francis <David.Francis@amd.com>
Change-Id: Ie1b2d5b1d8986750b0e560ae2934b7c73cff942e
This commit is contained in:
David Francis
2022-11-16 10:39:07 -05:00
vanhempi e0476629fe
commit 88934cec2c
2 muutettua tiedostoa jossa 10 lisäystä ja 12 poistoa
+1 -1
Näytä tiedosto
@@ -27,7 +27,7 @@
// HSAKMT global data
int kfd_fd;
int kfd_fd = -1;
unsigned long kfd_open_count;
unsigned long system_properties_count;
pthread_mutex_t hsakmt_mutex = PTHREAD_MUTEX_INITIALIZER;
+9 -11
Näytä tiedosto
@@ -99,7 +99,7 @@ static void clear_after_fork(void)
destroy_device_debugging_memory();
if (kfd_fd) {
close(kfd_fd);
kfd_fd = 0;
kfd_fd = -1;
}
kfd_open_count = 0;
parent_pid = -1;
@@ -160,15 +160,17 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtOpenKFD(void)
if (result != HSAKMT_STATUS_SUCCESS)
goto open_failed;
fd = open(kfd_device_name, O_RDWR | O_CLOEXEC);
if (kfd_fd < 0) {
fd = open(kfd_device_name, O_RDWR | O_CLOEXEC);
if (fd == -1) {
result = HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED;
goto open_failed;
if (fd == -1) {
result = HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED;
goto open_failed;
}
kfd_fd = fd;
}
kfd_fd = fd;
init_page_size();
result = init_kfd_version();
@@ -223,10 +225,6 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtCloseKFD(void)
if (--kfd_open_count == 0) {
destroy_counter_props();
destroy_device_debugging_memory();
if (kfd_fd) {
close(kfd_fd);
kfd_fd = 0;
}
}
result = HSAKMT_STATUS_SUCCESS;