Skip to contentSkip to conversation

drm/amdgpu: load sdma ucode in the guest machine

PATCH In review YuanShang 2 participants 2 messages Jul 18, 2023 – Jul 21, 2023

Subsystems (2)
lore
Share & tools
lore

YuanShang

author
#0 lore raw

PATCH v3 1/1 drm/amdgpu: load sdma ucode in the guest machine

[why]
User mode driver need to check the sdma ucode version to see whether the sdma engine supports a new type of PM4 packet. In SRIOV, sdma is loaded by the host. And, there is no way to check the sdma ucode version of CHIP_NAVI12 and CHIP_SIENNA_CICHLID of the host in the guest machine.

[how]
Load the sdma ucode for CHIP_NAVI12 and CHIP_SIENNA_CICHLID in the guest machine.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c |  3 ---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 11 +++++++++++
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c   |  8 +++-----
 3 files changed, 14 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +0 -3
index dacf281d2b21..e2b9392d7f0d 100644
@@ -239,9 +239,6 @@ int amdgpu_sdma_init_microcode(struct amdgpu_device *adev,
 			       sizeof(struct amdgpu_sdma_instance));
 	}
 
-	if (amdgpu_sriov_vf(adev))
-		return 0;
-
 	DRM_DEBUG("psp_load == '%s'\n",
 		  adev->firmware.load_type == AMDGPU_FW_LOAD_PSP ? "true" : "false");
 
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +11 -0
index 41aa853a07d2..3365fe04275a 100644
@@ -845,6 +845,17 @@ bool amdgpu_virt_fw_load_skip_check(struct amdgpu_device *adev, uint32_t ucode_i
 			return false;
 		else
 			return true;
+	case IP_VERSION(11, 0, 9):
+	case IP_VERSION(11, 0, 7):
+		/* black list for CHIP_NAVI12 and CHIP_SIENNA_CICHLID */
+		if (ucode_id == AMDGPU_UCODE_ID_RLC_G
+		    || ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL
+		    || ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM
+		    || ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM
+		    || ucode_id == AMDGPU_UCODE_ID_SMC)
+			return true;
+		else
+			return false;
 	case IP_VERSION(13, 0, 10):
 		/* white list */
 		if (ucode_id == AMDGPU_UCODE_ID_CAP
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +3 -5
index 5c4d4df9cf94..1cc34efb455b 100644
@@ -237,17 +237,15 @@ static void sdma_v5_0_init_golden_registers(struct amdgpu_device *adev)
 // emulation only, won't work on real chip
 // navi10 real chip need to use PSP to load firmware
 static int sdma_v5_0_init_microcode(struct amdgpu_device *adev)
-{	int ret, i;
-
-	if (amdgpu_sriov_vf(adev) && (adev->ip_versions[SDMA0_HWIP][0] == IP_VERSION(5, 0, 5)))
-		return 0;
+{
+	int ret, i;
 
 	for (i = 0; i < adev->sdma.num_instances; i++) {
 		ret = amdgpu_sdma_init_microcode(adev, i, false);
 		if (ret)
 			return ret;
 	}
-	
+
 	return ret;
 }
 
Signature · 1 line
2.25.1
Reviewed-by on v3 1/1
#1 lore raw

[AMD Official Use Only - General]

-----Original Message-----
From: YuanShang Mao (River) <[email protected]>
Sent: Tuesday, July 18, 2023 4:31 PM
To: [email protected]
Cc: YuanShang Mao (River) <[email protected]>; Chen, Horace <[email protected]>; YuanShang Mao (River) <[email protected]>
Subject: [PATCH v3] drm/amdgpu: load sdma ucode in the guest machine

[why]
User mode driver need to check the sdma ucode version to see whether the sdma engine supports a new type of PM4 packet. In SRIOV, sdma is loaded by the host. And, there is no way to check the sdma ucode version of CHIP_NAVI12 and CHIP_SIENNA_CICHLID of the host in the guest machine.

[how]
Load the sdma ucode for CHIP_NAVI12 and CHIP_SIENNA_CICHLID in the guest machine.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c |  3 ---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 11 +++++++++++
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c   |  8 +++-----
 3 files changed, 14 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +0 -3
index dacf281d2b21..e2b9392d7f0d 100644
@@ -239,9 +239,6 @@ int amdgpu_sdma_init_microcode(struct amdgpu_device *adev,
                               sizeof(struct amdgpu_sdma_instance));
        }
 
-       if (amdgpu_sriov_vf(adev))
-               return 0;
-
        DRM_DEBUG("psp_load == '%s'\n",
                  adev->firmware.load_type == AMDGPU_FW_LOAD_PSP ? "true" : "false");
 
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +11 -0
index 41aa853a07d2..3365fe04275a 100644
@@ -845,6 +845,17 @@ bool amdgpu_virt_fw_load_skip_check(struct amdgpu_device *adev, uint32_t ucode_i
                        return false;
                else
                        return true;
+       case IP_VERSION(11, 0, 9):
+       case IP_VERSION(11, 0, 7):
+               /* black list for CHIP_NAVI12 and CHIP_SIENNA_CICHLID */
+               if (ucode_id == AMDGPU_UCODE_ID_RLC_G
+                   || ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL
+                   || ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM
+                   || ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM
+                   || ucode_id == AMDGPU_UCODE_ID_SMC)
+                       return true;
+               else
+                       return false;
        case IP_VERSION(13, 0, 10):
                /* white list */
                if (ucode_id == AMDGPU_UCODE_ID_CAP
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +3 -5
index 5c4d4df9cf94..1cc34efb455b 100644
@@ -237,17 +237,15 @@ static void sdma_v5_0_init_golden_registers(struct amdgpu_device *adev)
 // emulation only, won't work on real chip
 // navi10 real chip need to use PSP to load firmware
 static int sdma_v5_0_init_microcode(struct amdgpu_device *adev)
-{      int ret, i;
-
-       if (amdgpu_sriov_vf(adev) && (adev->ip_versions[SDMA0_HWIP][0] == IP_VERSION(5, 0, 5)))
-               return 0;
+{
+       int ret, i;
 
        for (i = 0; i < adev->sdma.num_instances; i++) {
                ret = amdgpu_sdma_init_microcode(adev, i, false);
                if (ret)
                        return ret;
        }
-
+
        return ret;
 }
 

--
2.25.1