Skip to contentSkip to conversation

drm/amdgpu: Add user queue instance count reporting for gfx12

PATCH In review Jesse Zhang 3 participants 5 messages Jun 23, 2025 – Jun 25, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amdgpu: Add user queue instance count reporting for gfx12

This change exposes the number of available user queue instances through the HW IP info query interface. The information helps user mode drivers properly allocate and manage queue resources.

Key changes:
1. Added userq_gfx_instances and userq_compute_instances fields to amdgpu_gfx structure
2. Initialized the values during GFX IP early init for v12 (only when user queues are not disabled via disable_uq)
3. Exposed the values through drm_amdgpu_info_hw_ip structure via amdgpu_hw_ip_info()

The values represent:
- userq_gfx_instances: Number of GFX ring instances available
- userq_compute_instances: Number of compute ring instances available

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ++++
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c  | 5 +++++
 include/uapi/drm/amdgpu_drm.h           | 2 ++
 4 files changed, 13 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +2 -0
index 08f268dab8f5..63a7f0e0db5b 100644
@@ -452,6 +452,8 @@ struct amdgpu_gfx {
 	unsigned			num_gfx_rings;
 	struct amdgpu_ring		compute_ring[AMDGPU_MAX_COMPUTE_RINGS * AMDGPU_MAX_GC_INSTANCES];
 	unsigned			num_compute_rings;
+	unsigned			userq_gfx_instances;
+	unsigned			userq_compute_instances;
 	struct amdgpu_irq_src		eop_irq;
 	struct amdgpu_irq_src		priv_reg_irq;
 	struct amdgpu_irq_src		priv_inst_irq;
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +4 -0
index 195ed81d39ff..ff05c82a3dff 100644
@@ -411,6 +411,8 @@ static int amdgpu_hw_ip_info(struct amdgpu_device *adev,
 			if (adev->gfx.gfx_ring[i].sched.ready &&
 			    !adev->gfx.gfx_ring[i].no_user_submission)
 				++num_rings;
+
+		result->userq_num_instance = adev->gfx.userq_gfx_instances;
 		ib_start_alignment = 32;
 		ib_size_alignment = 32;
 		break;
@@ -420,6 +422,8 @@ static int amdgpu_hw_ip_info(struct amdgpu_device *adev,
 			if (adev->gfx.compute_ring[i].sched.ready &&
 			    !adev->gfx.compute_ring[i].no_user_submission)
 				++num_rings;
+
+		result->userq_num_instance = adev->gfx.userq_compute_instances;
 		ib_start_alignment = 32;
 		ib_size_alignment = 32;
 		break;
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +5 -0
index 1234c8d64e20..482490783a0a 100644
@@ -3852,6 +3852,11 @@ static int gfx_v12_0_early_init(struct amdgpu_ip_block *ip_block)
 						  AMDGPU_MAX_COMPUTE_RINGS);
 	}
 
+	if (!adev->gfx.disable_uq) {
+		adev->gfx.userq_gfx_instances = GFX12_NUM_GFX_RINGS;
+		adev->gfx.userq_compute_instances = AMDGPU_MAX_COMPUTE_RINGS;
+	}
+
 	gfx_v12_0_set_kiq_pm4_funcs(adev);
 	gfx_v12_0_set_ring_funcs(adev);
 	gfx_v12_0_set_irq_funcs(adev);
include/uapi/drm/amdgpu_drm.h +2 -0
index 45c4fa13499c..8082270a7ceb 100644
@@ -1493,6 +1493,8 @@ struct drm_amdgpu_info_hw_ip {
 	__u32  available_rings;
 	/** version info: bits 23:16 major, 15:8 minor, 7:0 revision */
 	__u32  ip_discovery_version;
+	/* Userq available instance */
+	__u32  userq_num_instance;
 };
 
 /* GFX metadata BO sizes and alignment info (in bytes) */
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 drm/amdgpu: Add user queue instance count reporting for gfx11

Initialize the number of available user queue instances for GFX11 hardware when user queues are enabled (!disable_uq).

This sets:
- userq_gfx_instances to GFX11_NUM_GFX_RINGS
- userq_compute_instances to AMDGPU_MAX_COMPUTE_RINGS

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +5 -0
index ec9b84f92d46..775036146d5a 100644
@@ -5226,6 +5226,11 @@ static int gfx_v11_0_early_init(struct amdgpu_ip_block *ip_block)
 						  AMDGPU_MAX_COMPUTE_RINGS);
 	}
 
+	if (!adev->gfx.disable_uq) {
+		adev->gfx.userq_gfx_instances = GFX11_NUM_GFX_RINGS;
+		adev->gfx.userq_compute_instances = AMDGPU_MAX_COMPUTE_RINGS;
+	}
+
 	gfx_v11_0_set_kiq_pm4_funcs(adev);
 	gfx_v11_0_set_ring_funcs(adev);
 	gfx_v11_0_set_irq_funcs(adev);
Signature · 1 line
2.34.1
#2 lore raw
In reply to Jesse Zhang
Quoted 65 lines · Jesse Zhang

This change exposes the number of available user queue instances through the HW IP info query interface. The information helps user mode drivers properly allocate and manage queue resources.

Key changes:
1. Added userq_gfx_instances and userq_compute_instances fields to amdgpu_gfx structure
2. Initialized the values during GFX IP early init for v12 (only when user queues are not disabled via disable_uq)
3. Exposed the values through drm_amdgpu_info_hw_ip structure via amdgpu_hw_ip_info()

The values represent:
- userq_gfx_instances: Number of GFX ring instances available
- userq_compute_instances: Number of compute ring instances available

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ++++
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c  | 5 +++++
 include/uapi/drm/amdgpu_drm.h           | 2 ++
 4 files changed, 13 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +2 -0
index 08f268dab8f5..63a7f0e0db5b 100644
@@ -452,6 +452,8 @@ struct amdgpu_gfx {
        unsigned                        num_gfx_rings;
        struct amdgpu_ring              compute_ring[AMDGPU_MAX_COMPUTE_RINGS * AMDGPU_MAX_GC_INSTANCES];
        unsigned                        num_compute_rings;
+       unsigned                        userq_gfx_instances;
+       unsigned                        userq_compute_instances;
        struct amdgpu_irq_src           eop_irq;
        struct amdgpu_irq_src           priv_reg_irq;
        struct amdgpu_irq_src           priv_inst_irq;
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +4 -0
index 195ed81d39ff..ff05c82a3dff 100644
@@ -411,6 +411,8 @@ static int amdgpu_hw_ip_info(struct amdgpu_device *adev,
                        if (adev->gfx.gfx_ring[i].sched.ready &&
                            !adev->gfx.gfx_ring[i].no_user_submission)
                                ++num_rings;
+
+               result->userq_num_instance = adev->gfx.userq_gfx_instances;
                ib_start_alignment = 32;
                ib_size_alignment = 32;
                break;
@@ -420,6 +422,8 @@ static int amdgpu_hw_ip_info(struct amdgpu_device *adev,
                        if (adev->gfx.compute_ring[i].sched.ready &&
                            !adev->gfx.compute_ring[i].no_user_submission)
                                ++num_rings;
+
+               result->userq_num_instance = adev->gfx.userq_compute_instances;
                ib_start_alignment = 32;
                ib_size_alignment = 32;
                break;
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0 -0
index 1234c8d64e20..482490783a0a 100644

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c static int gfx_v12_0_early_init(struct amdgpu_ip_block *ip_block) · line 3857

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +3 -0
@@ -3852,6 +3852,11 @@ static int gfx_v12_0_early_init(struct amdgpu_ip_block *ip_block)
                                                  AMDGPU_MAX_COMPUTE_RINGS);
        }
 
+       if (!adev->gfx.disable_uq) {
+               adev->gfx.userq_gfx_instances = GFX12_NUM_GFX_RINGS;
+               adev->gfx.userq_compute_instances = AMDGPU_MAX_COMPUTE_RINGS;

These are kernel queue values. If you want to expose something like this, it should be something like the number of HQD slots available for user queues for each queue type. That said, what's the use case for this? Applications don't know what other applications are doing.

Alex

Quoted 21 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +2 -0
+       }
+
        gfx_v12_0_set_kiq_pm4_funcs(adev);
        gfx_v12_0_set_ring_funcs(adev);
        gfx_v12_0_set_irq_funcs(adev);
include/uapi/drm/amdgpu_drm.h +2 -1
index 45c4fa13499c..8082270a7ceb 100644
@@ -1493,6 +1493,8 @@ struct drm_amdgpu_info_hw_ip {
        __u32  available_rings;
        /** version info: bits 23:16 major, 15:8 minor, 7:0 revision */
        __u32  ip_discovery_version;
+       /* Userq available instance */
+       __u32  userq_num_instance;
 };
 
 /* GFX metadata BO sizes and alignment info (in bytes) */
--

2.34.1

#3 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, June 23, 2025 11:51 PM
To: Zhang, Jesse(Jie) <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Add user queue instance count reporting for gfx12

Quoted 70 lines · Jesse Zhang

This change exposes the number of available user queue instances through the HW IP info query interface. The information helps user mode drivers properly allocate and manage queue resources.

Key changes:
1. Added userq_gfx_instances and userq_compute_instances fields to amdgpu_gfx structure
2. Initialized the values during GFX IP early init for v12 (only when user queues are not disabled via disable_uq) 3. Exposed
the values through drm_amdgpu_info_hw_ip structure
via amdgpu_hw_ip_info()

The values represent:
- userq_gfx_instances: Number of GFX ring instances available
- userq_compute_instances: Number of compute ring instances available

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 2 ++
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ++++
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c  | 5 +++++
 include/uapi/drm/amdgpu_drm.h           | 2 ++
 4 files changed, 13 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +2 -0
index 08f268dab8f5..63a7f0e0db5b 100644
@@ -452,6 +452,8 @@ struct amdgpu_gfx {
        unsigned                        num_gfx_rings;
        struct amdgpu_ring              compute_ring[AMDGPU_MAX_COMPUTE_RINGS * AMDGPU_MAX_GC_INSTANCES];
        unsigned                        num_compute_rings;
+       unsigned                        userq_gfx_instances;
+       unsigned                        userq_compute_instances;
        struct amdgpu_irq_src           eop_irq;
        struct amdgpu_irq_src           priv_reg_irq;
        struct amdgpu_irq_src           priv_inst_irq;
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +6 -0
index 195ed81d39ff..ff05c82a3dff 100644
@@ -411,6 +411,8 @@ static int amdgpu_hw_ip_info(struct amdgpu_device *adev,
                        if (adev->gfx.gfx_ring[i].sched.ready &&
                            !adev->gfx.gfx_ring[i].no_user_submission)
                                ++num_rings;
+
+               result->userq_num_instance =
+ adev->gfx.userq_gfx_instances;
                ib_start_alignment = 32;
                ib_size_alignment = 32;
                break;
@@ -420,6 +422,8 @@ static int amdgpu_hw_ip_info(struct amdgpu_device *adev,
                        if (adev->gfx.compute_ring[i].sched.ready &&
                            !adev->gfx.compute_ring[i].no_user_submission)
                                ++num_rings;
+
+               result->userq_num_instance =
+ adev->gfx.userq_compute_instances;
                ib_start_alignment = 32;
                ib_size_alignment = 32;
                break;
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0 -0
index 1234c8d64e20..482490783a0a 100644

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c static int gfx_v12_0_early_init(struct amdgpu_ip_block *ip_block) · line 3858

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +4 -0
@@ -3852,6 +3852,11 @@ static int gfx_v12_0_early_init(struct amdgpu_ip_block *ip_block)
                                                  AMDGPU_MAX_COMPUTE_RINGS);
        }
 
+       if (!adev->gfx.disable_uq) {
+               adev->gfx.userq_gfx_instances = GFX12_NUM_GFX_RINGS;
+               adev->gfx.userq_compute_instances =
+ AMDGPU_MAX_COMPUTE_RINGS;

These are kernel queue values. If you want to expose something like this, it should be something like the number of HQD slots available for user queues for each queue type. That said, what's the use case for this? Applications don't know what other applications are doing.

It is used to unify kfdtest and IGT tests.
Userspace needs to get the number of instance of each type and then perform concurrent tests, just like KFDQMTest.AllCpQueues.

Thanks
Jesse

Alex

Quoted 21 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +2 -0
+       }
+
        gfx_v12_0_set_kiq_pm4_funcs(adev);
        gfx_v12_0_set_ring_funcs(adev);
        gfx_v12_0_set_irq_funcs(adev); diff --git

a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h index 45c4fa13499c..8082270a7ceb 100644

include/uapi/drm/amdgpu_drm.h +2 -1
@@ -1493,6 +1493,8 @@ struct drm_amdgpu_info_hw_ip {
        __u32  available_rings;
        /** version info: bits 23:16 major, 15:8 minor, 7:0 revision */
        __u32  ip_discovery_version;
+       /* Userq available instance */
+       __u32  userq_num_instance;
 };
 
 /* GFX metadata BO sizes and alignment info (in bytes) */
--

2.34.1

#4 lore raw

[Public]

Quoted 104 lines

-----Original Message-----
From: Zhang, Jesse(Jie) <[email protected]>
Sent: Tuesday, June 24, 2025 5:18 AM
To: Alex Deucher <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: Add user queue instance count reporting for gfx12

[AMD Official Use Only - AMD Internal Distribution Only]

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, June 23, 2025 11:51 PM
To: Zhang, Jesse(Jie) <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: Add user queue instance count reporting for gfx12

Quoted 31 lines · Jesse Zhang

This change exposes the number of available user queue instances through the HW IP info query interface. The information helps user mode drivers properly allocate and manage queue resources.

Key changes:
1. Added userq_gfx_instances and userq_compute_instances fields to amdgpu_gfx structure
2. Initialized the values during GFX IP early init for v12 (only when user queues are not disabled via disable_uq) 3. Exposed
the values through drm_amdgpu_info_hw_ip structure
via amdgpu_hw_ip_info()

The values represent:
- userq_gfx_instances: Number of GFX ring instances available
- userq_compute_instances: Number of compute ring instances available

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 2 ++
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ++++
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c  | 5 +++++
 include/uapi/drm/amdgpu_drm.h           | 2 ++
 4 files changed, 13 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0 -0
index 08f268dab8f5..63a7f0e0db5b 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h struct amdgpu_gfx { · line 453

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +0 -0
@@ -452,6 +452,8 @@ struct amdgpu_gfx {
        unsigned                        num_gfx_rings;
        struct amdgpu_ring

compute_ring[AMDGPU_MAX_COMPUTE_RINGS *
AMDGPU_MAX_GC_INSTANCES];

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_hw_ip_info(struct amdgpu_device

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +2 -0
        unsigned                        num_compute_rings;
+       unsigned                        userq_gfx_instances;
+       unsigned                        userq_compute_instances;
        struct amdgpu_irq_src           eop_irq;
        struct amdgpu_irq_src           priv_reg_irq;
        struct amdgpu_irq_src           priv_inst_irq;
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -0
index 195ed81d39ff..ff05c82a3dff 100644
@@ -411,6 +411,8 @@ static int amdgpu_hw_ip_info(struct amdgpu_device

*adev,

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_hw_ip_info(struct amdgpu_device

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3 -0
                        if (adev->gfx.gfx_ring[i].sched.ready &&
                            !adev->gfx.gfx_ring[i].no_user_submission)
                                ++num_rings;
+
+               result->userq_num_instance =
+ adev->gfx.userq_gfx_instances;
                ib_start_alignment = 32;
                ib_size_alignment = 32;
                break;
@@ -420,6 +422,8 @@ static int amdgpu_hw_ip_info(struct amdgpu_device

*adev,

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c static int gfx_v12_0_early_init(struct

Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3 -0
                        if (adev->gfx.compute_ring[i].sched.ready &&
                            !adev->gfx.compute_ring[i].no_user_submission)
                                ++num_rings;
+
+               result->userq_num_instance =
+ adev->gfx.userq_compute_instances;
                ib_start_alignment = 32;
                ib_size_alignment = 32;
                break;
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0 -0
index 1234c8d64e20..482490783a0a 100644
@@ -3852,6 +3852,11 @@ static int gfx_v12_0_early_init(struct

amdgpu_ip_block *ip_block)

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c static int gfx_v12_0_early_init(struct amdgpu_ip_block *ip_block)

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +4 -0
                                                  AMDGPU_MAX_COMPUTE_RINGS);
        }
 
+       if (!adev->gfx.disable_uq) {
+               adev->gfx.userq_gfx_instances = GFX12_NUM_GFX_RINGS;
+               adev->gfx.userq_compute_instances =
+ AMDGPU_MAX_COMPUTE_RINGS;
Quoted 8 lines

These are kernel queue values. If you want to expose something like this, it should be something like the number of HQD slots available for user queues for each queue type. That said, what's the use case for this? Applications don't know what other applications are doing.

It is used to unify kfdtest and IGT tests.
Userspace needs to get the number of instance of each type and then perform concurrent tests, just like KFDQMTest.AllCpQueues.

In that case, I'd suggest using the adev->mes.gfx_hqd_mask[]/compute_hqd_mask[]/sdma_hqd_mask[] masks to determine the number of queue slots available for each engine type.

Alex

Quoted 27 lines

Thanks
Jesse

Alex

Quoted 21 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +2 -0
+       }
+
        gfx_v12_0_set_kiq_pm4_funcs(adev);
        gfx_v12_0_set_ring_funcs(adev);
        gfx_v12_0_set_irq_funcs(adev); diff --git

a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h index 45c4fa13499c..8082270a7ceb 100644

include/uapi/drm/amdgpu_drm.h +2 -1
@@ -1493,6 +1493,8 @@ struct drm_amdgpu_info_hw_ip {
        __u32  available_rings;
        /** version info: bits 23:16 major, 15:8 minor, 7:0 revision */
        __u32  ip_discovery_version;
+       /* Userq available instance */
+       __u32  userq_num_instance;
 };
 
 /* GFX metadata BO sizes and alignment info (in bytes) */
--

2.34.1