drivers/gpu/drm/xe/xe_ttm_sys_mgr.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_ttm_sys_mgr.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_ttm_sys_mgr.c- Extension
.c- Size
- 2872 bytes
- Lines
- 120
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
xe_ttm_sys_mgr.hdrm/drm_managed.hdrm/ttm/ttm_placement.hdrm/ttm/ttm_range_manager.hdrm/ttm/ttm_tt.hxe_bo.h
Detected Declarations
struct xe_ttm_sys_nodefunction to_xe_ttm_sys_nodefunction xe_ttm_sys_mgr_newfunction xe_ttm_sys_mgr_delfunction xe_ttm_sys_mgr_debugfunction xe_ttm_sys_mgr_finifunction xe_ttm_sys_mgr_init
Annotated Snippet
struct xe_ttm_sys_node {
struct ttm_buffer_object *tbo;
struct ttm_range_mgr_node base;
};
static inline struct xe_ttm_sys_node *
to_xe_ttm_sys_node(struct ttm_resource *res)
{
return container_of(res, struct xe_ttm_sys_node, base.base);
}
static int xe_ttm_sys_mgr_new(struct ttm_resource_manager *man,
struct ttm_buffer_object *tbo,
const struct ttm_place *place,
struct ttm_resource **res)
{
struct xe_ttm_sys_node *node;
int r;
node = kzalloc_flex(*node, base.mm_nodes, 1);
if (!node)
return -ENOMEM;
node->tbo = tbo;
ttm_resource_init(tbo, place, &node->base.base);
if (!(place->flags & TTM_PL_FLAG_TEMPORARY) &&
ttm_resource_manager_usage(man) > (man->size << PAGE_SHIFT)) {
r = -ENOSPC;
goto err_fini;
}
node->base.mm_nodes[0].start = 0;
node->base.mm_nodes[0].size = PFN_UP(node->base.base.size);
node->base.base.start = XE_BO_INVALID_OFFSET;
*res = &node->base.base;
return 0;
err_fini:
ttm_resource_fini(man, &node->base.base);
kfree(node);
return r;
}
static void xe_ttm_sys_mgr_del(struct ttm_resource_manager *man,
struct ttm_resource *res)
{
struct xe_ttm_sys_node *node = to_xe_ttm_sys_node(res);
ttm_resource_fini(man, res);
kfree(node);
}
static void xe_ttm_sys_mgr_debug(struct ttm_resource_manager *man,
struct drm_printer *printer)
{
/*
* This function is called by debugfs entry and would require
* pm_runtime_{get,put} wrappers around any operation.
*/
}
static const struct ttm_resource_manager_func xe_ttm_sys_mgr_func = {
.alloc = xe_ttm_sys_mgr_new,
.free = xe_ttm_sys_mgr_del,
.debug = xe_ttm_sys_mgr_debug
};
static void xe_ttm_sys_mgr_fini(struct drm_device *drm, void *arg)
{
struct xe_device *xe = (struct xe_device *)arg;
struct ttm_resource_manager *man = &xe->mem.sys_mgr;
int err;
ttm_resource_manager_set_used(man, false);
err = ttm_resource_manager_evict_all(&xe->ttm, man);
if (err)
return;
ttm_resource_manager_cleanup(man);
ttm_set_driver_manager(&xe->ttm, XE_PL_TT, NULL);
}
int xe_ttm_sys_mgr_init(struct xe_device *xe)
{
struct ttm_resource_manager *man = &xe->mem.sys_mgr;
struct sysinfo si;
Annotation
- Immediate include surface: `xe_ttm_sys_mgr.h`, `drm/drm_managed.h`, `drm/ttm/ttm_placement.h`, `drm/ttm/ttm_range_manager.h`, `drm/ttm/ttm_tt.h`, `xe_bo.h`.
- Detected declarations: `struct xe_ttm_sys_node`, `function to_xe_ttm_sys_node`, `function xe_ttm_sys_mgr_new`, `function xe_ttm_sys_mgr_del`, `function xe_ttm_sys_mgr_debug`, `function xe_ttm_sys_mgr_fini`, `function xe_ttm_sys_mgr_init`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source 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.