1 // SPDX-License-Identifier: GPL-2.0-or-later
3 #include <linux/module.h>
5 #include <drm/drm_gem_ttm_helper.h>
10 * This library provides helper functions for gem objects backed by
15 * drm_gem_ttm_print_info() - Print &ttm_buffer_object info for debugfs
17 * @indent: Tab indentation level
20 * This function can be used as &drm_gem_object_funcs.print_info
23 void drm_gem_ttm_print_info(struct drm_printer
*p
, unsigned int indent
,
24 const struct drm_gem_object
*gem
)
26 static const char * const plname
[] = {
27 [ TTM_PL_SYSTEM
] = "system",
29 [ TTM_PL_VRAM
] = "vram",
30 [ TTM_PL_PRIV
] = "priv",
37 [ 21 ] = "pinned", /* NO_EVICT */
40 const struct ttm_buffer_object
*bo
= drm_gem_ttm_of_gem(gem
);
42 drm_printf_indent(p
, indent
, "placement=");
43 drm_print_bits(p
, bo
->mem
.placement
, plname
, ARRAY_SIZE(plname
));
46 if (bo
->mem
.bus
.is_iomem
) {
47 drm_printf_indent(p
, indent
, "bus.base=%lx\n",
48 (unsigned long)bo
->mem
.bus
.base
);
49 drm_printf_indent(p
, indent
, "bus.offset=%lx\n",
50 (unsigned long)bo
->mem
.bus
.offset
);
53 EXPORT_SYMBOL(drm_gem_ttm_print_info
);
56 * drm_gem_ttm_mmap() - mmap &ttm_buffer_object
60 * This function can be used as &drm_gem_object_funcs.mmap
63 int drm_gem_ttm_mmap(struct drm_gem_object
*gem
,
64 struct vm_area_struct
*vma
)
66 struct ttm_buffer_object
*bo
= drm_gem_ttm_of_gem(gem
);
69 ret
= ttm_bo_mmap_obj(vma
, bo
);
74 * ttm has its own object refcounting, so drop gem reference
75 * to avoid double accounting counting.
77 drm_gem_object_put_unlocked(gem
);
81 EXPORT_SYMBOL(drm_gem_ttm_mmap
);
83 MODULE_DESCRIPTION("DRM gem ttm helpers");
84 MODULE_LICENSE("GPL");