Merge tag 'drm-misc-next-2022-09-09' of git://anongit.freedesktop.org/drm/drm-misc...
[linux-2.6-block.git] / drivers / gpu / drm / ttm / ttm_bo.c
index 590110fdf59cde5c0b138ea13fe8e29b1a8a09f5..7c8e8be774f1d493d6efd7524ca97595672cbfbe 100644 (file)
@@ -518,6 +518,9 @@ out:
 bool ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
                              const struct ttm_place *place)
 {
+       struct ttm_resource *res = bo->resource;
+       struct ttm_device *bdev = bo->bdev;
+
        dma_resv_assert_held(bo->base.resv);
        if (bo->resource->mem_type == TTM_PL_SYSTEM)
                return true;
@@ -525,11 +528,7 @@ bool ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
        /* Don't evict this BO if it's outside of the
         * requested placement range
         */
-       if (place->fpfn >= (bo->resource->start + bo->resource->num_pages) ||
-           (place->lpfn && place->lpfn <= bo->resource->start))
-               return false;
-
-       return true;
+       return ttm_resource_intersects(bdev, res, place, bo->base.size);
 }
 EXPORT_SYMBOL(ttm_bo_eviction_valuable);