drm/i915: Extract general object init routine
authorChris Wilson <chris@chris-wilson.co.uk>
Sat, 11 Aug 2012 14:41:06 +0000 (15:41 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 24 Aug 2012 00:04:38 +0000 (02:04 +0200)
As we wish to create specialised object constructions in the near
future that share the same basic GEM object struct, export the default
initializer.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c

index 06a88be067f194b9503fa1ac73ef48ed3c9760a9..9f4c27eab0466c9a49d6c71078007980ed77f589 100644 (file)
@@ -1302,6 +1302,7 @@ int i915_gem_wait_ioctl(struct drm_device *dev, void *data,
                        struct drm_file *file_priv);
 void i915_gem_load(struct drm_device *dev);
 int i915_gem_init_object(struct drm_gem_object *obj);
+void i915_gem_object_init(struct drm_i915_gem_object *obj);
 struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,
                                                  size_t size);
 void i915_gem_free_object(struct drm_gem_object *obj);
index eb54a6d8151729c0982cf115b660dfa1d3c5129c..553175856e81f1fd00c1277f1b8dea6e0d8999e9 100644 (file)
@@ -3558,10 +3558,26 @@ unlock:
        return ret;
 }
 
+void i915_gem_object_init(struct drm_i915_gem_object *obj)
+{
+       obj->base.driver_private = NULL;
+
+       INIT_LIST_HEAD(&obj->mm_list);
+       INIT_LIST_HEAD(&obj->gtt_list);
+       INIT_LIST_HEAD(&obj->ring_list);
+       INIT_LIST_HEAD(&obj->exec_list);
+
+       obj->fence_reg = I915_FENCE_REG_NONE;
+       obj->madv = I915_MADV_WILLNEED;
+       /* Avoid an unnecessary call to unbind on the first bind. */
+       obj->map_and_fenceable = true;
+
+       i915_gem_info_add_obj(obj->base.dev->dev_private, obj->base.size);
+}
+
 struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,
                                                  size_t size)
 {
-       struct drm_i915_private *dev_priv = dev->dev_private;
        struct drm_i915_gem_object *obj;
        struct address_space *mapping;
        u32 mask;
@@ -3585,7 +3601,7 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,
        mapping = obj->base.filp->f_path.dentry->d_inode->i_mapping;
        mapping_set_gfp_mask(mapping, mask);
 
-       i915_gem_info_add_obj(dev_priv, size);
+       i915_gem_object_init(obj);
 
        obj->base.write_domain = I915_GEM_DOMAIN_CPU;
        obj->base.read_domains = I915_GEM_DOMAIN_CPU;
@@ -3607,16 +3623,6 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,
        } else
                obj->cache_level = I915_CACHE_NONE;
 
-       obj->base.driver_private = NULL;
-       obj->fence_reg = I915_FENCE_REG_NONE;
-       INIT_LIST_HEAD(&obj->mm_list);
-       INIT_LIST_HEAD(&obj->gtt_list);
-       INIT_LIST_HEAD(&obj->ring_list);
-       INIT_LIST_HEAD(&obj->exec_list);
-       obj->madv = I915_MADV_WILLNEED;
-       /* Avoid an unnecessary call to unbind on the first bind. */
-       obj->map_and_fenceable = true;
-
        return obj;
 }