drm: store the gem vma offset manager in a typed pointer
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 11 Dec 2013 13:24:46 +0000 (14:24 +0100)
committerDave Airlie <airlied@redhat.com>
Tue, 14 Jan 2014 02:38:32 +0000 (12:38 +1000)
This was hidden in a generic void * dev->mm_private. But only ever
used for gem. But thanks to this fake generic pretension no one
noticed that Rob's drm drivers are now all broken.

So just give the offset manager a type pointer and fix up msm, omapdrm
and tilcdc.

v2: Fixup compile fail.

v3: Fixup rebase fail that David spotted.

Cc: David Herrmann <dh.herrmann@gmail.com>
Cc: Rob Clark <robdclark@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/drm_gem.c
drivers/gpu/drm/msm/msm_drv.c
drivers/gpu/drm/omapdrm/omap_debugfs.c
drivers/gpu/drm/tilcdc/tilcdc_drv.c
include/drm/drmP.h

index 3ff39bb0402dd39e29780dc516f185e1753715f7..bed5c3bfed762ee34227fb286e233e42371d770b 100644 (file)
 int
 drm_gem_init(struct drm_device *dev)
 {
-       struct drm_gem_mm *mm;
+       struct drm_vma_offset_manager *vma_offset_manager;
 
        mutex_init(&dev->object_name_lock);
        idr_init(&dev->object_name_idr);
 
-       mm = kzalloc(sizeof(struct drm_gem_mm), GFP_KERNEL);
-       if (!mm) {
+       vma_offset_manager = kzalloc(sizeof(*vma_offset_manager), GFP_KERNEL);
+       if (!vma_offset_manager) {
                DRM_ERROR("out of memory\n");
                return -ENOMEM;
        }
 
-       dev->mm_private = mm;
-       drm_vma_offset_manager_init(&mm->vma_manager,
+       dev->vma_offset_manager = vma_offset_manager;
+       drm_vma_offset_manager_init(vma_offset_manager,
                                    DRM_FILE_PAGE_OFFSET_START,
                                    DRM_FILE_PAGE_OFFSET_SIZE);
 
@@ -113,11 +113,10 @@ drm_gem_init(struct drm_device *dev)
 void
 drm_gem_destroy(struct drm_device *dev)
 {
-       struct drm_gem_mm *mm = dev->mm_private;
 
-       drm_vma_offset_manager_destroy(&mm->vma_manager);
-       kfree(mm);
-       dev->mm_private = NULL;
+       drm_vma_offset_manager_destroy(dev->vma_offset_manager);
+       kfree(dev->vma_offset_manager);
+       dev->vma_offset_manager = NULL;
 }
 
 /**
@@ -362,9 +361,8 @@ void
 drm_gem_free_mmap_offset(struct drm_gem_object *obj)
 {
        struct drm_device *dev = obj->dev;
-       struct drm_gem_mm *mm = dev->mm_private;
 
-       drm_vma_offset_remove(&mm->vma_manager, &obj->vma_node);
+       drm_vma_offset_remove(dev->vma_offset_manager, &obj->vma_node);
 }
 EXPORT_SYMBOL(drm_gem_free_mmap_offset);
 
@@ -386,9 +384,8 @@ int
 drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size)
 {
        struct drm_device *dev = obj->dev;
-       struct drm_gem_mm *mm = dev->mm_private;
 
-       return drm_vma_offset_add(&mm->vma_manager, &obj->vma_node,
+       return drm_vma_offset_add(dev->vma_offset_manager, &obj->vma_node,
                                  size / PAGE_SIZE);
 }
 EXPORT_SYMBOL(drm_gem_create_mmap_offset_size);
@@ -818,7 +815,6 @@ 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_gem_object *obj;
        struct drm_vma_offset_node *node;
        int ret = 0;
@@ -828,7 +824,8 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
 
        mutex_lock(&dev->struct_mutex);
 
-       node = drm_vma_offset_exact_lookup(&mm->vma_manager, vma->vm_pgoff,
+       node = drm_vma_offset_exact_lookup(dev->vma_offset_manager,
+                                          vma->vm_pgoff,
                                           vma_pages(vma));
        if (!node) {
                mutex_unlock(&dev->struct_mutex);
index 63ed79fe8a056d906b9456008e90d2f38cce8b53..e6adafc7eff3177b789395f6bc81f4ab62042e11 100644 (file)
@@ -461,7 +461,7 @@ static int msm_gem_show(struct drm_device *dev, struct seq_file *m)
 
 static int msm_mm_show(struct drm_device *dev, struct seq_file *m)
 {
-       return drm_mm_dump_table(m, dev->mm_private);
+       return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm);
 }
 
 static int msm_fb_show(struct drm_device *dev, struct seq_file *m)
index c27f59da7f2935f0fe3a1908b9a73c9a4c6b7529..d4c04d69fc4df62a62352db72cd035ae6e5e53d1 100644 (file)
@@ -48,7 +48,7 @@ static int mm_show(struct seq_file *m, void *arg)
 {
        struct drm_info_node *node = (struct drm_info_node *) m->private;
        struct drm_device *dev = node->minor->dev;
-       return drm_mm_dump_table(m, dev->mm_private);
+       return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm);
 }
 
 static int fb_show(struct seq_file *m, void *arg)
index 0c22b6ca7fd231aef01b0ac947641e36b40a8a96..171a8203892ce16b7767b2fb3fa11fc1995f0fad 100644 (file)
@@ -444,7 +444,7 @@ static int tilcdc_mm_show(struct seq_file *m, void *arg)
 {
        struct drm_info_node *node = (struct drm_info_node *) m->private;
        struct drm_device *dev = node->minor->dev;
-       return drm_mm_dump_table(m, dev->mm_private);
+       return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm);
 }
 
 static struct drm_info_list tilcdc_debugfs_list[] = {
index 2fe9b5d5d16244963da88739a71c139829deeb86..63eab2b72ee7acb10bd0a0baf7f3c3608dee5cf5 100644 (file)
@@ -621,13 +621,6 @@ struct drm_ati_pcigart_info {
        int table_size;
 };
 
-/**
- * GEM specific mm private for tracking GEM objects
- */
-struct drm_gem_mm {
-       struct drm_vma_offset_manager vma_manager;
-};
-
 /**
  * This structure defines the drm_mm memory object, which will be used by the
  * DRM for its buffer objects.
@@ -1185,7 +1178,6 @@ struct drm_device {
        struct drm_sg_mem *sg;  /**< Scatter gather memory */
        unsigned int num_crtcs;                  /**< Number of CRTCs on this device */
        void *dev_private;              /**< device private data */
-       void *mm_private;
        struct address_space *dev_mapping;
        struct drm_sigdata sigdata;        /**< For block_all_signals */
        sigset_t sigmask;
@@ -1203,6 +1195,7 @@ struct drm_device {
        /*@{ */
        struct mutex object_name_lock;
        struct idr object_name_idr;
+       struct drm_vma_offset_manager *vma_offset_manager;
        /*@} */
        int switch_power_state;