aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2011-02-18 11:59:17 -0500
committerDave Airlie <airlied@redhat.com>2011-02-22 19:34:47 -0500
commit7e4d15d90afe46d34b510f3c70217d3469a7dd70 (patch)
tree8ad4fd3c7e93d1518a879bb72afd8859b27ef51c /drivers/gpu/drm/radeon
parent441921d5309cfe098747d9840fd71bdc6ca2a93b (diff)
drm/radeon: introduce gem_to_radeon_bo helper
... and switch it to container_of upcasting. v2: converted new pageflip code-paths. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/radeon')
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c8
-rw-r--r--drivers/gpu/drm/radeon/radeon.h1
-rw-r--r--drivers/gpu/drm/radeon/radeon_cs.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_display.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_fb.c10
-rw-r--r--drivers/gpu/drm/radeon/radeon_gem.c21
-rw-r--r--drivers/gpu/drm/radeon/radeon_legacy_crtc.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_object.c3
9 files changed, 27 insertions, 28 deletions
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index b1537000a104..d56f08d3cbdc 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -1030,7 +1030,7 @@ static int evergreen_crtc_do_set_base(struct drm_crtc *crtc,
1030 * just update base pointers 1030 * just update base pointers
1031 */ 1031 */
1032 obj = radeon_fb->obj; 1032 obj = radeon_fb->obj;
1033 rbo = obj->driver_private; 1033 rbo = gem_to_radeon_bo(obj);
1034 r = radeon_bo_reserve(rbo, false); 1034 r = radeon_bo_reserve(rbo, false);
1035 if (unlikely(r != 0)) 1035 if (unlikely(r != 0))
1036 return r; 1036 return r;
@@ -1145,7 +1145,7 @@ static int evergreen_crtc_do_set_base(struct drm_crtc *crtc,
1145 1145
1146 if (!atomic && fb && fb != crtc->fb) { 1146 if (!atomic && fb && fb != crtc->fb) {
1147 radeon_fb = to_radeon_framebuffer(fb); 1147 radeon_fb = to_radeon_framebuffer(fb);
1148 rbo = radeon_fb->obj->driver_private; 1148 rbo = gem_to_radeon_bo(radeon_fb->obj);
1149 r = radeon_bo_reserve(rbo, false); 1149 r = radeon_bo_reserve(rbo, false);
1150 if (unlikely(r != 0)) 1150 if (unlikely(r != 0))
1151 return r; 1151 return r;
@@ -1191,7 +1191,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
1191 } 1191 }
1192 1192
1193 obj = radeon_fb->obj; 1193 obj = radeon_fb->obj;
1194 rbo = obj->driver_private; 1194 rbo = gem_to_radeon_bo(obj);
1195 r = radeon_bo_reserve(rbo, false); 1195 r = radeon_bo_reserve(rbo, false);
1196 if (unlikely(r != 0)) 1196 if (unlikely(r != 0))
1197 return r; 1197 return r;
@@ -1308,7 +1308,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
1308 1308
1309 if (!atomic && fb && fb != crtc->fb) { 1309 if (!atomic && fb && fb != crtc->fb) {
1310 radeon_fb = to_radeon_framebuffer(fb); 1310 radeon_fb = to_radeon_framebuffer(fb);
1311 rbo = radeon_fb->obj->driver_private; 1311 rbo = gem_to_radeon_bo(radeon_fb->obj);
1312 r = radeon_bo_reserve(rbo, false); 1312 r = radeon_bo_reserve(rbo, false);
1313 if (unlikely(r != 0)) 1313 if (unlikely(r != 0))
1314 return r; 1314 return r;
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index f4d194649012..f29229c51d73 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -261,6 +261,7 @@ struct radeon_bo {
261 struct drm_gem_object *gobj; 261 struct drm_gem_object *gobj;
262 struct drm_gem_object gem_base; 262 struct drm_gem_object gem_base;
263}; 263};
264#define gem_to_radeon_bo(gobj) container_of((gobj), struct radeon_bo, gem_base)
264 265
265struct radeon_bo_list { 266struct radeon_bo_list {
266 struct ttm_validate_buffer tv; 267 struct ttm_validate_buffer tv;
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index 35b5eb8fbe2a..8c1916941871 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -75,7 +75,7 @@ int radeon_cs_parser_relocs(struct radeon_cs_parser *p)
75 return -ENOENT; 75 return -ENOENT;
76 } 76 }
77 p->relocs_ptr[i] = &p->relocs[i]; 77 p->relocs_ptr[i] = &p->relocs[i];
78 p->relocs[i].robj = p->relocs[i].gobj->driver_private; 78 p->relocs[i].robj = gem_to_radeon_bo(p->relocs[i].gobj);
79 p->relocs[i].lobj.bo = p->relocs[i].robj; 79 p->relocs[i].lobj.bo = p->relocs[i].robj;
80 p->relocs[i].lobj.wdomain = r->write_domain; 80 p->relocs[i].lobj.wdomain = r->write_domain;
81 p->relocs[i].lobj.rdomain = r->read_domains; 81 p->relocs[i].lobj.rdomain = r->read_domains;
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 13945bd10461..7c0a3f26ab5e 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -860,7 +860,7 @@ int radeon_suspend_kms(struct drm_device *dev, pm_message_t state)
860 if (rfb == NULL || rfb->obj == NULL) { 860 if (rfb == NULL || rfb->obj == NULL) {
861 continue; 861 continue;
862 } 862 }
863 robj = rfb->obj->driver_private; 863 robj = gem_to_radeon_bo(rfb->obj);
864 /* don't unpin kernel fb objects */ 864 /* don't unpin kernel fb objects */
865 if (!radeon_fbdev_robj_is_fb(rdev, robj)) { 865 if (!radeon_fbdev_robj_is_fb(rdev, robj)) {
866 r = radeon_bo_reserve(robj, false); 866 r = radeon_bo_reserve(robj, false);
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 2eff98cfd728..4409975a363c 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -371,7 +371,7 @@ static int radeon_crtc_page_flip(struct drm_crtc *crtc,
371 new_radeon_fb = to_radeon_framebuffer(fb); 371 new_radeon_fb = to_radeon_framebuffer(fb);
372 /* schedule unpin of the old buffer */ 372 /* schedule unpin of the old buffer */
373 obj = old_radeon_fb->obj; 373 obj = old_radeon_fb->obj;
374 rbo = obj->driver_private; 374 rbo = gem_to_radeon_bo(obj);
375 work->old_rbo = rbo; 375 work->old_rbo = rbo;
376 INIT_WORK(&work->work, radeon_unpin_work_func); 376 INIT_WORK(&work->work, radeon_unpin_work_func);
377 377
@@ -391,7 +391,7 @@ static int radeon_crtc_page_flip(struct drm_crtc *crtc,
391 391
392 /* pin the new buffer */ 392 /* pin the new buffer */
393 obj = new_radeon_fb->obj; 393 obj = new_radeon_fb->obj;
394 rbo = obj->driver_private; 394 rbo = gem_to_radeon_bo(obj);
395 395
396 DRM_DEBUG_DRIVER("flip-ioctl() cur_fbo = %p, cur_bbo = %p\n", 396 DRM_DEBUG_DRIVER("flip-ioctl() cur_fbo = %p, cur_bbo = %p\n",
397 work->old_rbo, rbo); 397 work->old_rbo, rbo);
diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c
index cb968f997ce7..28431e78ab56 100644
--- a/drivers/gpu/drm/radeon/radeon_fb.c
+++ b/drivers/gpu/drm/radeon/radeon_fb.c
@@ -90,7 +90,7 @@ int radeon_align_pitch(struct radeon_device *rdev, int width, int bpp, bool tile
90 90
91static void radeonfb_destroy_pinned_object(struct drm_gem_object *gobj) 91static void radeonfb_destroy_pinned_object(struct drm_gem_object *gobj)
92{ 92{
93 struct radeon_bo *rbo = gobj->driver_private; 93 struct radeon_bo *rbo = gem_to_radeon_bo(gobj);
94 int ret; 94 int ret;
95 95
96 ret = radeon_bo_reserve(rbo, false); 96 ret = radeon_bo_reserve(rbo, false);
@@ -128,7 +128,7 @@ static int radeonfb_create_pinned_object(struct radeon_fbdev *rfbdev,
128 aligned_size); 128 aligned_size);
129 return -ENOMEM; 129 return -ENOMEM;
130 } 130 }
131 rbo = gobj->driver_private; 131 rbo = gem_to_radeon_bo(gobj);
132 132
133 if (fb_tiled) 133 if (fb_tiled)
134 tiling_flags = RADEON_TILING_MACRO; 134 tiling_flags = RADEON_TILING_MACRO;
@@ -202,7 +202,7 @@ static int radeonfb_create(struct radeon_fbdev *rfbdev,
202 mode_cmd.depth = sizes->surface_depth; 202 mode_cmd.depth = sizes->surface_depth;
203 203
204 ret = radeonfb_create_pinned_object(rfbdev, &mode_cmd, &gobj); 204 ret = radeonfb_create_pinned_object(rfbdev, &mode_cmd, &gobj);
205 rbo = gobj->driver_private; 205 rbo = gem_to_radeon_bo(gobj);
206 206
207 /* okay we have an object now allocate the framebuffer */ 207 /* okay we have an object now allocate the framebuffer */
208 info = framebuffer_alloc(0, device); 208 info = framebuffer_alloc(0, device);
@@ -403,14 +403,14 @@ int radeon_fbdev_total_size(struct radeon_device *rdev)
403 struct radeon_bo *robj; 403 struct radeon_bo *robj;
404 int size = 0; 404 int size = 0;
405 405
406 robj = rdev->mode_info.rfbdev->rfb.obj->driver_private; 406 robj = gem_to_radeon_bo(rdev->mode_info.rfbdev->rfb.obj);
407 size += radeon_bo_size(robj); 407 size += radeon_bo_size(robj);
408 return size; 408 return size;
409} 409}
410 410
411bool radeon_fbdev_robj_is_fb(struct radeon_device *rdev, struct radeon_bo *robj) 411bool radeon_fbdev_robj_is_fb(struct radeon_device *rdev, struct radeon_bo *robj)
412{ 412{
413 if (robj == rdev->mode_info.rfbdev->rfb.obj->driver_private) 413 if (robj == gem_to_radeon_bo(rdev->mode_info.rfbdev->rfb.obj))
414 return true; 414 return true;
415 return false; 415 return false;
416} 416}
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
index 69d00bf85b13..a419b67d8401 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -39,9 +39,8 @@ int radeon_gem_object_init(struct drm_gem_object *obj)
39 39
40void radeon_gem_object_free(struct drm_gem_object *gobj) 40void radeon_gem_object_free(struct drm_gem_object *gobj)
41{ 41{
42 struct radeon_bo *robj = gobj->driver_private; 42 struct radeon_bo *robj = gem_to_radeon_bo(gobj);
43 43
44 gobj->driver_private = NULL;
45 if (robj) { 44 if (robj) {
46 radeon_bo_unref(&robj); 45 radeon_bo_unref(&robj);
47 } 46 }
@@ -79,7 +78,7 @@ int radeon_gem_object_create(struct radeon_device *rdev, int size,
79int radeon_gem_object_pin(struct drm_gem_object *obj, uint32_t pin_domain, 78int radeon_gem_object_pin(struct drm_gem_object *obj, uint32_t pin_domain,
80 uint64_t *gpu_addr) 79 uint64_t *gpu_addr)
81{ 80{
82 struct radeon_bo *robj = obj->driver_private; 81 struct radeon_bo *robj = gem_to_radeon_bo(obj);
83 int r; 82 int r;
84 83
85 r = radeon_bo_reserve(robj, false); 84 r = radeon_bo_reserve(robj, false);
@@ -92,7 +91,7 @@ int radeon_gem_object_pin(struct drm_gem_object *obj, uint32_t pin_domain,
92 91
93void radeon_gem_object_unpin(struct drm_gem_object *obj) 92void radeon_gem_object_unpin(struct drm_gem_object *obj)
94{ 93{
95 struct radeon_bo *robj = obj->driver_private; 94 struct radeon_bo *robj = gem_to_radeon_bo(obj);
96 int r; 95 int r;
97 96
98 r = radeon_bo_reserve(robj, false); 97 r = radeon_bo_reserve(robj, false);
@@ -110,7 +109,7 @@ int radeon_gem_set_domain(struct drm_gem_object *gobj,
110 int r; 109 int r;
111 110
112 /* FIXME: reeimplement */ 111 /* FIXME: reeimplement */
113 robj = gobj->driver_private; 112 robj = gem_to_radeon_bo(gobj);
114 /* work out where to validate the buffer to */ 113 /* work out where to validate the buffer to */
115 domain = wdomain; 114 domain = wdomain;
116 if (!domain) { 115 if (!domain) {
@@ -224,7 +223,7 @@ int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data,
224 if (gobj == NULL) { 223 if (gobj == NULL) {
225 return -ENOENT; 224 return -ENOENT;
226 } 225 }
227 robj = gobj->driver_private; 226 robj = gem_to_radeon_bo(gobj);
228 227
229 r = radeon_gem_set_domain(gobj, args->read_domains, args->write_domain); 228 r = radeon_gem_set_domain(gobj, args->read_domains, args->write_domain);
230 229
@@ -243,7 +242,7 @@ int radeon_mode_dumb_mmap(struct drm_file *filp,
243 if (gobj == NULL) { 242 if (gobj == NULL) {
244 return -ENOENT; 243 return -ENOENT;
245 } 244 }
246 robj = gobj->driver_private; 245 robj = gem_to_radeon_bo(gobj);
247 *offset_p = radeon_bo_mmap_offset(robj); 246 *offset_p = radeon_bo_mmap_offset(robj);
248 drm_gem_object_unreference_unlocked(gobj); 247 drm_gem_object_unreference_unlocked(gobj);
249 return 0; 248 return 0;
@@ -270,7 +269,7 @@ int radeon_gem_busy_ioctl(struct drm_device *dev, void *data,
270 if (gobj == NULL) { 269 if (gobj == NULL) {
271 return -ENOENT; 270 return -ENOENT;
272 } 271 }
273 robj = gobj->driver_private; 272 robj = gem_to_radeon_bo(gobj);
274 r = radeon_bo_wait(robj, &cur_placement, true); 273 r = radeon_bo_wait(robj, &cur_placement, true);
275 switch (cur_placement) { 274 switch (cur_placement) {
276 case TTM_PL_VRAM: 275 case TTM_PL_VRAM:
@@ -300,7 +299,7 @@ int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data,
300 if (gobj == NULL) { 299 if (gobj == NULL) {
301 return -ENOENT; 300 return -ENOENT;
302 } 301 }
303 robj = gobj->driver_private; 302 robj = gem_to_radeon_bo(gobj);
304 r = radeon_bo_wait(robj, NULL, false); 303 r = radeon_bo_wait(robj, NULL, false);
305 /* callback hw specific functions if any */ 304 /* callback hw specific functions if any */
306 if (robj->rdev->asic->ioctl_wait_idle) 305 if (robj->rdev->asic->ioctl_wait_idle)
@@ -321,7 +320,7 @@ int radeon_gem_set_tiling_ioctl(struct drm_device *dev, void *data,
321 gobj = drm_gem_object_lookup(dev, filp, args->handle); 320 gobj = drm_gem_object_lookup(dev, filp, args->handle);
322 if (gobj == NULL) 321 if (gobj == NULL)
323 return -ENOENT; 322 return -ENOENT;
324 robj = gobj->driver_private; 323 robj = gem_to_radeon_bo(gobj);
325 r = radeon_bo_set_tiling_flags(robj, args->tiling_flags, args->pitch); 324 r = radeon_bo_set_tiling_flags(robj, args->tiling_flags, args->pitch);
326 drm_gem_object_unreference_unlocked(gobj); 325 drm_gem_object_unreference_unlocked(gobj);
327 return r; 326 return r;
@@ -339,7 +338,7 @@ int radeon_gem_get_tiling_ioctl(struct drm_device *dev, void *data,
339 gobj = drm_gem_object_lookup(dev, filp, args->handle); 338 gobj = drm_gem_object_lookup(dev, filp, args->handle);
340 if (gobj == NULL) 339 if (gobj == NULL)
341 return -ENOENT; 340 return -ENOENT;
342 rbo = gobj->driver_private; 341 rbo = gem_to_radeon_bo(gobj);
343 r = radeon_bo_reserve(rbo, false); 342 r = radeon_bo_reserve(rbo, false);
344 if (unlikely(r != 0)) 343 if (unlikely(r != 0))
345 goto out; 344 goto out;
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
index cf0638c3b7c7..9ae599eb2e6d 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
@@ -415,7 +415,7 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
415 415
416 /* Pin framebuffer & get tilling informations */ 416 /* Pin framebuffer & get tilling informations */
417 obj = radeon_fb->obj; 417 obj = radeon_fb->obj;
418 rbo = obj->driver_private; 418 rbo = gem_to_radeon_bo(obj);
419 r = radeon_bo_reserve(rbo, false); 419 r = radeon_bo_reserve(rbo, false);
420 if (unlikely(r != 0)) 420 if (unlikely(r != 0))
421 return r; 421 return r;
@@ -520,7 +520,7 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
520 520
521 if (!atomic && fb && fb != crtc->fb) { 521 if (!atomic && fb && fb != crtc->fb) {
522 radeon_fb = to_radeon_framebuffer(fb); 522 radeon_fb = to_radeon_framebuffer(fb);
523 rbo = radeon_fb->obj->driver_private; 523 rbo = gem_to_radeon_bo(radeon_fb->obj);
524 r = radeon_bo_reserve(rbo, false); 524 r = radeon_bo_reserve(rbo, false);
525 if (unlikely(r != 0)) 525 if (unlikely(r != 0))
526 return r; 526 return r;
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index 9324c881d640..2be18960409e 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -128,7 +128,7 @@ retry:
128 } 128 }
129 bo->rdev = rdev; 129 bo->rdev = rdev;
130 bo->gobj = &bo->gem_base; 130 bo->gobj = &bo->gem_base;
131 bo->gem_base.driver_private = bo; 131 bo->gem_base.driver_private = NULL;
132 bo->surface_reg = -1; 132 bo->surface_reg = -1;
133 INIT_LIST_HEAD(&bo->list); 133 INIT_LIST_HEAD(&bo->list);
134 radeon_ttm_placement_from_domain(bo, domain); 134 radeon_ttm_placement_from_domain(bo, domain);
@@ -282,7 +282,6 @@ void radeon_bo_force_delete(struct radeon_device *rdev)
282 list_del_init(&bo->list); 282 list_del_init(&bo->list);
283 mutex_unlock(&bo->rdev->gem.mutex); 283 mutex_unlock(&bo->rdev->gem.mutex);
284 radeon_bo_unref(&bo); 284 radeon_bo_unref(&bo);
285 gobj->driver_private = NULL;
286 drm_gem_object_unreference(gobj); 285 drm_gem_object_unreference(gobj);
287 mutex_unlock(&rdev->ddev->struct_mutex); 286 mutex_unlock(&rdev->ddev->struct_mutex);
288 } 287 }