amd-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amdkfd: Fix race in GWS queue scheduling
@ 2025-06-11 14:58 Jay Cornwall
  2025-06-17 15:16 ` Kasiviswanathan, Harish
  0 siblings, 1 reply; 2+ messages in thread
From: Jay Cornwall @ 2025-06-11 14:58 UTC (permalink / raw)
  To: amd-gfx; +Cc: Jay Cornwall

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.

Signed-off-by: Jay Cornwall <jay.cornwall@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c
index 8fa6489b6f5d..505036968a77 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c
@@ -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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH] drm/amdkfd: Fix race in GWS queue scheduling
  2025-06-11 14:58 [PATCH] drm/amdkfd: Fix race in GWS queue scheduling Jay Cornwall
@ 2025-06-17 15:16 ` Kasiviswanathan, Harish
  0 siblings, 0 replies; 2+ messages in thread
From: Kasiviswanathan, Harish @ 2025-06-17 15:16 UTC (permalink / raw)
  To: Cornwall, Jay, amd-gfx@lists.freedesktop.org; +Cc: Cornwall, Jay

[Public]

Reviewed-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>



-----Original Message-----
From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Jay Cornwall
Sent: Wednesday, June 11, 2025 10:58 AM
To: amd-gfx@lists.freedesktop.org
Cc: Cornwall, Jay <Jay.Cornwall@amd.com>
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.

Signed-off-by: Jay Cornwall <jay.cornwall@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c
index 8fa6489b6f5d..505036968a77 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c
@@ -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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-06-17 15:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-11 14:58 [PATCH] drm/amdkfd: Fix race in GWS queue scheduling Jay Cornwall
2025-06-17 15:16 ` Kasiviswanathan, Harish

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).