aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/omapdrm/omap_gem.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-07-24 15:07:52 -0400
committerDave Airlie <airlied@gmail.com>2013-07-25 06:47:06 -0400
commit0de23977cfeb5b357ec884ba15417ae118ff9e9b (patch)
treebad8f04fc993b778020f6a2f7e9e7d2be8deb293 /drivers/gpu/drm/omapdrm/omap_gem.c
parentfe3078fa5c367186c94a6652581ffbe9ccea4640 (diff)
drm/gem: convert to new unified vma manager
Use the new vma manager instead of the old hashtable. Also convert all drivers to use the new convenience helpers. This drops all the (map_list.hash.key << PAGE_SHIFT) non-sense. Locking and access-management is exactly the same as before with an additional lock inside of the vma-manager, which strictly wouldn't be needed for gem. v2: - rebase on drm-next - init nodes via drm_vma_node_reset() in drm_gem.c v3: - fix tegra v4: - remove duplicate if (drm_vma_node_has_offset()) checks - inline now trivial drm_vma_node_offset_addr() calls v5: - skip node-reset on gem-init due to kzalloc() - do not allow mapping gem-objects with offsets (backwards compat) - remove unneccessary casts Cc: Inki Dae <inki.dae@samsung.com> Cc: Rob Clark <robdclark@gmail.com> Cc: Dave Airlie <airlied@redhat.com> Cc: Thierry Reding <thierry.reding@gmail.com> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Acked-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@gmail.com>
Diffstat (limited to 'drivers/gpu/drm/omapdrm/omap_gem.c')
-rw-r--r--drivers/gpu/drm/omapdrm/omap_gem.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index cbcd71e6ed83..f90531fc00c9 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -20,6 +20,7 @@
20 20
21#include <linux/spinlock.h> 21#include <linux/spinlock.h>
22#include <linux/shmem_fs.h> 22#include <linux/shmem_fs.h>
23#include <drm/drm_vma_manager.h>
23 24
24#include "omap_drv.h" 25#include "omap_drv.h"
25#include "omap_dmm_tiler.h" 26#include "omap_dmm_tiler.h"
@@ -308,21 +309,20 @@ uint32_t omap_gem_flags(struct drm_gem_object *obj)
308static uint64_t mmap_offset(struct drm_gem_object *obj) 309static uint64_t mmap_offset(struct drm_gem_object *obj)
309{ 310{
310 struct drm_device *dev = obj->dev; 311 struct drm_device *dev = obj->dev;
312 int ret;
313 size_t size;
311 314
312 WARN_ON(!mutex_is_locked(&dev->struct_mutex)); 315 WARN_ON(!mutex_is_locked(&dev->struct_mutex));
313 316
314 if (!obj->map_list.map) { 317 /* Make it mmapable */
315 /* Make it mmapable */ 318 size = omap_gem_mmap_size(obj);
316 size_t size = omap_gem_mmap_size(obj); 319 ret = _drm_gem_create_mmap_offset_size(obj, size);
317 int ret = _drm_gem_create_mmap_offset_size(obj, size); 320 if (ret) {
318 321 dev_err(dev->dev, "could not allocate mmap offset\n");
319 if (ret) { 322 return 0;
320 dev_err(dev->dev, "could not allocate mmap offset\n");
321 return 0;
322 }
323 } 323 }
324 324
325 return (uint64_t)obj->map_list.hash.key << PAGE_SHIFT; 325 return drm_vma_node_offset_addr(&obj->vma_node);
326} 326}
327 327
328uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj) 328uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj)
@@ -997,12 +997,11 @@ void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m)
997{ 997{
998 struct drm_device *dev = obj->dev; 998 struct drm_device *dev = obj->dev;
999 struct omap_gem_object *omap_obj = to_omap_bo(obj); 999 struct omap_gem_object *omap_obj = to_omap_bo(obj);
1000 uint64_t off = 0; 1000 uint64_t off;
1001 1001
1002 WARN_ON(!mutex_is_locked(&dev->struct_mutex)); 1002 WARN_ON(!mutex_is_locked(&dev->struct_mutex));
1003 1003
1004 if (obj->map_list.map) 1004 off = drm_vma_node_start(&obj->vma_node);
1005 off = (uint64_t)obj->map_list.hash.key;
1006 1005
1007 seq_printf(m, "%08x: %2d (%2d) %08llx %08Zx (%2d) %p %4d", 1006 seq_printf(m, "%08x: %2d (%2d) %08llx %08Zx (%2d) %p %4d",
1008 omap_obj->flags, obj->name, obj->refcount.refcount.counter, 1007 omap_obj->flags, obj->name, obj->refcount.refcount.counter,
@@ -1309,8 +1308,7 @@ void omap_gem_free_object(struct drm_gem_object *obj)
1309 1308
1310 list_del(&omap_obj->mm_list); 1309 list_del(&omap_obj->mm_list);
1311 1310
1312 if (obj->map_list.map) 1311 drm_gem_free_mmap_offset(obj);
1313 drm_gem_free_mmap_offset(obj);
1314 1312
1315 /* this means the object is still pinned.. which really should 1313 /* this means the object is still pinned.. which really should
1316 * not happen. I think.. 1314 * not happen. I think..