Skip to contentSkip to conversation

drm/amdgpu: Use MEC FW with SJT on gfx_v9_4_3

PATCH In review Yuan Feng 3 participants 4 messages Dec 5, 2024 – Dec 6, 2024

Subsystems (2)
lore
Share & tools
lore

Yuan Feng

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Use MEC FW with SJT on gfx_v9_4_3

On SRIOV, guest driver and host driver might deploy different versions of MEC firmware binaries that lead to potential compability issues cause system hang. To solve this, host and guest deploy MEC fw copies with two level jump table.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +11 -1
index 03654bfda58a..f248449e93a7 100644
@@ -45,6 +45,7 @@ MODULE_FIRMWARE("amdgpu/gc_9_4_3_mec.bin");
 MODULE_FIRMWARE("amdgpu/gc_9_4_4_mec.bin");
 MODULE_FIRMWARE("amdgpu/gc_9_4_3_rlc.bin");
 MODULE_FIRMWARE("amdgpu/gc_9_4_4_rlc.bin");
+MODULE_FIRMWARE("amdgpu/gc_9_4_3_sjt_mec.bin");
 
 #define GFX9_MEC_HPD_SIZE 4096
 #define RLCG_UCODE_LOADING_START_ADDRESS 0x00002000L
@@ -574,7 +575,16 @@ static int gfx_v9_4_3_init_cp_compute_microcode(struct amdgpu_device *adev,
 {
 	int err;
 
-	err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw,
+	if (amdgpu_sriov_vf(adev)) {
+		err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw,
+				   "amdgpu/%s_sjt_mec.bin", chip_name);
+
+		if (err)
+			err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw,
+				   		"amdgpu/%s_mec.bin", chip_name);
+	}
+	else
+		err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw,
 				   "amdgpu/%s_mec.bin", chip_name);
 	if (err)
 		goto out;
Signature · 1 line
2.39.1.windows.1
#1 lore raw
Quoted 14 lines · Yuan Feng

On SRIOV, guest driver and host driver might deploy different versions of MEC firmware binaries that lead to potential compability issues cause system hang. To solve this, host and guest deploy MEC fw copies with two level jump table.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +0 -0
index 03654bfda58a..f248449e93a7 100644

drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c MODULE_FIRMWARE("amdgpu/gc_9_4_3_mec.bin"); · line 49

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +1 -0
@@ -45,6 +45,7 @@ MODULE_FIRMWARE("amdgpu/gc_9_4_3_mec.bin");
 MODULE_FIRMWARE("amdgpu/gc_9_4_4_mec.bin");
 MODULE_FIRMWARE("amdgpu/gc_9_4_3_rlc.bin");
 MODULE_FIRMWARE("amdgpu/gc_9_4_4_rlc.bin");
+MODULE_FIRMWARE("amdgpu/gc_9_4_3_sjt_mec.bin");
 

This change needs to be done on top of
https://patchwork.freedesktop.org/patch/626097/ as that one adds support for GFX 9.4.4 also.

Thanks,
Lijo

Quoted 20 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +10 -1
 #define GFX9_MEC_HPD_SIZE 4096
 #define RLCG_UCODE_LOADING_START_ADDRESS 0x00002000L
@@ -574,7 +575,16 @@ static int gfx_v9_4_3_init_cp_compute_microcode(struct amdgpu_device *adev,
 {
 	int err;
 
-	err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw,
+	if (amdgpu_sriov_vf(adev)) {
+		err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw,
+				   "amdgpu/%s_sjt_mec.bin", chip_name);
+
+		if (err)
+			err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw,
+				   		"amdgpu/%s_mec.bin", chip_name);
+	}
+	else
+		err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw,
 				   "amdgpu/%s_mec.bin", chip_name);
 	if (err)
 		goto out;
#2 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Hey @Lazar, Lijo,

Yes, Just pinged Victor, Zhao. Sure, I will make a change accordingly.

Thanks,
Yuan

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, December 6, 2024 12:18 AM
To: Feng, Yuan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Use MEC FW with SJT on gfx_v9_4_3

Quoted 15 lines · Yuan Feng

On SRIOV, guest driver and host driver might deploy different versions
of MEC firmware binaries that lead to potential compability issues
cause system hang. To solve this, host and guest deploy MEC fw copies with two level jump table.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +0 -0
index 03654bfda58a..f248449e93a7 100644

drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c MODULE_FIRMWARE("amdgpu/gc_9_4_3_mec.bin"); · line 49

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +1 -0
@@ -45,6 +45,7 @@ MODULE_FIRMWARE("amdgpu/gc_9_4_3_mec.bin");
 MODULE_FIRMWARE("amdgpu/gc_9_4_4_mec.bin");
 MODULE_FIRMWARE("amdgpu/gc_9_4_3_rlc.bin");
 MODULE_FIRMWARE("amdgpu/gc_9_4_4_rlc.bin");
+MODULE_FIRMWARE("amdgpu/gc_9_4_3_sjt_mec.bin");
 

This change needs to be done on top of
https://patchwork.freedesktop.org/patch/626097/ as that one adds support for GFX 9.4.4 also.

Thanks,
Lijo

Quoted 20 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +1 -0
 #define GFX9_MEC_HPD_SIZE 4096
 #define RLCG_UCODE_LOADING_START_ADDRESS 0x00002000L @@ -574,7
+575,16 @@ static int gfx_v9_4_3_init_cp_compute_microcode(struct
amdgpu_device *adev,  {
      int err;
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +10 -1
-     err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw,
+     if (amdgpu_sriov_vf(adev)) {
+             err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw,
+                                "amdgpu/%s_sjt_mec.bin", chip_name);
+
+             if (err)
+                     err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw,
+                                             "amdgpu/%s_mec.bin", chip_name);
+     }
+     else
+             err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw,
                                 "amdgpu/%s_mec.bin", chip_name);
      if (err)
              goto out;
#3 lore raw
In reply to Lazar, Lijo

[AMD Official Use Only - AMD Internal Distribution Only]

Hi @Lazar, Lijo,
Please refer the attached. The idea is to try to load regular MEC firmware if SJT one is not available.

Thanks,
Yuan

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, December 6, 2024 12:18 AM
To: Feng, Yuan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Use MEC FW with SJT on gfx_v9_4_3

Quoted 15 lines · Yuan Feng

On SRIOV, guest driver and host driver might deploy different versions
of MEC firmware binaries that lead to potential compability issues
cause system hang. To solve this, host and guest deploy MEC fw copies with two level jump table.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +0 -0
index 03654bfda58a..f248449e93a7 100644

drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c MODULE_FIRMWARE("amdgpu/gc_9_4_3_mec.bin"); · line 49

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +1 -0
@@ -45,6 +45,7 @@ MODULE_FIRMWARE("amdgpu/gc_9_4_3_mec.bin");
 MODULE_FIRMWARE("amdgpu/gc_9_4_4_mec.bin");
 MODULE_FIRMWARE("amdgpu/gc_9_4_3_rlc.bin");
 MODULE_FIRMWARE("amdgpu/gc_9_4_4_rlc.bin");
+MODULE_FIRMWARE("amdgpu/gc_9_4_3_sjt_mec.bin");
 

This change needs to be done on top of
https://patchwork.freedesktop.org/patch/626097/ as that one adds support for GFX 9.4.4 also.

Thanks,
Lijo

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +1 -0
 #define GFX9_MEC_HPD_SIZE 4096
 #define RLCG_UCODE_LOADING_START_ADDRESS 0x00002000L @@ -574,7
+575,16 @@ static int gfx_v9_4_3_init_cp_compute_microcode(struct
amdgpu_device *adev,  {
      int err;
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +3 -1
-     err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw,
+     if (amdgpu_sriov_vf(adev)) {
+             err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw,
+                                "amdgpu/%s_sjt_mec.bin", chip_name);

drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +7 -0
+
+             if (err)
+                     err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw,
+                                             "amdgpu/%s_mec.bin", chip_name);
+     }
+     else
+             err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw,
                                 "amdgpu/%s_mec.bin", chip_name);
      if (err)
              goto out;

From a73a30bfb023594782b45410f523a698f88422cd Mon Sep 17 00:00:00 2001
From: yfeng1 <[email protected]>
Date: Fri, 6 Dec 2024 01:36:46 -0500
Subject: [PATCH] drm/amdgpu: Fix for MEC SJT FW Load Fail on VF

Users might switch to ROCM build does not include MEC SJT FW and driver needs to consider this case.

Signed-of-yfeng1 <[email protected]>

---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +6 -1
index cc038f300a56..5e6c1aab2e83 100644
@@ -579,10 +579,15 @@ static int gfx_v9_4_3_init_cp_compute_microcode(struct amdgpu_device *adev,
 {
 	int err;
 
-	if (amdgpu_sriov_vf(adev))
+	if (amdgpu_sriov_vf(adev)) {
 		err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw,
 					   AMDGPU_UCODE_REQUIRED,
 					   "amdgpu/%s_sjt_mec.bin", chip_name);
+		if (err)
+			err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw,
+					   AMDGPU_UCODE_REQUIRED,
+					   "amdgpu/%s_mec.bin", chip_name);
+	}
 	else
 		err = amdgpu_ucode_request(adev, &adev->gfx.mec_fw,
 					   AMDGPU_UCODE_REQUIRED,
Signature · 1 line
2.34.1