diff options
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_object.c')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_object.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c index 7d6b8e88f746..9324c881d640 100644 --- a/drivers/gpu/drm/radeon/radeon_object.c +++ b/drivers/gpu/drm/radeon/radeon_object.c | |||
@@ -55,6 +55,7 @@ static void radeon_ttm_bo_destroy(struct ttm_buffer_object *tbo) | |||
55 | list_del_init(&bo->list); | 55 | list_del_init(&bo->list); |
56 | mutex_unlock(&bo->rdev->gem.mutex); | 56 | mutex_unlock(&bo->rdev->gem.mutex); |
57 | radeon_bo_clear_surface_reg(bo); | 57 | radeon_bo_clear_surface_reg(bo); |
58 | drm_gem_object_release(&bo->gem_base); | ||
58 | kfree(bo); | 59 | kfree(bo); |
59 | } | 60 | } |
60 | 61 | ||
@@ -86,7 +87,7 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain) | |||
86 | rbo->placement.num_busy_placement = c; | 87 | rbo->placement.num_busy_placement = c; |
87 | } | 88 | } |
88 | 89 | ||
89 | int radeon_bo_create(struct radeon_device *rdev, struct drm_gem_object *gobj, | 90 | int radeon_bo_create(struct radeon_device *rdev, |
90 | unsigned long size, int byte_align, bool kernel, u32 domain, | 91 | unsigned long size, int byte_align, bool kernel, u32 domain, |
91 | struct radeon_bo **bo_ptr) | 92 | struct radeon_bo **bo_ptr) |
92 | { | 93 | { |
@@ -96,6 +97,8 @@ int radeon_bo_create(struct radeon_device *rdev, struct drm_gem_object *gobj, | |||
96 | unsigned long max_size = 0; | 97 | unsigned long max_size = 0; |
97 | int r; | 98 | int r; |
98 | 99 | ||
100 | size = ALIGN(size, PAGE_SIZE); | ||
101 | |||
99 | if (unlikely(rdev->mman.bdev.dev_mapping == NULL)) { | 102 | if (unlikely(rdev->mman.bdev.dev_mapping == NULL)) { |
100 | rdev->mman.bdev.dev_mapping = rdev->ddev->dev_mapping; | 103 | rdev->mman.bdev.dev_mapping = rdev->ddev->dev_mapping; |
101 | } | 104 | } |
@@ -118,8 +121,14 @@ retry: | |||
118 | bo = kzalloc(sizeof(struct radeon_bo), GFP_KERNEL); | 121 | bo = kzalloc(sizeof(struct radeon_bo), GFP_KERNEL); |
119 | if (bo == NULL) | 122 | if (bo == NULL) |
120 | return -ENOMEM; | 123 | return -ENOMEM; |
124 | r = drm_gem_object_init(rdev->ddev, &bo->gem_base, size); | ||
125 | if (unlikely(r)) { | ||
126 | kfree(bo); | ||
127 | return r; | ||
128 | } | ||
121 | bo->rdev = rdev; | 129 | bo->rdev = rdev; |
122 | bo->gobj = gobj; | 130 | bo->gobj = &bo->gem_base; |
131 | bo->gem_base.driver_private = bo; | ||
123 | bo->surface_reg = -1; | 132 | bo->surface_reg = -1; |
124 | INIT_LIST_HEAD(&bo->list); | 133 | INIT_LIST_HEAD(&bo->list); |
125 | radeon_ttm_placement_from_domain(bo, domain); | 134 | radeon_ttm_placement_from_domain(bo, domain); |
@@ -142,12 +151,9 @@ retry: | |||
142 | return r; | 151 | return r; |
143 | } | 152 | } |
144 | *bo_ptr = bo; | 153 | *bo_ptr = bo; |
145 | if (gobj) { | 154 | |
146 | mutex_lock(&bo->rdev->gem.mutex); | ||
147 | list_add_tail(&bo->list, &rdev->gem.objects); | ||
148 | mutex_unlock(&bo->rdev->gem.mutex); | ||
149 | } | ||
150 | trace_radeon_bo_create(bo); | 155 | trace_radeon_bo_create(bo); |
156 | |||
151 | return 0; | 157 | return 0; |
152 | } | 158 | } |
153 | 159 | ||