aboutsummaryrefslogtreecommitdiffstats
path: root/src/amd/vulkan
diff options
context:
space:
mode:
authorBas Nieuwenhuizen <[email protected]>2020-04-29 23:13:17 +0200
committerBas Nieuwenhuizen <[email protected]>2020-05-15 03:16:29 +0200
commit9e3c6a7ba769d358dfffa690751cac6ca7f9c5df (patch)
treef19b28b7b05930e4a116ebc5962b8a253e21cea5 /src/amd/vulkan
parente7458f19e1de7d40ff8aa72b6a141f24d33451c6 (diff)
radv: Provide a better error for permission issues with priorities.
Cc: <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4816>
Diffstat (limited to 'src/amd/vulkan')
-rw-r--r--src/amd/vulkan/radv_device.c7
-rw-r--r--src/amd/vulkan/radv_radeon_winsys.h7
-rw-r--r--src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c20
-rw-r--r--src/amd/vulkan/winsys/null/radv_null_cs.c11
4 files changed, 29 insertions, 16 deletions
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index bc8bcdb6ab3..bdfb2dad355 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -2187,10 +2187,11 @@ radv_queue_init(struct radv_device *device, struct radv_queue *queue,
queue->queue_idx = idx;
queue->priority = radv_get_queue_global_priority(global_priority);
queue->flags = flags;
+ queue->hw_ctx = NULL;
- queue->hw_ctx = device->ws->ctx_create(device->ws, queue->priority);
- if (!queue->hw_ctx)
- return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
+ VkResult result = device->ws->ctx_create(device->ws, queue->priority, &queue->hw_ctx);
+ if (result != VK_SUCCESS)
+ return vk_error(device->instance, result);
list_inithead(&queue->pending_submissions);
pthread_mutex_init(&queue->pending_mutex, NULL);
diff --git a/src/amd/vulkan/radv_radeon_winsys.h b/src/amd/vulkan/radv_radeon_winsys.h
index e5a4ae57d99..fc6ec2594b4 100644
--- a/src/amd/vulkan/radv_radeon_winsys.h
+++ b/src/amd/vulkan/radv_radeon_winsys.h
@@ -34,6 +34,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
+#include <vulkan/vulkan.h>
#include "amd_family.h"
#include "util/u_memory.h"
#include "util/u_math.h"
@@ -158,6 +159,7 @@ struct radeon_bo_metadata {
};
struct radeon_winsys_fence;
+struct radeon_winsys_ctx;
struct radeon_winsys_bo {
uint64_t va;
@@ -256,8 +258,9 @@ struct radeon_winsys {
void (*buffer_virtual_bind)(struct radeon_winsys_bo *parent,
uint64_t offset, uint64_t size,
struct radeon_winsys_bo *bo, uint64_t bo_offset);
- struct radeon_winsys_ctx *(*ctx_create)(struct radeon_winsys *ws,
- enum radeon_ctx_priority priority);
+ VkResult (*ctx_create)(struct radeon_winsys *ws,
+ enum radeon_ctx_priority priority,
+ struct radeon_winsys_ctx **ctx);
void (*ctx_destroy)(struct radeon_winsys_ctx *ctx);
bool (*ctx_wait_idle)(struct radeon_winsys_ctx *ctx,
diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
index c4bcdb9ec92..de6bd6546ed 100644
--- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
+++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
@@ -1318,20 +1318,26 @@ static uint32_t radv_to_amdgpu_priority(enum radeon_ctx_priority radv_priority)
}
}
-static struct radeon_winsys_ctx *radv_amdgpu_ctx_create(struct radeon_winsys *_ws,
- enum radeon_ctx_priority priority)
+static VkResult radv_amdgpu_ctx_create(struct radeon_winsys *_ws,
+ enum radeon_ctx_priority priority,
+ struct radeon_winsys_ctx **rctx)
{
struct radv_amdgpu_winsys *ws = radv_amdgpu_winsys(_ws);
struct radv_amdgpu_ctx *ctx = CALLOC_STRUCT(radv_amdgpu_ctx);
uint32_t amdgpu_priority = radv_to_amdgpu_priority(priority);
+ VkResult result;
int r;
if (!ctx)
- return NULL;
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
r = amdgpu_cs_ctx_create2(ws->dev, amdgpu_priority, &ctx->ctx);
- if (r) {
+ if (r && r == -EACCES) {
+ result = VK_ERROR_NOT_PERMITTED_EXT;
+ goto error_create;
+ } else if (r) {
fprintf(stderr, "amdgpu: radv_amdgpu_cs_ctx_create2 failed. (%i)\n", r);
+ result = VK_ERROR_OUT_OF_HOST_MEMORY;
goto error_create;
}
ctx->ws = ws;
@@ -1346,10 +1352,12 @@ static struct radeon_winsys_ctx *radv_amdgpu_ctx_create(struct radeon_winsys *_w
ctx->fence_map = (uint64_t*)ws->base.buffer_map(ctx->fence_bo);
if (ctx->fence_map)
memset(ctx->fence_map, 0, 4096);
- return (struct radeon_winsys_ctx *)ctx;
+
+ *rctx = (struct radeon_winsys_ctx *)ctx;
+ return VK_SUCCESS;
error_create:
FREE(ctx);
- return NULL;
+ return result;
}
static void radv_amdgpu_ctx_destroy(struct radeon_winsys_ctx *rwctx)
diff --git a/src/amd/vulkan/winsys/null/radv_null_cs.c b/src/amd/vulkan/winsys/null/radv_null_cs.c
index fc76d5c6d4e..f549357e694 100644
--- a/src/amd/vulkan/winsys/null/radv_null_cs.c
+++ b/src/amd/vulkan/winsys/null/radv_null_cs.c
@@ -39,16 +39,17 @@ radv_null_cs(struct radeon_cmdbuf *base)
return (struct radv_null_cs*)base;
}
-static struct radeon_winsys_ctx *radv_null_ctx_create(struct radeon_winsys *_ws,
- enum radeon_ctx_priority priority)
+static VkResult radv_null_ctx_create(struct radeon_winsys *_ws,
+ enum radeon_ctx_priority priority,
+ struct radeon_winsys_ctx **rctx)
{
struct radv_null_ctx *ctx = CALLOC_STRUCT(radv_null_ctx);
if (!ctx)
- return NULL;
-
- return (struct radeon_winsys_ctx *)ctx;
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
+ *rctx = (struct radeon_winsys_ctx *)ctx;
+ return VK_SUCCESS;
}
static void radv_null_ctx_destroy(struct radeon_winsys_ctx *rwctx)