Skip to contentSkip to conversation

drm/amdkfd: Fix race in GWS queue scheduling

PATCH In review Jay Cornwall 2 participants 2 messages Jun 11, 2025 – Jun 17, 2025

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

PATCH 1/1 drm/amdkfd: Fix race in GWS queue scheduling

q->gws is not updated atomically with qpd->mapped_gws_queue. If a runlist is created between pqm_set_gws and update_queue it will contain a queue which uses GWS in a process with no GWS allocated. This will result in a scheduler hang.

Use q->properties.is_gws which is changed while holding the DQM lock.

---
 drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c +1 -1
index 8fa6489b6f5d..505036968a77 100644
@@ -240,7 +240,7 @@ static int pm_map_queues_v9(struct packet_manager *pm, uint32_t *buffer,
 
 	packet->bitfields2.engine_sel =
 		engine_sel__mes_map_queues__compute_vi;
-	packet->bitfields2.gws_control_queue = q->gws ? 1 : 0;
+	packet->bitfields2.gws_control_queue = q->properties.is_gws ? 1 : 0;
 	packet->bitfields2.extended_engine_sel =
 		extended_engine_sel__mes_map_queues__legacy_engine_sel;
 	packet->bitfields2.queue_type =
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw

[Public]

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Jay Cornwall
Sent: Wednesday, June 11, 2025 10:58 AM
To: [email protected]
Cc: Cornwall, Jay <[email protected]>
Subject: [PATCH] drm/amdkfd: Fix race in GWS queue scheduling

q->gws is not updated atomically with qpd->mapped_gws_queue. If a runlist is created between pqm_set_gws and update_queue it will contain a queue which uses GWS in a process with no GWS allocated. This will result in a scheduler hang.

Use q->properties.is_gws which is changed while holding the DQM lock.

---
 drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c +1 -1
index 8fa6489b6f5d..505036968a77 100644
@@ -240,7 +240,7 @@ static int pm_map_queues_v9(struct packet_manager *pm, uint32_t *buffer,
 
        packet->bitfields2.engine_sel =
                engine_sel__mes_map_queues__compute_vi;
-       packet->bitfields2.gws_control_queue = q->gws ? 1 : 0;
+       packet->bitfields2.gws_control_queue = q->properties.is_gws ? 1 : 0;
        packet->bitfields2.extended_engine_sel =
                extended_engine_sel__mes_map_queues__legacy_engine_sel;
        packet->bitfields2.queue_type =

--
2.34.1