Skip to contentSkip to conversation

drm/amd/pm: check whether smu is idle in sriov case

PATCH New Danijel Slivka 1 participant 1 message Jul 28, 2023

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

PATCH v4 1/1 drm/amd/pm: check whether smu is idle in sriov case

Why:
If the reg mmMP1_SMN_C2PMSG_90 is being programed to 0x0 before guest initialization, then modprobe amdgpu will fail at smu hw_init. (the default mmMP1_SMN_C2PMSG_90 at a clean guest environment is 0x1).

How to fix:
this patch is to check whether smu is idle by sending a test message to smu. If smu is idle, it will respond.

---
 .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c    | 18 ++++++--
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 43 +++++++++++++++++++
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |  2 +
 3 files changed, 59 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +14 -4
index aa4a5498a12f..a9e1bc55f15f 100644
@@ -184,15 +184,25 @@ int smu_v11_0_check_fw_status(struct smu_context *smu)
 {
 	struct amdgpu_device *adev = smu->adev;
 	uint32_t mp1_fw_flags;
+	int ret = 0;
 
 	mp1_fw_flags = RREG32_PCIE(MP1_Public |
 				   (smnMP1_FIRMWARE_FLAGS & 0xffffffff));
 
-	if ((mp1_fw_flags & MP1_FIRMWARE_FLAGS__INTERRUPTS_ENABLED_MASK) >>
-	    MP1_FIRMWARE_FLAGS__INTERRUPTS_ENABLED__SHIFT)
-		return 0;
+	if (!((mp1_fw_flags & MP1_FIRMWARE_FLAGS__INTERRUPTS_ENABLED_MASK) >>
+	    MP1_FIRMWARE_FLAGS__INTERRUPTS_ENABLED__SHIFT))
+		return -EIO;
+
+	if (amdgpu_sriov_vf(adev)) {
+		ret = smu_cmn_wait_smu_idle(smu);
+		if (ret) {
+			dev_err(adev->dev, "SMU is not idle\n");
+			return ret;
+		}
+	}
+
+	return 0;
 
-	return -EIO;
 }
 
 int smu_v11_0_check_fw_version(struct smu_context *smu)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +43 -0

49 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +2 -0
index d7cd358a53bd..65da886d6a8c 100644
@@ -50,6 +50,8 @@ int smu_cmn_send_debug_smc_msg_with_param(struct smu_context *smu,
 
 int smu_cmn_wait_for_response(struct smu_context *smu);
 
+int smu_cmn_wait_smu_idle(struct smu_context *smu);
+
 int smu_cmn_to_asic_specific_index(struct smu_context *smu,
 				   enum smu_cmn2asic_mapping_type type,
 				   uint32_t index);
Signature · 1 line
2.25.1