Skip to contentSkip to conversation

drm/amdgpu: fix SI UVD firmware validate resume fail

PATCH Superseded Sonny Jiang 2 participants 2 messages Nov 8, 2020 – Nov 9, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: fix SI UVD firmware validate resume fail

The SI UVD firmware validate key is stored at the end of firmware, which is changed during resume while playing video. So only to get the key at device initialization and save it for later using.

---
 drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +10 -7
index 7cf4b11a65c5..aab7415c1a32 100644
@@ -279,13 +279,16 @@ static int uvd_v3_1_fw_validate(struct amdgpu_device *adev)
 {
 	void *ptr;
 	uint32_t ucode_len, i;
-	uint32_t keysel;
-
-	ptr = adev->uvd.inst[0].cpu_addr;
-	ptr += 192 + 16;
-	memcpy(&ucode_len, ptr, 4);
-	ptr += ucode_len;
-	memcpy(&keysel, ptr, 4);
+	static uint32_t keysel = 0;
+
+	/* Only get the validate key at device initialization*/
+	if (!keysel) {
+		ptr = adev->uvd.inst[0].cpu_addr;
+		ptr += 192 + 16;
+		memcpy(&ucode_len, ptr, 4);
+		ptr += ucode_len;
+		memcpy(&keysel, ptr, 4);
+	}
 
 	WREG32(mmUVD_FW_START, keysel);
 
Signature · 6 lines
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw

Am 08.11.20 um 16:09 schrieb Sonny Jiang:

Quoted 15 lines

The SI UVD firmware validate key is stored at the end of firmware, which is changed during resume while playing video. So only to get the key at device initialization and save it for later using.

---
  drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c | 17 ++++++++++-------
  1 file changed, 10 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +0 -0
index 7cf4b11a65c5..aab7415c1a32 100644
@@ -279,13 +279,16 @@ static int uvd_v3_1_fw_validate(struct amdgpu_device *adev)
  {

drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c static int uvd_v3_1_fw_validate(struct amdgpu_device *adev) · line 282

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +1 -7
  	void *ptr;
  	uint32_t ucode_len, i;
-	uint32_t keysel;
-
-	ptr = adev->uvd.inst[0].cpu_addr;
-	ptr += 192 + 16;
-	memcpy(&ucode_len, ptr, 4);
-	ptr += ucode_len;
-	memcpy(&keysel, ptr, 4);
+	static uint32_t keysel = 0;

Well, that is a really big NAK.

You can't just make a variable static and hope that we don't have multiple instances of the device driver loaded.

If you need to keep the value around put it into adev somehow.

Christian.

drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c static int uvd_v3_1_fw_validate(struct amdgpu_device *adev) · line 294

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +9 -0
+
+	/* Only get the validate key at device initialization*/
+	if (!keysel) {
+		ptr = adev->uvd.inst[0].cpu_addr;
+		ptr += 192 + 16;
+		memcpy(&ucode_len, ptr, 4);
+		ptr += ucode_len;
+		memcpy(&keysel, ptr, 4);
+	}
 
  	WREG32(mmUVD_FW_START, keysel);
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx