All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 1/2] drm/amdgpu: add remove all process queues support for MES v12.1
@ 2026-12-04  3:33 Mukul Joshi
  2026-12-04  3:33 ` [PATCHv2 2/2] drm/amdkfd: remove all queues of a process with a single MES call Mukul Joshi
  0 siblings, 1 reply; 4+ messages in thread
From: Mukul Joshi @ 2026-12-04  3:33 UTC (permalink / raw)
  To: amd-gfx; +Cc: Felix.Kuehling, Harish.Kasiviswanathan, amber.lin, Mukul Joshi

MES recently added support to remove all queues of a process with a
single REMOVE_QUEUE request. Use it to optimize queue removal during
process eviction and termination.

Add the new fields to the MES v12 REMOVE_QUEUE packet definition and
to struct mes_remove_queue_input, program them in
mes_v12_1_remove_hw_queue(), and add
amdgpu_mes_remove_all_process_queues_supported() so callers can check
whether the running MES firmware supports it. It is supported on GC
12.1 with MES scheduler firmware version 0x87 or newer.

Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c       |  9 +++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h       |  3 +++
 drivers/gpu/drm/amd/amdgpu/mes_v12_1.c        | 13 +++++++++----
 drivers/gpu/drm/amd/include/mes_v12_api_def.h | 10 +++++++++-
 4 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
index 27d6371d8d79..9ff3c1dd4842 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
@@ -966,6 +966,15 @@ bool amdgpu_mes_queue_reset_by_mes_supported(struct amdgpu_device *adev)
 		((ip_maj == 12 && ip_min == 1) && mes_sched >= 0x7b);
 }
 
+bool amdgpu_mes_remove_all_process_queues_supported(struct amdgpu_device *adev)
+{
+	u32 ip_maj = IP_VERSION_MAJ(amdgpu_ip_version(adev, GC_HWIP, 0));
+	u32 ip_min = IP_VERSION_MIN(amdgpu_ip_version(adev, GC_HWIP, 0));
+	u32 mes_sched = adev->mes.sched_version & AMDGPU_MES_VERSION_MASK;
+
+	return ip_maj == 12 && ip_min == 1 && mes_sched >= 0x87;
+}
+
 /* Fix me -- node_id is used to identify the correct MES instances in the future */
 static int amdgpu_mes_set_enforce_isolation(struct amdgpu_device *adev,
 					    uint32_t node_id, bool enable)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h
index 89051073321d..b29633ede051 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h
@@ -333,6 +333,8 @@ struct mes_remove_queue_input {
 	uint32_t	queue_type;
 	bool		remove_queue_after_reset;
 	uint32_t	gang_context_array_index;
+	bool		remove_all_process_queues;
+	uint32_t	pasid;
 };
 
 struct mes_map_legacy_queue_input {
@@ -738,6 +740,7 @@ static inline void amdgpu_mes_unlock(struct amdgpu_mes *mes)
 
 bool amdgpu_mes_suspend_resume_all_supported(struct amdgpu_device *adev);
 bool amdgpu_mes_queue_reset_by_mes_supported(struct amdgpu_device *adev);
+bool amdgpu_mes_remove_all_process_queues_supported(struct amdgpu_device *adev);
 
 int amdgpu_mes_update_enforce_isolation(struct amdgpu_device *adev);
 
diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v12_1.c b/drivers/gpu/drm/amd/amdgpu/mes_v12_1.c
index 84a3693db6ad..378d4278377c 100644
--- a/drivers/gpu/drm/amd/amdgpu/mes_v12_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/mes_v12_1.c
@@ -363,10 +363,15 @@ static int mes_v12_1_remove_hw_queue(struct amdgpu_mes *mes,
 	mes_remove_queue_pkt.header.opcode = MES_SCH_API_REMOVE_QUEUE;
 	mes_remove_queue_pkt.header.dwsize = API_FRAME_SIZE_IN_DWORDS;
 
-	mes_remove_queue_pkt.doorbell_offset = input->doorbell_offset;
-	mes_remove_queue_pkt.gang_context_addr = input->gang_context_addr;
-	mes_remove_queue_pkt.queue_type =
-		convert_to_mes_queue_type(input->queue_type);
+	if (input->remove_all_process_queues) {
+		mes_remove_queue_pkt.remove_all_process_queues = 1;
+		mes_remove_queue_pkt.pasid = input->pasid;
+	} else {
+		mes_remove_queue_pkt.doorbell_offset = input->doorbell_offset;
+		mes_remove_queue_pkt.gang_context_addr = input->gang_context_addr;
+		mes_remove_queue_pkt.queue_type =
+			convert_to_mes_queue_type(input->queue_type);
+	}
 
 	return mes_v12_1_submit_pkt_and_poll_completion(mes,
 			xcc_id, AMDGPU_MES_SCHED_PIPE,
diff --git a/drivers/gpu/drm/amd/include/mes_v12_api_def.h b/drivers/gpu/drm/amd/include/mes_v12_api_def.h
index 090c9142674e..01d07b942347 100644
--- a/drivers/gpu/drm/amd/include/mes_v12_api_def.h
+++ b/drivers/gpu/drm/amd/include/mes_v12_api_def.h
@@ -411,7 +411,13 @@ union MESAPI__REMOVE_QUEUE {
 			uint32_t preempt_legacy_gfx_queue : 1;
 			uint32_t unmap_legacy_queue	  : 1;
 			uint32_t remove_queue_after_reset : 1;
-			uint32_t reserved		  : 27;
+			/*
+			 * Remove all queues of the process identified by pasid,
+			 * doorbell_offset/gang_context_addr/gang_context_array_index
+			 * are ignored
+			 */
+			uint32_t remove_all_process_queues : 1;
+			uint32_t reserved		  : 26;
 		};
 		struct MES_API_STATUS		api_status;
 
@@ -424,6 +430,8 @@ union MESAPI__REMOVE_QUEUE {
 		enum MES_QUEUE_TYPE		queue_type;
 		uint64_t			timestamp;
 		uint32_t			gang_context_array_index;
+		/* Only valid when remove_all_process_queues is set */
+		uint32_t			pasid;
 	};
 
 	uint32_t max_dwords_in_api[API_FRAME_SIZE_IN_DWORDS];
-- 
2.56.0


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

end of thread, other threads:[~2026-12-04  9:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04  3:33 [PATCHv2 1/2] drm/amdgpu: add remove all process queues support for MES v12.1 Mukul Joshi
2026-12-04  3:33 ` [PATCHv2 2/2] drm/amdkfd: remove all queues of a process with a single MES call Mukul Joshi
2026-12-04  3:57   ` sashiko-bot
2026-12-04  9:12   ` Lin, Amber

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.