Keep libdrm device_handle on older libdrm

Even if the version of libdrm older and does not support the
amdgpu_device_get_fd function, the device_handle stored in
amdgpu_handle[] is still valid and can be returned via
hsaKmtGetAMDGPUDeviceHandle.

Change-Id: I024a3e82e6cfebac5577aefe359b067746c4023e


[ROCm/ROCR-Runtime commit: 66b66e42cd]
Dieser Commit ist enthalten in:
David Yat Sin
2023-07-31 19:09:32 +00:00
Ursprung 72bd0f3a8d
Commit b5f6c688b6
+14 -13
Datei anzeigen
@@ -2062,20 +2062,21 @@ int open_drm_render_device(int minor)
}
drm_render_fds[index] = fd;
/* if amdgpu_device_get_fd availabe query render fd that libdrm uses,
* then close drm_render_fds above, replace it by fd libdrm uses.
*/
device_handle = &amdgpu_handle[index];
if (fn_amdgpu_device_get_fd &&
!amdgpu_device_initialize(fd, &major_drm, &minor_drm, device_handle)) {
fd = fn_amdgpu_device_get_fd(*device_handle);
if (fd > 0) {
close(drm_render_fds[index]);
drm_render_fds[index] = fd;
} else {
pr_err("amdgpu_device_get_fd failed: %d\n", fd);
amdgpu_device_deinitialize(*device_handle);
*device_handle = 0;
if (!amdgpu_device_initialize(fd, &major_drm, &minor_drm, device_handle)) {
/* if amdgpu_device_get_fd available query render fd that libdrm uses,
* then close drm_render_fds above, replace it by fd libdrm uses.
*/
if (fn_amdgpu_device_get_fd) {
fd = fn_amdgpu_device_get_fd(*device_handle);
if (fd > 0) {
close(drm_render_fds[index]);
drm_render_fds[index] = fd;
} else {
pr_err("amdgpu_device_get_fd failed: %d\n", fd);
amdgpu_device_deinitialize(*device_handle);
*device_handle = 0;
}
}
}