From: Daniel Vetter Subject: Re: [PATCH 6/6] drm: provide generic drm_vma_node_unmap() helper Date: Mon, 1 Jul 2013 21:44:45 +0200 Message-ID: <20130701194445.GA18285@phenom.ffwll.local> References: <1372703583-9550-1-git-send-email-dh.herrmann@gmail.com> <1372703583-9550-7-git-send-email-dh.herrmann@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-ee0-f43.google.com (mail-ee0-f43.google.com [74.125.83.43]) by gabe.freedesktop.org (Postfix) with ESMTP id D65F2E5E10 for ; Mon, 1 Jul 2013 12:44:46 -0700 (PDT) Received: by mail-ee0-f43.google.com with SMTP id l10so2248456eei.16 for ; Mon, 01 Jul 2013 12:44:46 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1372703583-9550-7-git-send-email-dh.herrmann@gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: David Herrmann Cc: Dave Airlie , dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org On Mon, Jul 01, 2013 at 08:33:03PM +0200, David Herrmann wrote: > Instead of unmapping the nodes in TTM and GEM users manually, we provide > a generic wrapper which does the correct thing for all vma-nodes. > > Signed-off-by: David Herrmann Nice. One nitpick below, otherwise: Reviewed-by: Daniel Vetter > --- > drivers/gpu/drm/i915/i915_gem.c | 6 +----- > drivers/gpu/drm/ttm/ttm_bo.c | 8 +------- > include/drm/drm_vma_manager.h | 16 ++++++++++++++++ > 3 files changed, 18 insertions(+), 12 deletions(-) > > diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c > index 1617166..43f9aaf 100644 > --- a/drivers/gpu/drm/i915/i915_gem.c > +++ b/drivers/gpu/drm/i915/i915_gem.c > @@ -1427,11 +1427,7 @@ 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_node), > - obj->base.size, 1); > - > + drm_vma_node_unmap(&obj->base.vma_node, obj->base.dev->dev_mapping); > obj->fault_mappable = false; > } > > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c > index 2b96a75..2979070 100644 > --- a/drivers/gpu/drm/ttm/ttm_bo.c > +++ b/drivers/gpu/drm/ttm/ttm_bo.c > @@ -1657,17 +1657,11 @@ bool ttm_mem_reg_is_pci(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) > void ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo) > { > struct ttm_bo_device *bdev = bo->bdev; > - loff_t offset, holelen; > > if (!bdev->dev_mapping) > return; Can't we kill this check now since your helper checks for the mapping already? > > - if (drm_vma_node_has_offset(&bo->vma_node)) { > - offset = (loff_t) drm_vma_node_offset_addr(&bo->vma_node); > - holelen = ((loff_t) bo->mem.num_pages) << PAGE_SHIFT; > - > - unmap_mapping_range(bdev->dev_mapping, offset, holelen, 1); > - } > + drm_vma_node_unmap(&bo->vma_node, bdev->dev_mapping); > ttm_mem_io_free_vm(bo); > } > > diff --git a/include/drm/drm_vma_manager.h b/include/drm/drm_vma_manager.h > index 4d6a734..185e9aa 100644 > --- a/include/drm/drm_vma_manager.h > +++ b/include/drm/drm_vma_manager.h > @@ -24,6 +24,7 @@ > */ > > #include > +#include > #include > #include > #include > @@ -103,4 +104,19 @@ static inline __u64 drm_vma_node_offset_addr(struct drm_vma_offset_node *node) > return ((__u64)node->vm_node.start) << PAGE_SHIFT; > } > > +/** drm_vma_node_unmap() > + * > + * Unmap all userspace mappings for a given offset node. The mappings must be > + * associated with the @file_mapping address-space. If no offset exists or > + * the address-space is invalid, nothing is done. > + */ > +static inline void drm_vma_node_unmap(struct drm_vma_offset_node *node, > + struct address_space *file_mapping) > +{ > + if (file_mapping && drm_vma_node_has_offset(node)) > + unmap_mapping_range(file_mapping, > + drm_vma_node_offset_addr(node), > + node->vm_pages << PAGE_SHIFT, 1); > +} > + > #endif /* __DRM_VMA_MANAGER_H__ */ > -- > 1.8.3.2 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch