aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_gem.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-08-11 10:41:06 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2012-08-23 20:04:38 -0400
commit0327d6ba998ca181013a5a1709701a6532a41972 (patch)
tree3f7a93685fbee161e7fb260b33d3d3db01be113b /drivers/gpu/drm/i915/i915_gem.c
parent4d6294bf77834276d41b51154a18663b0a8f2063 (diff)
drm/i915: Extract general object init routine
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>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem.c')
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c30
1 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 eb54a6d81517..553175856e81 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -3558,10 +3558,26 @@ unlock:
3558 return ret; 3558 return ret;
3559} 3559}
3560 3560
3561void i915_gem_object_init(struct drm_i915_gem_object *obj)
3562{
3563 obj->base.driver_private = NULL;
3564
3565 INIT_LIST_HEAD(&obj->mm_list);
3566 INIT_LIST_HEAD(&obj->gtt_list);
3567 INIT_LIST_HEAD(&obj->ring_list);
3568 INIT_LIST_HEAD(&obj->exec_list);
3569
3570 obj->fence_reg = I915_FENCE_REG_NONE;
3571 obj->madv = I915_MADV_WILLNEED;
3572 /* Avoid an unnecessary call to unbind on the first bind. */
3573 obj->map_and_fenceable = true;
3574
3575 i915_gem_info_add_obj(obj->base.dev->dev_private, obj->base.size);
3576}
3577
3561struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev, 3578struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,
3562 size_t size) 3579 size_t size)
3563{ 3580{
3564 struct drm_i915_private *dev_priv = dev->dev_private;
3565 struct drm_i915_gem_object *obj; 3581 struct drm_i915_gem_object *obj;
3566 struct address_space *mapping; 3582 struct address_space *mapping;
3567 u32 mask; 3583 u32 mask;
@@ -3585,7 +3601,7 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,
3585 mapping = obj->base.filp->f_path.dentry->d_inode->i_mapping; 3601 mapping = obj->base.filp->f_path.dentry->d_inode->i_mapping;
3586 mapping_set_gfp_mask(mapping, mask); 3602 mapping_set_gfp_mask(mapping, mask);
3587 3603
3588 i915_gem_info_add_obj(dev_priv, size); 3604 i915_gem_object_init(obj);
3589 3605
3590 obj->base.write_domain = I915_GEM_DOMAIN_CPU; 3606 obj->base.write_domain = I915_GEM_DOMAIN_CPU;
3591 obj->base.read_domains = I915_GEM_DOMAIN_CPU; 3607 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,
3607 } else 3623 } else
3608 obj->cache_level = I915_CACHE_NONE; 3624 obj->cache_level = I915_CACHE_NONE;
3609 3625
3610 obj->base.driver_private = NULL;
3611 obj->fence_reg = I915_FENCE_REG_NONE;
3612 INIT_LIST_HEAD(&obj->mm_list);
3613 INIT_LIST_HEAD(&obj->gtt_list);
3614 INIT_LIST_HEAD(&obj->ring_list);
3615 INIT_LIST_HEAD(&obj->exec_list);
3616 obj->madv = I915_MADV_WILLNEED;
3617 /* Avoid an unnecessary call to unbind on the first bind. */
3618 obj->map_and_fenceable = true;
3619
3620 return obj; 3626 return obj;
3621} 3627}
3622 3628