All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu/userq: Add INFO IOCTL query for doorbell ranges
@ 2026-11-17 19:23 Alex Deucher
  2026-11-17 20:01 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Deucher @ 2026-11-17 19:23 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher, Yogesh Mohan Marimuthu

Each IP gets a subset of each doorbell page.  Add a query
so userspace can query the ranges.

Cc: Yogesh Mohan Marimuthu <yogesh.mohanmarimuthu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 20 ++++++++++++++++++++
 include/uapi/drm/amdgpu_drm.h           |  6 ++++++
 2 files changed, 26 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index d7872acb4d790..42109f7706294 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -1453,6 +1453,26 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
 			return -EINVAL;
 		}
 	}
+	case AMDGPU_INFO_UQ_DOORBELL_RANGE: {
+		struct drm_amdgpu_info_doorbell_range db_range = {};
+
+		switch (info->query_hw_ip.type) {
+		case AMDGPU_HW_IP_GFX:
+		case AMDGPU_HW_IP_COMPUTE:
+			db_range.offset_bytes = adev->doorbell_index.kiq * 4;
+			db_range.size_bytes = (adev->doorbell_index.sdma_engine[0] -
+					       adev->doorbell_index.kiq) * 4;
+			return copy_to_user(out, &db_range,
+					    min((size_t)size, sizeof(db_range))) ? -EFAULT : 0;
+		case AMDGPU_HW_IP_DMA:
+			db_range.offset_bytes = adev->doorbell_index.sdma_engine[0] * 4;
+			db_range.size_bytes = adev->doorbell_index.sdma_doorbell_range * adev->sdma.num_instances;
+			return copy_to_user(out, &db_range,
+					    min((size_t)size, sizeof(db_range))) ? -EFAULT : 0;
+		default:
+			return -EINVAL;
+		}
+	}
 	default:
 		DRM_DEBUG_KMS("Invalid request %d\n", info->query);
 		return -EINVAL;
diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
index 29009f6aabde9..86d42a5d683c0 100644
--- a/include/uapi/drm/amdgpu_drm.h
+++ b/include/uapi/drm/amdgpu_drm.h
@@ -1289,6 +1289,7 @@ struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
 #define AMDGPU_INFO_GPUVM_FAULT			0x23
 /* query FW object size and alignment */
 #define AMDGPU_INFO_UQ_FW_AREAS			0x24
+#define AMDGPU_INFO_UQ_DOORBELL_RANGE		0x25
 
 #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT	0
 #define AMDGPU_INFO_MMR_SE_INDEX_MASK	0xff
@@ -1668,6 +1669,11 @@ struct drm_amdgpu_info_uq_metadata {
 	};
 };
 
+struct drm_amdgpu_info_doorbell_range {
+	__u32 offset_bytes;
+	__u32 size_bytes;
+};
+
 /*
  * Supported GPU families
  */
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-17 20:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 19:23 [PATCH] drm/amdgpu/userq: Add INFO IOCTL query for doorbell ranges Alex Deucher
2026-11-17 20:01 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.