From: Shashank Sharma <shashank.sharma@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Alex Deucher <alexander.deucher@amd.com>,
Shashank Sharma <shashank.sharma@amd.com>,
Christian Koenig <christian.koenig@amd.com>,
arvind.yadav@amd.com, arunpravin.paneerselvam@amd.com
Subject: [RFC 5/7] drm/amdgpu: Create context for usermode queue
Date: Fri, 23 Dec 2022 20:36:53 +0100 [thread overview]
Message-ID: <20221223193655.1972-6-shashank.sharma@amd.com> (raw)
In-Reply-To: <20221223193655.1972-1-shashank.sharma@amd.com>
The FW expects us to allocate atleast one page as process
context space, and one for gang context space. This patch adds some
object for the same.
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian Koenig <christian.koenig@amd.com>
Signed-off-by: Shashank Sharma <shashank.sharma@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c | 57 +++++++++++++++++++
.../drm/amd/include/amdgpu_usermode_queue.h | 8 +++
2 files changed, 65 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
index b566ce4cb7f0..2a854a5e2f70 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
@@ -69,6 +69,56 @@ amdgpu_userqueue_get_doorbell(struct amdgpu_device *adev,
return 0;
}
+static int
+amdgpu_userqueue_create_context(struct amdgpu_device *adev, struct amdgpu_usermode_queue *queue)
+{
+ int r;
+ struct amdgpu_userq_ctx *pctx = &queue->proc_ctx;
+ struct amdgpu_userq_ctx *gctx = &queue->gang_ctx;
+ /*
+ * The FW expects atleast one page space allocated for
+ * process context related work, and one for gang context.
+ */
+ r = amdgpu_bo_create_kernel(adev, PAGE_SIZE, PAGE_SIZE,
+ AMDGPU_GEM_DOMAIN_VRAM,
+ &pctx->obj,
+ &pctx->gpu_addr,
+ &pctx->cpu_ptr);
+ if (r) {
+ DRM_ERROR("Failed to allocate proc bo for userqueue (%d)", r);
+ return r;
+ }
+
+ r = amdgpu_bo_create_kernel(adev, PAGE_SIZE, PAGE_SIZE,
+ AMDGPU_GEM_DOMAIN_VRAM,
+ &gctx->obj,
+ &gctx->gpu_addr,
+ &gctx->cpu_ptr);
+ if (r) {
+ DRM_ERROR("Failed to allocate proc bo for userqueue (%d)", r);
+ amdgpu_bo_free_kernel(&pctx->obj,
+ &pctx->gpu_addr,
+ &pctx->cpu_ptr);
+ return r;
+ }
+
+ return 0;
+}
+
+static void
+amdgpu_userqueue_free_context(struct amdgpu_device *adev, struct amdgpu_usermode_queue *queue)
+{
+ struct amdgpu_userq_ctx *pctx = &queue->proc_ctx;
+ struct amdgpu_userq_ctx *gctx = &queue->gang_ctx;
+
+ amdgpu_bo_free_kernel(&pctx->obj,
+ &pctx->gpu_addr,
+ &pctx->cpu_ptr);
+ amdgpu_bo_free_kernel(&pctx->obj,
+ &gctx->gpu_addr,
+ &gctx->cpu_ptr);
+}
+
static void
amdgpu_userqueue_setup_mqd(struct amdgpu_device *adev, struct amdgpu_usermode_queue *queue)
{
@@ -282,6 +332,12 @@ int amdgpu_userqueue_create(struct amdgpu_device *adev, struct drm_file *filp,
goto free_mqd;
}
+ r = amdgpu_userqueue_create_context(adev, queue);
+ if (r < 0) {
+ DRM_ERROR("Failed to create context for queue\n");
+ goto free_mqd;
+ }
+
ctx->userq = queue;
args->out.q_id = queue->queue_id;
args->out.flags = 0;
@@ -306,6 +362,7 @@ void amdgpu_userqueue_destroy(struct amdgpu_device *adev, struct drm_file *filp,
struct amdgpu_usermode_queue *queue = ctx->userq;
mutex_lock(&adev->userq.userq_mutex);
+ amdgpu_userqueue_free_context(adev, queue);
amdgpu_userqueue_destroy_mqd(queue);
amdgpu_userqueue_remove_index(adev, queue);
ctx->userq = NULL;
diff --git a/drivers/gpu/drm/amd/include/amdgpu_usermode_queue.h b/drivers/gpu/drm/amd/include/amdgpu_usermode_queue.h
index c1fe39ffaf72..8bf3c0be6937 100644
--- a/drivers/gpu/drm/amd/include/amdgpu_usermode_queue.h
+++ b/drivers/gpu/drm/amd/include/amdgpu_usermode_queue.h
@@ -26,6 +26,12 @@
#define AMDGPU_MAX_USERQ 512
+struct amdgpu_userq_ctx {
+ struct amdgpu_bo *obj;
+ uint64_t gpu_addr;
+ void *cpu_ptr;
+};
+
struct amdgpu_usermode_queue {
int queue_id;
int queue_type;
@@ -44,6 +50,8 @@ struct amdgpu_usermode_queue {
struct amdgpu_bo *mqd_obj;
struct amdgpu_vm *vm;
+ struct amdgpu_userq_ctx proc_ctx;
+ struct amdgpu_userq_ctx gang_ctx;
struct list_head list;
};
--
2.34.1
next prev parent reply other threads:[~2022-12-23 19:37 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-23 19:36 [RFC 0/7] RFC: Usermode queue for AMDGPU driver Shashank Sharma
2022-12-23 19:36 ` [RFC 1/7] drm/amdgpu: UAPI for user queue management Shashank Sharma
2022-12-24 20:20 ` Bas Nieuwenhuizen
2022-12-27 16:58 ` Alex Deucher
2023-01-02 11:27 ` Christian König
2023-01-03 19:51 ` Alex Deucher
2023-01-02 13:26 ` Christian König
2023-01-03 14:23 ` Alex Deucher
2023-01-03 18:29 ` Felix Kuehling
2023-01-03 19:17 ` Liu, Shaoyun
2023-01-03 19:22 ` Alex Deucher
2023-01-03 19:25 ` Liu, Shaoyun
2023-01-03 19:52 ` Alex Deucher
2023-01-03 20:05 ` Felix Kuehling
2023-01-03 19:18 ` Alex Deucher
2022-12-23 19:36 ` [RFC 2/7] drm/amdgpu: Add usermode queue for gfx work Shashank Sharma
2022-12-24 18:19 ` Oded Gabbay
2022-12-26 10:34 ` Shashank Sharma
2022-12-25 15:44 ` Christian König
2022-12-26 10:41 ` Shashank Sharma
2023-01-02 12:39 ` Christian König
2023-01-03 9:12 ` Shashank Sharma
2023-01-03 9:15 ` Christian König
2023-01-03 9:22 ` Shashank Sharma
2023-01-03 9:35 ` Christian König
2023-01-03 14:34 ` Alex Deucher
2023-01-03 14:50 ` Christian König
2022-12-29 17:41 ` Alex Deucher
2023-01-02 13:53 ` Christian König
2023-01-03 9:32 ` Shashank Sharma
2023-01-03 9:16 ` Shashank Sharma
2023-01-04 8:55 ` Zhu, Jiadong
2023-01-04 8:58 ` Shashank Sharma
2022-12-23 19:36 ` [RFC 3/7] drm/amdgpu: Create MQD for userspace queue Shashank Sharma
2022-12-29 17:47 ` Alex Deucher
2023-01-03 9:36 ` Shashank Sharma
2023-01-03 18:37 ` Felix Kuehling
2023-01-04 6:21 ` Yadav, Arvind
2023-01-04 9:10 ` Christian König
2023-01-04 9:13 ` Shashank Sharma
2023-01-04 9:17 ` Christian König
2023-01-04 9:23 ` Shashank Sharma
2023-01-04 14:35 ` Felix Kuehling
2023-01-04 14:38 ` Yadav, Arvind
2023-01-04 14:41 ` Shashank Sharma
2023-01-04 14:28 ` Alex Deucher
2022-12-23 19:36 ` [RFC 4/7] drm/amdgpu: Allocate doorbell slot for user queue Shashank Sharma
2022-12-29 17:50 ` Alex Deucher
2023-01-03 9:37 ` Shashank Sharma
2022-12-23 19:36 ` Shashank Sharma [this message]
2022-12-29 17:54 ` [RFC 5/7] drm/amdgpu: Create context for usermode queue Alex Deucher
2023-01-03 9:40 ` Shashank Sharma
2023-01-03 14:48 ` Alex Deucher
2022-12-23 19:36 ` [RFC 6/7] drm/amdgpu: Map userqueue into HW Shashank Sharma
2022-12-29 17:51 ` Alex Deucher
2023-01-03 9:38 ` Shashank Sharma
2022-12-23 19:36 ` [RFC 7/7] drm/amdgpu: Secure semaphore for usermode queue Shashank Sharma
2022-12-25 10:07 ` Zhang, Yifan
2022-12-27 9:32 ` Arunpravin Paneer Selvam
2022-12-29 18:02 ` [RFC 0/7] RFC: Usermode queue for AMDGPU driver Alex Deucher
2023-01-03 9:43 ` Shashank Sharma
2023-01-03 9:47 ` Christian König
2023-01-03 10:00 ` Shashank Sharma
2023-01-03 10:02 ` Christian König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221223193655.1972-6-shashank.sharma@amd.com \
--to=shashank.sharma@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=arunpravin.paneerselvam@amd.com \
--cc=arvind.yadav@amd.com \
--cc=christian.koenig@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox