2019-12-04 23:06:00 -05:00
|
|
|
#include <stdio.h>
|
2014-12-29 15:37:42 +02:00
|
|
|
#include <errno.h>
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
|
|
|
|
|
#include "libhsakmt.h"
|
|
|
|
|
|
2017-04-20 08:25:00 -04:00
|
|
|
/* Call ioctl, restarting if it is interrupted */
|
|
|
|
|
int kmtIoctl(int fd, unsigned long request, void *arg)
|
2014-12-29 15:37:42 +02:00
|
|
|
{
|
2017-04-20 08:25:00 -04:00
|
|
|
int ret;
|
2014-12-29 15:37:42 +02:00
|
|
|
|
2017-04-20 08:25:00 -04:00
|
|
|
do {
|
|
|
|
|
ret = ioctl(fd, request, arg);
|
|
|
|
|
} while (ret == -1 && (errno == EINTR || errno == EAGAIN));
|
|
|
|
|
|
2020-04-01 20:11:42 -07:00
|
|
|
if (ret == -1 && errno == EBADF) {
|
2019-12-04 23:06:00 -05:00
|
|
|
/* In case pthread_atfork didn't catch it, this will
|
|
|
|
|
* make any subsequent hsaKmt calls fail in CHECK_KFD_OPEN.
|
|
|
|
|
*/
|
|
|
|
|
pr_err("KFD file descriptor not valid in this process\n");
|
2020-03-11 18:25:55 -05:00
|
|
|
is_forked_child();
|
2019-12-04 23:06:00 -05:00
|
|
|
}
|
|
|
|
|
|
2017-04-20 08:25:00 -04:00
|
|
|
return ret;
|
2014-12-29 15:37:42 +02:00
|
|
|
}
|