2 * Copyright 2009 Jerome Glisse.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
16 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
17 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
19 * USE OR OTHER DEALINGS IN THE SOFTWARE.
21 * The above copyright notice and this permission notice (including the
22 * next paragraph) shall be included in all copies or substantial portions
28 * Jerome Glisse <glisse@freedesktop.org>
29 * Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
32 #include <ttm/ttm_bo_api.h>
33 #include <ttm/ttm_bo_driver.h>
34 #include <ttm/ttm_placement.h>
35 #include <ttm/ttm_module.h>
37 #include <drm/radeon_drm.h>
38 #include <linux/seq_file.h>
39 #include <linux/slab.h>
40 #include "radeon_reg.h"
43 #define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
45 static int radeon_ttm_debugfs_init(struct radeon_device
*rdev
);
47 static struct radeon_device
*radeon_get_rdev(struct ttm_bo_device
*bdev
)
49 struct radeon_mman
*mman
;
50 struct radeon_device
*rdev
;
52 mman
= container_of(bdev
, struct radeon_mman
, bdev
);
53 rdev
= container_of(mman
, struct radeon_device
, mman
);
61 static int radeon_ttm_mem_global_init(struct ttm_global_reference
*ref
)
63 return ttm_mem_global_init(ref
->object
);
66 static void radeon_ttm_mem_global_release(struct ttm_global_reference
*ref
)
68 ttm_mem_global_release(ref
->object
);
71 static int radeon_ttm_global_init(struct radeon_device
*rdev
)
73 struct ttm_global_reference
*global_ref
;
76 rdev
->mman
.mem_global_referenced
= false;
77 global_ref
= &rdev
->mman
.mem_global_ref
;
78 global_ref
->global_type
= TTM_GLOBAL_TTM_MEM
;
79 global_ref
->size
= sizeof(struct ttm_mem_global
);
80 global_ref
->init
= &radeon_ttm_mem_global_init
;
81 global_ref
->release
= &radeon_ttm_mem_global_release
;
82 r
= ttm_global_item_ref(global_ref
);
84 DRM_ERROR("Failed setting up TTM memory accounting "
89 rdev
->mman
.bo_global_ref
.mem_glob
=
90 rdev
->mman
.mem_global_ref
.object
;
91 global_ref
= &rdev
->mman
.bo_global_ref
.ref
;
92 global_ref
->global_type
= TTM_GLOBAL_TTM_BO
;
93 global_ref
->size
= sizeof(struct ttm_bo_global
);
94 global_ref
->init
= &ttm_bo_global_init
;
95 global_ref
->release
= &ttm_bo_global_release
;
96 r
= ttm_global_item_ref(global_ref
);
98 DRM_ERROR("Failed setting up TTM BO subsystem.\n");
99 ttm_global_item_unref(&rdev
->mman
.mem_global_ref
);
103 rdev
->mman
.mem_global_referenced
= true;
107 static void radeon_ttm_global_fini(struct radeon_device
*rdev
)
109 if (rdev
->mman
.mem_global_referenced
) {
110 ttm_global_item_unref(&rdev
->mman
.bo_global_ref
.ref
);
111 ttm_global_item_unref(&rdev
->mman
.mem_global_ref
);
112 rdev
->mman
.mem_global_referenced
= false;
116 struct ttm_backend
*radeon_ttm_backend_create(struct radeon_device
*rdev
);
118 static struct ttm_backend
*
119 radeon_create_ttm_backend_entry(struct ttm_bo_device
*bdev
)
121 struct radeon_device
*rdev
;
123 rdev
= radeon_get_rdev(bdev
);
125 if (rdev
->flags
& RADEON_IS_AGP
) {
126 return ttm_agp_backend_init(bdev
, rdev
->ddev
->agp
->bridge
);
130 return radeon_ttm_backend_create(rdev
);
134 static int radeon_invalidate_caches(struct ttm_bo_device
*bdev
, uint32_t flags
)
139 static int radeon_init_mem_type(struct ttm_bo_device
*bdev
, uint32_t type
,
140 struct ttm_mem_type_manager
*man
)
142 struct radeon_device
*rdev
;
144 rdev
= radeon_get_rdev(bdev
);
149 man
->flags
= TTM_MEMTYPE_FLAG_MAPPABLE
;
150 man
->available_caching
= TTM_PL_MASK_CACHING
;
151 man
->default_caching
= TTM_PL_FLAG_CACHED
;
154 man
->gpu_offset
= rdev
->mc
.gtt_start
;
155 man
->available_caching
= TTM_PL_MASK_CACHING
;
156 man
->default_caching
= TTM_PL_FLAG_CACHED
;
157 man
->flags
= TTM_MEMTYPE_FLAG_MAPPABLE
| TTM_MEMTYPE_FLAG_CMA
;
159 if (rdev
->flags
& RADEON_IS_AGP
) {
160 if (!(drm_core_has_AGP(rdev
->ddev
) && rdev
->ddev
->agp
)) {
161 DRM_ERROR("AGP is not enabled for memory type %u\n",
165 man
->io_offset
= rdev
->mc
.agp_base
;
166 man
->io_size
= rdev
->mc
.gtt_size
;
168 if (!rdev
->ddev
->agp
->cant_use_aperture
)
169 man
->flags
= TTM_MEMTYPE_FLAG_NEEDS_IOREMAP
|
170 TTM_MEMTYPE_FLAG_MAPPABLE
;
171 man
->available_caching
= TTM_PL_FLAG_UNCACHED
|
173 man
->default_caching
= TTM_PL_FLAG_WC
;
183 /* "On-card" video ram */
184 man
->gpu_offset
= rdev
->mc
.vram_start
;
185 man
->flags
= TTM_MEMTYPE_FLAG_FIXED
|
186 TTM_MEMTYPE_FLAG_NEEDS_IOREMAP
|
187 TTM_MEMTYPE_FLAG_MAPPABLE
;
188 man
->available_caching
= TTM_PL_FLAG_UNCACHED
| TTM_PL_FLAG_WC
;
189 man
->default_caching
= TTM_PL_FLAG_WC
;
191 man
->io_offset
= rdev
->mc
.aper_base
;
192 man
->io_size
= rdev
->mc
.aper_size
;
195 DRM_ERROR("Unsupported memory type %u\n", (unsigned)type
);
201 static void radeon_evict_flags(struct ttm_buffer_object
*bo
,
202 struct ttm_placement
*placement
)
204 struct radeon_bo
*rbo
;
205 static u32 placements
= TTM_PL_MASK_CACHING
| TTM_PL_FLAG_SYSTEM
;
207 if (!radeon_ttm_bo_is_radeon_bo(bo
)) {
210 placement
->placement
= &placements
;
211 placement
->busy_placement
= &placements
;
212 placement
->num_placement
= 1;
213 placement
->num_busy_placement
= 1;
216 rbo
= container_of(bo
, struct radeon_bo
, tbo
);
217 switch (bo
->mem
.mem_type
) {
219 if (rbo
->rdev
->cp
.ready
== false)
220 radeon_ttm_placement_from_domain(rbo
, RADEON_GEM_DOMAIN_CPU
);
222 radeon_ttm_placement_from_domain(rbo
, RADEON_GEM_DOMAIN_GTT
);
226 radeon_ttm_placement_from_domain(rbo
, RADEON_GEM_DOMAIN_CPU
);
228 *placement
= rbo
->placement
;
231 static int radeon_verify_access(struct ttm_buffer_object
*bo
, struct file
*filp
)
236 static void radeon_move_null(struct ttm_buffer_object
*bo
,
237 struct ttm_mem_reg
*new_mem
)
239 struct ttm_mem_reg
*old_mem
= &bo
->mem
;
241 BUG_ON(old_mem
->mm_node
!= NULL
);
243 new_mem
->mm_node
= NULL
;
246 static int radeon_move_blit(struct ttm_buffer_object
*bo
,
247 bool evict
, int no_wait
,
248 struct ttm_mem_reg
*new_mem
,
249 struct ttm_mem_reg
*old_mem
)
251 struct radeon_device
*rdev
;
252 uint64_t old_start
, new_start
;
253 struct radeon_fence
*fence
;
256 rdev
= radeon_get_rdev(bo
->bdev
);
257 r
= radeon_fence_create(rdev
, &fence
);
261 old_start
= old_mem
->mm_node
->start
<< PAGE_SHIFT
;
262 new_start
= new_mem
->mm_node
->start
<< PAGE_SHIFT
;
264 switch (old_mem
->mem_type
) {
266 old_start
+= rdev
->mc
.vram_start
;
269 old_start
+= rdev
->mc
.gtt_start
;
272 DRM_ERROR("Unknown placement %d\n", old_mem
->mem_type
);
275 switch (new_mem
->mem_type
) {
277 new_start
+= rdev
->mc
.vram_start
;
280 new_start
+= rdev
->mc
.gtt_start
;
283 DRM_ERROR("Unknown placement %d\n", old_mem
->mem_type
);
286 if (!rdev
->cp
.ready
) {
287 DRM_ERROR("Trying to move memory with CP turned off.\n");
290 r
= radeon_copy(rdev
, old_start
, new_start
, new_mem
->num_pages
, fence
);
291 /* FIXME: handle copy error */
292 r
= ttm_bo_move_accel_cleanup(bo
, (void *)fence
, NULL
,
293 evict
, no_wait
, new_mem
);
294 radeon_fence_unref(&fence
);
298 static int radeon_move_vram_ram(struct ttm_buffer_object
*bo
,
299 bool evict
, bool interruptible
, bool no_wait
,
300 struct ttm_mem_reg
*new_mem
)
302 struct radeon_device
*rdev
;
303 struct ttm_mem_reg
*old_mem
= &bo
->mem
;
304 struct ttm_mem_reg tmp_mem
;
306 struct ttm_placement placement
;
309 rdev
= radeon_get_rdev(bo
->bdev
);
311 tmp_mem
.mm_node
= NULL
;
314 placement
.num_placement
= 1;
315 placement
.placement
= &placements
;
316 placement
.num_busy_placement
= 1;
317 placement
.busy_placement
= &placements
;
318 placements
= TTM_PL_MASK_CACHING
| TTM_PL_FLAG_TT
;
319 r
= ttm_bo_mem_space(bo
, &placement
, &tmp_mem
,
320 interruptible
, no_wait
);
325 r
= ttm_tt_set_placement_caching(bo
->ttm
, tmp_mem
.placement
);
330 r
= ttm_tt_bind(bo
->ttm
, &tmp_mem
);
334 r
= radeon_move_blit(bo
, true, no_wait
, &tmp_mem
, old_mem
);
338 r
= ttm_bo_move_ttm(bo
, true, no_wait
, new_mem
);
340 if (tmp_mem
.mm_node
) {
341 struct ttm_bo_global
*glob
= rdev
->mman
.bdev
.glob
;
343 spin_lock(&glob
->lru_lock
);
344 drm_mm_put_block(tmp_mem
.mm_node
);
345 spin_unlock(&glob
->lru_lock
);
351 static int radeon_move_ram_vram(struct ttm_buffer_object
*bo
,
352 bool evict
, bool interruptible
, bool no_wait
,
353 struct ttm_mem_reg
*new_mem
)
355 struct radeon_device
*rdev
;
356 struct ttm_mem_reg
*old_mem
= &bo
->mem
;
357 struct ttm_mem_reg tmp_mem
;
358 struct ttm_placement placement
;
362 rdev
= radeon_get_rdev(bo
->bdev
);
364 tmp_mem
.mm_node
= NULL
;
367 placement
.num_placement
= 1;
368 placement
.placement
= &placements
;
369 placement
.num_busy_placement
= 1;
370 placement
.busy_placement
= &placements
;
371 placements
= TTM_PL_MASK_CACHING
| TTM_PL_FLAG_TT
;
372 r
= ttm_bo_mem_space(bo
, &placement
, &tmp_mem
, interruptible
, no_wait
);
376 r
= ttm_bo_move_ttm(bo
, true, no_wait
, &tmp_mem
);
380 r
= radeon_move_blit(bo
, true, no_wait
, new_mem
, old_mem
);
385 if (tmp_mem
.mm_node
) {
386 struct ttm_bo_global
*glob
= rdev
->mman
.bdev
.glob
;
388 spin_lock(&glob
->lru_lock
);
389 drm_mm_put_block(tmp_mem
.mm_node
);
390 spin_unlock(&glob
->lru_lock
);
396 static int radeon_bo_move(struct ttm_buffer_object
*bo
,
397 bool evict
, bool interruptible
, bool no_wait
,
398 struct ttm_mem_reg
*new_mem
)
400 struct radeon_device
*rdev
;
401 struct ttm_mem_reg
*old_mem
= &bo
->mem
;
404 rdev
= radeon_get_rdev(bo
->bdev
);
405 if (old_mem
->mem_type
== TTM_PL_SYSTEM
&& bo
->ttm
== NULL
) {
406 radeon_move_null(bo
, new_mem
);
409 if ((old_mem
->mem_type
== TTM_PL_TT
&&
410 new_mem
->mem_type
== TTM_PL_SYSTEM
) ||
411 (old_mem
->mem_type
== TTM_PL_SYSTEM
&&
412 new_mem
->mem_type
== TTM_PL_TT
)) {
414 radeon_move_null(bo
, new_mem
);
417 if (!rdev
->cp
.ready
|| rdev
->asic
->copy
== NULL
) {
422 if (old_mem
->mem_type
== TTM_PL_VRAM
&&
423 new_mem
->mem_type
== TTM_PL_SYSTEM
) {
424 r
= radeon_move_vram_ram(bo
, evict
, interruptible
,
426 } else if (old_mem
->mem_type
== TTM_PL_SYSTEM
&&
427 new_mem
->mem_type
== TTM_PL_VRAM
) {
428 r
= radeon_move_ram_vram(bo
, evict
, interruptible
,
431 r
= radeon_move_blit(bo
, evict
, no_wait
, new_mem
, old_mem
);
436 r
= ttm_bo_move_memcpy(bo
, evict
, no_wait
, new_mem
);
442 static int radeon_sync_obj_wait(void *sync_obj
, void *sync_arg
,
443 bool lazy
, bool interruptible
)
445 return radeon_fence_wait((struct radeon_fence
*)sync_obj
, interruptible
);
448 static int radeon_sync_obj_flush(void *sync_obj
, void *sync_arg
)
453 static void radeon_sync_obj_unref(void **sync_obj
)
455 radeon_fence_unref((struct radeon_fence
**)sync_obj
);
458 static void *radeon_sync_obj_ref(void *sync_obj
)
460 return radeon_fence_ref((struct radeon_fence
*)sync_obj
);
463 static bool radeon_sync_obj_signaled(void *sync_obj
, void *sync_arg
)
465 return radeon_fence_signaled((struct radeon_fence
*)sync_obj
);
468 static struct ttm_bo_driver radeon_bo_driver
= {
469 .create_ttm_backend_entry
= &radeon_create_ttm_backend_entry
,
470 .invalidate_caches
= &radeon_invalidate_caches
,
471 .init_mem_type
= &radeon_init_mem_type
,
472 .evict_flags
= &radeon_evict_flags
,
473 .move
= &radeon_bo_move
,
474 .verify_access
= &radeon_verify_access
,
475 .sync_obj_signaled
= &radeon_sync_obj_signaled
,
476 .sync_obj_wait
= &radeon_sync_obj_wait
,
477 .sync_obj_flush
= &radeon_sync_obj_flush
,
478 .sync_obj_unref
= &radeon_sync_obj_unref
,
479 .sync_obj_ref
= &radeon_sync_obj_ref
,
480 .move_notify
= &radeon_bo_move_notify
,
481 .fault_reserve_notify
= &radeon_bo_fault_reserve_notify
,
484 int radeon_ttm_init(struct radeon_device
*rdev
)
488 r
= radeon_ttm_global_init(rdev
);
492 /* No others user of address space so set it to 0 */
493 r
= ttm_bo_device_init(&rdev
->mman
.bdev
,
494 rdev
->mman
.bo_global_ref
.ref
.object
,
495 &radeon_bo_driver
, DRM_FILE_PAGE_OFFSET
,
498 DRM_ERROR("failed initializing buffer object driver(%d).\n", r
);
501 rdev
->mman
.initialized
= true;
502 r
= ttm_bo_init_mm(&rdev
->mman
.bdev
, TTM_PL_VRAM
,
503 rdev
->mc
.real_vram_size
>> PAGE_SHIFT
);
505 DRM_ERROR("Failed initializing VRAM heap.\n");
508 r
= radeon_bo_create(rdev
, NULL
, 256 * 1024, true,
509 RADEON_GEM_DOMAIN_VRAM
,
510 &rdev
->stollen_vga_memory
);
514 r
= radeon_bo_reserve(rdev
->stollen_vga_memory
, false);
517 r
= radeon_bo_pin(rdev
->stollen_vga_memory
, RADEON_GEM_DOMAIN_VRAM
, NULL
);
518 radeon_bo_unreserve(rdev
->stollen_vga_memory
);
520 radeon_bo_unref(&rdev
->stollen_vga_memory
);
523 DRM_INFO("radeon: %uM of VRAM memory ready\n",
524 (unsigned)rdev
->mc
.real_vram_size
/ (1024 * 1024));
525 r
= ttm_bo_init_mm(&rdev
->mman
.bdev
, TTM_PL_TT
,
526 rdev
->mc
.gtt_size
>> PAGE_SHIFT
);
528 DRM_ERROR("Failed initializing GTT heap.\n");
531 DRM_INFO("radeon: %uM of GTT memory ready.\n",
532 (unsigned)(rdev
->mc
.gtt_size
/ (1024 * 1024)));
533 if (unlikely(rdev
->mman
.bdev
.dev_mapping
== NULL
)) {
534 rdev
->mman
.bdev
.dev_mapping
= rdev
->ddev
->dev_mapping
;
537 r
= radeon_ttm_debugfs_init(rdev
);
539 DRM_ERROR("Failed to init debugfs\n");
545 void radeon_ttm_fini(struct radeon_device
*rdev
)
549 if (!rdev
->mman
.initialized
)
551 if (rdev
->stollen_vga_memory
) {
552 r
= radeon_bo_reserve(rdev
->stollen_vga_memory
, false);
554 radeon_bo_unpin(rdev
->stollen_vga_memory
);
555 radeon_bo_unreserve(rdev
->stollen_vga_memory
);
557 radeon_bo_unref(&rdev
->stollen_vga_memory
);
559 ttm_bo_clean_mm(&rdev
->mman
.bdev
, TTM_PL_VRAM
);
560 ttm_bo_clean_mm(&rdev
->mman
.bdev
, TTM_PL_TT
);
561 ttm_bo_device_release(&rdev
->mman
.bdev
);
562 radeon_gart_fini(rdev
);
563 radeon_ttm_global_fini(rdev
);
564 rdev
->mman
.initialized
= false;
565 DRM_INFO("radeon: ttm finalized\n");
568 static struct vm_operations_struct radeon_ttm_vm_ops
;
569 static const struct vm_operations_struct
*ttm_vm_ops
= NULL
;
571 static int radeon_ttm_fault(struct vm_area_struct
*vma
, struct vm_fault
*vmf
)
573 struct ttm_buffer_object
*bo
;
576 bo
= (struct ttm_buffer_object
*)vma
->vm_private_data
;
578 return VM_FAULT_NOPAGE
;
580 r
= ttm_vm_ops
->fault(vma
, vmf
);
584 int radeon_mmap(struct file
*filp
, struct vm_area_struct
*vma
)
586 struct drm_file
*file_priv
;
587 struct radeon_device
*rdev
;
590 if (unlikely(vma
->vm_pgoff
< DRM_FILE_PAGE_OFFSET
)) {
591 return drm_mmap(filp
, vma
);
594 file_priv
= (struct drm_file
*)filp
->private_data
;
595 rdev
= file_priv
->minor
->dev
->dev_private
;
599 r
= ttm_bo_mmap(filp
, vma
, &rdev
->mman
.bdev
);
600 if (unlikely(r
!= 0)) {
603 if (unlikely(ttm_vm_ops
== NULL
)) {
604 ttm_vm_ops
= vma
->vm_ops
;
605 radeon_ttm_vm_ops
= *ttm_vm_ops
;
606 radeon_ttm_vm_ops
.fault
= &radeon_ttm_fault
;
608 vma
->vm_ops
= &radeon_ttm_vm_ops
;
614 * TTM backend functions.
616 struct radeon_ttm_backend
{
617 struct ttm_backend backend
;
618 struct radeon_device
*rdev
;
619 unsigned long num_pages
;
621 struct page
*dummy_read_page
;
627 static int radeon_ttm_backend_populate(struct ttm_backend
*backend
,
628 unsigned long num_pages
,
630 struct page
*dummy_read_page
)
632 struct radeon_ttm_backend
*gtt
;
634 gtt
= container_of(backend
, struct radeon_ttm_backend
, backend
);
636 gtt
->num_pages
= num_pages
;
637 gtt
->dummy_read_page
= dummy_read_page
;
638 gtt
->populated
= true;
642 static void radeon_ttm_backend_clear(struct ttm_backend
*backend
)
644 struct radeon_ttm_backend
*gtt
;
646 gtt
= container_of(backend
, struct radeon_ttm_backend
, backend
);
649 gtt
->dummy_read_page
= NULL
;
650 gtt
->populated
= false;
655 static int radeon_ttm_backend_bind(struct ttm_backend
*backend
,
656 struct ttm_mem_reg
*bo_mem
)
658 struct radeon_ttm_backend
*gtt
;
661 gtt
= container_of(backend
, struct radeon_ttm_backend
, backend
);
662 gtt
->offset
= bo_mem
->mm_node
->start
<< PAGE_SHIFT
;
663 if (!gtt
->num_pages
) {
664 WARN(1, "nothing to bind %lu pages for mreg %p back %p!\n", gtt
->num_pages
, bo_mem
, backend
);
666 r
= radeon_gart_bind(gtt
->rdev
, gtt
->offset
,
667 gtt
->num_pages
, gtt
->pages
);
669 DRM_ERROR("failed to bind %lu pages at 0x%08X\n",
670 gtt
->num_pages
, gtt
->offset
);
677 static int radeon_ttm_backend_unbind(struct ttm_backend
*backend
)
679 struct radeon_ttm_backend
*gtt
;
681 gtt
= container_of(backend
, struct radeon_ttm_backend
, backend
);
682 radeon_gart_unbind(gtt
->rdev
, gtt
->offset
, gtt
->num_pages
);
687 static void radeon_ttm_backend_destroy(struct ttm_backend
*backend
)
689 struct radeon_ttm_backend
*gtt
;
691 gtt
= container_of(backend
, struct radeon_ttm_backend
, backend
);
693 radeon_ttm_backend_unbind(backend
);
698 static struct ttm_backend_func radeon_backend_func
= {
699 .populate
= &radeon_ttm_backend_populate
,
700 .clear
= &radeon_ttm_backend_clear
,
701 .bind
= &radeon_ttm_backend_bind
,
702 .unbind
= &radeon_ttm_backend_unbind
,
703 .destroy
= &radeon_ttm_backend_destroy
,
706 struct ttm_backend
*radeon_ttm_backend_create(struct radeon_device
*rdev
)
708 struct radeon_ttm_backend
*gtt
;
710 gtt
= kzalloc(sizeof(struct radeon_ttm_backend
), GFP_KERNEL
);
714 gtt
->backend
.bdev
= &rdev
->mman
.bdev
;
715 gtt
->backend
.flags
= 0;
716 gtt
->backend
.func
= &radeon_backend_func
;
720 gtt
->dummy_read_page
= NULL
;
721 gtt
->populated
= false;
723 return >t
->backend
;
726 #define RADEON_DEBUGFS_MEM_TYPES 2
728 #if defined(CONFIG_DEBUG_FS)
729 static int radeon_mm_dump_table(struct seq_file
*m
, void *data
)
731 struct drm_info_node
*node
= (struct drm_info_node
*)m
->private;
732 struct drm_mm
*mm
= (struct drm_mm
*)node
->info_ent
->data
;
733 struct drm_device
*dev
= node
->minor
->dev
;
734 struct radeon_device
*rdev
= dev
->dev_private
;
736 struct ttm_bo_global
*glob
= rdev
->mman
.bdev
.glob
;
738 spin_lock(&glob
->lru_lock
);
739 ret
= drm_mm_dump_table(m
, mm
);
740 spin_unlock(&glob
->lru_lock
);
745 static int radeon_ttm_debugfs_init(struct radeon_device
*rdev
)
747 #if defined(CONFIG_DEBUG_FS)
748 static struct drm_info_list radeon_mem_types_list
[RADEON_DEBUGFS_MEM_TYPES
];
749 static char radeon_mem_types_names
[RADEON_DEBUGFS_MEM_TYPES
][32];
752 for (i
= 0; i
< RADEON_DEBUGFS_MEM_TYPES
; i
++) {
754 sprintf(radeon_mem_types_names
[i
], "radeon_vram_mm");
756 sprintf(radeon_mem_types_names
[i
], "radeon_gtt_mm");
757 radeon_mem_types_list
[i
].name
= radeon_mem_types_names
[i
];
758 radeon_mem_types_list
[i
].show
= &radeon_mm_dump_table
;
759 radeon_mem_types_list
[i
].driver_features
= 0;
761 radeon_mem_types_list
[i
].data
= &rdev
->mman
.bdev
.man
[TTM_PL_VRAM
].manager
;
763 radeon_mem_types_list
[i
].data
= &rdev
->mman
.bdev
.man
[TTM_PL_TT
].manager
;
766 return radeon_debugfs_add_files(rdev
, radeon_mem_types_list
, RADEON_DEBUGFS_MEM_TYPES
);