[PATCH 8/8] drm/amdgpu: DO-NOT-MERGE doorbell hack
Shashank Sharma
shashank.sharma at amd.com
Fri Feb 3 21:54:09 UTC 2023
From: Shashank Sharma <contactshashanksharma at gmail.com>
The doorbell patches, being reviewed here, are requied for Usermode
queues:
https://patchwork.freedesktop.org/series/113669/
This hack patch adds a doorbell IOCTL just to test the usermode
queues functionality, and must not be merged.
Cc: Alex Deucher <alexander.deucher at amd.com>
Cc: Christian König <christian.koenig at amd.com>
Signed-off-by: Shashank Sharma <contactshashanksharma at gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c | 19 +++++++++++++++++++
include/uapi/drm/amdgpu_drm.h | 6 ++++++
2 files changed, 25 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
index a28ed8e98f7b..b8715dfe27bc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
@@ -33,6 +33,8 @@ static inline void userqueue_busy_wait(unsigned long ms)
}
}
+#define AMDGPU_USERQ_DOORBELL_INDEX (AMDGPU_NAVI10_DOORBELL_GFX_USERQUEUE_START + 4)
+
static inline int
amdgpu_userqueue_index(struct amdgpu_userq_mgr *uq_mgr, struct amdgpu_usermode_queue *queue)
{
@@ -208,6 +210,7 @@ static int amdgpu_userqueue_create(struct drm_file *filp, union drm_amdgpu_userq
queue->queue_gpu_addr = mqd_in->queue_va;
queue->flags = mqd_in->flags;
queue->use_doorbell = true;
+ queue->doorbell_index = AMDGPU_USERQ_DOORBELL_INDEX;
queue->queue_id = amdgpu_userqueue_index(uq_mgr, queue);
if (queue->queue_id < 0) {
DRM_ERROR("Failed to allocate a queue id\n");
@@ -276,6 +279,22 @@ static void amdgpu_userqueue_destroy(struct drm_file *filp, int queue_id)
kfree(queue);
}
+int amdgpu_userq_doorbell_ring_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *filp)
+{
+ struct drm_amdgpu_db_ring *in = data;
+ struct amdgpu_fpriv *fpriv = filp->driver_priv;
+ struct amdgpu_userq_mgr *uq_mgr = &fpriv->userq_mgr;
+ struct amdgpu_device *adev = uq_mgr->adev;
+
+ mutex_lock(&uq_mgr->userq_mutex);
+ WDOORBELL32(AMDGPU_USERQ_DOORBELL_INDEX, in->val);
+ mutex_unlock(&uq_mgr->userq_mutex);
+
+ DRM_DEBUG_DRIVER("Doorbell rung\n");
+ return 0;
+}
+
int amdgpu_userq_ioctl(struct drm_device *dev, void *data,
struct drm_file *filp)
{
diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
index 6c5235d107b3..2d94cca566e0 100644
--- a/include/uapi/drm/amdgpu_drm.h
+++ b/include/uapi/drm/amdgpu_drm.h
@@ -55,6 +55,7 @@ extern "C" {
#define DRM_AMDGPU_FENCE_TO_HANDLE 0x14
#define DRM_AMDGPU_SCHED 0x15
#define DRM_AMDGPU_USERQ 0x16
+#define DRM_AMDGPU_USERQ_DOORBELL_RING 0x17
#define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
#define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
@@ -73,6 +74,7 @@ extern "C" {
#define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle)
#define DRM_IOCTL_AMDGPU_SCHED DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched)
#define DRM_IOCTL_AMDGPU_USERQ DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_USERQ, union drm_amdgpu_userq)
+#define DRM_IOCTL_AMDGPU_USERQ_DOORBELL_RING DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_USERQ_DOORBELL_RING, struct drm_amdgpu_db_ring)
/**
* DOC: memory domains
@@ -350,6 +352,10 @@ struct drm_amdgpu_userq_out {
__u32 flags;
};
+struct drm_amdgpu_db_ring {
+ __u64 val;
+};
+
union drm_amdgpu_userq {
struct drm_amdgpu_userq_in in;
struct drm_amdgpu_userq_out out;
--
2.34.1
More information about the amd-gfx
mailing list