summaryrefslogtreecommitdiff
path: root/linux-core
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2008-08-26 17:33:46 +1000
committerDave Airlie <airlied@redhat.com>2008-08-26 17:33:46 +1000
commit4c8e8e0d0bad839cf5aacb22524885e49fe86715 (patch)
treeb0d37af2d264f13155502bfbcf01048011d1df03 /linux-core
parent9afd2659430245c456cf887d47087de047c0aba8 (diff)
drm: add memory clean flag.
When the mapping is clean this flag will be set. This can be used by a driver to save migrating and allocating pages for an object that will first be used in VRAM.
Diffstat (limited to 'linux-core')
-rw-r--r--linux-core/drm_bo.c7
-rw-r--r--linux-core/drm_bo_move.c3
-rw-r--r--linux-core/drm_objects.h7
-rw-r--r--linux-core/drm_vm.c3
4 files changed, 18 insertions, 2 deletions
diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c
index 09b3fa39..ec63fa2a 100644
--- a/linux-core/drm_bo.c
+++ b/linux-core/drm_bo.c
@@ -1170,6 +1170,9 @@ out_unlock:
DRM_FLAG_MASKED(bo->priv_flags, _DRM_BO_FLAG_UNFENCED,
_DRM_BO_FLAG_UNFENCED);
}
+ /* clear the clean flags */
+ bo->mem.flags &= ~DRM_BO_FLAG_CLEAN;
+
mutex_unlock(&dev->struct_mutex);
mutex_unlock(&bm->evict_mutex);
return ret;
@@ -1493,12 +1496,14 @@ int drm_buffer_object_create(struct drm_device *dev,
bo->buffer_start = buffer_start & PAGE_MASK;
bo->priv_flags = 0;
bo->mem.flags = (DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_CACHED |
- DRM_BO_FLAG_MAPPABLE);
+ DRM_BO_FLAG_MAPPABLE | DRM_BO_FLAG_CLEAN);
bo->mem.proposed_flags = 0;
atomic_inc(&bm->count);
/*
* Use drm_bo_modify_proposed_flags to error-check the proposed flags
*/
+ flags |= DRM_BO_FLAG_CLEAN; /* or in the clean flag */
+
ret = drm_bo_modify_proposed_flags (bo, flags, flags);
if (ret)
goto out_err;
diff --git a/linux-core/drm_bo_move.c b/linux-core/drm_bo_move.c
index 5c290af2..e81967fd 100644
--- a/linux-core/drm_bo_move.c
+++ b/linux-core/drm_bo_move.c
@@ -562,6 +562,9 @@ int drm_bo_kmap(struct drm_buffer_object *bo, unsigned long start_page,
if (ret)
return ret;
+ /* clear the clean flags */
+ bo->mem.flags &= ~DRM_BO_FLAG_CLEAN;
+
if (bus_size == 0) {
return drm_bo_kmap_ttm(bo, start_page, num_pages, map);
} else {
diff --git a/linux-core/drm_objects.h b/linux-core/drm_objects.h
index 925b4d67..3eb8b902 100644
--- a/linux-core/drm_objects.h
+++ b/linux-core/drm_objects.h
@@ -146,6 +146,12 @@ struct drm_fence_arg {
#define DRM_BO_FLAG_TILE (1ULL << 15)
/*
+ * Buffer has been mapped or touched since creation
+ * for VRAM we don't need to migrate, just fill with 0s for non-dirty
+ */
+#define DRM_BO_FLAG_CLEAN (1ULL << 16)
+
+/*
* Memory type flags that can be or'ed together in the mask, but only
* one appears in flags.
*/
@@ -208,7 +214,6 @@ struct drm_fence_arg {
*/
#define DRM_BO_HINT_PRESUMED_OFFSET 0x00000010
-
#define DRM_BO_MEM_LOCAL 0
#define DRM_BO_MEM_TT 1
#define DRM_BO_MEM_VRAM 2
diff --git a/linux-core/drm_vm.c b/linux-core/drm_vm.c
index 0aabf943..48d7b057 100644
--- a/linux-core/drm_vm.c
+++ b/linux-core/drm_vm.c
@@ -792,6 +792,9 @@ static void drm_bo_vm_open_locked(struct vm_area_struct *vma)
{
struct drm_buffer_object *bo = (struct drm_buffer_object *) vma->vm_private_data;
+ /* clear the clean flags */
+ bo->mem.flags &= ~DRM_BO_FLAG_CLEAN;
+
drm_vm_open_locked(vma);
atomic_inc(&bo->usage);
#ifdef DRM_ODD_MM_COMPAT