+ if (r) {
+ DRM_ERROR("Failed to allocate ctx space bo for userqueue,
err:%d\n", r);
+ return r;
+ }
+
+ queue->proc_ctx_gpu_addr = ctx->gpu_addr;
+ queue->gang_ctx_gpu_addr = queue->proc_ctx_gpu_addr +
AMDGPU_USERQ_PROC_CTX_SZ;
+ queue->fw_ctx_gpu_addr = queue->gang_ctx_gpu_addr +
AMDGPU_USERQ_GANG_CTX_SZ;
+ queue->gds_ctx_gpu_addr = queue->fw_ctx_gpu_addr +
AMDGPU_USERQ_FW_CTX_SZ;
+ return 0;
+}
+
+static void gfx_v11_userq_destroy_ctx_space(struct amdgpu_userq_mgr
*uq_mgr,
+ struct amdgpu_usermode_queue *queue)
+{
+ struct amdgpu_userq_ctx_space *ctx = &queue->fw_space;
+
+ amdgpu_bo_free_kernel(&ctx->obj, &ctx->gpu_addr, &ctx->cpu_ptr);
+}
+
static int
gfx_v11_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, struct
amdgpu_usermode_queue *queue)
{
@@ -6426,10 +6469,16 @@ gfx_v11_userq_mqd_create(struct
amdgpu_userq_mgr *uq_mgr, struct amdgpu_usermode
}
memset(mqd->cpu_ptr, 0, size);
+ r = gfx_v11_userq_create_ctx_space(uq_mgr, queue);
+ if (r) {
+ DRM_ERROR("Failed to create CTX space for userqueue (%d)\n",
r);
+ goto free_mqd;
+ }
+
r = amdgpu_bo_reserve(mqd->obj, false);
if (unlikely(r != 0)) {
DRM_ERROR("Failed to reserve mqd for userqueue (%d)", r);
- goto free_mqd;
+ goto free_ctx;
}
queue->userq_prop.use_doorbell = true;
@@ -6438,12 +6487,15 @@ gfx_v11_userq_mqd_create(struct
amdgpu_userq_mgr *uq_mgr, struct amdgpu_usermode
amdgpu_bo_unreserve(mqd->obj);
if (r) {
DRM_ERROR("Failed to init MQD for queue\n");
- goto free_mqd;
+ goto free_ctx;
}
DRM_DEBUG_DRIVER("MQD for queue %d created\n", queue->queue_id);
return 0;
+free_ctx:
+ gfx_v11_userq_destroy_ctx_space(uq_mgr, queue);
+
free_mqd:
amdgpu_bo_free_kernel(&mqd->obj, &mqd->gpu_addr, &mqd->cpu_ptr);
return r;
@@ -6454,6 +6506,7 @@ gfx_v11_userq_mqd_destroy(struct
amdgpu_userq_mgr *uq_mgr, struct amdgpu_usermod
{
struct amdgpu_userq_ctx_space *mqd = &queue->mqd;
+ gfx_v11_userq_destroy_ctx_space(uq_mgr, queue);
amdgpu_bo_free_kernel(&mqd->obj, &mqd->gpu_addr, &mqd->cpu_ptr);
}
diff --git a/drivers/gpu/drm/amd/include/amdgpu_userqueue.h
b/drivers/gpu/drm/amd/include/amdgpu_userqueue.h
index e7da27918bd2..11e8ad649f6e 100644
--- a/drivers/gpu/drm/amd/include/amdgpu_userqueue.h
+++ b/drivers/gpu/drm/amd/include/amdgpu_userqueue.h
@@ -38,11 +38,17 @@ struct amdgpu_usermode_queue {
int queue_id;
int queue_type;
uint64_t doorbell_handle;
+ uint64_t proc_ctx_gpu_addr;
+ uint64_t gang_ctx_gpu_addr;
+ uint64_t gds_ctx_gpu_addr;
+ uint64_t fw_ctx_gpu_addr;
+ uint64_t shadow_ctx_gpu_addr;
uint64_t flags;
struct amdgpu_mqd_prop userq_prop;
struct amdgpu_userq_mgr *userq_mgr;
struct amdgpu_vm *vm;
struct amdgpu_userq_ctx_space mqd;
+ struct amdgpu_userq_ctx_space fw_space;
};
struct amdgpu_userq_funcs {