Skip to contentSkip to conversation

drm/amdgpu: track whether a queue is a kernel queue in amdgpu_mqd_prop

PATCH In review Alex Deucher 5 participants 10 messages Jul 16, 2025 – Jul 22, 2025

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/3 drm/amdgpu: track whether a queue is a kernel queue in amdgpu_mqd_prop

Used to to set the MQD appropriately for each queue type. Kernel queues have have additional privileges.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h      | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 ++
 2 files changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index a1737556a77eb..ef3af170dda4e 100644
@@ -883,6 +883,7 @@ struct amdgpu_mqd_prop {
 	uint64_t csa_addr;
 	uint64_t fence_address;
 	bool tmz_queue;
+	bool kernel_queue;
 };
 
 struct amdgpu_mqd {
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2 -0
index acac646a4e4e9..617dc009a2550 100644
@@ -719,6 +719,8 @@ static void amdgpu_ring_to_mqd_prop(struct amdgpu_ring *ring,
 	prop->eop_gpu_addr = ring->eop_gpu_addr;
 	prop->use_doorbell = ring->use_doorbell;
 	prop->doorbell_index = ring->doorbell_index;
+	/* kernel queues are privileged */
+	prop->kernel_queue = true;
 
 	/* map_queues packet doesn't need activate the queue,
 	 * so only kiq need set this field.
Signature · 1 line
2.50.1
author maintainer
#1 lore raw

PATCH 2/3 drm/amdgpu/gfx11: set MQD as appriopriate for queue types

Set the MQD as appropriate for the kernel vs user queues.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +6 -2
index 372dceceff359..9dd49b1caa605 100644
@@ -4129,6 +4129,8 @@ static int gfx_v11_0_gfx_mqd_init(struct amdgpu_device *adev, void *m,
 #endif
 	if (prop->tmz_queue)
 		tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, TMZ_MATCH, 1);
+	if (!prop->kernel_queue)
+		tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, RB_NON_PRIV, 1);
 	mqd->cp_gfx_hqd_cntl = tmp;
 
 	/* set up cp_doorbell_control */
@@ -4281,8 +4283,10 @@ static int gfx_v11_0_compute_mqd_init(struct amdgpu_device *adev, void *m,
 	tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, UNORD_DISPATCH, 1);
 	tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, TUNNEL_DISPATCH,
 			    prop->allow_tunneling);
-	tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, PRIV_STATE, 1);
-	tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, KMD_QUEUE, 1);
+	if (prop->kernel_queue) {
+		tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, PRIV_STATE, 1);
+		tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, KMD_QUEUE, 1);
+	}
 	if (prop->tmz_queue)
 		tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, TMZ, 1);
 	mqd->cp_hqd_pq_control = tmp;
Signature · 1 line
2.50.1
Acked-by Christian König on v1 2/3
#2 lore raw

RE: [PATCH 2/3] drm/amdgpu/gfx11: set MQD as appriopriate for queue types

[AMD Official Use Only - AMD Internal Distribution Only]

Hi Alex,

With this mqd configuration we get many cases of illegal register flooding and reset not working. Should we create the privileged user queue ?

Log:
[drm:gfx_v11_0_priv_reg_irq [amdgpu]] *ERROR* Illegal register access in command stream

[  180.429970] [drm:gfx_v11_0_priv_reg_irq [amdgpu]] *ERROR* Illegal register access in command stream

Thanks
Jesse
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, July 17, 2025 6:01 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu/gfx11: set MQD as appriopriate for queue types

Set the MQD as appropriate for the kernel vs user queues.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +6 -2
index 372dceceff359..9dd49b1caa605 100644
@@ -4129,6 +4129,8 @@ static int gfx_v11_0_gfx_mqd_init(struct amdgpu_device *adev, void *m,  #endif
        if (prop->tmz_queue)
                tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, TMZ_MATCH, 1);
+       if (!prop->kernel_queue)
+               tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, RB_NON_PRIV, 1);
        mqd->cp_gfx_hqd_cntl = tmp;
 
        /* set up cp_doorbell_control */
@@ -4281,8 +4283,10 @@ static int gfx_v11_0_compute_mqd_init(struct amdgpu_device *adev, void *m,
        tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, UNORD_DISPATCH, 1);
        tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, TUNNEL_DISPATCH,
                            prop->allow_tunneling);
-       tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, PRIV_STATE, 1);
-       tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, KMD_QUEUE, 1);
+       if (prop->kernel_queue) {
+               tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, PRIV_STATE, 1);
+               tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, KMD_QUEUE, 1);
+       }
        if (prop->tmz_queue)
                tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, TMZ, 1);
        mqd->cp_hqd_pq_control = tmp;

--
2.50.1

#3 lore raw

RE: [PATCH 2/3] drm/amdgpu/gfx11: set MQD as appriopriate for queue types

[Public]

Maybe this issue is introduced by the userq mapped to a privileged queue, could you try whether the issue can be seen when only enable the userq?

Regards,
Prike

Quoted 79 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Zhang, Jesse(Jie)
Sent: Tuesday, July 22, 2025 10:38 AM
To: Deucher, Alexander <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu/gfx11: set MQD as appriopriate for queue types

[AMD Official Use Only - AMD Internal Distribution Only]

Hi Alex,

With this mqd configuration we get many cases of illegal register flooding and reset not working.
Should we create the privileged user queue ?

Log:
[drm:gfx_v11_0_priv_reg_irq [amdgpu]] *ERROR* Illegal register access in command stream [ 180.429970] [drm:gfx_v11_0_priv_reg_irq [amdgpu]] *ERROR* Illegal register access in command stream

Thanks
Jesse
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, July 17, 2025 6:01 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu/gfx11: set MQD as appriopriate for queue types

Set the MQD as appropriate for the kernel vs user queues.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +3 -0
index 372dceceff359..9dd49b1caa605 100644
@@ -4129,6 +4129,8 @@ static int gfx_v11_0_gfx_mqd_init(struct amdgpu_device
 *adev, void *m,  #endif
        if (prop->tmz_queue)
                tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, TMZ_MATCH, 1);
+       if (!prop->kernel_queue)
+               tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, RB_NON_PRIV,
+ 1);
        mqd->cp_gfx_hqd_cntl = tmp;
 
        /* set up cp_doorbell_control */ @@ -4281,8 +4283,10 @@ static int

gfx_v11_0_compute_mqd_init(struct amdgpu_device *adev, void *m,
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL,
UNORD_DISPATCH, 1);
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL,
TUNNEL_DISPATCH,

                            prop->allow_tunneling);
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2 -2
-       tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, PRIV_STATE, 1);
-       tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, KMD_QUEUE, 1);
+       if (prop->kernel_queue) {
+               tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, PRIV_STATE,

1);
+ tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, KMD_QUEUE,
1);
+ }

        if (prop->tmz_queue)
                tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, TMZ, 1);
        mqd->cp_hqd_pq_control = tmp;

--
2.50.1

#4 lore raw

RE: [PATCH 2/3] drm/amdgpu/gfx11: set MQD as appriopriate for queue types

[Public]

Yes, enabled privileged user queues and the flood disappeared, and the reset worked.

Thanks
Jesse
-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Tuesday, July 22, 2025 11:11 AM
To: Zhang, Jesse(Jie) <[email protected]>; Deucher, Alexander <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu/gfx11: set MQD as appriopriate for queue types

[Public]

Maybe this issue is introduced by the userq mapped to a privileged queue, could you try whether the issue can be seen when only enable the userq?

Regards,
Prike

Quoted 82 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Zhang,
Jesse(Jie)
Sent: Tuesday, July 22, 2025 10:38 AM
To: Deucher, Alexander <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu/gfx11: set MQD as appriopriate for queue types

[AMD Official Use Only - AMD Internal Distribution Only]

Hi Alex,

With this mqd configuration we get many cases of illegal register flooding and reset not working.
Should we create the privileged user queue ?

Log:
[drm:gfx_v11_0_priv_reg_irq [amdgpu]] *ERROR* Illegal register access in command stream [ 180.429970] [drm:gfx_v11_0_priv_reg_irq [amdgpu]] *ERROR* Illegal register access in command stream

Thanks
Jesse
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, July 17, 2025 6:01 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu/gfx11: set MQD as appriopriate for queue types

Set the MQD as appropriate for the kernel vs user queues.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0 -0
index 372dceceff359..9dd49b1caa605 100644
@@ -4129,6 +4129,8 @@ static int gfx_v11_0_gfx_mqd_init(struct

amdgpu_device *adev, void *m, #endif
if (prop->tmz_queue)
tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, TMZ_MATCH,
1);

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +3 -0
+       if (!prop->kernel_queue)
+               tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, RB_NON_PRIV,
+ 1);
        mqd->cp_gfx_hqd_cntl = tmp;
 
        /* set up cp_doorbell_control */ @@ -4281,8 +4283,10 @@ static

int gfx_v11_0_compute_mqd_init(struct amdgpu_device *adev, void *m,
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, UNORD_DISPATCH,
1);
tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, TUNNEL_DISPATCH,
prop->allow_tunneling);

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +3 -2
-       tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, PRIV_STATE, 1);
-       tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, KMD_QUEUE, 1);
+       if (prop->kernel_queue) {
+               tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL,
+ PRIV_STATE,

1);
+ tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, KMD_QUEUE,
1);
+ }

        if (prop->tmz_queue)
                tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, TMZ, 1);
        mqd->cp_hqd_pq_control = tmp;

--
2.50.1

author maintainer
#5 lore raw

PATCH 3/3 drm/amdgpu/gfx12: set MQD as appriopriate for queue types

In reply to Alex Deucher

Set the MQD as appropriate for the kernel vs user queues.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +6 -2
index 7220ed2fa2a33..73a04d07bb494 100644
@@ -3020,6 +3020,8 @@ static int gfx_v12_0_gfx_mqd_init(struct amdgpu_device *adev, void *m,
 #endif
 	if (prop->tmz_queue)
 		tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, TMZ_MATCH, 1);
+	if (!prop->kernel_queue)
+		tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, RB_NON_PRIV, 1);
 	mqd->cp_gfx_hqd_cntl = tmp;
 
 	/* set up cp_doorbell_control */
@@ -3169,8 +3171,10 @@ static int gfx_v12_0_compute_mqd_init(struct amdgpu_device *adev, void *m,
 			    (order_base_2(AMDGPU_GPU_PAGE_SIZE / 4) - 1));
 	tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, UNORD_DISPATCH, 1);
 	tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, TUNNEL_DISPATCH, 0);
-	tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, PRIV_STATE, 1);
-	tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, KMD_QUEUE, 1);
+	if (prop->kernel_queue) {
+		tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, PRIV_STATE, 1);
+		tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, KMD_QUEUE, 1);
+	}
 	if (prop->tmz_queue)
 		tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, TMZ, 1);
 	mqd->cp_hqd_pq_control = tmp;
Signature · 1 line
2.50.1
Reviewed-by on v1 3/3
#6 lore raw

Re: [PATCH 3/3] drm/amdgpu/gfx12: set MQD as appriopriate for queue types

Quoted 4 lines · Alex Deucher

Set the MQD as appropriate for the kernel vs user queues.

A couple of nit-picks for patch 1.

Series is -

Thanks,
Lijo

Quoted 30 lines
---
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +6 -2
index 7220ed2fa2a33..73a04d07bb494 100644
@@ -3020,6 +3020,8 @@ static int gfx_v12_0_gfx_mqd_init(struct amdgpu_device *adev, void *m,
 #endif
 	if (prop->tmz_queue)
 		tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, TMZ_MATCH, 1);
+	if (!prop->kernel_queue)
+		tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, RB_NON_PRIV, 1);
 	mqd->cp_gfx_hqd_cntl = tmp;
 
 	/* set up cp_doorbell_control */
@@ -3169,8 +3171,10 @@ static int gfx_v12_0_compute_mqd_init(struct amdgpu_device *adev, void *m,
 			    (order_base_2(AMDGPU_GPU_PAGE_SIZE / 4) - 1));
 	tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, UNORD_DISPATCH, 1);
 	tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, TUNNEL_DISPATCH, 0);
-	tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, PRIV_STATE, 1);
-	tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, KMD_QUEUE, 1);
+	if (prop->kernel_queue) {
+		tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, PRIV_STATE, 1);
+		tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, KMD_QUEUE, 1);
+	}
 	if (prop->tmz_queue)
 		tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, TMZ, 1);
 	mqd->cp_hqd_pq_control = tmp;
#7 lore raw

RE: [PATCH 3/3] drm/amdgpu/gfx12: set MQD as appriopriate for queue types

[Public]

What if when the kernel queue and user queue are enabled at the same time, then how to handle the case when userq mapped to a queue that has been enabled privileged bit by kernel queue?

Regards,
Prike

Quoted 64 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lazar, Lijo
Sent: Friday, July 18, 2025 12:13 PM
To: Deucher, Alexander <[email protected]>; amd- [email protected]
Cc: Koenig, Christian <[email protected]>
Subject: Re: [PATCH 3/3] drm/amdgpu/gfx12: set MQD as appriopriate for queue types

Quoted 4 lines · Alex Deucher

Set the MQD as appropriate for the kernel vs user queues.

A couple of nit-picks for patch 1.

Series is -

Thanks,
Lijo

Quoted 10 lines
---
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0 -0
index 7220ed2fa2a33..73a04d07bb494 100644
@@ -3020,6 +3020,8 @@ static int gfx_v12_0_gfx_mqd_init(struct
Quoted 3 lines

amdgpu_device *adev, void *m, #endif
if (prop->tmz_queue)
tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, TMZ_MATCH,

1);

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +2 -0
+   if (!prop->kernel_queue)
+           tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL,

RB_NON_PRIV, 1);

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

Quoted 4 lines
    mqd->cp_gfx_hqd_cntl = tmp;

    /* set up cp_doorbell_control */
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0 -0
@@ -3169,8 +3171,10 @@ static int gfx_v12_0_compute_mqd_init(struct

amdgpu_device *adev, void *m,

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c static int gfx_v12_0_compute_mqd_init(struct · line 3172

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0 -0
                        (order_base_2(AMDGPU_GPU_PAGE_SIZE / 4) - 1));
    tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL,

UNORD_DISPATCH, 1);

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c static int gfx_v12_0_compute_mqd_init(struct · line 3173

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0 -0
    tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL,

TUNNEL_DISPATCH, 0);

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c static int gfx_v12_0_compute_mqd_init(struct amdgpu_device *adev, void *m,

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +2 -2
-   tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, PRIV_STATE, 1);
-   tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, KMD_QUEUE, 1);
+   if (prop->kernel_queue) {
+           tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL,

PRIV_STATE, 1);

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c static int gfx_v12_0_compute_mqd_init(struct · line 3176

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1 -0
+           tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL,

KMD_QUEUE, 1);

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1 -0
+   }
    if (prop->tmz_queue)
            tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, TMZ, 1);
    mqd->cp_hqd_pq_control = tmp;
#8 lore raw

Re: [PATCH 3/3] drm/amdgpu/gfx12: set MQD as appriopriate for queue types

Quoted 6 lines · Prike

[Public]

What if when the kernel queue and user queue are enabled at the same time, then how to handle the case when userq mapped to a queue that has been enabled privileged bit by kernel queue?

These settings are per queue. kernel queues will be privileged and user queues will not be privileged. The MES will program the values from the MQD into the HQD when it maps the queues.

Alex

Quoted 69 lines

Regards,
Prike

Quoted 64 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lazar, Lijo
Sent: Friday, July 18, 2025 12:13 PM
To: Deucher, Alexander <[email protected]>; amd- [email protected]
Cc: Koenig, Christian <[email protected]>
Subject: Re: [PATCH 3/3] drm/amdgpu/gfx12: set MQD as appriopriate for queue types

Quoted 4 lines · Alex Deucher

Set the MQD as appropriate for the kernel vs user queues.

A couple of nit-picks for patch 1.

Series is -

Thanks,
Lijo

Quoted 10 lines
---
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0 -0
index 7220ed2fa2a33..73a04d07bb494 100644
@@ -3020,6 +3020,8 @@ static int gfx_v12_0_gfx_mqd_init(struct
Quoted 3 lines

amdgpu_device *adev, void *m, #endif
if (prop->tmz_queue)
tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, TMZ_MATCH,

1);

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +2 -0
+   if (!prop->kernel_queue)
+           tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL,

RB_NON_PRIV, 1);

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

Quoted 4 lines
    mqd->cp_gfx_hqd_cntl = tmp;

    /* set up cp_doorbell_control */
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0 -0
@@ -3169,8 +3171,10 @@ static int gfx_v12_0_compute_mqd_init(struct

amdgpu_device *adev, void *m,

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c static int gfx_v12_0_compute_mqd_init(struct · line 3172

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0 -0
                        (order_base_2(AMDGPU_GPU_PAGE_SIZE / 4) - 1));
    tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL,

UNORD_DISPATCH, 1);

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c static int gfx_v12_0_compute_mqd_init(struct · line 3173

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +0 -0
    tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL,

TUNNEL_DISPATCH, 0);

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c static int gfx_v12_0_compute_mqd_init(struct amdgpu_device *adev, void *m,

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +2 -2
-   tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, PRIV_STATE, 1);
-   tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, KMD_QUEUE, 1);
+   if (prop->kernel_queue) {
+           tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL,

PRIV_STATE, 1);

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c static int gfx_v12_0_compute_mqd_init(struct · line 3176

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1 -0
+           tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL,

KMD_QUEUE, 1);

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1 -0
+   }
    if (prop->tmz_queue)
            tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, TMZ, 1);
    mqd->cp_hqd_pq_control = tmp;
#9 lore raw
In reply to Alex Deucher
Quoted 3 lines · Alex Deucher

Used to to set the MQD appropriately for each queue type. Kernel queues have have additional privileges.

<nit> Extra 'have'

Quoted 24 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h      | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 ++
 2 files changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index a1737556a77eb..ef3af170dda4e 100644
@@ -883,6 +883,7 @@ struct amdgpu_mqd_prop {
 	uint64_t csa_addr;
 	uint64_t fence_address;
 	bool tmz_queue;
+	bool kernel_queue;
 };
 
 struct amdgpu_mqd {
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0 -0
index acac646a4e4e9..617dc009a2550 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c static void amdgpu_ring_to_mqd_prop(struct amdgpu_ring *ring, · line 722

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1 -0
@@ -719,6 +719,8 @@ static void amdgpu_ring_to_mqd_prop(struct amdgpu_ring *ring,
 	prop->eop_gpu_addr = ring->eop_gpu_addr;
 	prop->use_doorbell = ring->use_doorbell;
 	prop->doorbell_index = ring->doorbell_index;
+	/* kernel queues are privileged */

<nit> This comment is no longer needed here.

Thanks,
Lijo

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1 -0
+	prop->kernel_queue = true;
 
 	/* map_queues packet doesn't need activate the queue,
 	 * so only kiq need set this field.