aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/files/1108-drm-amdgpu-fix-uvd-fini-mem-leak.patch
blob: 7f7afa9b1b1776d81870b84f9963dd8ca3d0453e (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
From 8d08dbb0b24d54b199c0fa1b39232ae8b73155d4 Mon Sep 17 00:00:00 2001
From: Monk Liu <Monk.Liu@amd.com>
Date: Mon, 30 May 2016 15:13:59 +0800
Subject: [PATCH 1108/1110] drm/amdgpu:fix uvd fini mem leak
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Change-Id: I970ff5639fd22464a494750956646296b932ba3c
Signed-off-by: Monk Liu <Monk.Liu@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Kalyan Alle <kalyan.alle@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
index 88a7942..efb07fe 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
@@ -244,11 +244,11 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)
 int amdgpu_uvd_sw_fini(struct amdgpu_device *adev)
 {
 	int r;
-
-	if (adev->uvd.vcpu_bo == NULL)
-		return 0;
+	
+	kfree(adev->uvd.saved_bo);
         amd_sched_entity_fini(&adev->uvd.ring.sched, &adev->uvd.entity);
-
+	
+	if (adev->uvd.vcpu_bo) {
 	r = amdgpu_bo_reserve(adev->uvd.vcpu_bo, false);
 	if (!r) {
 		amdgpu_bo_kunmap(adev->uvd.vcpu_bo);
@@ -257,7 +257,7 @@ int amdgpu_uvd_sw_fini(struct amdgpu_device *adev)
 	}
 
 	amdgpu_bo_unref(&adev->uvd.vcpu_bo);
-
+    }
 	amdgpu_ring_fini(&adev->uvd.ring);
 
 	release_firmware(adev->uvd.fw);
@@ -280,8 +280,10 @@ int amdgpu_uvd_suspend(struct amdgpu_device *adev)
  
         if (i == AMDGPU_MAX_UVD_HANDLES)
                 return 0;
-
-        size = amdgpu_bo_size(adev->uvd.vcpu_bo);
+	
+	cancel_delayed_work_sync(&adev->uvd.idle_work);
+        
+	size = amdgpu_bo_size(adev->uvd.vcpu_bo);
         ptr = adev->uvd.cpu_addr;
         
 	adev->uvd.saved_bo = kmalloc(size, GFP_KERNEL);
@@ -301,8 +303,6 @@ int amdgpu_uvd_resume(struct amdgpu_device *adev)
 	if (adev->uvd.vcpu_bo == NULL)
 		return -EINVAL;
 
-	cancel_delayed_work_sync(&adev->uvd.idle_work);
-
 	size = amdgpu_bo_size(adev->uvd.vcpu_bo);
 	ptr = adev->uvd.cpu_addr;
 
@@ -916,7 +916,7 @@ static int amdgpu_uvd_send_msg(struct amdgpu_ring *ring, struct amdgpu_bo *bo,
 
                 amdgpu_job_free(job);
         } else {
-                r = amdgpu_job_submit(job, ring, NULL,
+                r = amdgpu_job_submit(job, ring, &adev->uvd.entity,
                                       AMDGPU_FENCE_OWNER_UNDEFINED, &f);
                 if (r)
                         goto err_free;
-- 
2.7.4