Skip to content

Commit e300180

Browse files
Michel Dänzeralexdeucher
authored andcommitted
drm/ttm: Don't evict BOs outside of the requested placement range
The radeon driver uses placement range restrictions for several reasons, in particular to make sure BOs in VRAM can be accessed by the CPU, e.g. during a page fault. Without this change, TTM could evict other BOs while trying to satisfy the requested placement, even if the evicted BOs were outside of the requested placement range. Doing so didn't free up any space in the requested placement range, so the (potentially high) eviction cost was incurred for no benefit. Nominating for stable because radeon driver changes in 3.17 made this much more noticeable than before. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84662 Cc: stable@vger.kernel.org Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 9ace2ef commit e300180

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

‎drivers/gpu/drm/ttm/ttm_bo.c‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
709709

710710
static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
711711
uint32_t mem_type,
712+
const struct ttm_place *place,
712713
bool interruptible,
713714
bool no_wait_gpu)
714715
{
@@ -720,8 +721,21 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
720721
spin_lock(&glob->lru_lock);
721722
list_for_each_entry(bo, &man->lru, lru) {
722723
ret = __ttm_bo_reserve(bo, false, true, false, NULL);
723-
if (!ret)
724+
if (!ret) {
725+
if (place && (place->fpfn || place->lpfn)) {
726+
/* Don't evict this BO if it's outside of the
727+
* requested placement range
728+
*/
729+
if (place->fpfn >= (bo->mem.start + bo->mem.size) ||
730+
(place->lpfn && place->lpfn <= bo->mem.start)) {
731+
__ttm_bo_unreserve(bo);
732+
ret = -EBUSY;
733+
continue;
734+
}
735+
}
736+
724737
break;
738+
}
725739
}
726740

727741
if (ret) {
@@ -782,7 +796,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
782796
return ret;
783797
if (mem->mm_node)
784798
break;
785-
ret = ttm_mem_evict_first(bdev, mem_type,
799+
ret = ttm_mem_evict_first(bdev, mem_type, place,
786800
interruptible, no_wait_gpu);
787801
if (unlikely(ret != 0))
788802
return ret;
@@ -1233,7 +1247,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
12331247
spin_lock(&glob->lru_lock);
12341248
while (!list_empty(&man->lru)) {
12351249
spin_unlock(&glob->lru_lock);
1236-
ret = ttm_mem_evict_first(bdev, mem_type, false, false);
1250+
ret = ttm_mem_evict_first(bdev, mem_type, NULL, false, false);
12371251
if (ret) {
12381252
if (allow_errors) {
12391253
return ret;

0 commit comments

Comments
 (0)