Skip to contentSkip to conversation

drm/amdgpu: poll BACO status after RPM BACO exits

PATCH In review Guchun Chen 2 participants 2 messages Nov 21, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 drm/amdgpu: poll BACO status after RPM BACO exits

After executing BACO exit, driver needs to poll the status to ensure FW has completed BACO exit sequence to prevent timing issue.

---
 .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c    | 23 ++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +22 -1
index dccbd9f70723..796c8179bfbf 100644
@@ -79,6 +79,16 @@ MODULE_FIRMWARE("amdgpu/beige_goby_smc.bin");
 #define mmTHM_BACO_CNTL_ARCT			0xA7
 #define mmTHM_BACO_CNTL_ARCT_BASE_IDX		0
 
+static void smu_v11_0_poll_baco_exit(struct smu_context *smu)
+{
+	uint32_t data, loop = 0;
+
+	do {
+		msleep(1);
+		data = RREG32_SOC15(THM, 0, mmTHM_BACO_CNTL);
+	} while ((data & 0x100) && (++loop < 100));
+}
+
 int smu_v11_0_init_microcode(struct smu_context *smu)
 {
 	struct amdgpu_device *adev = smu->adev;
@@ -1685,7 +1695,18 @@ int smu_v11_0_baco_enter(struct smu_context *smu)
 
 int smu_v11_0_baco_exit(struct smu_context *smu)
 {
-	return smu_v11_0_baco_set_state(smu, SMU_BACO_STATE_EXIT);
+	int ret = 0;
+
+	ret = smu_v11_0_baco_set_state(smu, SMU_BACO_STATE_EXIT);
+	if (!ret) {
+		/*
+		 * Poll BACO exit status to ensure FW has completed
+		 * BACO exit process to avoid timing issues.
+		 */
+		smu_v11_0_poll_baco_exit(smu);
+	}
+
+	return ret;
 }
 
 int smu_v11_0_mode1_reset(struct smu_context *smu)
Signature · 1 line
2.25.1
#1 lore raw

[AMD Official Use Only - General]

Quoted 29 lines

-----Original Message-----
From: Chen, Guchun <[email protected]>
Sent: Monday, November 21, 2022 8:39 AM
To: [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Lazar, Lijo <[email protected]>; Quan, Evan <[email protected]>
Cc: Chen, Guchun <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: poll BACO status after RPM BACO exits

After executing BACO exit, driver needs to poll the status to ensure FW has completed BACO exit sequence to prevent timing issue.

---
 .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c    | 23
++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +0 -0
index dccbd9f70723..796c8179bfbf 100644
@@ -79,6 +79,16 @@
 MODULE_FIRMWARE("amdgpu/beige_goby_smc.bin");
 #define mmTHM_BACO_CNTL_ARCT			0xA7
 #define mmTHM_BACO_CNTL_ARCT_BASE_IDX		0

drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c line 91

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +9 -0
 
+static void smu_v11_0_poll_baco_exit(struct smu_context *smu)
+{
+	uint32_t data, loop = 0;
+
+	do {
+		msleep(1);
+		data = RREG32_SOC15(THM, 0, mmTHM_BACO_CNTL);
+	} while ((data & 0x100) && (++loop < 100));
+}

[Quan, Evan] Better to update the msleep with udelay. Otherwise, you might hit some checkpatch.pl errors. Other than that, the series is Reviewed-by: Evan Quan <[email protected]>

Evan

Quoted 27 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +1 -0
+
 int smu_v11_0_init_microcode(struct smu_context *smu)
 {
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +12 -1
 	struct amdgpu_device *adev = smu->adev;
@@ -1685,7 +1695,18 @@ int smu_v11_0_baco_enter(struct smu_context
 *smu)
 
 int smu_v11_0_baco_exit(struct smu_context *smu)
 {
-	return smu_v11_0_baco_set_state(smu, SMU_BACO_STATE_EXIT);
+	int ret = 0;
+
+	ret = smu_v11_0_baco_set_state(smu, SMU_BACO_STATE_EXIT);
+	if (!ret) {
+		/*
+		 * Poll BACO exit status to ensure FW has completed
+		 * BACO exit process to avoid timing issues.
+		 */
+		smu_v11_0_poll_baco_exit(smu);
+	}
+
+	return ret;
 }
 

int smu_v11_0_mode1_reset(struct smu_context *smu)
--
2.25.1