[PATCH 1/3] drm/vma/gem/ttm: consolide unmapping range

Dave Airlie airlied at gmail.com
Tue Dec 18 20:41:57 PST 2012


From: Dave Airlie <airlied at redhat.com>

This is just a cleanup, can probably do better, but at least it makes
the calls to the unmap_mapping_range consistent.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 drivers/gpu/drm/drm_vma_offset_man.c | 11 +++++++++++
 drivers/gpu/drm/i915/i915_gem.c      |  7 ++-----
 drivers/gpu/drm/ttm/ttm_bo.c         |  8 ++------
 include/drm/drm_vma_offset_man.h     |  3 +++
 4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/drm_vma_offset_man.c b/drivers/gpu/drm/drm_vma_offset_man.c
index cf2e291..7456892 100644
--- a/drivers/gpu/drm/drm_vma_offset_man.c
+++ b/drivers/gpu/drm/drm_vma_offset_man.c
@@ -125,6 +125,17 @@ out_unlock:
 }
 EXPORT_SYMBOL(drm_vma_offset_setup);
 
+void drm_vma_unmap_mapping(struct address_space *dev_mapping,
+			   struct drm_vma_offset_node *node)
+{
+	if (dev_mapping && drm_vma_node_is_allocated(node)) {
+		unmap_mapping_range(dev_mapping,
+				    drm_vma_node_offset_addr(node),
+				    node->num_pages << PAGE_SHIFT, 1);
+	}
+}
+EXPORT_SYMBOL(drm_vma_unmap_mapping);
+
 int drm_vma_offset_man_init(struct drm_vma_offset_manager *man, uint64_t file_page_offset, uint64_t size)
 {
 	int ret;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 16f1b2c..8d28123 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1424,11 +1424,8 @@ i915_gem_release_mmap(struct drm_i915_gem_object *obj)
 	if (!obj->fault_mappable)
 		return;
 
-	if (obj->base.dev->dev_mapping)
-		unmap_mapping_range(obj->base.dev->dev_mapping,
-				    (loff_t)drm_vma_node_offset_addr(&obj->base.vma_offset),
-				    obj->base.size, 1);
-
+	drm_vma_unmap_mapping(obj->base.dev->dev_mapping,
+			      &obj->base.vma_offset);
 	obj->fault_mappable = false;
 }
 
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 3f42621..2a7b6a6 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1597,12 +1597,8 @@ void ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo)
 {
 	struct ttm_bo_device *bdev = bo->bdev;
 
-	if (drm_vma_node_is_allocated(&bo->vma_offset) && bdev->dev_mapping) {
-		loff_t offset = (loff_t) drm_vma_node_offset_addr(&bo->vma_offset);
-		loff_t holelen = ((loff_t) bo->mem.num_pages) << PAGE_SHIFT;
-
-		unmap_mapping_range(bdev->dev_mapping, offset, holelen, 1);
-	}
+	drm_vma_unmap_mapping(bdev->dev_mapping,
+			      &bo->vma_offset);
 	ttm_mem_io_free_vm(bo);
 }
 
diff --git a/include/drm/drm_vma_offset_man.h b/include/drm/drm_vma_offset_man.h
index 4211c60..b8ef845 100644
--- a/include/drm/drm_vma_offset_man.h
+++ b/include/drm/drm_vma_offset_man.h
@@ -35,6 +35,9 @@ void drm_vma_offset_destroy(struct drm_vma_offset_manager *man,
 int drm_vma_offset_man_init(struct drm_vma_offset_manager *man, uint64_t file_page_offset, uint64_t size);
 void drm_vma_offset_man_fini(struct drm_vma_offset_manager *man);
 
+void drm_vma_unmap_mapping(struct address_space *dev_mapping,
+			   struct drm_vma_offset_node *node);
+
 static inline void drm_vma_node_reset(struct drm_vma_offset_node *node)
 {
 	node->vm_node = NULL;
-- 
1.8.0.2



More information about the dri-devel mailing list