From 23b16b69d5a4aa9066617a49f3b0469ccf880668 Mon Sep 17 00:00:00 2001 From: Imre Deak Date: Thu, 22 Dec 2011 22:48:27 +0200 Subject: [PATCH] gfx: drm: ttm: add support for non-swappable buffers Needed by buffers that can move in GPU address space, but are not swappable. An example is a wrapped PVR buffer, added by an upcoming patch. Signed-off-by: Imre Deak Signed-off-by: Pauli Nieminen Signed-off-by: Kirill A. Shutemov --- drivers/gpu/drm/ttm/ttm_bo.c | 4 +++- include/drm/ttm/ttm_placement.h | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 6adf0a9..18eac74 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -177,6 +177,7 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo) BUG_ON(!atomic_read(&bo->reserved)); if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) { + bool swappable; BUG_ON(!list_empty(&bo->lru)); @@ -184,7 +185,8 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo) list_add_tail(&bo->lru, &man->lru); kref_get(&bo->list_kref); - if (bo->ttm != NULL) { + swappable = !(bo->mem.placement & TTM_PL_FLAG_NO_SWAP); + if (bo->ttm != NULL && swappable) { list_add_tail(&bo->swap, &bo->glob->swap_lru); kref_get(&bo->list_kref); } diff --git a/include/drm/ttm/ttm_placement.h b/include/drm/ttm/ttm_placement.h index c84ff15..06f7443 100644 --- a/include/drm/ttm/ttm_placement.h +++ b/include/drm/ttm/ttm_placement.h @@ -65,6 +65,9 @@ * reference the buffer. * TTM_PL_FLAG_NO_EVICT means that the buffer may never * be evicted to make room for other buffers. + * TTM_PL_FLAG_NO_SWAP means that the buffer cannot be + * swapped. If NO_EVICT is not set the buffer can still + * be moved as long as its placement allows it. */ #define TTM_PL_FLAG_CACHED (1 << 16) @@ -72,6 +75,7 @@ #define TTM_PL_FLAG_WC (1 << 18) #define TTM_PL_FLAG_SHARED (1 << 20) #define TTM_PL_FLAG_NO_EVICT (1 << 21) +#define TTM_PL_FLAG_NO_SWAP (1 << 22) #define TTM_PL_MASK_CACHING (TTM_PL_FLAG_CACHED | \ TTM_PL_FLAG_UNCACHED | \ -- 2.7.4