Skip to contentSkip to conversation

drm/amdgpu: update mes max sdma pipes

PATCH In review Alex Deucher 2 participants 6 messages Nov 9 – Nov 17

Subsystems (3)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 drm/amdgpu: update mes max sdma pipes

From: Frank Min <[email protected]>

Newer SDMA IPs support more instances, so update mes max sdma pipe.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 11 +++++------
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h |  2 +-
 2 files changed, 6 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +5 -6
index 0409325017a27..a00160ad7b61c 100644
@@ -114,6 +114,8 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
 {
 	int i, r, num_pipes, num_queues = 0;
 	int num_xcc = adev->gfx.xcc_mask ? NUM_XCC(adev->gfx.xcc_mask) : 1;
+	int max_sdma_pipes = amdgpu_ip_version(adev, GC_HWIP, 0) >= IP_VERSION(13, 0, 0) ?
+		AMDGPU_MES_MAX_SDMA_PIPES : 2;
 	u32 gfx_hqd_mask = amdgpu_mes_get_hqd_mask(adev->gfx.me.num_pipe_per_me,
 				adev->gfx.me.num_queue_per_pipe,
 				adev->gfx.disable_kq ? 0 : adev->gfx.num_gfx_rings);
@@ -169,15 +171,12 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
 
 	num_pipes = adev->sdma.num_inst_per_xcc ?
 		adev->sdma.num_inst_per_xcc : adev->sdma.num_instances;
-	if (num_pipes > AMDGPU_MES_MAX_SDMA_PIPES)
+	if (num_pipes > max_sdma_pipes)
 		dev_warn(adev->dev, "more SDMA pipes than supported by MES! (%d vs %d)\n",
-			 num_pipes, AMDGPU_MES_MAX_SDMA_PIPES);
+			 num_pipes, max_sdma_pipes);
 
-	for (i = 0; i < AMDGPU_MES_MAX_SDMA_PIPES; i++) {
-		if (i >= num_pipes)
-			break;
+	for (i = 0; i < min(num_pipes, max_sdma_pipes); i++)
 		adev->mes.sdma_hqd_mask[i] = 0xfc;
-	}
 
 	dev_info(adev->dev,
 			 "MES: vmid_uq_mask_mmhub 0x%08x, vmid_uq_mask_gfxhub 0x%08x\n",
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h +1 -1
index 652cd09504538..ff38e45f4ff01 100644
@@ -33,7 +33,7 @@
 
 #define AMDGPU_MES_MAX_COMPUTE_PIPES        8
 #define AMDGPU_MES_MAX_GFX_PIPES            2
-#define AMDGPU_MES_MAX_SDMA_PIPES           2
+#define AMDGPU_MES_MAX_SDMA_PIPES           4
 
 #define AMDGPU_MES_API_VERSION_SHIFT	12
 #define AMDGPU_MES_FEAT_VERSION_SHIFT	24
Signature · 1 line
2.56.0
author maintainer
#1 lore raw

PATCH 1/1 drm/amdkfd: Add max_cu_per_engine property

From: David Belanger <[email protected]>

This property is the max possible number of CU for an engine and consider asymmetric configuration.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 6 ++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h       | 1 +
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c     | 4 ++++
 drivers/gpu/drm/amd/amdkfd/kfd_topology.h     | 1 +
 4 files changed, 12 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +6 -0
index f10560b65f116..9d500e4d01951 100644
@@ -2168,6 +2168,8 @@ static int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev)
 		adev->gfx.config.max_cu_per_sh = 2 * (le32_to_cpu(gc_info->v1.gc_num_wgp0_per_sa) +
 					      le32_to_cpu(gc_info->v1.gc_num_wgp1_per_sa));
 		adev->gfx.config.max_sh_per_se = le32_to_cpu(gc_info->v1.gc_num_sa_per_se);
+		adev->gfx.config.max_cu_per_se =
+			adev->gfx.config.max_sh_per_se * adev->gfx.config.max_cu_per_sh;
 		adev->gfx.config.max_backends_per_se = le32_to_cpu(gc_info->v1.gc_num_rb_per_se);
 		adev->gfx.config.max_texture_channel_caches = le32_to_cpu(gc_info->v1.gc_num_gl2c);
 		adev->gfx.config.max_gprs = le32_to_cpu(gc_info->v1.gc_num_gprs);
@@ -2208,6 +2210,7 @@ static int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev)
 					   le32_to_cpu(gc_info->v1_4.gc_num_twgp1_per_sa1);
 			adev->gfx.config.max_cu_per_sh = 2 * (num_wgps_per_sa >= num_wgps_per_sa1 ?
 							      num_wgps_per_sa : num_wgps_per_sa1);
+			adev->gfx.config.max_cu_per_se = 2 * (num_wgps_per_sa + num_wgps_per_sa1);
 		} else if (le16_to_cpu(gc_info->v1.header.version_minor) >= 3) {
 			adev->gfx.config.gc_tcp_size_per_cu = le32_to_cpu(gc_info->v1_3.gc_tcp_size_per_cu);
 			adev->gfx.config.gc_tcp_cache_line_size = le32_to_cpu(gc_info->v1_3.gc_tcp_cache_line_size);
@@ -2229,12 +2232,15 @@ static int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev)
 					   le32_to_cpu(gc_info->v1_5.gc_num_wgp1_per_sa1);
 			adev->gfx.config.max_cu_per_sh = num_wgps_per_sa >= num_wgps_per_sa1 ?
 							 num_wgps_per_sa : num_wgps_per_sa1;
+			adev->gfx.config.max_cu_per_se = 2 * (num_wgps_per_sa + num_wgps_per_sa1);
 		}
 		break;
 	case 2:
 		adev->gfx.config.max_shader_engines = le32_to_cpu(gc_info->v2.gc_num_se);
 		adev->gfx.config.max_cu_per_sh = le32_to_cpu(gc_info->v2.gc_num_cu_per_sh);
 		adev->gfx.config.max_sh_per_se = le32_to_cpu(gc_info->v2.gc_num_sh_per_se);
+		adev->gfx.config.max_cu_per_se =
+			adev->gfx.config.max_sh_per_se * adev->gfx.config.max_cu_per_sh;
 		adev->gfx.config.max_backends_per_se = le32_to_cpu(gc_info->v2.gc_num_rb_per_se);
 		adev->gfx.config.max_texture_channel_caches = le32_to_cpu(gc_info->v2.gc_num_tccs);
 		adev->gfx.config.max_gprs = le32_to_cpu(gc_info->v2.gc_num_gprs);
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1 -0
index 5939e1fb3b241..e4458b5e35380 100644
@@ -238,6 +238,7 @@ struct amdgpu_gfx_config {
 	unsigned max_tile_pipes;
 	unsigned max_cu_per_sh;
 	unsigned max_sh_per_se;
+	unsigned max_cu_per_se;
 	unsigned max_backends_per_se;
 	unsigned max_texture_channel_caches;
 	unsigned max_gprs;
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +4 -0
index 1ef4d26a0ac69..af0c161c520dd 100644
@@ -466,6 +466,8 @@ static ssize_t node_show(struct kobject *kobj, struct attribute *attr,
 			      dev->node_props.cu_per_simd_array);
 	sysfs_show_32bit_prop(buffer, offs, "simd_per_cu",
 			      dev->node_props.simd_per_cu);
+	sysfs_show_32bit_prop(buffer, offs, "max_cu_per_engine",
+			      dev->node_props.max_cu_per_engine);
 	sysfs_show_32bit_prop(buffer, offs, "max_slots_scratch_cu",
 			      dev->node_props.max_slots_scratch_cu);
 	sysfs_show_32bit_prop(buffer, offs, "gfx_target_version",
@@ -2100,6 +2102,8 @@ int kfd_topology_add_device(struct kfd_node *gpu)
 	dev->node_props.simd_arrays_per_engine =
 		gfx_info->max_sh_per_se;
 
+	dev->node_props.max_cu_per_engine = gpu->adev->gfx.config.max_cu_per_se;
+
 	dev->node_props.gfx_target_version =
 				gpu->kfd->device_info.gfx_target_version;
 	dev->node_props.vendor_id = gpu->adev->pdev->vendor;
drivers/gpu/drm/amd/amdkfd/kfd_topology.h +1 -0
index ad63ba67b5774..0f29da44c45ae 100644
@@ -62,6 +62,7 @@ struct kfd_node_properties {
 	uint32_t simd_arrays_per_engine;
 	uint32_t cu_per_simd_array;
 	uint32_t simd_per_cu;
+	uint32_t max_cu_per_engine;
 	uint32_t max_slots_scratch_cu;
 	uint32_t engine_id;
 	uint32_t gfx_target_version;
Signature · 1 line
2.56.0
Reviewed-by on v1 1/1
#2 lore raw

Re: [PATCH] drm/amdkfd: Add max_cu_per_engine property

Quoted 8 lines · Alex Deucher

From: David Belanger <[email protected]>

This property is the max possible number of CU for an engine and consider asymmetric configuration.

Quoted 93 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 6 ++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h       | 1 +
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c     | 4 ++++
 drivers/gpu/drm/amd/amdkfd/kfd_topology.h     | 1 +
 4 files changed, 12 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +6 -0
index f10560b65f116..9d500e4d01951 100644
@@ -2168,6 +2168,8 @@ static int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev)
                adev->gfx.config.max_cu_per_sh = 2 * (le32_to_cpu(gc_info->v1.gc_num_wgp0_per_sa) +
                                              le32_to_cpu(gc_info->v1.gc_num_wgp1_per_sa));
                adev->gfx.config.max_sh_per_se = le32_to_cpu(gc_info->v1.gc_num_sa_per_se);
+               adev->gfx.config.max_cu_per_se =
+                       adev->gfx.config.max_sh_per_se * adev->gfx.config.max_cu_per_sh;
                adev->gfx.config.max_backends_per_se = le32_to_cpu(gc_info->v1.gc_num_rb_per_se);
                adev->gfx.config.max_texture_channel_caches = le32_to_cpu(gc_info->v1.gc_num_gl2c);
                adev->gfx.config.max_gprs = le32_to_cpu(gc_info->v1.gc_num_gprs);
@@ -2208,6 +2210,7 @@ static int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev)
                                           le32_to_cpu(gc_info->v1_4.gc_num_twgp1_per_sa1);
                        adev->gfx.config.max_cu_per_sh = 2 * (num_wgps_per_sa >= num_wgps_per_sa1 ?
                                                              num_wgps_per_sa : num_wgps_per_sa1);
+                       adev->gfx.config.max_cu_per_se = 2 * (num_wgps_per_sa + num_wgps_per_sa1);
                } else if (le16_to_cpu(gc_info->v1.header.version_minor) >= 3) {
                        adev->gfx.config.gc_tcp_size_per_cu = le32_to_cpu(gc_info->v1_3.gc_tcp_size_per_cu);
                        adev->gfx.config.gc_tcp_cache_line_size = le32_to_cpu(gc_info->v1_3.gc_tcp_cache_line_size);
@@ -2229,12 +2232,15 @@ static int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev)
                                           le32_to_cpu(gc_info->v1_5.gc_num_wgp1_per_sa1);
                        adev->gfx.config.max_cu_per_sh = num_wgps_per_sa >= num_wgps_per_sa1 ?
                                                         num_wgps_per_sa : num_wgps_per_sa1;
+                       adev->gfx.config.max_cu_per_se = 2 * (num_wgps_per_sa + num_wgps_per_sa1);
                }
                break;
        case 2:
                adev->gfx.config.max_shader_engines = le32_to_cpu(gc_info->v2.gc_num_se);
                adev->gfx.config.max_cu_per_sh = le32_to_cpu(gc_info->v2.gc_num_cu_per_sh);
                adev->gfx.config.max_sh_per_se = le32_to_cpu(gc_info->v2.gc_num_sh_per_se);
+               adev->gfx.config.max_cu_per_se =
+                       adev->gfx.config.max_sh_per_se * adev->gfx.config.max_cu_per_sh;
                adev->gfx.config.max_backends_per_se = le32_to_cpu(gc_info->v2.gc_num_rb_per_se);
                adev->gfx.config.max_texture_channel_caches = le32_to_cpu(gc_info->v2.gc_num_tccs);
                adev->gfx.config.max_gprs = le32_to_cpu(gc_info->v2.gc_num_gprs);
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1 -0
index 5939e1fb3b241..e4458b5e35380 100644
@@ -238,6 +238,7 @@ struct amdgpu_gfx_config {
        unsigned max_tile_pipes;
        unsigned max_cu_per_sh;
        unsigned max_sh_per_se;
+       unsigned max_cu_per_se;
        unsigned max_backends_per_se;
        unsigned max_texture_channel_caches;
        unsigned max_gprs;
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +4 -0
index 1ef4d26a0ac69..af0c161c520dd 100644
@@ -466,6 +466,8 @@ static ssize_t node_show(struct kobject *kobj, struct attribute *attr,
                              dev->node_props.cu_per_simd_array);
        sysfs_show_32bit_prop(buffer, offs, "simd_per_cu",
                              dev->node_props.simd_per_cu);
+       sysfs_show_32bit_prop(buffer, offs, "max_cu_per_engine",
+                             dev->node_props.max_cu_per_engine);
        sysfs_show_32bit_prop(buffer, offs, "max_slots_scratch_cu",
                              dev->node_props.max_slots_scratch_cu);
        sysfs_show_32bit_prop(buffer, offs, "gfx_target_version",
@@ -2100,6 +2102,8 @@ int kfd_topology_add_device(struct kfd_node *gpu)
        dev->node_props.simd_arrays_per_engine =
                gfx_info->max_sh_per_se;
 
+       dev->node_props.max_cu_per_engine = gpu->adev->gfx.config.max_cu_per_se;
+
        dev->node_props.gfx_target_version =
                                gpu->kfd->device_info.gfx_target_version;
        dev->node_props.vendor_id = gpu->adev->pdev->vendor;
drivers/gpu/drm/amd/amdkfd/kfd_topology.h +1 -1
index ad63ba67b5774..0f29da44c45ae 100644
@@ -62,6 +62,7 @@ struct kfd_node_properties {
        uint32_t simd_arrays_per_engine;
        uint32_t cu_per_simd_array;
        uint32_t simd_per_cu;
+       uint32_t max_cu_per_engine;
        uint32_t max_slots_scratch_cu;
        uint32_t engine_id;
        uint32_t gfx_target_version;
--

2.56.0

author maintainer
#3 lore raw

PATCH 1/1 drm/amdkfd: Add a helper to handle IP version specific client id

In reply to Alex Deucher

From: Lang Yu <[email protected]>

kfd_int_process_v11.c is common for gfx11/12/13, while GC VM fault client id is IP version specific. gfx13 uses a different GC VM fault client id - SOC_V2_0_IH_CLIENTID_GC_UTCL2.

---
 drivers/gpu/drm/amd/amdkfd/kfd_int_process_v11.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_int_process_v11.c +12 -2
index 24d13a74a181a..224b0e1e38ff5 100644
@@ -255,6 +255,16 @@ static void event_interrupt_poison_consumption_v11(struct kfd_node *dev,
 	amdgpu_amdkfd_ras_poison_consumption_handler(dev->adev, block, reset);
 }
 
+static inline u32 gc_vm_fault_client_id(struct kfd_node *dev)
+{
+	switch (KFD_GC_VERSION(dev)) {
+	case IP_VERSION(13, 0, 1):
+		return SOC_V2_0_IH_CLIENTID_GC_UTCL2;
+	default:
+		return SOC21_IH_CLIENTID_GFX;
+	}
+}
+
 static bool event_interrupt_isr_v11(struct kfd_node *dev,
 					const uint32_t *ih_ring_entry,
 					uint32_t *patched_ihre,
@@ -299,7 +309,7 @@ static bool event_interrupt_isr_v11(struct kfd_node *dev,
 		source_id == SOC21_INTSRC_SDMA_TRAP ||
 		KFD_IRQ_IS_FENCE(client_id, source_id) ||
 		(((client_id == SOC21_IH_CLIENTID_VMC) ||
-		 ((client_id == SOC21_IH_CLIENTID_GFX) &&
+		 ((client_id == gc_vm_fault_client_id(dev)) &&
 		  (source_id == UTCL2_1_0__SRCID__FAULT))) &&
 		  !amdgpu_no_queue_eviction_on_vm_fault);
 }
@@ -323,7 +333,7 @@ static void event_interrupt_wq_v11(struct kfd_node *dev,
 
 	/* VMC, UTCL2 */
 	if (client_id == SOC21_IH_CLIENTID_VMC ||
-	     ((client_id == SOC21_IH_CLIENTID_GFX) &&
+	     ((client_id == gc_vm_fault_client_id(dev)) &&
 	     (source_id == UTCL2_1_0__SRCID__FAULT))) {
 
 		info.vmid = vmid;
Signature · 1 line
2.56.0
Reviewed-by on v1 1/1
#4 lore raw

Re: [PATCH] drm/amdkfd: Add a helper to handle IP version specific client id

Quoted 10 lines · Alex Deucher

From: Lang Yu <[email protected]>

kfd_int_process_v11.c is common for gfx11/12/13, while GC VM fault client id is IP version specific. gfx13 uses a different GC VM fault client id - SOC_V2_0_IH_CLIENTID_GC_UTCL2.

Quoted 46 lines
---
 drivers/gpu/drm/amd/amdkfd/kfd_int_process_v11.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_int_process_v11.c +12 -3
index 24d13a74a181a..224b0e1e38ff5 100644
@@ -255,6 +255,16 @@ static void event_interrupt_poison_consumption_v11(struct kfd_node *dev,
        amdgpu_amdkfd_ras_poison_consumption_handler(dev->adev, block, reset);
 }
 
+static inline u32 gc_vm_fault_client_id(struct kfd_node *dev)
+{
+       switch (KFD_GC_VERSION(dev)) {
+       case IP_VERSION(13, 0, 1):
+               return SOC_V2_0_IH_CLIENTID_GC_UTCL2;
+       default:
+               return SOC21_IH_CLIENTID_GFX;
+       }
+}
+
 static bool event_interrupt_isr_v11(struct kfd_node *dev,
                                        const uint32_t *ih_ring_entry,
                                        uint32_t *patched_ihre,
@@ -299,7 +309,7 @@ static bool event_interrupt_isr_v11(struct kfd_node *dev,
                source_id == SOC21_INTSRC_SDMA_TRAP ||
                KFD_IRQ_IS_FENCE(client_id, source_id) ||
                (((client_id == SOC21_IH_CLIENTID_VMC) ||
-                ((client_id == SOC21_IH_CLIENTID_GFX) &&
+                ((client_id == gc_vm_fault_client_id(dev)) &&
                  (source_id == UTCL2_1_0__SRCID__FAULT))) &&
                  !amdgpu_no_queue_eviction_on_vm_fault);
 }
@@ -323,7 +333,7 @@ static void event_interrupt_wq_v11(struct kfd_node *dev,
 
        /* VMC, UTCL2 */
        if (client_id == SOC21_IH_CLIENTID_VMC ||
-            ((client_id == SOC21_IH_CLIENTID_GFX) &&
+            ((client_id == gc_vm_fault_client_id(dev)) &&
             (source_id == UTCL2_1_0__SRCID__FAULT))) {
 
                info.vmid = vmid;
--

2.56.0

Reviewed-by on v1 1/1
#5 lore raw
In reply to Alex Deucher
Quoted 7 lines · Alex Deucher

From: Frank Min <[email protected]>

Newer SDMA IPs support more instances, so update mes max sdma pipe.

Quoted 53 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 11 +++++------
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h |  2 +-
 2 files changed, 6 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +5 -6
index 0409325017a27..a00160ad7b61c 100644
@@ -114,6 +114,8 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
 {
        int i, r, num_pipes, num_queues = 0;
        int num_xcc = adev->gfx.xcc_mask ? NUM_XCC(adev->gfx.xcc_mask) : 1;
+       int max_sdma_pipes = amdgpu_ip_version(adev, GC_HWIP, 0) >= IP_VERSION(13, 0, 0) ?
+               AMDGPU_MES_MAX_SDMA_PIPES : 2;
        u32 gfx_hqd_mask = amdgpu_mes_get_hqd_mask(adev->gfx.me.num_pipe_per_me,
                                adev->gfx.me.num_queue_per_pipe,
                                adev->gfx.disable_kq ? 0 : adev->gfx.num_gfx_rings);
@@ -169,15 +171,12 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
 
        num_pipes = adev->sdma.num_inst_per_xcc ?
                adev->sdma.num_inst_per_xcc : adev->sdma.num_instances;
-       if (num_pipes > AMDGPU_MES_MAX_SDMA_PIPES)
+       if (num_pipes > max_sdma_pipes)
                dev_warn(adev->dev, "more SDMA pipes than supported by MES! (%d vs %d)\n",
-                        num_pipes, AMDGPU_MES_MAX_SDMA_PIPES);
+                        num_pipes, max_sdma_pipes);
 
-       for (i = 0; i < AMDGPU_MES_MAX_SDMA_PIPES; i++) {
-               if (i >= num_pipes)
-                       break;
+       for (i = 0; i < min(num_pipes, max_sdma_pipes); i++)
                adev->mes.sdma_hqd_mask[i] = 0xfc;
-       }
 
        dev_info(adev->dev,
                         "MES: vmid_uq_mask_mmhub 0x%08x, vmid_uq_mask_gfxhub 0x%08x\n",
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h +1 -2
index 652cd09504538..ff38e45f4ff01 100644
@@ -33,7 +33,7 @@
 
 #define AMDGPU_MES_MAX_COMPUTE_PIPES        8
 #define AMDGPU_MES_MAX_GFX_PIPES            2
-#define AMDGPU_MES_MAX_SDMA_PIPES           2
+#define AMDGPU_MES_MAX_SDMA_PIPES           4
 
 #define AMDGPU_MES_API_VERSION_SHIFT   12
 #define AMDGPU_MES_FEAT_VERSION_SHIFT  24
--

2.56.0