]> Git Repo - linux.git/blobdiff - drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
Merge tag 'drm-misc-next-2017-08-08' of git://anongit.freedesktop.org/git/drm-misc...
[linux.git] / drivers / gpu / drm / amd / amdgpu / amdgpu_object.c
index 93601fbea695bca8fbb292b1b347f3bf060766da..3ec43cf9ad78fc17420dcf8c4be86173e20d9ff3 100644 (file)
@@ -93,6 +93,7 @@ static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo)
 
        bo = container_of(tbo, struct amdgpu_bo, tbo);
 
+       amdgpu_bo_kunmap(bo);
        amdgpu_update_memory_usage(adev, &bo->tbo.mem, NULL);
 
        drm_gem_object_release(&bo->gem_base);
@@ -734,15 +735,16 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
                dev_err(adev->dev, "%p pin failed\n", bo);
                goto error;
        }
-       r = amdgpu_ttm_bind(&bo->tbo, &bo->tbo.mem);
-       if (unlikely(r)) {
-               dev_err(adev->dev, "%p bind failed\n", bo);
-               goto error;
-       }
 
        bo->pin_count = 1;
-       if (gpu_addr != NULL)
+       if (gpu_addr != NULL) {
+               r = amdgpu_ttm_bind(&bo->tbo, &bo->tbo.mem);
+               if (unlikely(r)) {
+                       dev_err(adev->dev, "%p bind failed\n", bo);
+                       goto error;
+               }
                *gpu_addr = amdgpu_bo_gpu_offset(bo);
+       }
        if (domain == AMDGPU_GEM_DOMAIN_VRAM) {
                adev->vram_pin_size += amdgpu_bo_size(bo);
                if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)
@@ -931,6 +933,8 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
        abo = container_of(bo, struct amdgpu_bo, tbo);
        amdgpu_vm_bo_invalidate(adev, abo);
 
+       amdgpu_bo_kunmap(abo);
+
        /* remember the eviction */
        if (evict)
                atomic64_inc(&adev->num_evictions);
@@ -974,18 +978,21 @@ int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
 
        /* hurrah the memory is not visible ! */
        atomic64_inc(&adev->num_vram_cpu_page_faults);
-       amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM);
+       amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM |
+                                        AMDGPU_GEM_DOMAIN_GTT);
+
+       /* Avoid costly evictions; only set GTT as a busy placement */
+       abo->placement.num_busy_placement = 1;
+       abo->placement.busy_placement = &abo->placements[1];
+
        r = ttm_bo_validate(bo, &abo->placement, false, false);
-       if (unlikely(r == -ENOMEM)) {
-               amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT);
-               return ttm_bo_validate(bo, &abo->placement, false, false);
-       } else if (unlikely(r != 0)) {
+       if (unlikely(r != 0))
                return r;
-       }
 
        offset = bo->mem.start << PAGE_SHIFT;
        /* this should never happen */
-       if ((offset + size) > adev->mc.visible_vram_size)
+       if (bo->mem.mem_type == TTM_PL_VRAM &&
+           (offset + size) > adev->mc.visible_vram_size)
                return -EINVAL;
 
        return 0;
This page took 0.035557 seconds and 4 git commands to generate.