mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 07:18:17 +02:00
virgl/drm: handle flink name better.
This realigns this code with code from radeon. Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
This commit is contained in:
parent
92ef4cf9f0
commit
8a39f83fb2
2 changed files with 11 additions and 20 deletions
|
|
@ -60,20 +60,13 @@ static void virgl_hw_res_destroy(struct virgl_drm_winsys *qdws,
|
|||
{
|
||||
struct drm_gem_close args;
|
||||
|
||||
if (res->flinked) {
|
||||
mtx_lock(&qdws->bo_handles_mutex);
|
||||
mtx_lock(&qdws->bo_handles_mutex);
|
||||
util_hash_table_remove(qdws->bo_handles,
|
||||
(void *)(uintptr_t)res->bo_handle);
|
||||
if (res->flink_name)
|
||||
util_hash_table_remove(qdws->bo_names,
|
||||
(void *)(uintptr_t)res->flink);
|
||||
mtx_unlock(&qdws->bo_handles_mutex);
|
||||
}
|
||||
|
||||
if (res->bo_handle) {
|
||||
mtx_lock(&qdws->bo_handles_mutex);
|
||||
util_hash_table_remove(qdws->bo_handles,
|
||||
(void *)(uintptr_t)res->bo_handle);
|
||||
mtx_unlock(&qdws->bo_handles_mutex);
|
||||
}
|
||||
|
||||
(void *)(uintptr_t)res->flink_name);
|
||||
mtx_unlock(&qdws->bo_handles_mutex);
|
||||
if (res->ptr)
|
||||
os_munmap(res->ptr, res->size);
|
||||
|
||||
|
|
@ -483,21 +476,20 @@ static boolean virgl_drm_winsys_resource_get_handle(struct virgl_winsys *qws,
|
|||
return FALSE;
|
||||
|
||||
if (whandle->type == WINSYS_HANDLE_TYPE_SHARED) {
|
||||
if (!res->flinked) {
|
||||
if (!res->flink_name) {
|
||||
memset(&flink, 0, sizeof(flink));
|
||||
flink.handle = res->bo_handle;
|
||||
|
||||
if (drmIoctl(qdws->fd, DRM_IOCTL_GEM_FLINK, &flink)) {
|
||||
return FALSE;
|
||||
}
|
||||
res->flinked = TRUE;
|
||||
res->flink = flink.name;
|
||||
res->flink_name = flink.name;
|
||||
|
||||
mtx_lock(&qdws->bo_handles_mutex);
|
||||
util_hash_table_set(qdws->bo_names, (void *)(uintptr_t)res->flink, res);
|
||||
util_hash_table_set(qdws->bo_names, (void *)(uintptr_t)res->flink_name, res);
|
||||
mtx_unlock(&qdws->bo_handles_mutex);
|
||||
}
|
||||
whandle->handle = res->flink;
|
||||
whandle->handle = res->flink_name;
|
||||
} else if (whandle->type == WINSYS_HANDLE_TYPE_KMS) {
|
||||
whandle->handle = res->bo_handle;
|
||||
} else if (whandle->type == WINSYS_HANDLE_TYPE_FD) {
|
||||
|
|
|
|||
|
|
@ -47,8 +47,7 @@ struct virgl_hw_res {
|
|||
uint32_t bind;
|
||||
boolean cacheable;
|
||||
int64_t start, end;
|
||||
boolean flinked;
|
||||
uint32_t flink;
|
||||
uint32_t flink_name;
|
||||
};
|
||||
|
||||
struct virgl_drm_winsys
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue