gfx: drm: ttm: add support for non-swappable buffers
authorImre Deak <imre.deak@intel.com>
Thu, 22 Dec 2011 20:48:27 +0000 (22:48 +0200)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 3 Jul 2012 09:29:18 +0000 (12:29 +0300)
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 <imre.deak@intel.com>
Signed-off-by: Pauli Nieminen <pauli.nieminen@linux.intel.com>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
drivers/gpu/drm/ttm/ttm_bo.c
include/drm/ttm/ttm_placement.h

index 6adf0a9..18eac74 100644 (file)
@@ -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);
                }
index c84ff15..06f7443 100644 (file)
@@ -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 | \