drm/amdgpu: Enable tunneling on high-priority compute queues
Subsystems (2)
PATCH 1/1 drm/amdgpu: Enable tunneling on high-priority compute queues
This improves latency if the GPU is already busy with other work. This is useful for VR compositors that submit highly latency-sensitive compositing work on high-priority compute queues while the GPU is busy rendering the next frame.
Userspace merge request:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26462
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 10 ++++++---- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 3 ++- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -790,6 +790,7 @@ struct amdgpu_mqd_prop {uint64_t eop_gpu_addr;uint32_t hqd_pipe_priority;uint32_t hqd_queue_priority; +bool allow_tunneling;bool hqd_active; };
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +6 -4
@@ -620,6 +620,10 @@ static void amdgpu_ring_to_mqd_prop(struct amdgpu_ring *ring, struct amdgpu_mqd_prop *prop) {struct amdgpu_device *adev = ring->adev; +bool is_high_prio_compute = ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE && +amdgpu_gfx_is_high_priority_compute_queue (adev, ring); +bool is_high_prio_gfx = ring->funcs->type ==AMDGPU_RING_TYPE_GFX && +amdgpu_gfx_is_high_priority_graphics_queue (adev, ring);memset (prop,0 ,sizeof (*prop));
@@ -637,10 +641,8 @@ static void amdgpu_ring_to_mqd_prop(struct amdgpu_ring *ring,*/ prop->hqd_active = ring->funcs->type ==AMDGPU_RING_TYPE_KIQ ; -if ((ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE && -amdgpu_gfx_is_high_priority_compute_queue (adev, ring)) || - (ring->funcs->type ==AMDGPU_RING_TYPE_GFX && -amdgpu_gfx_is_high_priority_graphics_queue (adev, ring))) { + prop->allow_tunneling = is_high_prio_compute; +if (is_high_prio_compute || is_high_prio_gfx) { prop->hqd_pipe_priority =AMDGPU_GFX_PIPE_PRIO_HIGH ; prop->hqd_queue_priority =AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM ; }
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2 -1
@@ -6593,7 +6593,8 @@ static int gfx_v10_0_compute_mqd_init(struct amdgpu_device *adev, void *m, tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,ENDIAN_SWAP ,1 );#endif tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,UNORD_DISPATCH ,0 ); - tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,TUNNEL_DISPATCH ,0 ); + 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 ); mqd->cp_hqd_pq_control = tmp;
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2 -1
@@ -3847,7 +3847,8 @@ static int gfx_v11_0_compute_mqd_init(struct amdgpu_device *adev, void *m, tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,RPTR_BLOCK_SIZE , (order_base_2 (AMDGPU_GPU_PAGE_SIZE /4 ) -1 )); tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,UNORD_DISPATCH ,0 ); - tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,TUNNEL_DISPATCH ,0 ); + 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 ); mqd->cp_hqd_pq_control = tmp;
--
2.43.0
Interesting!
Gamescope also uses a high priority dedicated compute queue.
I'll see if this improves things on Deck with FSR, and other (sad) times we have to composite.
Have you looked at how things change with gpuvis at all by the way?
- Joshie 🐸✨
Quoted 87 lines · Friedrich Vock
This improves latency if the GPU is already busy with other work. This is useful for VR compositors that submit highly latency-sensitive compositing work on high-priority compute queues while the GPU is busy rendering the next frame.
Userspace merge request:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26462Signed-off-by Friedrich Vock <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 10 ++++++---- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 3 ++- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -790,6 +790,7 @@ struct amdgpu_mqd_prop {uint64_t eop_gpu_addr;uint32_t hqd_pipe_priority;uint32_t hqd_queue_priority; +bool allow_tunneling;bool hqd_active; };drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +6
-4@@ -620,6 +620,10 @@ static void amdgpu_ring_to_mqd_prop(struct amdgpu_ring *ring, struct amdgpu_mqd_prop *prop) {struct amdgpu_device *adev = ring->adev; +bool is_high_prio_compute = ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE && +amdgpu_gfx_is_high_priority_compute_queue (adev, ring); +bool is_high_prio_gfx = ring->funcs->type ==AMDGPU_RING_TYPE_GFX && +amdgpu_gfx_is_high_priority_graphics_queue (adev, ring);memset (prop,0 ,sizeof (*prop));@@ -637,10 +641,8 @@ static void amdgpu_ring_to_mqd_prop(struct amdgpu_ring *ring,*/ prop->hqd_active = ring->funcs->type ==AMDGPU_RING_TYPE_KIQ ; -if ((ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE && -amdgpu_gfx_is_high_priority_compute_queue (adev, ring)) || - (ring->funcs->type ==AMDGPU_RING_TYPE_GFX && -amdgpu_gfx_is_high_priority_graphics_queue (adev, ring))) { + prop->allow_tunneling = is_high_prio_compute; +if (is_high_prio_compute || is_high_prio_gfx) { prop->hqd_pipe_priority =AMDGPU_GFX_PIPE_PRIO_HIGH ; prop->hqd_queue_priority =AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM ; }drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2
-1@@ -6593,7 +6593,8 @@ static int gfx_v10_0_compute_mqd_init(struct amdgpu_device *adev, void *m, tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,ENDIAN_SWAP ,1 );#endif tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,UNORD_DISPATCH ,0 ); - tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,TUNNEL_DISPATCH ,0 ); + 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 ); mqd->cp_hqd_pq_control = tmp;drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2
-2@@ -3847,7 +3847,8 @@ static int gfx_v11_0_compute_mqd_init(struct amdgpu_device *adev, void *m, tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,RPTR_BLOCK_SIZE , (order_base_2 (AMDGPU_GPU_PAGE_SIZE /4 ) -1 )); tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,UNORD_DISPATCH ,0 ); - tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,TUNNEL_DISPATCH ,0 ); + 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 ); mqd->cp_hqd_pq_control = tmp; --2.43.0
Friendly ping on this one.
Userspace side got merged, so would be great to land this patch too :)
Quoted 87 lines · Friedrich Vock
This improves latency if the GPU is already busy with other work. This is useful for VR compositors that submit highly latency-sensitive compositing work on high-priority compute queues while the GPU is busy rendering the next frame.
Userspace merge request:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26462Signed-off-by Friedrich Vock <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 10 ++++++---- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 3 ++- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -790,6 +790,7 @@ struct amdgpu_mqd_prop {uint64_t eop_gpu_addr;uint32_t hqd_pipe_priority;uint32_t hqd_queue_priority; +bool allow_tunneling;bool hqd_active; };drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +6
-4@@ -620,6 +620,10 @@ static void amdgpu_ring_to_mqd_prop(struct amdgpu_ring *ring, struct amdgpu_mqd_prop *prop) {struct amdgpu_device *adev = ring->adev; +bool is_high_prio_compute = ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE && +amdgpu_gfx_is_high_priority_compute_queue (adev, ring); +bool is_high_prio_gfx = ring->funcs->type ==AMDGPU_RING_TYPE_GFX && +amdgpu_gfx_is_high_priority_graphics_queue (adev, ring);memset (prop,0 ,sizeof (*prop));@@ -637,10 +641,8 @@ static void amdgpu_ring_to_mqd_prop(struct amdgpu_ring *ring,*/ prop->hqd_active = ring->funcs->type ==AMDGPU_RING_TYPE_KIQ ; -if ((ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE && -amdgpu_gfx_is_high_priority_compute_queue (adev, ring)) || - (ring->funcs->type ==AMDGPU_RING_TYPE_GFX && -amdgpu_gfx_is_high_priority_graphics_queue (adev, ring))) { + prop->allow_tunneling = is_high_prio_compute; +if (is_high_prio_compute || is_high_prio_gfx) { prop->hqd_pipe_priority =AMDGPU_GFX_PIPE_PRIO_HIGH ; prop->hqd_queue_priority =AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM ; }drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2
-1@@ -6593,7 +6593,8 @@ static int gfx_v10_0_compute_mqd_init(struct amdgpu_device *adev, void *m, tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,ENDIAN_SWAP ,1 );#endif tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,UNORD_DISPATCH ,0 ); - tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,TUNNEL_DISPATCH ,0 ); + 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 ); mqd->cp_hqd_pq_control = tmp;drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2
-2@@ -3847,7 +3847,8 @@ static int gfx_v11_0_compute_mqd_init(struct amdgpu_device *adev, void *m, tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,RPTR_BLOCK_SIZE , (order_base_2 (AMDGPU_GPU_PAGE_SIZE /4 ) -1 )); tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,UNORD_DISPATCH ,0 ); - tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,TUNNEL_DISPATCH ,0 ); + 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 ); mqd->cp_hqd_pq_control = tmp; --2.43.0
Christian König
maintainerWell longer story short Alex and I have been digging up the documentation for this and as far as we can tell this isn't correct.
You need to do quite a bit more before you can turn on this feature. What userspace side do you refer to?
Regards,
Christian.
Am 08.12.23 um 09:19 schrieb Friedrich Vock:
Quoted 97 lines
Friendly ping on this one.
Userspace side got merged, so would be great to land this patch too :)Quoted 93 lines · Friedrich Vock
This improves latency if the GPU is already busy with other work. This is useful for VR compositors that submit highly latency-sensitive compositing work on high-priority compute queues while the GPU is busy rendering the next frame.
Userspace merge request:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26462Signed-off-by Friedrich Vock <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 +drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c| 10 ++++++---- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 3 ++- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 3 ++-4 files changed, 11 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -790,6 +790,7 @@ struct amdgpu_mqd_prop { uint64_t eop_gpu_addr; uint32_t hqd_pipe_priority; uint32_t hqd_queue_priority; + bool allow_tunneling; bool hqd_active; };drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1
-0@@ -620,6 +620,10 @@ static void amdgpu_ring_to_mqd_prop(struct amdgpu_ring *ring, struct amdgpu_mqd_prop *prop) { struct amdgpu_device *adev = ring->adev; + bool is_high_prio_compute = ring->funcs->type ==
AMDGPU_RING_TYPE_COMPUTE&&
+amdgpu_gfx_is_high_priority_compute_queue(adev, ring); + boolis_high_prio_gfx=ring->funcs->type==AMDGPU_RING_TYPE_GFX&&
+amdgpu_gfx_is_high_priority_graphics_queue(adev, ring);
memset(prop, 0, sizeof(*prop));drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2
-4@@ -637,10 +641,8 @@ static void amdgpu_ring_to_mqd_prop(structamdgpu_ring *ring, */ prop->hqd_active = ring->funcs->type == AMDGPU_RING_TYPE_KIQ; - if ((ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE && - amdgpu_gfx_is_high_priority_compute_queue(adev, ring)) || - (ring->funcs->type == AMDGPU_RING_TYPE_GFX && - amdgpu_gfx_is_high_priority_graphics_queue(adev, ring))) { + prop->allow_tunneling = is_high_prio_compute; + if (is_high_prio_compute || is_high_prio_gfx) { prop->hqd_pipe_priority = AMDGPU_GFX_PIPE_PRIO_HIGH; prop->hqd_queue_priority = AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM;}
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2
-1@@ -6593,7 +6593,8 @@ static int gfx_v10_0_compute_mqd_init(struct amdgpu_device *adev, void *m, tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, ENDIAN_SWAP, 1); #endif tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, UNORD_DISPATCH, 0); - tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, TUNNEL_DISPATCH, 0); + 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);
mqd->cp_hqd_pq_control= tmp;drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2
-1@@ -3847,7 +3847,8 @@ static int gfx_v11_0_compute_mqd_init(struct amdgpu_device *adev, void *m, tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, RPTR_BLOCK_SIZE, (order_base_2(AMDGPU_GPU_PAGE_SIZE / 4) - 1)); tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, UNORD_DISPATCH, 0); - tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, TUNNEL_DISPATCH, 0); + 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);
mqd->cp_hqd_pq_control= tmp;Signature · 1 line
2.43.0
Quoted 2 lines · Christian König
Well longer story short Alex and I have been digging up the documentation for this and as far as we can tell this isn't correct.
Huh. I initially talked to Marek about this, adding him in Cc.
Quoted 3 lines
You need to do quite a bit more before you can turn on this feature. What userspace side do you refer to?
I was referring to the Mesa merge request I made
(https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26462).
If/When you have more details about what else needs to be done, feel free to let me know.
I'm happy to expand this to add the rest of what's needed as well.
Thanks,
Friedrich
Quoted 107 lines
Regards,
Christian.Am 08.12.23 um 09:19 schrieb Friedrich Vock:
Quoted 101 lines
Friendly ping on this one.
Userspace side got merged, so would be great to land this patch too :)Quoted 97 lines · Friedrich Vock
This improves latency if the GPU is already busy with other work. This is useful for VR compositors that submit highly latency-sensitive compositing work on high-priority compute queues while the GPU is busy rendering the next frame.
Userspace merge request:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26462Signed-off-by Friedrich Vock <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 +drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c| 10 ++++++---- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 3 ++- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 3 ++-4 files changed, 11 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -790,6 +790,7 @@ struct amdgpu_mqd_prop { uint64_t eop_gpu_addr; uint32_t hqd_pipe_priority; uint32_t hqd_queue_priority; + bool allow_tunneling; bool hqd_active; };drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1
-0@@ -620,6 +620,10 @@ static void amdgpu_ring_to_mqd_prop(struct amdgpu_ring *ring, struct amdgpu_mqd_prop *prop) { struct amdgpu_device *adev = ring->adev; + bool is_high_prio_compute = ring->funcs->type ==
AMDGPU_RING_TYPE_COMPUTE&&
+amdgpu_gfx_is_high_priority_compute_queue(adev, ring); + boolis_high_prio_gfx=ring->funcs->type==AMDGPU_RING_TYPE_GFX&&
+amdgpu_gfx_is_high_priority_graphics_queue(adev, ring);
memset(prop, 0, sizeof(*prop));drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2
-4@@ -637,10 +641,8 @@ static void amdgpu_ring_to_mqd_prop(structamdgpu_ring *ring, */ prop->hqd_active = ring->funcs->type == AMDGPU_RING_TYPE_KIQ; - if ((ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE && - amdgpu_gfx_is_high_priority_compute_queue(adev, ring)) || - (ring->funcs->type == AMDGPU_RING_TYPE_GFX && - amdgpu_gfx_is_high_priority_graphics_queue(adev, ring))) { + prop->allow_tunneling = is_high_prio_compute; + if (is_high_prio_compute || is_high_prio_gfx) { prop->hqd_pipe_priority = AMDGPU_GFX_PIPE_PRIO_HIGH; prop->hqd_queue_priority = AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM;}
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2
-1@@ -6593,7 +6593,8 @@ static int gfx_v10_0_compute_mqd_init(struct amdgpu_device *adev, void *m, tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, ENDIAN_SWAP, 1); #endif tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, UNORD_DISPATCH, 0); - tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, TUNNEL_DISPATCH, 0); + 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);
mqd->cp_hqd_pq_control= tmp;drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2
-1@@ -3847,7 +3847,8 @@ static int gfx_v11_0_compute_mqd_init(struct amdgpu_device *adev, void *m, tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, RPTR_BLOCK_SIZE, (order_base_2(AMDGPU_GPU_PAGE_SIZE / 4) - 1)); tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, UNORD_DISPATCH, 0); - tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, TUNNEL_DISPATCH, 0); + 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);
mqd->cp_hqd_pq_control= tmp;
--
2.43.0
Christian König
maintainerAm 08.12.23 um 12:43 schrieb Friedrich Vock:
Quoted 4 lines · Christian König
Quoted 2 lines
Well longer story short Alex and I have been digging up the documentation for this and as far as we can tell this isn't correct.
Huh. I initially talked to Marek about this, adding him in Cc.
Yeah, from the userspace side all you need to do is to set the bit as far as I can tell.
Quoted 7 lines
Quoted 3 lines
You need to do quite a bit more before you can turn on this feature. What userspace side do you refer to?
I was referring to the Mesa merge request I made
(https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26462).
If/When you have more details about what else needs to be done, feel free to let me know.
For example from the hardware specification explicitly states that the kernel driver should make sure that only one app/queue is using this at the same time. That might work for now since we should only have a single compute priority queue, but we are not 100% sure yet.
Apart from that the hardware documentation only says that it's a nice to have feature and when we pinged firmware engineers to get more information they didn't know the feature immediately either.
That is usually a strong indicator that stuff was implemented in the hardware, but not fully completed and tested by the firmware team and validation team.
Alex and I need to confirm that this feature actually works the way it should and that it's validated/stable/read for production use.
Regards,
Christian.
Quoted 112 lines
I'm happy to expand this to add the rest of what's needed as well.
Thanks,
FriedrichQuoted 107 lines
Regards,
Christian.Am 08.12.23 um 09:19 schrieb Friedrich Vock:
Quoted 101 lines
Friendly ping on this one.
Userspace side got merged, so would be great to land this patch too :)Quoted 97 lines · Friedrich Vock
This improves latency if the GPU is already busy with other work. This is useful for VR compositors that submit highly latency-sensitive compositing work on high-priority compute queues while the GPU is busy rendering the next frame.
Userspace merge request:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26462Signed-off-by Friedrich Vock <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 +drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c| 10 ++++++---- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 3 ++- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 3 ++-4 files changed, 11 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -790,6 +790,7 @@ struct amdgpu_mqd_prop { uint64_t eop_gpu_addr; uint32_t hqd_pipe_priority; uint32_t hqd_queue_priority; + bool allow_tunneling; bool hqd_active; };drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1
-0@@ -620,6 +620,10 @@ static void amdgpu_ring_to_mqd_prop(struct amdgpu_ring *ring, struct amdgpu_mqd_prop *prop) { struct amdgpu_device *adev = ring->adev; + bool is_high_prio_compute = ring->funcs->type ==
AMDGPU_RING_TYPE_COMPUTE&&
+amdgpu_gfx_is_high_priority_compute_queue(adev, ring); + boolis_high_prio_gfx=ring->funcs->type==AMDGPU_RING_TYPE_GFX&&
+amdgpu_gfx_is_high_priority_graphics_queue(adev, ring);
memset(prop, 0, sizeof(*prop));drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2
-4@@ -637,10 +641,8 @@ static void amdgpu_ring_to_mqd_prop(structamdgpu_ring *ring, */ prop->hqd_active = ring->funcs->type == AMDGPU_RING_TYPE_KIQ; - if ((ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE && - amdgpu_gfx_is_high_priority_compute_queue(adev, ring)) || - (ring->funcs->type == AMDGPU_RING_TYPE_GFX && - amdgpu_gfx_is_high_priority_graphics_queue(adev, ring))) { + prop->allow_tunneling = is_high_prio_compute; + if (is_high_prio_compute || is_high_prio_gfx) { prop->hqd_pipe_priority = AMDGPU_GFX_PIPE_PRIO_HIGH; prop->hqd_queue_priority = AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM;}
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2
-1@@ -6593,7 +6593,8 @@ static int gfx_v10_0_compute_mqd_init(struct amdgpu_device *adev, void *m, tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, ENDIAN_SWAP, 1); #endif tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, UNORD_DISPATCH, 0); - tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, TUNNEL_DISPATCH, 0); + 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);
mqd->cp_hqd_pq_control= tmp;drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2
-1@@ -3847,7 +3847,8 @@ static int gfx_v11_0_compute_mqd_init(struct amdgpu_device *adev, void *m, tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, RPTR_BLOCK_SIZE, (order_base_2(AMDGPU_GPU_PAGE_SIZE / 4) - 1)); tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, UNORD_DISPATCH, 0); - tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, TUNNEL_DISPATCH, 0); + 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);
mqd->cp_hqd_pq_control= tmp;Signature · 1 line
2.43.0
[AMD Official Use Only - General]
Christian, firmware has nothing to do with it and doesn't control it. That was a wrong group of people to ping. It's only implemented in the SPI and tested by the SPI team and PAL team.
Marek
________________________________
From: Koenig, Christian <[email protected]>
Sent: December 8, 2023 09:38
To: Friedrich Vock <[email protected]>; [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Olsak, Marek <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Enable tunneling on high-priority compute queues
Am 08.12.23 um 12:43 schrieb Friedrich Vock:
Quoted 4 lines · Christian König
Quoted 2 lines
Well longer story short Alex and I have been digging up the documentation for this and as far as we can tell this isn't correct.
Huh. I initially talked to Marek about this, adding him in Cc.
Yeah, from the userspace side all you need to do is to set the bit as far as I can tell.
Quoted 7 lines
Quoted 3 lines
You need to do quite a bit more before you can turn on this feature. What userspace side do you refer to?
I was referring to the Mesa merge request I made
(https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26462).
If/When you have more details about what else needs to be done, feel free to let me know.
For example from the hardware specification explicitly states that the kernel driver should make sure that only one app/queue is using this at the same time. That might work for now since we should only have a single compute priority queue, but we are not 100% sure yet.
Apart from that the hardware documentation only says that it's a nice to have feature and when we pinged firmware engineers to get more information they didn't know the feature immediately either.
That is usually a strong indicator that stuff was implemented in the hardware, but not fully completed and tested by the firmware team and validation team.
Alex and I need to confirm that this feature actually works the way it should and that it's validated/stable/read for production use.
Regards,
Christian.
Quoted 113 lines
I'm happy to expand this to add the rest of what's needed as well.
Thanks,
FriedrichQuoted 108 lines
Regards,
Christian.Am 08.12.23 um 09:19 schrieb Friedrich Vock:
Quoted 102 lines
Friendly ping on this one.
Userspace side got merged, so would be great to land this patch too :)Quoted 98 lines · Friedrich Vock
This improves latency if the GPU is already busy with other work. This is useful for VR compositors that submit highly latency-sensitive compositing work on high-priority compute queues while the GPU is busy rendering the next frame.
Userspace merge request:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26462Signed-off-by Friedrich Vock <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 10 ++++++---- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 3 ++- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -790,6 +790,7 @@ struct amdgpu_mqd_prop {uint64_t eop_gpu_addr;uint32_t hqd_pipe_priority;uint32_t hqd_queue_priority; +bool allow_tunneling;bool hqd_active; };drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1
-0@@ -620,6 +620,10 @@ static void amdgpu_ring_to_mqd_prop(structamdgpu_ring *ring, struct amdgpu_mqd_prop *prop) { struct amdgpu_device *adev = ring->adev; + bool is_high_prio_compute = ring->funcs->type ==
AMDGPU_RING_TYPE_COMPUTE&&
+amdgpu_gfx_is_high_priority_compute_queue(adev, ring);
+ boolis_high_prio_gfx=ring->funcs->type==AMDGPU_RING_TYPE_GFX&&
+amdgpu_gfx_is_high_priority_graphics_queue(adev, ring);memset(prop, 0, sizeof(*prop));drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2
-4@@ -637,10 +641,8 @@ static void amdgpu_ring_to_mqd_prop(structamdgpu_ring *ring, */ prop->hqd_active = ring->funcs->type ==AMDGPU_RING_TYPE_KIQ ; -if ((ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE && -amdgpu_gfx_is_high_priority_compute_queue (adev, ring)) || - (ring->funcs->type ==AMDGPU_RING_TYPE_GFX && -amdgpu_gfx_is_high_priority_graphics_queue (adev, ring))) { + prop->allow_tunneling = is_high_prio_compute; +if (is_high_prio_compute || is_high_prio_gfx) { prop->hqd_pipe_priority =AMDGPU_GFX_PIPE_PRIO_HIGH ; prop->hqd_queue_priority =AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM; }drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2
-1@@ -6593,7 +6593,8 @@ static int gfx_v10_0_compute_mqd_init(struct amdgpu_device *adev, void *m, tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,ENDIAN_SWAP ,1 );#endif tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,UNORD_DISPATCH ,0 ); - tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,TUNNEL_DISPATCH ,0 ); + 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 );mqd->cp_hqd_pq_control = tmp;drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2
-1@@ -3847,7 +3847,8 @@ static int gfx_v11_0_compute_mqd_init(struct amdgpu_device *adev, void *m, tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,RPTR_BLOCK_SIZE , (order_base_2 (AMDGPU_GPU_PAGE_SIZE /4 ) -1 )); tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,UNORD_DISPATCH ,0 ); - tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,TUNNEL_DISPATCH ,0 ); + 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 );mqd->cp_hqd_pq_control = tmp;--
2.43.0
Quoted 17 lines · Christian König
Am 08.12.23 um 12:43 schrieb Friedrich Vock:
Quoted 4 lines · Christian König
Quoted 2 lines
Well longer story short Alex and I have been digging up the documentation for this and as far as we can tell this isn't correct.
Huh. I initially talked to Marek about this, adding him in Cc.
Yeah, from the userspace side all you need to do is to set the bit as far as I can tell.
Quoted 7 lines
Quoted 3 lines
You need to do quite a bit more before you can turn on this feature. What userspace side do you refer to?
I was referring to the Mesa merge request I made
(https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26462).
If/When you have more details about what else needs to be done, feel free to let me know.
Quoted 5 lines
For example from the hardware specification explicitly states that the kernel driver should make sure that only one app/queue is using this at the same time. That might work for now since we should only have a single compute priority queue, but we are not 100% sure yet.
This is incorrect. While the hw documentation says it's considered "unexpected programming", it also says that the hardware algorithm handles it correctly and it describes what happens in this case: Tunneled waves from different queues are treated as equal.
Marek
FWIW, we are shipping this right now in SteamOS Preview channel (probably going to Stable soon) and it seems to be working as expected and fixing issues there in instances we need to composite, compositor work we are forced to do would take longer than the compositor redzone to vblank.
Previously in high gfx workloads like Cyberpunk using 100% of the GPU, we would consistently miss the deadline as composition could take anywhere from 2-6ms fairly randomly.
Now it seems the time for the compositor's work to complete is pretty consistent and well in-time in gpuvis for every frame.
The only times we are not meeting deadline now is when there is an application using very little GPU and finishes incredibly quick, and the compositor is doing significantly more work (eg. FSR from 800p -> 4K or whatever), but that's a separate problem that can likely be solved by inlining some of the composition work with the client's dmabuf work if it has focus to avoid those clock bubbles.
I heard some musings about dmabuf deadline kernel work recently, but not sure if any of that is applicable to AMD.
- Joshie 🐸✨
Quoted 29 lines · Marek Olšák
On Fri, Dec 8, 2023 at 9:57 AM Christian König <[email protected] <mailto:[email protected]>> wrote:
Am 08.12.23 um 12:43 schrieb Friedrich Vock:
> On 08.12.23 10:51, Christian König wrote:
>> Well longer story short Alex and I have been digging up the >> documentation for this and as far as we can tell this isn't correct. > Huh. I initially talked to Marek about this, adding him in Cc.Yeah, from the userspace side all you need to do is to set the bit as far as I can tell.
>>
>> You need to do quite a bit more before you can turn on this feature. >> What userspace side do you refer to?
> I was referring to the Mesa merge request I made
> (https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26462
<https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26462>).
> If/When you have more details about what else needs to be done, feel > free to let me know.For example from the hardware specification explicitly states that the kernel driver should make sure that only one app/queue is using this at the same time. That might work for now since we should only have a single compute priority queue, but we are not 100% sure yet.
This is incorrect. While the hw documentation says it's considered "unexpected programming", it also says that the hardware algorithm handles it correctly and it describes what happens in this case: Tunneled waves from different queues are treated as equal.
Marek
Quoted 7 lines · Joshua Ashton
FWIW, we are shipping this right now in SteamOS Preview channel (probably going to Stable soon) and it seems to be working as expected and fixing issues there in instances we need to composite, compositor work we are forced to do would take longer than the compositor redzone to vblank.
Quoted 6 lines
Previously in high gfx workloads like Cyberpunk using 100% of the GPU, we would consistently miss the deadline as composition could take anywhere from 2-6ms fairly randomly.
Now it seems the time for the compositor's work to complete is pretty consistent and well in-time in gpuvis for every frame.
I was mostly just trying to look up the information to verify that it was set up correctly, but I guess Marek already did and provided you with that info, so it's probably fine as is.
Quoted 10 lines
The only times we are not meeting deadline now is when there is an application using very little GPU and finishes incredibly quick, and the compositor is doing significantly more work (eg. FSR from 800p -> 4K or whatever), but that's a separate problem that can likely be solved by inlining some of the composition work with the client's dmabuf work if it has focus to avoid those clock bubbles.
I heard some musings about dmabuf deadline kernel work recently, but not sure if any of that is applicable to AMD.
I think something like a workload hint would be more useful. We did a few patch sets to allow userspace to provide a hint to the kernel about the workload type so the kernel could adjust the power management heuristics accordingly, but there were concerns that the UMDs would have to maintain application lists to select which heuristic worked best for each application. Maybe it would be better to provide a general classification? E.g., if the GL or vulkan app uses these extensions, it's probably a compute type application vs something more graphics-y. The usual trade-off between power and performance. In general, just letting the firmware pick the clock based on perf counters generally seems to work the best. Maybe a general workload hint set by the compositor based on the content type it's displaying would be a better option (video vs gaming vs desktop)?
The deadline stuff doesn't really align well with what we can do with our firmware and seems ripe for abuse. Apps can just ask for high clocks all the time which is great for performance, but not great for power. Plus there is not much room for anything other than max clocks since you don't know how big the workload is or which clocks are the limiting factor.
Alex
Quoted 38 lines
- Joshie 🐸✨
Quoted 33 lines · Marek Olšák
On Fri, Dec 8, 2023 at 9:57 AM Christian König <[email protected] <mailto:[email protected]>> wrote:
Am 08.12.23 um 12:43 schrieb Friedrich Vock:
> On 08.12.23 10:51, Christian König wrote:
>> Well longer story short Alex and I have been digging up the >> documentation for this and as far as we can tell this isn't correct. > Huh. I initially talked to Marek about this, adding him in Cc.Yeah, from the userspace side all you need to do is to set the bit as far as I can tell.
>>
>> You need to do quite a bit more before you can turn on this feature. >> What userspace side do you refer to?
> I was referring to the Mesa merge request I made
> (https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26462
<https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26462>).
> If/When you have more details about what else needs to be done, feel > free to let me know.For example from the hardware specification explicitly states that the kernel driver should make sure that only one app/queue is using this at the same time. That might work for now since we should only have a single compute priority queue, but we are not 100% sure yet.
This is incorrect. While the hw documentation says it's considered "unexpected programming", it also says that the hardware algorithm handles it correctly and it describes what happens in this case:
Tunneled waves from different queues are treated as equal.Marek
Quoted 44 lines · Alex Deucher
Quoted 7 lines · Joshua Ashton
FWIW, we are shipping this right now in SteamOS Preview channel (probably going to Stable soon) and it seems to be working as expected and fixing issues there in instances we need to composite, compositor work we are forced to do would take longer than the compositor redzone to vblank.
Quoted 6 lines
Previously in high gfx workloads like Cyberpunk using 100% of the GPU, we would consistently miss the deadline as composition could take anywhere from 2-6ms fairly randomly.
Now it seems the time for the compositor's work to complete is pretty consistent and well in-time in gpuvis for every frame.
I was mostly just trying to look up the information to verify that it was set up correctly, but I guess Marek already did and provided you with that info, so it's probably fine as is.
Quoted 10 lines
The only times we are not meeting deadline now is when there is an application using very little GPU and finishes incredibly quick, and the compositor is doing significantly more work (eg. FSR from 800p -> 4K or whatever), but that's a separate problem that can likely be solved by inlining some of the composition work with the client's dmabuf work if it has focus to avoid those clock bubbles.
I heard some musings about dmabuf deadline kernel work recently, but not sure if any of that is applicable to AMD.
I think something like a workload hint would be more useful. We did a few patch sets to allow userspace to provide a hint to the kernel about the workload type so the kernel could adjust the power management heuristics accordingly, but there were concerns that the UMDs would have to maintain application lists to select which heuristic worked best for each application. Maybe it would be better to provide a general classification? E.g., if the GL or vulkan app uses these extensions, it's probably a compute type application vs something more graphics-y. The usual trade-off between power and performance. In general, just letting the firmware pick the clock based on perf counters generally seems to work the best. Maybe a general workload hint set by the compositor based on the content type it's displaying would be a better option (video vs gaming vs desktop)?
Quoted 7 lines
The deadline stuff doesn't really align well with what we can do with our firmware and seems ripe for abuse. Apps can just ask for high clocks all the time which is great for performance, but not great for power. Plus there is not much room for anything other than max clocks since you don't know how big the workload is or which clocks are the limiting factor.
Max clocks also decrease performance due to thermal and power limits. You'll get more performance and less heat if you let the GPU turn off idle blocks and boost clocks for busy blocks.
Marek
Quoted 5 lines · Alex Deucher
Quoted 3 lines · Joshua Ashton
I heard some musings about dmabuf deadline kernel work recently, but not sure if any of that is applicable to AMD.
Quoted 13 lines
I think something like a workload hint would be more useful. We did a few patch sets to allow userspace to provide a hint to the kernel about the workload type so the kernel could adjust the power management heuristics accordingly, but there were concerns that the UMDs would have to maintain application lists to select which heuristic worked best for each application. Maybe it would be better to provide a general classification? E.g., if the GL or vulkan app uses these extensions, it's probably a compute type application vs something more graphics-y. The usual trade-off between power and performance. In general, just letting the firmware pick the clock based on perf counters generally seems to work the best. Maybe a general workload hint set by the compositor based on the content type it's displaying would be a better option (video vs gaming vs desktop)?
Low clocks can be an issue even for normal desktop workloads, so doubtful that this would be a complete solution.
Quoted 4 lines
The deadline stuff doesn't really align well with what we can do with our firmware and seems ripe for abuse. Apps can just ask for high clocks all the time which is great for performance, but not great for power.
Maybe the firmware power management heuristics could be derived from the system power profile and fence deadline? E.g. the power profile defines the upper and lower boundaries, the upper boundary is used while there's a pending fence deadline, otherwise the lower boundary.
Signature · 2 lines
Earthling Michel Dänzer | https://redhat.com Libre software enthusiast | Mesa and Xwayland developer
Marek Olšák
Reviewed-byIt's correct according to our documentation.
Marek
Quoted 113 lines · Christian König
Well longer story short Alex and I have been digging up the documentation for this and as far as we can tell this isn't correct.
You need to do quite a bit more before you can turn on this feature. What userspace side do you refer to?
Regards,
Christian.Am 08.12.23 um 09:19 schrieb Friedrich Vock:
Quoted 101 lines
Friendly ping on this one.
Userspace side got merged, so would be great to land this patch too :)Quoted 97 lines · Friedrich Vock
This improves latency if the GPU is already busy with other work. This is useful for VR compositors that submit highly latency-sensitive compositing work on high-priority compute queues while the GPU is busy rendering the next frame.
Userspace merge request:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26462Signed-off-by Friedrich Vock <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 10 ++++++---- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 3 ++- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -790,6 +790,7 @@ struct amdgpu_mqd_prop {uint64_t eop_gpu_addr;uint32_t hqd_pipe_priority;uint32_t hqd_queue_priority; +bool allow_tunneling;bool hqd_active; };drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1
-0@@ -620,6 +620,10 @@ static void amdgpu_ring_to_mqd_prop(structamdgpu_ring *ring, struct amdgpu_mqd_prop *prop) { struct amdgpu_device *adev = ring->adev; + bool is_high_prio_compute = ring->funcs->type ==
AMDGPU_RING_TYPE_COMPUTE&&
+amdgpu_gfx_is_high_priority_compute_queue(adev, ring);
+ boolis_high_prio_gfx=ring->funcs->type==AMDGPU_RING_TYPE_GFX&&
+amdgpu_gfx_is_high_priority_graphics_queue(adev, ring);memset(prop, 0, sizeof(*prop));drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2
-4@@ -637,10 +641,8 @@ static void amdgpu_ring_to_mqd_prop(structamdgpu_ring *ring, */ prop->hqd_active = ring->funcs->type ==AMDGPU_RING_TYPE_KIQ ; -if ((ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE && -amdgpu_gfx_is_high_priority_compute_queue (adev, ring)) || - (ring->funcs->type ==AMDGPU_RING_TYPE_GFX && -amdgpu_gfx_is_high_priority_graphics_queue (adev, ring))) { + prop->allow_tunneling = is_high_prio_compute; +if (is_high_prio_compute || is_high_prio_gfx) { prop->hqd_pipe_priority =AMDGPU_GFX_PIPE_PRIO_HIGH ; prop->hqd_queue_priority =AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM ;}drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2
-1@@ -6593,7 +6593,8 @@ static int gfx_v10_0_compute_mqd_init(struct amdgpu_device *adev, void *m, tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,ENDIAN_SWAP ,1 );#endif tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,UNORD_DISPATCH ,0 ); - tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,TUNNEL_DISPATCH ,0 ); + 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 );mqd->cp_hqd_pq_control = tmp;drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2
-1@@ -3847,7 +3847,8 @@ static int gfx_v11_0_compute_mqd_init(struct amdgpu_device *adev, void *m, tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,RPTR_BLOCK_SIZE , (order_base_2 (AMDGPU_GPU_PAGE_SIZE /4 ) -1 )); tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,UNORD_DISPATCH ,0 ); - tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,TUNNEL_DISPATCH ,0 ); + 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 );mqd->cp_hqd_pq_control = tmp;--
2.43.0
Quoted 10 lines · Friedrich Vock
This improves latency if the GPU is already busy with other work. This is useful for VR compositors that submit highly latency-sensitive compositing work on high-priority compute queues while the GPU is busy rendering the next frame.
Userspace merge request:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26462Signed-off-by Friedrich Vock <[email protected]>
Applied with a minor change to bump the driver version as well so userspace can detect this if necessary. It shouldn't matter, but better safe than sorry.
Alex
Quoted 78 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 10 ++++++---- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 3 ++- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -790,6 +790,7 @@ struct amdgpu_mqd_prop {uint64_t eop_gpu_addr;uint32_t hqd_pipe_priority;uint32_t hqd_queue_priority; +bool allow_tunneling;bool hqd_active; };drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +6
-4@@ -620,6 +620,10 @@ static void amdgpu_ring_to_mqd_prop(struct amdgpu_ring *ring, struct amdgpu_mqd_prop *prop) {struct amdgpu_device *adev = ring->adev; +bool is_high_prio_compute = ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE && +amdgpu_gfx_is_high_priority_compute_queue (adev, ring); +bool is_high_prio_gfx = ring->funcs->type ==AMDGPU_RING_TYPE_GFX && +amdgpu_gfx_is_high_priority_graphics_queue (adev, ring);memset (prop,0 ,sizeof (*prop));@@ -637,10 +641,8 @@ static void amdgpu_ring_to_mqd_prop(struct amdgpu_ring *ring,*/ prop->hqd_active = ring->funcs->type ==AMDGPU_RING_TYPE_KIQ ; -if ((ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE && -amdgpu_gfx_is_high_priority_compute_queue (adev, ring)) || - (ring->funcs->type ==AMDGPU_RING_TYPE_GFX && -amdgpu_gfx_is_high_priority_graphics_queue (adev, ring))) { + prop->allow_tunneling = is_high_prio_compute; +if (is_high_prio_compute || is_high_prio_gfx) { prop->hqd_pipe_priority =AMDGPU_GFX_PIPE_PRIO_HIGH ; prop->hqd_queue_priority =AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM ; }drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2
-1@@ -6593,7 +6593,8 @@ static int gfx_v10_0_compute_mqd_init(struct amdgpu_device *adev, void *m, tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,ENDIAN_SWAP ,1 );#endif tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,UNORD_DISPATCH ,0 ); - tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,TUNNEL_DISPATCH ,0 ); + 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 ); mqd->cp_hqd_pq_control = tmp;drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2
-2@@ -3847,7 +3847,8 @@ static int gfx_v11_0_compute_mqd_init(struct amdgpu_device *adev, void *m, tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,RPTR_BLOCK_SIZE , (order_base_2 (AMDGPU_GPU_PAGE_SIZE /4 ) -1 )); tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,UNORD_DISPATCH ,0 ); - tmp =REG_SET_FIELD (tmp,CP_HQD_PQ_CONTROL ,TUNNEL_DISPATCH ,0 ); + 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 ); mqd->cp_hqd_pq_control = tmp; --2.43.0