diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2018-06-14 07:02:07 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-06-19 14:51:45 -0400 |
commit | 7303b39e46b2f523334591f05fd9566cf929eb26 (patch) | |
tree | 1fc6b696d761fc670ca1a41c2a63892a02e39f50 | |
parent | 5e9244ff585239630f15f8ad8e676bc91a94ca9e (diff) |
drm/amdgpu: Make amdgpu_vram_mgr_bo_invisible_size always accurate
Even BOs with AMDGPU_GEM_CREATE_NO_CPU_ACCESS may end up at least
partially in CPU visible VRAM, in particular when all VRAM is visible.
v2:
* Don't take VRAM mgr spinlock, not needed (Christian König)
* Make loop logic simpler and clearer.
Cc: stable@vger.kernel.org
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c index ae0049c6c52c..b6333f92ba45 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | |||
@@ -106,10 +106,26 @@ static u64 amdgpu_vram_mgr_vis_size(struct amdgpu_device *adev, | |||
106 | */ | 106 | */ |
107 | u64 amdgpu_vram_mgr_bo_invisible_size(struct amdgpu_bo *bo) | 107 | u64 amdgpu_vram_mgr_bo_invisible_size(struct amdgpu_bo *bo) |
108 | { | 108 | { |
109 | if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) | 109 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); |
110 | struct ttm_mem_reg *mem = &bo->tbo.mem; | ||
111 | struct drm_mm_node *nodes = mem->mm_node; | ||
112 | unsigned pages = mem->num_pages; | ||
113 | u64 usage = 0; | ||
114 | |||
115 | if (adev->gmc.visible_vram_size == adev->gmc.real_vram_size) | ||
116 | return 0; | ||
117 | |||
118 | if (mem->start >= adev->gmc.visible_vram_size >> PAGE_SHIFT) | ||
110 | return amdgpu_bo_size(bo); | 119 | return amdgpu_bo_size(bo); |
111 | 120 | ||
112 | return 0; | 121 | while (nodes && pages) { |
122 | usage += nodes->size << PAGE_SHIFT; | ||
123 | usage -= amdgpu_vram_mgr_vis_size(adev, nodes); | ||
124 | pages -= nodes->size; | ||
125 | ++nodes; | ||
126 | } | ||
127 | |||
128 | return usage; | ||
113 | } | 129 | } |
114 | 130 | ||
115 | /** | 131 | /** |