From 769603564ececf8edc6424ba500090bee661dadb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 15 Mar 2018 15:58:57 -0400 Subject: [PATCH] radeonsi: don't reallocate on DMABUF export if local BOs are disabled --- src/amd/common/ac_gpu_info.c | 2 ++ src/amd/common/ac_gpu_info.h | 1 + src/gallium/drivers/radeon/r600_texture.c | 4 +++- src/gallium/winsys/amdgpu/drm/amdgpu_bo.c | 7 +++---- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/amd/common/ac_gpu_info.c b/src/amd/common/ac_gpu_info.c index 73b5da0fe18..73fc36203c1 100644 --- a/src/amd/common/ac_gpu_info.c +++ b/src/amd/common/ac_gpu_info.c @@ -313,6 +313,8 @@ bool ac_query_gpu_info(int fd, amdgpu_device_handle dev, info->has_syncobj_wait_for_submit = info->has_syncobj && info->drm_minor >= 20; info->has_fence_to_handle = info->has_syncobj && info->drm_minor >= 21; info->has_ctx_priority = info->drm_minor >= 22; + /* TODO: Enable this once the kernel handles it efficiently. */ + /*info->has_local_buffers = ws->info.drm_minor >= 20;*/ info->num_render_backends = amdinfo->rb_pipes; info->clock_crystal_freq = amdinfo->gpu_counter_freq; if (!info->clock_crystal_freq) { diff --git a/src/amd/common/ac_gpu_info.h b/src/amd/common/ac_gpu_info.h index 34d91bec142..3f08b577c4b 100644 --- a/src/amd/common/ac_gpu_info.h +++ b/src/amd/common/ac_gpu_info.h @@ -89,6 +89,7 @@ struct radeon_info { bool has_syncobj_wait_for_submit; bool has_fence_to_handle; bool has_ctx_priority; + bool has_local_buffers; /* Shader cores. */ uint32_t r600_max_quad_pipes; /* wave size / 16 */ diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c index 3a0a79187b8..1614df63c98 100644 --- a/src/gallium/drivers/radeon/r600_texture.c +++ b/src/gallium/drivers/radeon/r600_texture.c @@ -701,6 +701,7 @@ static boolean r600_texture_get_handle(struct pipe_screen* screen, if (sscreen->ws->buffer_is_suballocated(res->buf) || rtex->surface.tile_swizzle || (rtex->resource.flags & RADEON_FLAG_NO_INTERPROCESS_SHARING && + sscreen->info.has_local_buffers && whandle->type != DRM_API_HANDLE_TYPE_KMS)) { assert(!res->b.is_shared); r600_reallocate_texture_inplace(rctx, rtex, @@ -762,7 +763,8 @@ static boolean r600_texture_get_handle(struct pipe_screen* screen, /* Move a suballocated buffer into a non-suballocated allocation. */ if (sscreen->ws->buffer_is_suballocated(res->buf) || /* A DMABUF export always fails if the BO is local. */ - rtex->resource.flags & RADEON_FLAG_NO_INTERPROCESS_SHARING) { + (rtex->resource.flags & RADEON_FLAG_NO_INTERPROCESS_SHARING && + sscreen->info.has_local_buffers)) { assert(!res->b.is_shared); /* Allocate a new buffer with PIPE_BIND_SHARED. */ diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c index 12d497d2921..7740b46b7b9 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c @@ -423,10 +423,9 @@ static struct amdgpu_winsys_bo *amdgpu_create_bo(struct amdgpu_winsys *ws, request.flags |= AMDGPU_GEM_CREATE_NO_CPU_ACCESS; if (flags & RADEON_FLAG_GTT_WC) request.flags |= AMDGPU_GEM_CREATE_CPU_GTT_USWC; - /* TODO: Enable this once the kernel handles it efficiently. */ - /*if (flags & RADEON_FLAG_NO_INTERPROCESS_SHARING && - ws->info.drm_minor >= 20) - request.flags |= AMDGPU_GEM_CREATE_VM_ALWAYS_VALID;*/ + if (flags & RADEON_FLAG_NO_INTERPROCESS_SHARING && + ws->info.has_local_buffers) + request.flags |= AMDGPU_GEM_CREATE_VM_ALWAYS_VALID; r = amdgpu_bo_alloc(ws->dev, &request, &buf_handle); if (r) { -- 2.30.2