aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon/radeon_gem.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2011-02-18 11:59:16 -0500
committerDave Airlie <airlied@redhat.com>2011-02-22 19:33:03 -0500
commit441921d5309cfe098747d9840fd71bdc6ca2a93b (patch)
tree38abd54dd4869b9b2872c4d6993fdd8bf791ee9c /drivers/gpu/drm/radeon/radeon_gem.c
parentae0cec2880a4dc6d90c7f8392bdc6705988389ca (diff)
drm/radeon: embed struct drm_gem_object
Unconditionally initialize the drm gem object - it's not worth the trouble not to for the few kernel objects. This patch only changes the place of the drm gem object, access is still done via pointers. v2: Uncoditionally align the size in radeon_bo_create. At least the r600/evergreen blit code didn't to this, angering the paranoid gem code. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_gem.c')
-rw-r--r--drivers/gpu/drm/radeon/radeon_gem.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
index ede5dccdf79f..69d00bf85b13 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -32,7 +32,8 @@
32 32
33int radeon_gem_object_init(struct drm_gem_object *obj) 33int radeon_gem_object_init(struct drm_gem_object *obj)
34{ 34{
35 /* we do nothings here */ 35 BUG();
36
36 return 0; 37 return 0;
37} 38}
38 39
@@ -44,9 +45,6 @@ void radeon_gem_object_free(struct drm_gem_object *gobj)
44 if (robj) { 45 if (robj) {
45 radeon_bo_unref(&robj); 46 radeon_bo_unref(&robj);
46 } 47 }
47
48 drm_gem_object_release(gobj);
49 kfree(gobj);
50} 48}
51 49
52int radeon_gem_object_create(struct radeon_device *rdev, int size, 50int radeon_gem_object_create(struct radeon_device *rdev, int size,
@@ -54,29 +52,27 @@ int radeon_gem_object_create(struct radeon_device *rdev, int size,
54 bool discardable, bool kernel, 52 bool discardable, bool kernel,
55 struct drm_gem_object **obj) 53 struct drm_gem_object **obj)
56{ 54{
57 struct drm_gem_object *gobj;
58 struct radeon_bo *robj; 55 struct radeon_bo *robj;
59 int r; 56 int r;
60 57
61 *obj = NULL; 58 *obj = NULL;
62 gobj = drm_gem_object_alloc(rdev->ddev, size);
63 if (!gobj) {
64 return -ENOMEM;
65 }
66 /* At least align on page size */ 59 /* At least align on page size */
67 if (alignment < PAGE_SIZE) { 60 if (alignment < PAGE_SIZE) {
68 alignment = PAGE_SIZE; 61 alignment = PAGE_SIZE;
69 } 62 }
70 r = radeon_bo_create(rdev, gobj, size, alignment, kernel, initial_domain, &robj); 63 r = radeon_bo_create(rdev, size, alignment, kernel, initial_domain, &robj);
71 if (r) { 64 if (r) {
72 if (r != -ERESTARTSYS) 65 if (r != -ERESTARTSYS)
73 DRM_ERROR("Failed to allocate GEM object (%d, %d, %u, %d)\n", 66 DRM_ERROR("Failed to allocate GEM object (%d, %d, %u, %d)\n",
74 size, initial_domain, alignment, r); 67 size, initial_domain, alignment, r);
75 drm_gem_object_unreference_unlocked(gobj);
76 return r; 68 return r;
77 } 69 }
78 gobj->driver_private = robj; 70 *obj = &robj->gem_base;
79 *obj = gobj; 71
72 mutex_lock(&rdev->gem.mutex);
73 list_add_tail(&robj->list, &rdev->gem.objects);
74 mutex_unlock(&rdev->gem.mutex);
75
80 return 0; 76 return 0;
81} 77}
82 78