drivers/gpu/drm/drm_gem_ttm_helper.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_gem_ttm_helper.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_gem_ttm_helper.c- Extension
.c- Size
- 3916 bytes
- Lines
- 156
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/module.hdrm/drm_gem_ttm_helper.hdrm/drm_print.hdrm/ttm/ttm_placement.hdrm/ttm/ttm_tt.h
Detected Declarations
function drm_gem_ttm_print_infofunction drm_gem_ttm_vmapfunction drm_gem_ttm_vunmapfunction drm_gem_ttm_mmapfunction drm_gem_ttm_dumb_map_offsetexport drm_gem_ttm_print_infoexport drm_gem_ttm_vmapexport drm_gem_ttm_vunmapexport drm_gem_ttm_mmapexport drm_gem_ttm_dumb_map_offset
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
#include <linux/export.h>
#include <linux/module.h>
#include <drm/drm_gem_ttm_helper.h>
#include <drm/drm_print.h>
#include <drm/ttm/ttm_placement.h>
#include <drm/ttm/ttm_tt.h>
/**
* DOC: overview
*
* This library provides helper functions for gem objects backed by
* ttm.
*/
/**
* drm_gem_ttm_print_info() - Print &ttm_buffer_object info for debugfs
* @p: DRM printer
* @indent: Tab indentation level
* @gem: GEM object
*
* This function can be used as &drm_gem_object_funcs.print_info
* callback.
*/
void drm_gem_ttm_print_info(struct drm_printer *p, unsigned int indent,
const struct drm_gem_object *gem)
{
static const char * const plname[] = {
[ TTM_PL_SYSTEM ] = "system",
[ TTM_PL_TT ] = "tt",
[ TTM_PL_VRAM ] = "vram",
[ TTM_PL_PRIV ] = "priv",
[ 16 ] = "cached",
[ 17 ] = "uncached",
[ 18 ] = "wc",
[ 19 ] = "contig",
[ 21 ] = "pinned", /* NO_EVICT */
[ 22 ] = "topdown",
};
const struct ttm_buffer_object *bo = drm_gem_ttm_of_gem(gem);
drm_printf_indent(p, indent, "placement=");
drm_print_bits(p, bo->resource->placement, plname, ARRAY_SIZE(plname));
drm_printf(p, "\n");
if (bo->resource->bus.is_iomem)
drm_printf_indent(p, indent, "bus.offset=%lx\n",
(unsigned long)bo->resource->bus.offset);
}
EXPORT_SYMBOL(drm_gem_ttm_print_info);
/**
* drm_gem_ttm_vmap() - vmap &ttm_buffer_object
* @gem: GEM object.
* @map: [out] returns the dma-buf mapping.
*
* Maps a GEM object with ttm_bo_vmap(). This function can be used as
* &drm_gem_object_funcs.vmap callback.
*
* Returns:
* 0 on success, or a negative errno code otherwise.
*/
int drm_gem_ttm_vmap(struct drm_gem_object *gem,
struct iosys_map *map)
{
struct ttm_buffer_object *bo = drm_gem_ttm_of_gem(gem);
return ttm_bo_vmap(bo, map);
}
EXPORT_SYMBOL(drm_gem_ttm_vmap);
/**
* drm_gem_ttm_vunmap() - vunmap &ttm_buffer_object
* @gem: GEM object.
* @map: dma-buf mapping.
*
* Unmaps a GEM object with ttm_bo_vunmap(). This function can be used as
* &drm_gem_object_funcs.vmap callback.
*/
void drm_gem_ttm_vunmap(struct drm_gem_object *gem,
struct iosys_map *map)
{
struct ttm_buffer_object *bo = drm_gem_ttm_of_gem(gem);
ttm_bo_vunmap(bo, map);
}
Annotation
- Immediate include surface: `linux/export.h`, `linux/module.h`, `drm/drm_gem_ttm_helper.h`, `drm/drm_print.h`, `drm/ttm/ttm_placement.h`, `drm/ttm/ttm_tt.h`.
- Detected declarations: `function drm_gem_ttm_print_info`, `function drm_gem_ttm_vmap`, `function drm_gem_ttm_vunmap`, `function drm_gem_ttm_mmap`, `function drm_gem_ttm_dumb_map_offset`, `export drm_gem_ttm_print_info`, `export drm_gem_ttm_vmap`, `export drm_gem_ttm_vunmap`, `export drm_gem_ttm_mmap`, `export drm_gem_ttm_dumb_map_offset`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.