Skip to contentSkip to conversation

drm/amdgpu/mes: enable compute pipes across all MEC

PATCH In review Alex Deucher 3 participants 6 messages Mar 20, 2025

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/3 drm/amdgpu/mes: enable compute pipes across all MEC

Enable pipes on both MECs for MES.

Fixes 745f46b6a99f ("drm/amdgpu: enable mes v12 self test")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1 -2
index 6b2842de4ad87..fddec5d1f2444 100644
@@ -130,8 +130,7 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
 	}
 
 	for (i = 0; i < AMDGPU_MES_MAX_COMPUTE_PIPES; i++) {
-		/* use only 1st MEC pipes */
-		if (i >= adev->gfx.mec.num_pipe_per_mec)
+		if (i >= (adev->gfx.mec.num_pipe_per_mec * adev->gfx.mec.num_mec))
 			break;
 		adev->mes.compute_hqd_mask[i] = 0xc;
 	}
Signature · 1 line
2.49.0
author maintainer
#1 lore raw

PATCH 2/3 drm/amdgpu/mes: clean up SDMA HQD loop

Follow the same logic as the other IP types.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +3 -5
index fddec5d1f2444..016af4e9c35fa 100644
@@ -136,11 +136,9 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
 	}
 
 	for (i = 0; i < AMDGPU_MES_MAX_SDMA_PIPES; i++) {
-		/* zero sdma_hqd_mask for non-existent engine */
-		if (adev->sdma.num_instances == 1)
-			adev->mes.sdma_hqd_mask[i] = i ? 0 : 0xfc;
-		else
-			adev->mes.sdma_hqd_mask[i] = 0xfc;
+		if (i >= adev->sdma.num_instances)
+			break;
+		adev->mes.sdma_hqd_mask[i] = 0xfc;
 	}
 
 	for (i = 0; i < AMDGPU_MAX_MES_PIPES; i++) {
Signature · 1 line
2.49.0
Reviewed-by Prike Liang on v1 2/3
#2 lore raw

RE: [PATCH 2/3] drm/amdgpu/mes: clean up SDMA HQD loop

[AMD Official Use Only - AMD Internal Distribution Only]

Should the SDMA mask be ASIC specific ? I think some ASIC might need to be set to 0x3fc .

Shaoyun.liu

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, March 20, 2025 10:23 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu/mes: clean up SDMA HQD loop

Follow the same logic as the other IP types.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +3 -5
index fddec5d1f2444..016af4e9c35fa 100644
@@ -136,11 +136,9 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
        }
 
        for (i = 0; i < AMDGPU_MES_MAX_SDMA_PIPES; i++) {
-               /* zero sdma_hqd_mask for non-existent engine */
-               if (adev->sdma.num_instances == 1)
-                       adev->mes.sdma_hqd_mask[i] = i ? 0 : 0xfc;
-               else
-                       adev->mes.sdma_hqd_mask[i] = 0xfc;
+               if (i >= adev->sdma.num_instances)
+                       break;
+               adev->mes.sdma_hqd_mask[i] = 0xfc;
        }
 
        for (i = 0; i < AMDGPU_MAX_MES_PIPES; i++) {

--
2.49.0

author maintainer
#3 lore raw

PATCH 3/3 drm/amdgpu/mes: warn on unexpected pipe numbers

In reply to Alex Deucher

Warn if the number of pipes exceeds what the MES supports.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +19 -4
index 016af4e9c35fa..c52071841226f 100644
@@ -90,7 +90,7 @@ static void amdgpu_mes_doorbell_free(struct amdgpu_device *adev)
 
 int amdgpu_mes_init(struct amdgpu_device *adev)
 {
-	int i, r;
+	int i, r, num_pipes;
 
 	adev->mes.adev = adev;
 
@@ -108,8 +108,13 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
 	adev->mes.vmid_mask_mmhub = 0xffffff00;
 	adev->mes.vmid_mask_gfxhub = 0xffffff00;
 
+	num_pipes = adev->gfx.me.num_pipe_per_me * adev->gfx.me.num_me;
+	if (num_pipes > AMDGPU_MES_MAX_GFX_PIPES)
+		dev_warn(adev->dev, "more gfx pipes than supported by MES! (%d vs %d)\n",
+			 num_pipes, AMDGPU_MES_MAX_GFX_PIPES);
+
 	for (i = 0; i < AMDGPU_MES_MAX_GFX_PIPES; i++) {
-		if (i >= adev->gfx.me.num_pipe_per_me * adev->gfx.me.num_me)
+		if (i >= num_pipes)
 			break;
 		if (amdgpu_ip_version(adev, GC_HWIP, 0) >=
 		    IP_VERSION(12, 0, 0))
@@ -129,14 +134,24 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
 			adev->mes.gfx_hqd_mask[i] = 0x2;
 	}
 
+	num_pipes = adev->gfx.mec.num_pipe_per_mec * adev->gfx.mec.num_mec;
+	if (num_pipes > AMDGPU_MES_MAX_COMPUTE_PIPES)
+		dev_warn(adev->dev, "more compute pipes than supported by MES! (%d vs %d)\n",
+			 num_pipes, AMDGPU_MES_MAX_COMPUTE_PIPES);
+
 	for (i = 0; i < AMDGPU_MES_MAX_COMPUTE_PIPES; i++) {
-		if (i >= (adev->gfx.mec.num_pipe_per_mec * adev->gfx.mec.num_mec))
+		if (i >= num_pipes)
 			break;
 		adev->mes.compute_hqd_mask[i] = 0xc;
 	}
 
+	num_pipes = adev->sdma.num_instances;
+	if (num_pipes > AMDGPU_MES_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);
+
 	for (i = 0; i < AMDGPU_MES_MAX_SDMA_PIPES; i++) {
-		if (i >= adev->sdma.num_instances)
+		if (i >= num_pipes)
 			break;
 		adev->mes.sdma_hqd_mask[i] = 0xfc;
 	}
Signature · 1 line
2.49.0
Acked-by Reviewed-by on v1 3/3
#4 lore raw

Re: [PATCH 3/3] drm/amdgpu/mes: warn on unexpected pipe numbers

Quoted 3 lines · Alex Deucher

Warn if the number of pipes exceeds what the MES supports.

Patches 1,2

Patch 3

Thanks,
Lijo

Quoted 59 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +19 -4
index 016af4e9c35fa..c52071841226f 100644
@@ -90,7 +90,7 @@ static void amdgpu_mes_doorbell_free(struct amdgpu_device *adev)
 
 int amdgpu_mes_init(struct amdgpu_device *adev)
 {
-	int i, r;
+	int i, r, num_pipes;
 
 	adev->mes.adev = adev;
 
@@ -108,8 +108,13 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
 	adev->mes.vmid_mask_mmhub = 0xffffff00;
 	adev->mes.vmid_mask_gfxhub = 0xffffff00;
 
+	num_pipes = adev->gfx.me.num_pipe_per_me * adev->gfx.me.num_me;
+	if (num_pipes > AMDGPU_MES_MAX_GFX_PIPES)
+		dev_warn(adev->dev, "more gfx pipes than supported by MES! (%d vs %d)\n",
+			 num_pipes, AMDGPU_MES_MAX_GFX_PIPES);
+
 	for (i = 0; i < AMDGPU_MES_MAX_GFX_PIPES; i++) {
-		if (i >= adev->gfx.me.num_pipe_per_me * adev->gfx.me.num_me)
+		if (i >= num_pipes)
 			break;
 		if (amdgpu_ip_version(adev, GC_HWIP, 0) >=
 		    IP_VERSION(12, 0, 0))
@@ -129,14 +134,24 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
 			adev->mes.gfx_hqd_mask[i] = 0x2;
 	}
 
+	num_pipes = adev->gfx.mec.num_pipe_per_mec * adev->gfx.mec.num_mec;
+	if (num_pipes > AMDGPU_MES_MAX_COMPUTE_PIPES)
+		dev_warn(adev->dev, "more compute pipes than supported by MES! (%d vs %d)\n",
+			 num_pipes, AMDGPU_MES_MAX_COMPUTE_PIPES);
+
 	for (i = 0; i < AMDGPU_MES_MAX_COMPUTE_PIPES; i++) {
-		if (i >= (adev->gfx.mec.num_pipe_per_mec * adev->gfx.mec.num_mec))
+		if (i >= num_pipes)
 			break;
 		adev->mes.compute_hqd_mask[i] = 0xc;
 	}
 
+	num_pipes = adev->sdma.num_instances;
+	if (num_pipes > AMDGPU_MES_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);
+
 	for (i = 0; i < AMDGPU_MES_MAX_SDMA_PIPES; i++) {
-		if (i >= adev->sdma.num_instances)
+		if (i >= num_pipes)
 			break;
 		adev->mes.sdma_hqd_mask[i] = 0xfc;
 	}
Reviewed-by on v1 3/3
#5 lore raw

RE: [PATCH 3/3] drm/amdgpu/mes: warn on unexpected pipe numbers

In reply to Alex Deucher

[AMD Official Use Only - AMD Internal Distribution Only]

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, March 20, 2025 10:23 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 3/3] drm/amdgpu/mes: warn on unexpected pipe numbers

Warn if the number of pipes exceeds what the MES supports.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +19 -4
index 016af4e9c35fa..c52071841226f 100644
@@ -90,7 +90,7 @@ static void amdgpu_mes_doorbell_free(struct amdgpu_device *adev)
 
 int amdgpu_mes_init(struct amdgpu_device *adev)  {
-       int i, r;
+       int i, r, num_pipes;
 
        adev->mes.adev = adev;
 
@@ -108,8 +108,13 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
        adev->mes.vmid_mask_mmhub = 0xffffff00;
        adev->mes.vmid_mask_gfxhub = 0xffffff00;
 
+       num_pipes = adev->gfx.me.num_pipe_per_me * adev->gfx.me.num_me;
+       if (num_pipes > AMDGPU_MES_MAX_GFX_PIPES)
+               dev_warn(adev->dev, "more gfx pipes than supported by MES! (%d vs %d)\n",
+                        num_pipes, AMDGPU_MES_MAX_GFX_PIPES);
+
        for (i = 0; i < AMDGPU_MES_MAX_GFX_PIPES; i++) {
-               if (i >= adev->gfx.me.num_pipe_per_me * adev->gfx.me.num_me)
+               if (i >= num_pipes)
                        break;
                if (amdgpu_ip_version(adev, GC_HWIP, 0) >=
                    IP_VERSION(12, 0, 0))
@@ -129,14 +134,24 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
                        adev->mes.gfx_hqd_mask[i] = 0x2;
        }
 
+       num_pipes = adev->gfx.mec.num_pipe_per_mec * adev->gfx.mec.num_mec;
+       if (num_pipes > AMDGPU_MES_MAX_COMPUTE_PIPES)
+               dev_warn(adev->dev, "more compute pipes than supported by MES! (%d vs %d)\n",
+                        num_pipes, AMDGPU_MES_MAX_COMPUTE_PIPES);
+
        for (i = 0; i < AMDGPU_MES_MAX_COMPUTE_PIPES; i++) {
-               if (i >= (adev->gfx.mec.num_pipe_per_mec * adev->gfx.mec.num_mec))
+               if (i >= num_pipes)
                        break;
                adev->mes.compute_hqd_mask[i] = 0xc;
        }
 
+       num_pipes = adev->sdma.num_instances;
+       if (num_pipes > AMDGPU_MES_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);
+
        for (i = 0; i < AMDGPU_MES_MAX_SDMA_PIPES; i++) {
-               if (i >= adev->sdma.num_instances)
+               if (i >= num_pipes)
                        break;
                adev->mes.sdma_hqd_mask[i] = 0xfc;
        }

--
2.49.0