Skip to contentSkip to conversation

drm/amdgpu: add UAPI to query if user queues are supported

PATCH In review Alex Deucher 5 participants 7 messages Mar 17, 2025 – Mar 23, 2025

Subsystems (3)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 drm/amdgpu: add UAPI to query if user queues are supported

Add an INFO query to check if user queues are supported.

v2: switch to a mask of IPs (Marek)

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 13 +++++++++++++
 include/uapi/drm/amdgpu_drm.h           |  8 ++++++++
 2 files changed, 21 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +13 -0
index 3b7dfd56ccd0e..1d683c0487697 100644
@@ -1340,6 +1340,19 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
 			return -EINVAL;
 		}
 	}
+	case AMDGPU_INFO_UQ_SUPPORTED: {
+		struct drm_amdgpu_info_uq_supported uq_supported = {};
+
+		if (adev->userq_funcs[AMDGPU_HW_IP_GFX])
+			uq_supported.supported |= (1 << AMDGPU_HW_IP_GFX);
+		if (adev->userq_funcs[AMDGPU_HW_IP_COMPUTE])
+			uq_supported.supported |= (1 << AMDGPU_HW_IP_COMPUTE);
+		if (adev->userq_funcs[AMDGPU_HW_IP_DMA])
+			uq_supported.supported |= (1 << AMDGPU_HW_IP_DMA);
+		ret = copy_to_user(out, &uq_supported,
+				   min((size_t)size, sizeof(uq_supported))) ? -EFAULT : 0;
+		return 0;
+	}
 	default:
 		DRM_DEBUG_KMS("Invalid request %d\n", info->query);
 		return -EINVAL;
include/uapi/drm/amdgpu_drm.h +8 -0
index 5dbd9037afe75..4b64e91002c05 100644
@@ -1195,6 +1195,8 @@ 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
+/* query if user queues are supported */
+#define AMDGPU_INFO_UQ_SUPPORTED		0x25
 
 #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT	0
 #define AMDGPU_INFO_MMR_SE_INDEX_MASK	0xff
@@ -1572,6 +1574,12 @@ struct drm_amdgpu_info_uq_metadata {
 	};
 };
 
+struct drm_amdgpu_info_uq_supported {
+	/** returns a mask for each IP type (1 << AMDGPU_HW_IP_*) */
+	__u32   supported;
+	__u32   pad;
+};
+
 /*
  * Supported GPU families
  */
Signature · 1 line
2.48.1
Reviewed-by on v1 1/1
#1 lore raw

[Public]

May I know when the counterpart part of Libdrm and Mesa can support this UAPI?

Regards,
Prike

Quoted 78 lines

-----Original Message-----
From: Deucher, Alexander <[email protected]>
Sent: Tuesday, March 18, 2025 5:29 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Olsak, Marek <[email protected]>; Liang, Prike <[email protected]>; Khatri, Sunil <[email protected]>
Subject: [PATCH] drm/amdgpu: add UAPI to query if user queues are supported

Add an INFO query to check if user queues are supported.

v2: switch to a mask of IPs (Marek)

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 13 +++++++++++++
 include/uapi/drm/amdgpu_drm.h           |  8 ++++++++
 2 files changed, 21 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +13 -0
index 3b7dfd56ccd0e..1d683c0487697 100644
@@ -1340,6 +1340,19 @@ int amdgpu_info_ioctl(struct drm_device *dev, void
 *data, struct drm_file *filp)
                      return -EINVAL;
              }
      }
+     case AMDGPU_INFO_UQ_SUPPORTED: {
+             struct drm_amdgpu_info_uq_supported uq_supported = {};
+
+             if (adev->userq_funcs[AMDGPU_HW_IP_GFX])
+                     uq_supported.supported |= (1 << AMDGPU_HW_IP_GFX);
+             if (adev->userq_funcs[AMDGPU_HW_IP_COMPUTE])
+                     uq_supported.supported |= (1 <<
 AMDGPU_HW_IP_COMPUTE);
+             if (adev->userq_funcs[AMDGPU_HW_IP_DMA])
+                     uq_supported.supported |= (1 << AMDGPU_HW_IP_DMA);
+             ret = copy_to_user(out, &uq_supported,
+                                min((size_t)size, sizeof(uq_supported))) ? -
 EFAULT : 0;
+             return 0;
+     }
      default:
              DRM_DEBUG_KMS("Invalid request %d\n", info->query);
              return -EINVAL;
include/uapi/drm/amdgpu_drm.h +8 -1
index 5dbd9037afe75..4b64e91002c05 100644
@@ -1195,6 +1195,8 @@ 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
+/* query if user queues are supported */
+#define AMDGPU_INFO_UQ_SUPPORTED             0x25
 
 #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT       0
 #define AMDGPU_INFO_MMR_SE_INDEX_MASK        0xff
@@ -1572,6 +1574,12 @@ struct drm_amdgpu_info_uq_metadata {
      };
 };
 
+struct drm_amdgpu_info_uq_supported {
+     /** returns a mask for each IP type (1 << AMDGPU_HW_IP_*) */
+     __u32   supported;
+     __u32   pad;
+};
+
 /*
  * Supported GPU families
  */
--

2.48.1

#2 lore raw
Quoted 6 lines · Prike

[Public]

May I know when the counterpart part of Libdrm and Mesa can support this UAPI?

+ Yogesh

Assuming this is agreeable to the mesa team, I'd expect them to start using it. @[email protected], @Marek Olšák does this look good to you?

Alex

Quoted 83 lines

Regards,
Prike

Quoted 78 lines

-----Original Message-----
From: Deucher, Alexander <[email protected]>
Sent: Tuesday, March 18, 2025 5:29 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Olsak, Marek <[email protected]>; Liang, Prike <[email protected]>; Khatri, Sunil <[email protected]>
Subject: [PATCH] drm/amdgpu: add UAPI to query if user queues are supported

Add an INFO query to check if user queues are supported.

v2: switch to a mask of IPs (Marek)

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 13 +++++++++++++
 include/uapi/drm/amdgpu_drm.h           |  8 ++++++++
 2 files changed, 21 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +13 -0
index 3b7dfd56ccd0e..1d683c0487697 100644
@@ -1340,6 +1340,19 @@ int amdgpu_info_ioctl(struct drm_device *dev, void
 *data, struct drm_file *filp)
                      return -EINVAL;
              }
      }
+     case AMDGPU_INFO_UQ_SUPPORTED: {
+             struct drm_amdgpu_info_uq_supported uq_supported = {};
+
+             if (adev->userq_funcs[AMDGPU_HW_IP_GFX])
+                     uq_supported.supported |= (1 << AMDGPU_HW_IP_GFX);
+             if (adev->userq_funcs[AMDGPU_HW_IP_COMPUTE])
+                     uq_supported.supported |= (1 <<
 AMDGPU_HW_IP_COMPUTE);
+             if (adev->userq_funcs[AMDGPU_HW_IP_DMA])
+                     uq_supported.supported |= (1 << AMDGPU_HW_IP_DMA);
+             ret = copy_to_user(out, &uq_supported,
+                                min((size_t)size, sizeof(uq_supported))) ? -
 EFAULT : 0;
+             return 0;
+     }
      default:
              DRM_DEBUG_KMS("Invalid request %d\n", info->query);
              return -EINVAL;
include/uapi/drm/amdgpu_drm.h +8 -1
index 5dbd9037afe75..4b64e91002c05 100644
@@ -1195,6 +1195,8 @@ 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
+/* query if user queues are supported */
+#define AMDGPU_INFO_UQ_SUPPORTED             0x25
 
 #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT       0
 #define AMDGPU_INFO_MMR_SE_INDEX_MASK        0xff
@@ -1572,6 +1574,12 @@ struct drm_amdgpu_info_uq_metadata {
      };
 };
 
+struct drm_amdgpu_info_uq_supported {
+     /** returns a mask for each IP type (1 << AMDGPU_HW_IP_*) */
+     __u32   supported;
+     __u32   pad;
+};
+
 /*
  * Supported GPU families
  */
--

2.48.1

#3 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Hi Alex,

Yes, this looks good to me. Thank you.

Thank you,
Yogesh

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Tuesday, March 18, 2025 8:29 PM
To: Liang, Prike <[email protected]>; Mohan Marimuthu, Yogesh <[email protected]>; Olsak, Marek <[email protected]>
Cc: Deucher, Alexander <[email protected]>; [email protected]; Khatri, Sunil <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add UAPI to query if user queues are supported

Quoted 6 lines · Prike

[Public]

May I know when the counterpart part of Libdrm and Mesa can support this UAPI?

+ Yogesh

Assuming this is agreeable to the mesa team, I'd expect them to start using it. @[email protected], @Marek Olšák does this look good to you?

Alex

Quoted 86 lines

Regards,
Prike

Quoted 81 lines

-----Original Message-----
From: Deucher, Alexander <[email protected]>
Sent: Tuesday, March 18, 2025 5:29 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Olsak, Marek <[email protected]>; Liang, Prike <[email protected]>; Khatri, Sunil <[email protected]>
Subject: [PATCH] drm/amdgpu: add UAPI to query if user queues are supported

Add an INFO query to check if user queues are supported.

v2: switch to a mask of IPs (Marek)

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 13 +++++++++++++
 include/uapi/drm/amdgpu_drm.h           |  8 ++++++++
 2 files changed, 21 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +14 -0
index 3b7dfd56ccd0e..1d683c0487697 100644
@@ -1340,6 +1340,19 @@ int amdgpu_info_ioctl(struct drm_device *dev,
 void *data, struct drm_file *filp)
                      return -EINVAL;
              }
      }
+     case AMDGPU_INFO_UQ_SUPPORTED: {
+             struct drm_amdgpu_info_uq_supported uq_supported = {};
+
+             if (adev->userq_funcs[AMDGPU_HW_IP_GFX])
+                     uq_supported.supported |= (1 << AMDGPU_HW_IP_GFX);
+             if (adev->userq_funcs[AMDGPU_HW_IP_COMPUTE])
+                     uq_supported.supported |= (1 <<
 AMDGPU_HW_IP_COMPUTE);
+             if (adev->userq_funcs[AMDGPU_HW_IP_DMA])
+                     uq_supported.supported |= (1 << AMDGPU_HW_IP_DMA);
+             ret = copy_to_user(out, &uq_supported,
+                                min((size_t)size,
+ sizeof(uq_supported))) ? -
 EFAULT : 0;
+             return 0;
+     }
      default:
              DRM_DEBUG_KMS("Invalid request %d\n", info->query);
              return -EINVAL;
(quoted diff) +0 -0

b/include/uapi/drm/amdgpu_drm.h index 5dbd9037afe75..4b64e91002c05 100644

include/uapi/drm/amdgpu_drm.h +8 -1
@@ -1195,6 +1195,8 @@ 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
+/* query if user queues are supported */
+#define AMDGPU_INFO_UQ_SUPPORTED             0x25
 
 #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT       0
 #define AMDGPU_INFO_MMR_SE_INDEX_MASK        0xff
@@ -1572,6 +1574,12 @@ struct drm_amdgpu_info_uq_metadata {
      };
 };
 
+struct drm_amdgpu_info_uq_supported {
+     /** returns a mask for each IP type (1 << AMDGPU_HW_IP_*) */
+     __u32   supported;
+     __u32   pad;
+};
+
 /*
  * Supported GPU families
  */
--

2.48.1

Reviewed-by on v1 1/1
#4 lore raw
In reply to Alex Deucher

This is not in device_info, but it'll do.

Marek

Quoted 71 lines · Alex Deucher

Add an INFO query to check if user queues are supported.

v2: switch to a mask of IPs (Marek)

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 13 +++++++++++++
 include/uapi/drm/amdgpu_drm.h           |  8 ++++++++
 2 files changed, 21 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +13 -0
index 3b7dfd56ccd0e..1d683c0487697 100644
@@ -1340,6 +1340,19 @@ int amdgpu_info_ioctl(struct drm_device *dev, void
 *data, struct drm_file *filp)
                        return -EINVAL;
                }
        }
+       case AMDGPU_INFO_UQ_SUPPORTED: {
+               struct drm_amdgpu_info_uq_supported uq_supported = {};
+
+               if (adev->userq_funcs[AMDGPU_HW_IP_GFX])
+                       uq_supported.supported |= (1 << AMDGPU_HW_IP_GFX);
+               if (adev->userq_funcs[AMDGPU_HW_IP_COMPUTE])
+                       uq_supported.supported |= (1 <<
 AMDGPU_HW_IP_COMPUTE);
+               if (adev->userq_funcs[AMDGPU_HW_IP_DMA])
+                       uq_supported.supported |= (1 << AMDGPU_HW_IP_DMA);
+               ret = copy_to_user(out, &uq_supported,
+                                  min((size_t)size,
 sizeof(uq_supported))) ? -EFAULT : 0;
+               return 0;
+       }
        default:
                DRM_DEBUG_KMS("Invalid request %d\n", info->query);
                return -EINVAL;
include/uapi/drm/amdgpu_drm.h +8 -1
index 5dbd9037afe75..4b64e91002c05 100644
@@ -1195,6 +1195,8 @@ 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
+/* query if user queues are supported */
+#define AMDGPU_INFO_UQ_SUPPORTED               0x25
 
 #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
 #define AMDGPU_INFO_MMR_SE_INDEX_MASK  0xff
@@ -1572,6 +1574,12 @@ struct drm_amdgpu_info_uq_metadata {
        };
 };
 
+struct drm_amdgpu_info_uq_supported {
+       /** returns a mask for each IP type (1 << AMDGPU_HW_IP_*) */
+       __u32   supported;
+       __u32   pad;
+};
+
 /*
  * Supported GPU families
  */
--

2.48.1

#5 lore raw

I can move it into device_info if that's better.

Alex

Quoted 75 lines · Marek Olšák

This is not in device_info, but it'll do.

Marek

Quoted 67 lines · Alex Deucher

Add an INFO query to check if user queues are supported.

v2: switch to a mask of IPs (Marek)

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 13 +++++++++++++
 include/uapi/drm/amdgpu_drm.h           |  8 ++++++++
 2 files changed, 21 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +13 -0
index 3b7dfd56ccd0e..1d683c0487697 100644
@@ -1340,6 +1340,19 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
                        return -EINVAL;
                }
        }
+       case AMDGPU_INFO_UQ_SUPPORTED: {
+               struct drm_amdgpu_info_uq_supported uq_supported = {};
+
+               if (adev->userq_funcs[AMDGPU_HW_IP_GFX])
+                       uq_supported.supported |= (1 << AMDGPU_HW_IP_GFX);
+               if (adev->userq_funcs[AMDGPU_HW_IP_COMPUTE])
+                       uq_supported.supported |= (1 << AMDGPU_HW_IP_COMPUTE);
+               if (adev->userq_funcs[AMDGPU_HW_IP_DMA])
+                       uq_supported.supported |= (1 << AMDGPU_HW_IP_DMA);
+               ret = copy_to_user(out, &uq_supported,
+                                  min((size_t)size, sizeof(uq_supported))) ? -EFAULT : 0;
+               return 0;
+       }
        default:
                DRM_DEBUG_KMS("Invalid request %d\n", info->query);
                return -EINVAL;
include/uapi/drm/amdgpu_drm.h +8 -1
index 5dbd9037afe75..4b64e91002c05 100644
@@ -1195,6 +1195,8 @@ 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
+/* query if user queues are supported */
+#define AMDGPU_INFO_UQ_SUPPORTED               0x25
 
 #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
 #define AMDGPU_INFO_MMR_SE_INDEX_MASK  0xff
@@ -1572,6 +1574,12 @@ struct drm_amdgpu_info_uq_metadata {
        };
 };
 
+struct drm_amdgpu_info_uq_supported {
+       /** returns a mask for each IP type (1 << AMDGPU_HW_IP_*) */
+       __u32   supported;
+       __u32   pad;
+};
+
 /*
  * Supported GPU families
  */
--

2.48.1

#6 lore raw

Adding it into drm_amdgpu_info_device with a DRM version bump is better.

Marek

Quoted 89 lines · Alex Deucher

I can move it into device_info if that's better.

Alex

Quoted 8 lines · Marek Olšák

This is not in device_info, but it'll do.

Marek

On Mon, Mar 17, 2025 at 5:38 PM Alex Deucher <[email protected]>

Quoted 14 lines · wrote:
Quoted 14 lines

Add an INFO query to check if user queues are supported.

v2: switch to a mask of IPs (Marek)

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 13 +++++++++++++
 include/uapi/drm/amdgpu_drm.h           |  8 ++++++++
 2 files changed, 21 insertions(+)
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_info_ioctl(struct drm_device *dev,

Quoted 4 lines

index 3b7dfd56ccd0e..1d683c0487697 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -0
@@ -1340,6 +1340,19 @@ int amdgpu_info_ioctl(struct drm_device *dev,

void *data, struct drm_file *filp)

Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +5 -0
                        return -EINVAL;
                }
        }
+       case AMDGPU_INFO_UQ_SUPPORTED: {
+               struct drm_amdgpu_info_uq_supported uq_supported = {};
+
+               if (adev->userq_funcs[AMDGPU_HW_IP_GFX])
+                       uq_supported.supported |= (1 <<

AMDGPU_HW_IP_GFX);

Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_info_ioctl(struct drm_device *dev, · line 1349

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2 -0
+               if (adev->userq_funcs[AMDGPU_HW_IP_COMPUTE])
+                       uq_supported.supported |= (1 <<

AMDGPU_HW_IP_COMPUTE);

Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_info_ioctl(struct drm_device *dev, · line 1351

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2 -0
+               if (adev->userq_funcs[AMDGPU_HW_IP_DMA])
+                       uq_supported.supported |= (1 <<

AMDGPU_HW_IP_DMA);

Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_info_ioctl(struct drm_device *dev, · line 1353

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2 -0
+               ret = copy_to_user(out, &uq_supported,
+                                  min((size_t)size,

sizeof(uq_supported))) ? -EFAULT : 0;

Quoted 6 lines

Review

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2 -0
+               return 0;
+       }
        default:
                DRM_DEBUG_KMS("Invalid request %d\n", info->query);
                return -EINVAL;
(quoted diff) +0 -0

b/include/uapi/drm/amdgpu_drm.h

Quoted 28 lines
Quoted 28 lines

index 5dbd9037afe75..4b64e91002c05 100644

include/uapi/drm/amdgpu_drm.h +8 -1
@@ -1195,6 +1195,8 @@ 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
+/* query if user queues are supported */
+#define AMDGPU_INFO_UQ_SUPPORTED               0x25
 
 #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
 #define AMDGPU_INFO_MMR_SE_INDEX_MASK  0xff
@@ -1572,6 +1574,12 @@ struct drm_amdgpu_info_uq_metadata {
        };
 };
 
+struct drm_amdgpu_info_uq_supported {
+       /** returns a mask for each IP type (1 << AMDGPU_HW_IP_*) */
+       __u32   supported;
+       __u32   pad;
+};
+
 /*
  * Supported GPU families
  */
--

2.48.1