drm/ttm, drm/amdgpu: Allow the driver some control over swapping
authorThomas Hellström <thomas.hellstrom@linux.intel.com>
Wed, 2 Jun 2021 08:38:14 +0000 (10:38 +0200)
committerThomas Hellström <thomas.hellstrom@linux.intel.com>
Mon, 7 Jun 2021 14:07:09 +0000 (16:07 +0200)
commitabb50d67adf3f01f567f365b45ecb49df8289296
treea97e174a774b1e0de49e1b521bb1b7ae29a9ef84
parenta3be8cd70fec2aa8913b59c9026031205c29df28
drm/ttm, drm/amdgpu: Allow the driver some control over swapping

We are calling the eviction_valuable driver callback at eviction time to
determine whether we actually can evict a buffer object.
The upcoming i915 TTM backend needs the same functionality for swapout,
and that might actually be beneficial to other drivers as well.

Add an eviction_valuable call also in the swapout path. Try to keep the
current behaviour for all drivers by returning true if the buffer object
is already in the TTM_PL_SYSTEM placement. We change behaviour for the
case where a buffer object is in a TT backed placement when swapped out,
in which case the drivers normal eviction_valuable path is run.

Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Christian König <christian.koenig@amd.com>
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Acked-by: Christian König <christian.koenig@amd.com>
Link: https://lore.kernel.org/r/20210602083818.241793-8-thomas.hellstrom@linux.intel.com
Link: https://patchwork.freedesktop.org/patch/msgid/20210602083818.241793-8-thomas.hellstrom@linux.intel.com
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
drivers/gpu/drm/ttm/ttm_bo.c