diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2010-04-09 15:05:07 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2010-04-19 23:22:45 -0400 |
commit | c397b9084cabdcaae26266bd0bd32ba62e757046 (patch) | |
tree | 0031339b913e25a485884d67c1e33c8a3cef8281 /drivers | |
parent | ac52bc56de25535a907ef07f8755f1387b89b0f5 (diff) |
drm/i915: embed the gem object into drm_i915_gem_object
Just embed it and adjust the pointers, No other changes (that's
for later patches).
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem.c | 58 |
2 files changed, 30 insertions, 29 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 6b931b8750aa..d1b7dec9add2 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -647,6 +647,7 @@ typedef struct drm_i915_private { | |||
647 | 647 | ||
648 | /** driver private structure attached to each drm_gem_object */ | 648 | /** driver private structure attached to each drm_gem_object */ |
649 | struct drm_i915_gem_object { | 649 | struct drm_i915_gem_object { |
650 | struct drm_gem_object base; | ||
650 | struct drm_gem_object *obj; | 651 | struct drm_gem_object *obj; |
651 | 652 | ||
652 | /** Current space allocated to this object in the GTT, if any. */ | 653 | /** Current space allocated to this object in the GTT, if any. */ |
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 92dd52216825..23c67e084de7 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
@@ -4424,37 +4424,38 @@ i915_gem_madvise_ioctl(struct drm_device *dev, void *data, | |||
4424 | struct drm_gem_object * i915_gem_alloc_object(struct drm_device *dev, | 4424 | struct drm_gem_object * i915_gem_alloc_object(struct drm_device *dev, |
4425 | size_t size) | 4425 | size_t size) |
4426 | { | 4426 | { |
4427 | return drm_gem_object_alloc(dev, size); | 4427 | struct drm_i915_gem_object *obj; |
4428 | } | ||
4429 | 4428 | ||
4430 | int i915_gem_init_object(struct drm_gem_object *obj) | 4429 | obj = kzalloc(sizeof(*obj), GFP_KERNEL); |
4431 | { | 4430 | if (obj == NULL) |
4432 | struct drm_i915_gem_object *obj_priv; | 4431 | return NULL; |
4433 | 4432 | ||
4434 | obj_priv = kzalloc(sizeof(*obj_priv), GFP_KERNEL); | 4433 | if (drm_gem_object_init(dev, &obj->base, size) != 0) { |
4435 | if (obj_priv == NULL) | 4434 | kfree(obj); |
4436 | return -ENOMEM; | 4435 | return NULL; |
4436 | } | ||
4437 | 4437 | ||
4438 | /* | 4438 | obj->base.write_domain = I915_GEM_DOMAIN_CPU; |
4439 | * We've just allocated pages from the kernel, | 4439 | obj->base.read_domains = I915_GEM_DOMAIN_CPU; |
4440 | * so they've just been written by the CPU with | ||
4441 | * zeros. They'll need to be clflushed before we | ||
4442 | * use them with the GPU. | ||
4443 | */ | ||
4444 | obj->write_domain = I915_GEM_DOMAIN_CPU; | ||
4445 | obj->read_domains = I915_GEM_DOMAIN_CPU; | ||
4446 | 4440 | ||
4447 | obj_priv->agp_type = AGP_USER_MEMORY; | 4441 | obj->agp_type = AGP_USER_MEMORY; |
4448 | 4442 | ||
4449 | obj->driver_private = obj_priv; | 4443 | obj->base.driver_private = obj; |
4450 | obj_priv->obj = obj; | 4444 | obj->obj = &obj->base; |
4451 | obj_priv->fence_reg = I915_FENCE_REG_NONE; | 4445 | obj->fence_reg = I915_FENCE_REG_NONE; |
4452 | INIT_LIST_HEAD(&obj_priv->list); | 4446 | INIT_LIST_HEAD(&obj->list); |
4453 | INIT_LIST_HEAD(&obj_priv->gpu_write_list); | 4447 | INIT_LIST_HEAD(&obj->gpu_write_list); |
4454 | INIT_LIST_HEAD(&obj_priv->fence_list); | 4448 | INIT_LIST_HEAD(&obj->fence_list); |
4455 | obj_priv->madv = I915_MADV_WILLNEED; | 4449 | obj->madv = I915_MADV_WILLNEED; |
4456 | 4450 | ||
4457 | trace_i915_gem_object_create(obj); | 4451 | trace_i915_gem_object_create(&obj->base); |
4452 | |||
4453 | return &obj->base; | ||
4454 | } | ||
4455 | |||
4456 | int i915_gem_init_object(struct drm_gem_object *obj) | ||
4457 | { | ||
4458 | BUG(); | ||
4458 | 4459 | ||
4459 | return 0; | 4460 | return 0; |
4460 | } | 4461 | } |
@@ -4477,12 +4478,11 @@ void i915_gem_free_object(struct drm_gem_object *obj) | |||
4477 | if (obj_priv->mmap_offset) | 4478 | if (obj_priv->mmap_offset) |
4478 | i915_gem_free_mmap_offset(obj); | 4479 | i915_gem_free_mmap_offset(obj); |
4479 | 4480 | ||
4481 | drm_gem_object_release(obj); | ||
4482 | |||
4480 | kfree(obj_priv->page_cpu_valid); | 4483 | kfree(obj_priv->page_cpu_valid); |
4481 | kfree(obj_priv->bit_17); | 4484 | kfree(obj_priv->bit_17); |
4482 | kfree(obj->driver_private); | 4485 | kfree(obj_priv); |
4483 | |||
4484 | drm_gem_object_release(obj); | ||
4485 | kfree(obj); | ||
4486 | } | 4486 | } |
4487 | 4487 | ||
4488 | /** Unbinds all inactive objects. */ | 4488 | /** Unbinds all inactive objects. */ |