From patchwork Wed Dec 19 04:41:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 1894431 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 7AAB4DF230 for ; Wed, 19 Dec 2012 04:50:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 737FAE5F65 for ; Tue, 18 Dec 2012 20:50:18 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from ipmail06.adl6.internode.on.net (ipmail06.adl6.internode.on.net [150.101.137.145]) by gabe.freedesktop.org (Postfix) with ESMTP id 8722AE5FE0 for ; Tue, 18 Dec 2012 20:48:23 -0800 (PST) Received: from ppp118-208-134-74.lns20.bne1.internode.on.net (HELO optimus.redhat.com) ([118.208.134.74]) by ipmail06.adl6.internode.on.net with ESMTP; 19 Dec 2012 15:18:17 +1030 From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/3] drm/vma/gem/ttm: consolide unmapping range Date: Wed, 19 Dec 2012 14:41:57 +1000 Message-Id: <1355892119-13926-2-git-send-email-airlied@gmail.com> X-Mailer: git-send-email 1.8.0.2 In-Reply-To: <1355892119-13926-1-git-send-email-airlied@gmail.com> References: <1355892119-13926-1-git-send-email-airlied@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org From: Dave Airlie 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 --- 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;