Fix hsaKmtOpen incorrectly doing nothing in some fork scenarios
Currently, if a process' parent called hsaKmtOpen, the child will be unable to open a connection to KFD, since kfd_open_count will be > 0. When forking, the refcount should be reset, in order to allow the child to re-open /dev/kfd. Change-Id: Ia4b78f6bacc4f82e8ac724e5f488a3eff5084007
Este commit está contenido en:
@@ -37,6 +37,19 @@ static const char kfd_device_name[] = "/dev/kfd";
|
||||
static const char tmp_file[] = "/var/lock/.amd_hsa_thunk_lock";
|
||||
int amd_hsa_thunk_lock_fd = 0;
|
||||
|
||||
static bool is_forked_child(void)
|
||||
{
|
||||
static pid_t open_pid = -1;
|
||||
pid_t my_pid = getpid();
|
||||
|
||||
if (open_pid == -1 || open_pid != my_pid) {
|
||||
open_pid = my_pid;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
HSAKMT_STATUS
|
||||
HSAKMTAPI
|
||||
hsaKmtOpenKFD(void)
|
||||
@@ -47,6 +60,13 @@ hsaKmtOpenKFD(void)
|
||||
|
||||
pthread_mutex_lock(&hsakmt_mutex);
|
||||
|
||||
/* If the process has forked, the child process must re-initialize
|
||||
* it's connection to KFD. Any references tracked by kfd_open_count
|
||||
* belong to the parent
|
||||
*/
|
||||
if (is_forked_child())
|
||||
kfd_open_count = 0;
|
||||
|
||||
if (kfd_open_count == 0)
|
||||
{
|
||||
fd = open(kfd_device_name, O_RDWR | O_CLOEXEC);
|
||||
|
||||
Referencia en una nueva incidencia
Block a user