]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
drm/radeon: Try evicting from CPU accessible to inaccessible VRAM first
authorMichel Dänzer <michel.daenzer@amd.com>
Thu, 9 Oct 2014 09:55:04 +0000 (18:55 +0900)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 12 Nov 2014 16:29:10 +0000 (11:29 -0500)
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon_ttm.c

index 8624979afb65f55ecba4ffb888aa09d0b3c8b39d..cbe7b32d181c2f3bf2972b14f12c72597d3e15f5 100644 (file)
@@ -198,7 +198,30 @@ static void radeon_evict_flags(struct ttm_buffer_object *bo,
        case TTM_PL_VRAM:
                if (rbo->rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ready == false)
                        radeon_ttm_placement_from_domain(rbo, RADEON_GEM_DOMAIN_CPU);
-               else
+               else if (rbo->rdev->mc.visible_vram_size < rbo->rdev->mc.real_vram_size &&
+                        bo->mem.start < (rbo->rdev->mc.visible_vram_size >> PAGE_SHIFT)) {
+                       unsigned fpfn = rbo->rdev->mc.visible_vram_size >> PAGE_SHIFT;
+                       int i;
+
+                       /* Try evicting to the CPU inaccessible part of VRAM
+                        * first, but only set GTT as busy placement, so this
+                        * BO will be evicted to GTT rather than causing other
+                        * BOs to be evicted from VRAM
+                        */
+                       radeon_ttm_placement_from_domain(rbo, RADEON_GEM_DOMAIN_VRAM |
+                                                        RADEON_GEM_DOMAIN_GTT);
+                       rbo->placement.num_busy_placement = 0;
+                       for (i = 0; i < rbo->placement.num_placement; i++) {
+                               if (rbo->placements[i].flags & TTM_PL_FLAG_VRAM) {
+                                       if (rbo->placements[0].fpfn < fpfn)
+                                               rbo->placements[0].fpfn = fpfn;
+                               } else {
+                                       rbo->placement.busy_placement =
+                                               &rbo->placements[i];
+                                       rbo->placement.num_busy_placement = 1;
+                               }
+                       }
+               } else
                        radeon_ttm_placement_from_domain(rbo, RADEON_GEM_DOMAIN_GTT);
                break;
        case TTM_PL_TT: