libhsakmt: Query KFD version once after opening /dev/kfd

Query the KFD interface version once and store it in a global variable.
This makes it more efficient for KFD APIs to query the API version
later.

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Change-Id: I267f3465f754e78fb21a7c42c5877cd68eaa9d05


[ROCm/ROCR-Runtime commit: 43ce63b68b]
This commit is contained in:
Felix Kuehling
2020-07-11 23:37:32 -04:00
parent 3f3b280a4c
commit f267a5251c
3 changed files with 27 additions and 2 deletions
+14 -2
View File
@@ -28,17 +28,29 @@
#include <string.h>
#include "linux/kfd_ioctl.h"
HsaVersionInfo kfd_version_info;
HSAKMT_STATUS HSAKMTAPI hsaKmtGetVersion(HsaVersionInfo *VersionInfo)
{
CHECK_KFD_OPEN();
*VersionInfo = kfd_version_info;
return HSAKMT_STATUS_SUCCESS;
}
HSAKMT_STATUS init_kfd_version(void)
{
struct kfd_ioctl_get_version_args args = {0};
if (kmtIoctl(kfd_fd, AMDKFD_IOC_GET_VERSION, &args) == -1)
return HSAKMT_STATUS_ERROR;
VersionInfo->KernelInterfaceMajorVersion = args.major_version;
VersionInfo->KernelInterfaceMinorVersion = args.minor_version;
kfd_version_info.KernelInterfaceMajorVersion = args.major_version;
kfd_version_info.KernelInterfaceMinorVersion = args.minor_version;
if (args.major_version != 1)
return HSAKMT_STATUS_DRIVER_MISMATCH;
return HSAKMT_STATUS_SUCCESS;
}