diff options
author | Christian König <christian.koenig@amd.com> | 2018-04-05 10:42:03 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-05-15 14:43:05 -0400 |
commit | 5422a28fe86f9f77480471385e0a416c27a9ca72 (patch) | |
tree | 3fda88b779e1f2505ee90ec61b9a369003e2038c /drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | |
parent | f1018f50d48395b4a189bf8ea9af1e4441209cfd (diff) |
drm/amdgpu: fix and cleanup cpu visible VRAM handling
The detection if a BO was placed in CPU visible VRAM was incorrect.
Fix it and merge it with the correct detection in amdgpu_ttm.c
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 205da3ff9cd0..ab73300e6c7f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | |||
@@ -223,20 +223,8 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo, | |||
223 | if (!adev->mman.buffer_funcs_enabled) { | 223 | if (!adev->mman.buffer_funcs_enabled) { |
224 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_CPU); | 224 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_CPU); |
225 | } else if (adev->gmc.visible_vram_size < adev->gmc.real_vram_size && | 225 | } else if (adev->gmc.visible_vram_size < adev->gmc.real_vram_size && |
226 | !(abo->flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED)) { | 226 | !(abo->flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) && |
227 | unsigned fpfn = adev->gmc.visible_vram_size >> PAGE_SHIFT; | 227 | amdgpu_bo_in_cpu_visible_vram(abo)) { |
228 | struct drm_mm_node *node = bo->mem.mm_node; | ||
229 | unsigned long pages_left; | ||
230 | |||
231 | for (pages_left = bo->mem.num_pages; | ||
232 | pages_left; | ||
233 | pages_left -= node->size, node++) { | ||
234 | if (node->start < fpfn) | ||
235 | break; | ||
236 | } | ||
237 | |||
238 | if (!pages_left) | ||
239 | goto gtt; | ||
240 | 228 | ||
241 | /* Try evicting to the CPU inaccessible part of VRAM | 229 | /* Try evicting to the CPU inaccessible part of VRAM |
242 | * first, but only set GTT as busy placement, so this | 230 | * first, but only set GTT as busy placement, so this |
@@ -245,12 +233,11 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo, | |||
245 | */ | 233 | */ |
246 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM | | 234 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM | |
247 | AMDGPU_GEM_DOMAIN_GTT); | 235 | AMDGPU_GEM_DOMAIN_GTT); |
248 | abo->placements[0].fpfn = fpfn; | 236 | abo->placements[0].fpfn = adev->gmc.visible_vram_size >> PAGE_SHIFT; |
249 | abo->placements[0].lpfn = 0; | 237 | abo->placements[0].lpfn = 0; |
250 | abo->placement.busy_placement = &abo->placements[1]; | 238 | abo->placement.busy_placement = &abo->placements[1]; |
251 | abo->placement.num_busy_placement = 1; | 239 | abo->placement.num_busy_placement = 1; |
252 | } else { | 240 | } else { |
253 | gtt: | ||
254 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT); | 241 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT); |
255 | } | 242 | } |
256 | break; | 243 | break; |