aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/files/0432-drm-amdgpu-save-and-restore-the-firwmware-cache-part.patch
blob: 7fd7bab65856cd3f7e0ed2ded62dd0be555633b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
From bda6d7754c62d614accae5a483b85dc6dfe7364f Mon Sep 17 00:00:00 2001
From: Leo Liu <leo.liu@amd.com>
Date: Mon, 4 Apr 2016 10:55:43 -0400
Subject: [PATCH 0432/1110] drm/amdgpu: save and restore the firwmware cache
 part when suspend resume
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Leo Liu <leo.liu@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Kalyan Alle <kalyan.alle@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
index 69547c3..86dead7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
@@ -245,7 +245,6 @@ int amdgpu_uvd_suspend(struct amdgpu_device *adev)
 {
         unsigned size;
         void *ptr;
-        const struct common_firmware_header *hdr;
         int i;
 
 	if (adev->uvd.vcpu_bo == NULL)
@@ -257,15 +256,11 @@ int amdgpu_uvd_suspend(struct amdgpu_device *adev)
  
         if (i == AMDGPU_MAX_UVD_HANDLES)
                 return 0;
-        hdr = (const struct common_firmware_header *)adev->uvd.fw->data;
 
         size = amdgpu_bo_size(adev->uvd.vcpu_bo);
-        size -= le32_to_cpu(hdr->ucode_size_bytes);
-
         ptr = adev->uvd.cpu_addr;
-        ptr += le32_to_cpu(hdr->ucode_size_bytes);
- 
-        adev->uvd.saved_bo = kmalloc(size, GFP_KERNEL);
+        
+	adev->uvd.saved_bo = kmalloc(size, GFP_KERNEL);
         if (!adev->uvd.saved_bo)
                 return -ENOMEM;
  
@@ -278,30 +273,31 @@ int amdgpu_uvd_resume(struct amdgpu_device *adev)
 {
 	unsigned size;
 	void *ptr;
-	const struct common_firmware_header *hdr;
-	unsigned offset;
 
 	if (adev->uvd.vcpu_bo == NULL)
 		return -EINVAL;
 
-	hdr = (const struct common_firmware_header *)adev->uvd.fw->data;
-	offset = le32_to_cpu(hdr->ucode_array_offset_bytes);
-	memcpy(adev->uvd.cpu_addr, (adev->uvd.fw->data) + offset,
-		(adev->uvd.fw->size) - offset);
-
 	cancel_delayed_work_sync(&adev->uvd.idle_work);
 
 	size = amdgpu_bo_size(adev->uvd.vcpu_bo);
-	size -= le32_to_cpu(hdr->ucode_size_bytes);
 	ptr = adev->uvd.cpu_addr;
-	ptr += le32_to_cpu(hdr->ucode_size_bytes);
 
 	if (adev->uvd.saved_bo != NULL) {
 		memcpy(ptr, adev->uvd.saved_bo, size);
 		kfree(adev->uvd.saved_bo);
 		adev->uvd.saved_bo = NULL;
-	} else
+        } else {
+                const struct common_firmware_header *hdr;
+                unsigned offset;
+ 
+                hdr = (const struct common_firmware_header *)adev->uvd.fw->data;
+                offset = le32_to_cpu(hdr->ucode_array_offset_bytes);
+                memcpy(adev->uvd.cpu_addr, (adev->uvd.fw->data) + offset,
+                        (adev->uvd.fw->size) - offset);
+                size -= le32_to_cpu(hdr->ucode_size_bytes);
+                ptr += le32_to_cpu(hdr->ucode_size_bytes);
 		memset(ptr, 0, size);
+        }
 
 	return 0;
 }
-- 
2.7.4