aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/3940-drm-amdgpu-fix-the-missed-vram-gart-usage-counting-f.patch
blob: 5e30da96adc37c51e9efaea5e668d0623a8e4786 (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
From c2b26d6ce8e419845694fc74bae98df57d3ebb6e Mon Sep 17 00:00:00 2001
From: Huang Rui <ray.huang@amd.com>
Date: Thu, 29 Mar 2018 11:50:41 +0800
Subject: [PATCH 3940/4131] drm/amdgpu: fix the missed vram/gart usage counting
 for direct gma

Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Roger He <Hongbo.He@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 60870dd..e7e13dc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -34,7 +34,16 @@
 void amdgpu_gem_object_free(struct drm_gem_object *gobj)
 {
 	struct amdgpu_bo *robj = gem_to_amdgpu_bo(gobj);
+	struct amdgpu_device *adev = amdgpu_ttm_adev(robj->tbo.bdev);
+
         if (robj) {
+		if (robj->tbo.mem.mem_type == AMDGPU_PL_DGMA)
+                        atomic64_sub(amdgpu_bo_size(robj),
+                                     &adev->direct_gma.vram_usage);
+                else if (robj->tbo.mem.mem_type == AMDGPU_PL_DGMA_IMPORT)
+                        atomic64_sub(amdgpu_bo_size(robj),
+                                     &adev->direct_gma.gart_usage);
+
                 amdgpu_mn_unregister(robj);
                 amdgpu_bo_unref(&robj);
         }
@@ -83,6 +92,11 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size,
 	}
 	*obj = &bo->gem_base;
 
+	if (initial_domain & AMDGPU_GEM_DOMAIN_DGMA)
+		atomic64_add(size, &adev->direct_gma.vram_usage);
+	else if (initial_domain & AMDGPU_GEM_DOMAIN_DGMA_IMPORT)
+		atomic64_add(size, &adev->direct_gma.gart_usage);
+
 	return 0;
 }
 
-- 
2.7.4