]> Git Repo - linux.git/blobdiff - drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
BackMerge v4.18-rc7 into drm-next
[linux.git] / drivers / gpu / drm / amd / amdgpu / amdgpu_vram_mgr.c
index b6333f92ba4565e9b5949f48e643f2d47daaa2a0..9cfa8a9ada921b8b0844a9bd140a68e1c1eca8c1 100644 (file)
@@ -97,33 +97,29 @@ static u64 amdgpu_vram_mgr_vis_size(struct amdgpu_device *adev,
 }
 
 /**
- * amdgpu_vram_mgr_bo_invisible_size - CPU invisible BO size
+ * amdgpu_vram_mgr_bo_visible_size - CPU visible BO size
  *
  * @bo: &amdgpu_bo buffer object (must be in VRAM)
  *
  * Returns:
- * How much of the given &amdgpu_bo buffer object lies in CPU invisible VRAM.
+ * How much of the given &amdgpu_bo buffer object lies in CPU visible VRAM.
  */
-u64 amdgpu_vram_mgr_bo_invisible_size(struct amdgpu_bo *bo)
+u64 amdgpu_vram_mgr_bo_visible_size(struct amdgpu_bo *bo)
 {
        struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
        struct ttm_mem_reg *mem = &bo->tbo.mem;
        struct drm_mm_node *nodes = mem->mm_node;
        unsigned pages = mem->num_pages;
-       u64 usage = 0;
+       u64 usage;
 
-       if (adev->gmc.visible_vram_size == adev->gmc.real_vram_size)
-               return 0;
+       if (amdgpu_gmc_vram_full_visible(&adev->gmc))
+               return amdgpu_bo_size(bo);
 
        if (mem->start >= adev->gmc.visible_vram_size >> PAGE_SHIFT)
-               return amdgpu_bo_size(bo);
+               return 0;
 
-       while (nodes && pages) {
-               usage += nodes->size << PAGE_SHIFT;
-               usage -= amdgpu_vram_mgr_vis_size(adev, nodes);
-               pages -= nodes->size;
-               ++nodes;
-       }
+       for (usage = 0; nodes && pages; pages -= nodes->size, nodes++)
+               usage += amdgpu_vram_mgr_vis_size(adev, nodes);
 
        return usage;
 }
This page took 0.034667 seconds and 4 git commands to generate.