From patchwork Wed Dec 19 01:56:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 1894371 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 6AABDDF2F6 for ; Wed, 19 Dec 2012 02:03:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DA5A0E5DEB for ; Tue, 18 Dec 2012 18:03:51 -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 D2100E5DEB for ; Tue, 18 Dec 2012 18:02:39 -0800 (PST) Received: from ppp118-208-134-74.lns20.bne1.internode.on.net (HELO localhost.localdomain) ([118.208.134.74]) by ipmail06.adl6.internode.on.net with ESMTP; 19 Dec 2012 12:32:38 +1030 From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/3] drm/gem: drop maplist from gem objects. Date: Wed, 19 Dec 2012 11:56:19 +1000 Message-Id: <1355882180-27659-3-git-send-email-airlied@gmail.com> X-Mailer: git-send-email 1.8.0.2 In-Reply-To: <1355882180-27659-1-git-send-email-airlied@gmail.com> References: <1355882180-27659-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 We currently don't need map_lists to store this information, with the new encapsulation, just move the vma_offset object into the gem object. In the future I'd guess we need per-filp vma offsets so this might make it a bit cleaner to start from. Signed-off-by: Dave Airlie --- drivers/gpu/drm/drm_gem.c | 44 ++++----------------------------- drivers/gpu/drm/drm_gem_cma_helper.c | 4 +-- drivers/gpu/drm/exynos/exynos_drm_gem.c | 6 ++--- drivers/gpu/drm/gma500/gem.c | 6 ++--- drivers/gpu/drm/i915/i915_gem.c | 8 +++--- drivers/gpu/drm/udl/udl_gem.c | 6 ++--- include/drm/drmP.h | 3 +-- 7 files changed, 21 insertions(+), 56 deletions(-) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 551352f..bb5ac23 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -304,11 +304,8 @@ drm_gem_free_mmap_offset(struct drm_gem_object *obj) { struct drm_device *dev = obj->dev; struct drm_gem_mm *mm = dev->mm_private; - struct drm_map_list *list = &obj->map_list; - drm_vma_offset_destroy(&mm->vma_manager, &list->vma_offset); - kfree(list->map); - list->map = NULL; + drm_vma_offset_destroy(&mm->vma_manager, &obj->vma_offset); } EXPORT_SYMBOL(drm_gem_free_mmap_offset); @@ -328,32 +325,10 @@ drm_gem_create_mmap_offset(struct drm_gem_object *obj) { struct drm_device *dev = obj->dev; struct drm_gem_mm *mm = dev->mm_private; - struct drm_map_list *list; - struct drm_local_map *map; int ret; - /* Set the object up for mmap'ing */ - list = &obj->map_list; - list->map = kzalloc(sizeof(struct drm_map_list), GFP_KERNEL); - if (!list->map) - return -ENOMEM; - - map = list->map; - map->type = _DRM_GEM; - map->size = obj->size; - map->handle = obj; - - ret = drm_vma_offset_setup(&mm->vma_manager, &list->vma_offset, + ret = drm_vma_offset_setup(&mm->vma_manager, &obj->vma_offset, obj->size / PAGE_SIZE); - if (ret) - goto out_free_list; - - return 0; - -out_free_list: - kfree(list->map); - list->map = NULL; - return ret; } EXPORT_SYMBOL(drm_gem_create_mmap_offset); @@ -642,10 +617,8 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) struct drm_file *priv = filp->private_data; struct drm_device *dev = priv->minor->dev; struct drm_gem_mm *mm = dev->mm_private; - struct drm_local_map *map = NULL; struct drm_gem_object *obj; struct drm_vma_offset_node *offset_node; - struct drm_map_list *list; int ret = 0; if (drm_device_is_unplugged(dev)) @@ -660,21 +633,14 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) return drm_mmap(filp, vma); } - list = container_of(offset_node, struct drm_map_list, vma_offset); - map = list->map; - if (!map || - ((map->flags & _DRM_RESTRICTED) && !capable(CAP_SYS_ADMIN))) { - ret = -EPERM; - goto out_unlock; - } + obj = container_of(offset_node, struct drm_gem_object, vma_offset); /* Check for valid size. */ - if (map->size < vma->vm_end - vma->vm_start) { + if (obj->size < vma->vm_end - vma->vm_start) { ret = -EINVAL; goto out_unlock; } - obj = map->handle; if (!obj->dev->driver->gem_vm_ops) { ret = -EINVAL; goto out_unlock; @@ -682,7 +648,7 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP; vma->vm_ops = obj->dev->driver->gem_vm_ops; - vma->vm_private_data = map->handle; + vma->vm_private_data = (void *)obj; vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags)); /* Take a ref for this mapping of the object, so that the fault diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c index 43b485f..a567a6e 100644 --- a/drivers/gpu/drm/drm_gem_cma_helper.c +++ b/drivers/gpu/drm/drm_gem_cma_helper.c @@ -29,7 +29,7 @@ static unsigned int get_gem_mmap_offset(struct drm_gem_object *obj) { - return (unsigned int)drm_vma_node_offset_addr(&obj->map_list.vma_offset); + return (unsigned int)drm_vma_node_offset_addr(&obj->vma_offset); } static void drm_gem_cma_buf_destroy(struct drm_device *drm, @@ -140,7 +140,7 @@ void drm_gem_cma_free_object(struct drm_gem_object *gem_obj) { struct drm_gem_cma_object *cma_obj; - if (drm_vma_node_is_allocated(&obj->map_list.vma_offset)) + if (drm_vma_node_is_allocated(&obj->vma_offset)) drm_gem_free_mmap_offset(gem_obj); drm_gem_object_release(gem_obj); diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c index 5389bfb..8e64997 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c @@ -168,7 +168,7 @@ out: exynos_drm_fini_buf(obj->dev, buf); exynos_gem_obj->buffer = NULL; - if (drm_vma_node_is_allocated(&obj->map_list.vma_offset)) + if (drm_vma_node_is_allocated(&obj->vma_offset)) drm_gem_free_mmap_offset(obj); /* release file pointer to gem object. */ @@ -704,13 +704,13 @@ int exynos_drm_gem_dumb_map_offset(struct drm_file *file_priv, goto unlock; } - if (!drm_vma_node_is_allocated(&obj->map_list.vma_offset)) { + if (!drm_vma_node_is_allocated(&obj->vma_offset)) { ret = drm_gem_create_mmap_offset(obj); if (ret) goto out; } - *offset = drm_vma_node_offset_addr(&obj->map_list.vma_offset); + *offset = drm_vma_node_offset_addr(&obj->vma_offset); DRM_DEBUG_KMS("offset = 0x%lx\n", (unsigned long)*offset); out: diff --git a/drivers/gpu/drm/gma500/gem.c b/drivers/gpu/drm/gma500/gem.c index 1c49fbc..c60252c 100644 --- a/drivers/gpu/drm/gma500/gem.c +++ b/drivers/gpu/drm/gma500/gem.c @@ -38,7 +38,7 @@ void psb_gem_free_object(struct drm_gem_object *obj) struct gtt_range *gtt = container_of(obj, struct gtt_range, gem); /* Remove the list map if one is present */ - if (drm_vma_node_is_allocated(&obj->map_list.vma_offset)) + if (drm_vma_node_is_allocated(&obj->vma_offset)) drm_gem_free_mmap_offset(obj); drm_gem_object_release(obj); @@ -81,13 +81,13 @@ int psb_gem_dumb_map_gtt(struct drm_file *file, struct drm_device *dev, /* What validation is needed here ? */ /* Make it mmapable */ - if (!drm_vma_node_is_allocated(&obj->map_list.vma_offset)) { + if (!drm_vma_node_is_allocated(&obj->vma_offset)) { ret = drm_gem_create_mmap_offset(obj); if (ret) goto out; } /* GEM should really work out the hash offsets for us */ - *offset = drm_vma_node_offset_addr(&obj->map_list.vma_offset); + *offset = drm_vma_node_offset_addr(&obj->vma_offset); out: drm_gem_object_unreference(obj); unlock: diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 75138cb..16f1b2c 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -1426,7 +1426,7 @@ i915_gem_release_mmap(struct drm_i915_gem_object *obj) if (obj->base.dev->dev_mapping) unmap_mapping_range(obj->base.dev->dev_mapping, - (loff_t)drm_vma_node_offset_addr(&obj->base.map_list.vma_offset), + (loff_t)drm_vma_node_offset_addr(&obj->base.vma_offset), obj->base.size, 1); obj->fault_mappable = false; @@ -1514,7 +1514,7 @@ static int i915_gem_object_create_mmap_offset(struct drm_i915_gem_object *obj) struct drm_i915_private *dev_priv = obj->base.dev->dev_private; int ret; - if (drm_vma_node_is_allocated(&obj->base.map_list.vma_offset)) + if (drm_vma_node_is_allocated(&obj->base.vma_offset)) return 0; ret = drm_gem_create_mmap_offset(&obj->base); @@ -1539,7 +1539,7 @@ static int i915_gem_object_create_mmap_offset(struct drm_i915_gem_object *obj) static void i915_gem_object_free_mmap_offset(struct drm_i915_gem_object *obj) { - if (!drm_vma_node_is_allocated(&obj->base.map_list.vma_offset)) + if (!drm_vma_node_is_allocated(&obj->base.vma_offset)) return; drm_gem_free_mmap_offset(&obj->base); @@ -1580,7 +1580,7 @@ i915_gem_mmap_gtt(struct drm_file *file, if (ret) goto out; - *offset = drm_vma_node_offset_addr(&obj->base.map_list.vma_offset); + *offset = drm_vma_node_offset_addr(&obj->base.vma_offset); out: drm_gem_object_unreference(&obj->base); diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c index 2cc79d2..7b5fb1f 100644 --- a/drivers/gpu/drm/udl/udl_gem.c +++ b/drivers/gpu/drm/udl/udl_gem.c @@ -223,7 +223,7 @@ void udl_gem_free_object(struct drm_gem_object *gem_obj) if (obj->pages) udl_gem_put_pages(obj); - if (drm_vma_node_is_allocated(&gem_obj->map_list.vma_offset)) + if (drm_vma_node_is_allocated(&gem_obj->vma_offset)) drm_gem_free_mmap_offset(gem_obj); } @@ -247,13 +247,13 @@ int udl_gem_mmap(struct drm_file *file, struct drm_device *dev, ret = udl_gem_get_pages(gobj, GFP_KERNEL); if (ret) goto out; - if (!drm_vma_node_is_allocated(&gobj->base.map_list.vma_offset)) { + if (!drm_vma_node_is_allocated(&gobj->base.vma_offset)) { ret = drm_gem_create_mmap_offset(obj); if (ret) goto out; } - *offset = drm_vma_node_offset_addr(&obj->map_list.vma_offset); + *offset = drm_vma_node_offset_addr(&obj->vma_offset); out: drm_gem_object_unreference(&gobj->base); diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 963e00e..f7186e8 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -580,7 +580,6 @@ struct drm_map_list { struct drm_local_map *map; /**< mapping */ uint64_t user_token; struct drm_master *master; - struct drm_vma_offset_node vma_offset; }; /** @@ -636,7 +635,7 @@ struct drm_gem_object { struct file *filp; /* Mapping info for this object */ - struct drm_map_list map_list; + struct drm_vma_offset_node vma_offset; /** * Size of the object, in bytes. Immutable over the object's