Skip to contentSkip to conversation

drm/amdgpu/mes11: optimize MES pipe FW version fetching

PATCH In review Alex Deucher 4 participants 5 messages Mar 28, 2025 – Apr 7, 2025

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/2 drm/amdgpu/mes11: optimize MES pipe FW version fetching

Don't fetch it again if we already have it. It seems the registers don't reliably have the value at resume in some cases.

Fixes 028c3fb37e70 ("drm/amdgpu/mes11: initiate mes v11 support")
---
 drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +4 -0
index 16f8bc36afa07..06b51867c9aac 100644
@@ -895,6 +895,10 @@ static void mes_v11_0_get_fw_version(struct amdgpu_device *adev)
 {
 	int pipe;
 
+	/* return early if we have already fetched these */
+	if (adev->mes.sched_version && adev->mes.kiq_version)
+		return;
+
 	/* get MES scheduler/KIQ versions */
 	mutex_lock(&adev->srbm_mutex);
 
Signature · 1 line
2.49.0
author maintainer
#1 lore raw

PATCH 2/2 drm/amdgpu/mes12: optimize MES pipe FW version fetching

Don't fetch it again if we already have it. It seems the registers don't reliably have the value at resume in some cases.

Fixes 785f0f9fe742 ("drm/amdgpu: Add mes v12_0 ip block support (v4)")
---
 drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +12 -9
index bcabebd18fe84..8892858cfd9ae 100644
@@ -1392,17 +1392,20 @@ static int mes_v12_0_queue_init(struct amdgpu_device *adev,
 		mes_v12_0_queue_init_register(ring);
 	}
 
-	/* get MES scheduler/KIQ versions */
-	mutex_lock(&adev->srbm_mutex);
-	soc21_grbm_select(adev, 3, pipe, 0, 0);
+	if (((pipe == AMDGPU_MES_SCHED_PIPE) && !adev->mes.sched_version) ||
+	    ((pipe == AMDGPU_MES_KIQ_PIPE) && !adev->mes.kiq_version)) {
+		/* get MES scheduler/KIQ versions */
+		mutex_lock(&adev->srbm_mutex);
+		soc21_grbm_select(adev, 3, pipe, 0, 0);
 
-	if (pipe == AMDGPU_MES_SCHED_PIPE)
-		adev->mes.sched_version = RREG32_SOC15(GC, 0, regCP_MES_GP3_LO);
-	else if (pipe == AMDGPU_MES_KIQ_PIPE && adev->enable_mes_kiq)
-		adev->mes.kiq_version = RREG32_SOC15(GC, 0, regCP_MES_GP3_LO);
+		if (pipe == AMDGPU_MES_SCHED_PIPE)
+			adev->mes.sched_version = RREG32_SOC15(GC, 0, regCP_MES_GP3_LO);
+		else if (pipe == AMDGPU_MES_KIQ_PIPE && adev->enable_mes_kiq)
+			adev->mes.kiq_version = RREG32_SOC15(GC, 0, regCP_MES_GP3_LO);
 
-	soc21_grbm_select(adev, 0, 0, 0, 0);
-	mutex_unlock(&adev->srbm_mutex);
+		soc21_grbm_select(adev, 0, 0, 0, 0);
+		mutex_unlock(&adev->srbm_mutex);
+	}
 
 	return 0;
 }
Signature · 1 line
2.49.0
#2 lore raw

Re: [PATCH 2/2] drm/amdgpu/mes12: optimize MES pipe FW version fetching

Ping?

Alex

Quoted 48 lines · Alex Deucher

Don't fetch it again if we already have it. It seems the registers don't reliably have the value at resume in some cases.

Fixes 785f0f9fe742 ("drm/amdgpu: Add mes v12_0 ip block support (v4)")
---
 drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +12 -10
index bcabebd18fe84..8892858cfd9ae 100644
@@ -1392,17 +1392,20 @@ static int mes_v12_0_queue_init(struct amdgpu_device *adev,
                mes_v12_0_queue_init_register(ring);
        }
 
-       /* get MES scheduler/KIQ versions */
-       mutex_lock(&adev->srbm_mutex);
-       soc21_grbm_select(adev, 3, pipe, 0, 0);
+       if (((pipe == AMDGPU_MES_SCHED_PIPE) && !adev->mes.sched_version) ||
+           ((pipe == AMDGPU_MES_KIQ_PIPE) && !adev->mes.kiq_version)) {
+               /* get MES scheduler/KIQ versions */
+               mutex_lock(&adev->srbm_mutex);
+               soc21_grbm_select(adev, 3, pipe, 0, 0);
 
-       if (pipe == AMDGPU_MES_SCHED_PIPE)
-               adev->mes.sched_version = RREG32_SOC15(GC, 0, regCP_MES_GP3_LO);
-       else if (pipe == AMDGPU_MES_KIQ_PIPE && adev->enable_mes_kiq)
-               adev->mes.kiq_version = RREG32_SOC15(GC, 0, regCP_MES_GP3_LO);
+               if (pipe == AMDGPU_MES_SCHED_PIPE)
+                       adev->mes.sched_version = RREG32_SOC15(GC, 0, regCP_MES_GP3_LO);
+               else if (pipe == AMDGPU_MES_KIQ_PIPE && adev->enable_mes_kiq)
+                       adev->mes.kiq_version = RREG32_SOC15(GC, 0, regCP_MES_GP3_LO);
 
-       soc21_grbm_select(adev, 0, 0, 0, 0);
-       mutex_unlock(&adev->srbm_mutex);
+               soc21_grbm_select(adev, 0, 0, 0, 0);
+               mutex_unlock(&adev->srbm_mutex);
+       }
 
        return 0;
 }
--

2.49.0

#3 lore raw

RE: [PATCH 2/2] drm/amdgpu/mes12: optimize MES pipe FW version fetching

[AMD Official Use Only - AMD Internal Distribution Only]

Looks good to me .

Reviewed by : Shaoyun.liu <[email protected]>

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Monday, April 7, 2025 10:17 AM
To: Deucher, Alexander <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 2/2] drm/amdgpu/mes12: optimize MES pipe FW version fetching

Ping?

Alex

Quoted 50 lines · Alex Deucher

Don't fetch it again if we already have it. It seems the registers don't reliably have the value at resume in some cases.

Fixes 785f0f9fe742 ("drm/amdgpu: Add mes v12_0 ip block support

(v4)")

---
 drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +13 -10
index bcabebd18fe84..8892858cfd9ae 100644
@@ -1392,17 +1392,20 @@ static int mes_v12_0_queue_init(struct amdgpu_device *adev,
                mes_v12_0_queue_init_register(ring);
        }
 
-       /* get MES scheduler/KIQ versions */
-       mutex_lock(&adev->srbm_mutex);
-       soc21_grbm_select(adev, 3, pipe, 0, 0);
+       if (((pipe == AMDGPU_MES_SCHED_PIPE) && !adev->mes.sched_version) ||
+           ((pipe == AMDGPU_MES_KIQ_PIPE) && !adev->mes.kiq_version)) {
+               /* get MES scheduler/KIQ versions */
+               mutex_lock(&adev->srbm_mutex);
+               soc21_grbm_select(adev, 3, pipe, 0, 0);
 
-       if (pipe == AMDGPU_MES_SCHED_PIPE)
-               adev->mes.sched_version = RREG32_SOC15(GC, 0, regCP_MES_GP3_LO);
-       else if (pipe == AMDGPU_MES_KIQ_PIPE && adev->enable_mes_kiq)
-               adev->mes.kiq_version = RREG32_SOC15(GC, 0, regCP_MES_GP3_LO);
+               if (pipe == AMDGPU_MES_SCHED_PIPE)
+                       adev->mes.sched_version = RREG32_SOC15(GC, 0, regCP_MES_GP3_LO);
+               else if (pipe == AMDGPU_MES_KIQ_PIPE && adev->enable_mes_kiq)
+                       adev->mes.kiq_version = RREG32_SOC15(GC, 0,
+ regCP_MES_GP3_LO);
 
-       soc21_grbm_select(adev, 0, 0, 0, 0);
-       mutex_unlock(&adev->srbm_mutex);
+               soc21_grbm_select(adev, 0, 0, 0, 0);
+               mutex_unlock(&adev->srbm_mutex);
+       }
 
        return 0;
 }
--

2.49.0

Reviewed-by on v1 1/2
#4 lore raw
In reply to Alex Deucher
Quoted 16 lines · Alex Deucher

Don't fetch it again if we already have it. It seems the registers don't reliably have the value at resume in some cases.

Fixes 028c3fb37e70 ("drm/amdgpu/mes11: initiate mes v11 support")
---
  drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +0 -0
index 16f8bc36afa07..06b51867c9aac 100644

drivers/gpu/drm/amd/amdgpu/mes_v11_0.c static void mes_v11_0_get_fw_version(struct amdgpu_device *adev) · line 904

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +4 -0
@@ -895,6 +895,10 @@ static void mes_v11_0_get_fw_version(struct amdgpu_device *adev)
  {
  	int pipe;
 
+	/* return early if we have already fetched these */
+	if (adev->mes.sched_version && adev->mes.kiq_version)
+		return;
+
  	/* get MES scheduler/KIQ versions */
  	mutex_lock(&adev->srbm_mutex);