2 * Copyright 2008 Advanced Micro Devices, Inc.
3 * Copyright 2008 Red Hat Inc.
4 * Copyright 2009 Jerome Glisse.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
24 * Authors: Dave Airlie
29 #include <drm/radeon_drm.h>
32 void radeon_gem_object_free(struct drm_gem_object
*gobj
)
34 struct radeon_bo
*robj
= gem_to_radeon_bo(gobj
);
37 if (robj
->gem_base
.import_attach
)
38 drm_prime_gem_destroy(&robj
->gem_base
, robj
->tbo
.sg
);
39 radeon_mn_unregister(robj
);
40 radeon_bo_unref(&robj
);
44 int radeon_gem_object_create(struct radeon_device
*rdev
, unsigned long size
,
45 int alignment
, int initial_domain
,
46 u32 flags
, bool kernel
,
47 struct drm_gem_object
**obj
)
49 struct radeon_bo
*robj
;
50 unsigned long max_size
;
54 /* At least align on page size */
55 if (alignment
< PAGE_SIZE
) {
56 alignment
= PAGE_SIZE
;
59 /* Maximum bo size is the unpinned gtt size since we use the gtt to
60 * handle vram to system pool migrations.
62 max_size
= rdev
->mc
.gtt_size
- rdev
->gart_pin_size
;
63 if (size
> max_size
) {
64 DRM_DEBUG("Allocation size %ldMb bigger than %ldMb limit\n",
65 size
>> 20, max_size
>> 20);
70 r
= radeon_bo_create(rdev
, size
, alignment
, kernel
, initial_domain
,
71 flags
, NULL
, NULL
, &robj
);
73 if (r
!= -ERESTARTSYS
) {
74 if (initial_domain
== RADEON_GEM_DOMAIN_VRAM
) {
75 initial_domain
|= RADEON_GEM_DOMAIN_GTT
;
78 DRM_ERROR("Failed to allocate GEM object (%ld, %d, %u, %d)\n",
79 size
, initial_domain
, alignment
, r
);
83 *obj
= &robj
->gem_base
;
84 robj
->pid
= task_pid_nr(current
);
86 mutex_lock(&rdev
->gem
.mutex
);
87 list_add_tail(&robj
->list
, &rdev
->gem
.objects
);
88 mutex_unlock(&rdev
->gem
.mutex
);
93 static int radeon_gem_set_domain(struct drm_gem_object
*gobj
,
94 uint32_t rdomain
, uint32_t wdomain
)
96 struct radeon_bo
*robj
;
100 /* FIXME: reeimplement */
101 robj
= gem_to_radeon_bo(gobj
);
102 /* work out where to validate the buffer to */
109 printk(KERN_WARNING
"Set domain without domain !\n");
112 if (domain
== RADEON_GEM_DOMAIN_CPU
) {
113 /* Asking for cpu access wait for object idle */
114 r
= reservation_object_wait_timeout_rcu(robj
->tbo
.resv
, true, true, 30 * HZ
);
118 if (r
< 0 && r
!= -EINTR
) {
119 printk(KERN_ERR
"Failed to wait for object: %li\n", r
);
126 int radeon_gem_init(struct radeon_device
*rdev
)
128 INIT_LIST_HEAD(&rdev
->gem
.objects
);
132 void radeon_gem_fini(struct radeon_device
*rdev
)
134 radeon_bo_force_delete(rdev
);
138 * Call from drm_gem_handle_create which appear in both new and open ioctl
141 int radeon_gem_object_open(struct drm_gem_object
*obj
, struct drm_file
*file_priv
)
143 struct radeon_bo
*rbo
= gem_to_radeon_bo(obj
);
144 struct radeon_device
*rdev
= rbo
->rdev
;
145 struct radeon_fpriv
*fpriv
= file_priv
->driver_priv
;
146 struct radeon_vm
*vm
= &fpriv
->vm
;
147 struct radeon_bo_va
*bo_va
;
150 if ((rdev
->family
< CHIP_CAYMAN
) ||
151 (!rdev
->accel_working
)) {
155 r
= radeon_bo_reserve(rbo
, false);
160 bo_va
= radeon_vm_bo_find(vm
, rbo
);
162 bo_va
= radeon_vm_bo_add(rdev
, vm
, rbo
);
166 radeon_bo_unreserve(rbo
);
171 void radeon_gem_object_close(struct drm_gem_object
*obj
,
172 struct drm_file
*file_priv
)
174 struct radeon_bo
*rbo
= gem_to_radeon_bo(obj
);
175 struct radeon_device
*rdev
= rbo
->rdev
;
176 struct radeon_fpriv
*fpriv
= file_priv
->driver_priv
;
177 struct radeon_vm
*vm
= &fpriv
->vm
;
178 struct radeon_bo_va
*bo_va
;
181 if ((rdev
->family
< CHIP_CAYMAN
) ||
182 (!rdev
->accel_working
)) {
186 r
= radeon_bo_reserve(rbo
, true);
188 dev_err(rdev
->dev
, "leaking bo va because "
189 "we fail to reserve bo (%d)\n", r
);
192 bo_va
= radeon_vm_bo_find(vm
, rbo
);
194 if (--bo_va
->ref_count
== 0) {
195 radeon_vm_bo_rmv(rdev
, bo_va
);
198 radeon_bo_unreserve(rbo
);
201 static int radeon_gem_handle_lockup(struct radeon_device
*rdev
, int r
)
204 r
= radeon_gpu_reset(rdev
);
214 int radeon_gem_info_ioctl(struct drm_device
*dev
, void *data
,
215 struct drm_file
*filp
)
217 struct radeon_device
*rdev
= dev
->dev_private
;
218 struct drm_radeon_gem_info
*args
= data
;
219 struct ttm_mem_type_manager
*man
;
221 man
= &rdev
->mman
.bdev
.man
[TTM_PL_VRAM
];
223 args
->vram_size
= rdev
->mc
.real_vram_size
;
224 args
->vram_visible
= (u64
)man
->size
<< PAGE_SHIFT
;
225 args
->vram_visible
-= rdev
->vram_pin_size
;
226 args
->gart_size
= rdev
->mc
.gtt_size
;
227 args
->gart_size
-= rdev
->gart_pin_size
;
232 int radeon_gem_pread_ioctl(struct drm_device
*dev
, void *data
,
233 struct drm_file
*filp
)
235 /* TODO: implement */
236 DRM_ERROR("unimplemented %s\n", __func__
);
240 int radeon_gem_pwrite_ioctl(struct drm_device
*dev
, void *data
,
241 struct drm_file
*filp
)
243 /* TODO: implement */
244 DRM_ERROR("unimplemented %s\n", __func__
);
248 int radeon_gem_create_ioctl(struct drm_device
*dev
, void *data
,
249 struct drm_file
*filp
)
251 struct radeon_device
*rdev
= dev
->dev_private
;
252 struct drm_radeon_gem_create
*args
= data
;
253 struct drm_gem_object
*gobj
;
257 down_read(&rdev
->exclusive_lock
);
258 /* create a gem object to contain this object in */
259 args
->size
= roundup(args
->size
, PAGE_SIZE
);
260 r
= radeon_gem_object_create(rdev
, args
->size
, args
->alignment
,
261 args
->initial_domain
, args
->flags
,
264 up_read(&rdev
->exclusive_lock
);
265 r
= radeon_gem_handle_lockup(rdev
, r
);
268 r
= drm_gem_handle_create(filp
, gobj
, &handle
);
269 /* drop reference from allocate - handle holds it now */
270 drm_gem_object_unreference_unlocked(gobj
);
272 up_read(&rdev
->exclusive_lock
);
273 r
= radeon_gem_handle_lockup(rdev
, r
);
276 args
->handle
= handle
;
277 up_read(&rdev
->exclusive_lock
);
281 int radeon_gem_userptr_ioctl(struct drm_device
*dev
, void *data
,
282 struct drm_file
*filp
)
284 struct radeon_device
*rdev
= dev
->dev_private
;
285 struct drm_radeon_gem_userptr
*args
= data
;
286 struct drm_gem_object
*gobj
;
287 struct radeon_bo
*bo
;
291 if (offset_in_page(args
->addr
| args
->size
))
294 /* reject unknown flag values */
295 if (args
->flags
& ~(RADEON_GEM_USERPTR_READONLY
|
296 RADEON_GEM_USERPTR_ANONONLY
| RADEON_GEM_USERPTR_VALIDATE
|
297 RADEON_GEM_USERPTR_REGISTER
))
300 if (args
->flags
& RADEON_GEM_USERPTR_READONLY
) {
301 /* readonly pages not tested on older hardware */
302 if (rdev
->family
< CHIP_R600
)
305 } else if (!(args
->flags
& RADEON_GEM_USERPTR_ANONONLY
) ||
306 !(args
->flags
& RADEON_GEM_USERPTR_REGISTER
)) {
308 /* if we want to write to it we must require anonymous
309 memory and install a MMU notifier */
313 down_read(&rdev
->exclusive_lock
);
315 /* create a gem object to contain this object in */
316 r
= radeon_gem_object_create(rdev
, args
->size
, 0,
317 RADEON_GEM_DOMAIN_CPU
, 0,
322 bo
= gem_to_radeon_bo(gobj
);
323 r
= radeon_ttm_tt_set_userptr(bo
->tbo
.ttm
, args
->addr
, args
->flags
);
327 if (args
->flags
& RADEON_GEM_USERPTR_REGISTER
) {
328 r
= radeon_mn_register(bo
, args
->addr
);
333 if (args
->flags
& RADEON_GEM_USERPTR_VALIDATE
) {
334 down_read(¤t
->mm
->mmap_sem
);
335 r
= radeon_bo_reserve(bo
, true);
337 up_read(¤t
->mm
->mmap_sem
);
341 radeon_ttm_placement_from_domain(bo
, RADEON_GEM_DOMAIN_GTT
);
342 r
= ttm_bo_validate(&bo
->tbo
, &bo
->placement
, true, false);
343 radeon_bo_unreserve(bo
);
344 up_read(¤t
->mm
->mmap_sem
);
349 r
= drm_gem_handle_create(filp
, gobj
, &handle
);
350 /* drop reference from allocate - handle holds it now */
351 drm_gem_object_unreference_unlocked(gobj
);
355 args
->handle
= handle
;
356 up_read(&rdev
->exclusive_lock
);
360 drm_gem_object_unreference_unlocked(gobj
);
363 up_read(&rdev
->exclusive_lock
);
364 r
= radeon_gem_handle_lockup(rdev
, r
);
369 int radeon_gem_set_domain_ioctl(struct drm_device
*dev
, void *data
,
370 struct drm_file
*filp
)
372 /* transition the BO to a domain -
373 * just validate the BO into a certain domain */
374 struct radeon_device
*rdev
= dev
->dev_private
;
375 struct drm_radeon_gem_set_domain
*args
= data
;
376 struct drm_gem_object
*gobj
;
377 struct radeon_bo
*robj
;
380 /* for now if someone requests domain CPU -
381 * just make sure the buffer is finished with */
382 down_read(&rdev
->exclusive_lock
);
384 /* just do a BO wait for now */
385 gobj
= drm_gem_object_lookup(filp
, args
->handle
);
387 up_read(&rdev
->exclusive_lock
);
390 robj
= gem_to_radeon_bo(gobj
);
392 r
= radeon_gem_set_domain(gobj
, args
->read_domains
, args
->write_domain
);
394 drm_gem_object_unreference_unlocked(gobj
);
395 up_read(&rdev
->exclusive_lock
);
396 r
= radeon_gem_handle_lockup(robj
->rdev
, r
);
400 int radeon_mode_dumb_mmap(struct drm_file
*filp
,
401 struct drm_device
*dev
,
402 uint32_t handle
, uint64_t *offset_p
)
404 struct drm_gem_object
*gobj
;
405 struct radeon_bo
*robj
;
407 gobj
= drm_gem_object_lookup(filp
, handle
);
411 robj
= gem_to_radeon_bo(gobj
);
412 if (radeon_ttm_tt_has_userptr(robj
->tbo
.ttm
)) {
413 drm_gem_object_unreference_unlocked(gobj
);
416 *offset_p
= radeon_bo_mmap_offset(robj
);
417 drm_gem_object_unreference_unlocked(gobj
);
421 int radeon_gem_mmap_ioctl(struct drm_device
*dev
, void *data
,
422 struct drm_file
*filp
)
424 struct drm_radeon_gem_mmap
*args
= data
;
426 return radeon_mode_dumb_mmap(filp
, dev
, args
->handle
, &args
->addr_ptr
);
429 int radeon_gem_busy_ioctl(struct drm_device
*dev
, void *data
,
430 struct drm_file
*filp
)
432 struct drm_radeon_gem_busy
*args
= data
;
433 struct drm_gem_object
*gobj
;
434 struct radeon_bo
*robj
;
436 uint32_t cur_placement
= 0;
438 gobj
= drm_gem_object_lookup(filp
, args
->handle
);
442 robj
= gem_to_radeon_bo(gobj
);
444 r
= reservation_object_test_signaled_rcu(robj
->tbo
.resv
, true);
450 cur_placement
= ACCESS_ONCE(robj
->tbo
.mem
.mem_type
);
451 args
->domain
= radeon_mem_type_to_domain(cur_placement
);
452 drm_gem_object_unreference_unlocked(gobj
);
456 int radeon_gem_wait_idle_ioctl(struct drm_device
*dev
, void *data
,
457 struct drm_file
*filp
)
459 struct radeon_device
*rdev
= dev
->dev_private
;
460 struct drm_radeon_gem_wait_idle
*args
= data
;
461 struct drm_gem_object
*gobj
;
462 struct radeon_bo
*robj
;
464 uint32_t cur_placement
= 0;
467 gobj
= drm_gem_object_lookup(filp
, args
->handle
);
471 robj
= gem_to_radeon_bo(gobj
);
473 ret
= reservation_object_wait_timeout_rcu(robj
->tbo
.resv
, true, true, 30 * HZ
);
479 /* Flush HDP cache via MMIO if necessary */
480 cur_placement
= ACCESS_ONCE(robj
->tbo
.mem
.mem_type
);
481 if (rdev
->asic
->mmio_hdp_flush
&&
482 radeon_mem_type_to_domain(cur_placement
) == RADEON_GEM_DOMAIN_VRAM
)
483 robj
->rdev
->asic
->mmio_hdp_flush(rdev
);
484 drm_gem_object_unreference_unlocked(gobj
);
485 r
= radeon_gem_handle_lockup(rdev
, r
);
489 int radeon_gem_set_tiling_ioctl(struct drm_device
*dev
, void *data
,
490 struct drm_file
*filp
)
492 struct drm_radeon_gem_set_tiling
*args
= data
;
493 struct drm_gem_object
*gobj
;
494 struct radeon_bo
*robj
;
497 DRM_DEBUG("%d \n", args
->handle
);
498 gobj
= drm_gem_object_lookup(filp
, args
->handle
);
501 robj
= gem_to_radeon_bo(gobj
);
502 r
= radeon_bo_set_tiling_flags(robj
, args
->tiling_flags
, args
->pitch
);
503 drm_gem_object_unreference_unlocked(gobj
);
507 int radeon_gem_get_tiling_ioctl(struct drm_device
*dev
, void *data
,
508 struct drm_file
*filp
)
510 struct drm_radeon_gem_get_tiling
*args
= data
;
511 struct drm_gem_object
*gobj
;
512 struct radeon_bo
*rbo
;
516 gobj
= drm_gem_object_lookup(filp
, args
->handle
);
519 rbo
= gem_to_radeon_bo(gobj
);
520 r
= radeon_bo_reserve(rbo
, false);
521 if (unlikely(r
!= 0))
523 radeon_bo_get_tiling_flags(rbo
, &args
->tiling_flags
, &args
->pitch
);
524 radeon_bo_unreserve(rbo
);
526 drm_gem_object_unreference_unlocked(gobj
);
531 * radeon_gem_va_update_vm -update the bo_va in its VM
533 * @rdev: radeon_device pointer
534 * @bo_va: bo_va to update
536 * Update the bo_va directly after setting it's address. Errors are not
537 * vital here, so they are not reported back to userspace.
539 static void radeon_gem_va_update_vm(struct radeon_device
*rdev
,
540 struct radeon_bo_va
*bo_va
)
542 struct ttm_validate_buffer tv
, *entry
;
543 struct radeon_bo_list
*vm_bos
;
544 struct ww_acquire_ctx ticket
;
545 struct list_head list
;
549 INIT_LIST_HEAD(&list
);
551 tv
.bo
= &bo_va
->bo
->tbo
;
553 list_add(&tv
.head
, &list
);
555 vm_bos
= radeon_vm_get_bos(rdev
, bo_va
->vm
, &list
);
559 r
= ttm_eu_reserve_buffers(&ticket
, &list
, true, NULL
);
563 list_for_each_entry(entry
, &list
, head
) {
564 domain
= radeon_mem_type_to_domain(entry
->bo
->mem
.mem_type
);
565 /* if anything is swapped out don't swap it in here,
566 just abort and wait for the next CS */
567 if (domain
== RADEON_GEM_DOMAIN_CPU
)
568 goto error_unreserve
;
571 mutex_lock(&bo_va
->vm
->mutex
);
572 r
= radeon_vm_clear_freed(rdev
, bo_va
->vm
);
577 r
= radeon_vm_bo_update(rdev
, bo_va
, &bo_va
->bo
->tbo
.mem
);
580 mutex_unlock(&bo_va
->vm
->mutex
);
583 ttm_eu_backoff_reservation(&ticket
, &list
);
586 drm_free_large(vm_bos
);
588 if (r
&& r
!= -ERESTARTSYS
)
589 DRM_ERROR("Couldn't update BO_VA (%d)\n", r
);
592 int radeon_gem_va_ioctl(struct drm_device
*dev
, void *data
,
593 struct drm_file
*filp
)
595 struct drm_radeon_gem_va
*args
= data
;
596 struct drm_gem_object
*gobj
;
597 struct radeon_device
*rdev
= dev
->dev_private
;
598 struct radeon_fpriv
*fpriv
= filp
->driver_priv
;
599 struct radeon_bo
*rbo
;
600 struct radeon_bo_va
*bo_va
;
604 if (!rdev
->vm_manager
.enabled
) {
605 args
->operation
= RADEON_VA_RESULT_ERROR
;
610 * We don't support vm_id yet, to be sure we don't have have broken
611 * userspace, reject anyone trying to use non 0 value thus moving
612 * forward we can use those fields without breaking existant userspace
615 args
->operation
= RADEON_VA_RESULT_ERROR
;
619 if (args
->offset
< RADEON_VA_RESERVED_SIZE
) {
620 dev_err(&dev
->pdev
->dev
,
621 "offset 0x%lX is in reserved area 0x%X\n",
622 (unsigned long)args
->offset
,
623 RADEON_VA_RESERVED_SIZE
);
624 args
->operation
= RADEON_VA_RESULT_ERROR
;
628 /* don't remove, we need to enforce userspace to set the snooped flag
629 * otherwise we will endup with broken userspace and we won't be able
630 * to enable this feature without adding new interface
632 invalid_flags
= RADEON_VM_PAGE_VALID
| RADEON_VM_PAGE_SYSTEM
;
633 if ((args
->flags
& invalid_flags
)) {
634 dev_err(&dev
->pdev
->dev
, "invalid flags 0x%08X vs 0x%08X\n",
635 args
->flags
, invalid_flags
);
636 args
->operation
= RADEON_VA_RESULT_ERROR
;
640 switch (args
->operation
) {
642 case RADEON_VA_UNMAP
:
645 dev_err(&dev
->pdev
->dev
, "unsupported operation %d\n",
647 args
->operation
= RADEON_VA_RESULT_ERROR
;
651 gobj
= drm_gem_object_lookup(filp
, args
->handle
);
653 args
->operation
= RADEON_VA_RESULT_ERROR
;
656 rbo
= gem_to_radeon_bo(gobj
);
657 r
= radeon_bo_reserve(rbo
, false);
659 args
->operation
= RADEON_VA_RESULT_ERROR
;
660 drm_gem_object_unreference_unlocked(gobj
);
663 bo_va
= radeon_vm_bo_find(&fpriv
->vm
, rbo
);
665 args
->operation
= RADEON_VA_RESULT_ERROR
;
666 radeon_bo_unreserve(rbo
);
667 drm_gem_object_unreference_unlocked(gobj
);
671 switch (args
->operation
) {
673 if (bo_va
->it
.start
) {
674 args
->operation
= RADEON_VA_RESULT_VA_EXIST
;
675 args
->offset
= bo_va
->it
.start
* RADEON_GPU_PAGE_SIZE
;
676 radeon_bo_unreserve(rbo
);
679 r
= radeon_vm_bo_set_addr(rdev
, bo_va
, args
->offset
, args
->flags
);
681 case RADEON_VA_UNMAP
:
682 r
= radeon_vm_bo_set_addr(rdev
, bo_va
, 0, 0);
688 radeon_gem_va_update_vm(rdev
, bo_va
);
689 args
->operation
= RADEON_VA_RESULT_OK
;
691 args
->operation
= RADEON_VA_RESULT_ERROR
;
694 drm_gem_object_unreference_unlocked(gobj
);
698 int radeon_gem_op_ioctl(struct drm_device
*dev
, void *data
,
699 struct drm_file
*filp
)
701 struct drm_radeon_gem_op
*args
= data
;
702 struct drm_gem_object
*gobj
;
703 struct radeon_bo
*robj
;
706 gobj
= drm_gem_object_lookup(filp
, args
->handle
);
710 robj
= gem_to_radeon_bo(gobj
);
713 if (radeon_ttm_tt_has_userptr(robj
->tbo
.ttm
))
716 r
= radeon_bo_reserve(robj
, false);
721 case RADEON_GEM_OP_GET_INITIAL_DOMAIN
:
722 args
->value
= robj
->initial_domain
;
724 case RADEON_GEM_OP_SET_INITIAL_DOMAIN
:
725 robj
->initial_domain
= args
->value
& (RADEON_GEM_DOMAIN_VRAM
|
726 RADEON_GEM_DOMAIN_GTT
|
727 RADEON_GEM_DOMAIN_CPU
);
733 radeon_bo_unreserve(robj
);
735 drm_gem_object_unreference_unlocked(gobj
);
739 int radeon_mode_dumb_create(struct drm_file
*file_priv
,
740 struct drm_device
*dev
,
741 struct drm_mode_create_dumb
*args
)
743 struct radeon_device
*rdev
= dev
->dev_private
;
744 struct drm_gem_object
*gobj
;
748 args
->pitch
= radeon_align_pitch(rdev
, args
->width
,
749 DIV_ROUND_UP(args
->bpp
, 8), 0);
750 args
->size
= args
->pitch
* args
->height
;
751 args
->size
= ALIGN(args
->size
, PAGE_SIZE
);
753 r
= radeon_gem_object_create(rdev
, args
->size
, 0,
754 RADEON_GEM_DOMAIN_VRAM
, 0,
759 r
= drm_gem_handle_create(file_priv
, gobj
, &handle
);
760 /* drop reference from allocate - handle holds it now */
761 drm_gem_object_unreference_unlocked(gobj
);
765 args
->handle
= handle
;
769 #if defined(CONFIG_DEBUG_FS)
770 static int radeon_debugfs_gem_info(struct seq_file
*m
, void *data
)
772 struct drm_info_node
*node
= (struct drm_info_node
*)m
->private;
773 struct drm_device
*dev
= node
->minor
->dev
;
774 struct radeon_device
*rdev
= dev
->dev_private
;
775 struct radeon_bo
*rbo
;
778 mutex_lock(&rdev
->gem
.mutex
);
779 list_for_each_entry(rbo
, &rdev
->gem
.objects
, list
) {
781 const char *placement
;
783 domain
= radeon_mem_type_to_domain(rbo
->tbo
.mem
.mem_type
);
785 case RADEON_GEM_DOMAIN_VRAM
:
788 case RADEON_GEM_DOMAIN_GTT
:
791 case RADEON_GEM_DOMAIN_CPU
:
796 seq_printf(m
, "bo[0x%08x] %8ldkB %8ldMB %s pid %8ld\n",
797 i
, radeon_bo_size(rbo
) >> 10, radeon_bo_size(rbo
) >> 20,
798 placement
, (unsigned long)rbo
->pid
);
801 mutex_unlock(&rdev
->gem
.mutex
);
805 static struct drm_info_list radeon_debugfs_gem_list
[] = {
806 {"radeon_gem_info", &radeon_debugfs_gem_info
, 0, NULL
},
810 int radeon_gem_debugfs_init(struct radeon_device
*rdev
)
812 #if defined(CONFIG_DEBUG_FS)
813 return radeon_debugfs_add_files(rdev
, radeon_debugfs_gem_list
, 1);