drivers/gpu/drm/xe/xe_res_cursor.h
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_res_cursor.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_res_cursor.h- Extension
.h- Size
- 9152 bytes
- Lines
- 369
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/scatterlist.hdrm/drm_pagemap.hdrm/ttm/ttm_placement.hdrm/ttm/ttm_range_manager.hdrm/ttm/ttm_resource.hdrm/ttm/ttm_tt.hxe_bo.hxe_device.hxe_macros.hxe_svm.hxe_ttm_vram_mgr.h
Detected Declarations
struct xe_res_cursorfunction xe_res_firstfunction __xe_res_sg_nextfunction __xe_res_dma_nextfunction xe_res_first_sgfunction xe_res_first_dmafunction xe_res_nextfunction xe_res_dmafunction xe_res_is_vram
Annotated Snippet
struct xe_res_cursor {
/** @start: Start of cursor */
u64 start;
/** @size: Size of the current segment. */
u64 size;
/** @remaining: Remaining bytes in cursor */
u64 remaining;
/** @node: Opaque point current node cursor */
void *node;
/** @mem_type: Memory type */
u32 mem_type;
/** @sgl: Scatterlist for cursor */
struct scatterlist *sgl;
/** @dma_addr: Current element in a struct drm_pagemap_addr array */
const struct drm_pagemap_addr *dma_addr;
/** @mm: Buddy allocator for VRAM cursor */
struct gpu_buddy *mm;
/**
* @dma_start: DMA start address for the current segment.
* This may be different to @dma_addr.addr since elements in
* the array may be coalesced to a single segment.
*/
u64 dma_start;
/** @dma_seg_size: Size of the current DMA segment. */
u64 dma_seg_size;
};
static struct gpu_buddy *xe_res_get_buddy(struct ttm_resource *res)
{
struct ttm_resource_manager *mgr;
mgr = ttm_manager_type(res->bo->bdev, res->mem_type);
return &to_xe_ttm_vram_mgr(mgr)->mm;
}
/**
* xe_res_first - initialize a xe_res_cursor
*
* @res: TTM resource object to walk
* @start: Start of the range
* @size: Size of the range
* @cur: cursor object to initialize
*
* Start walking over the range of allocations between @start and @size.
*/
static inline void xe_res_first(struct ttm_resource *res,
u64 start, u64 size,
struct xe_res_cursor *cur)
{
cur->sgl = NULL;
cur->dma_addr = NULL;
if (!res)
goto fallback;
XE_WARN_ON(start + size > res->size);
cur->mem_type = res->mem_type;
switch (cur->mem_type) {
case XE_PL_STOLEN: {
/* res->start is in pages (ttm_range_manager). */
cur->start = (res->start << PAGE_SHIFT) + start;
cur->size = size;
cur->remaining = size;
cur->node = NULL;
cur->mm = NULL;
break;
}
case XE_PL_VRAM0:
case XE_PL_VRAM1: {
struct gpu_buddy_block *block;
struct list_head *head, *next;
struct gpu_buddy *mm = xe_res_get_buddy(res);
head = &to_xe_ttm_vram_mgr_resource(res)->blocks;
block = list_first_entry_or_null(head,
struct gpu_buddy_block,
link);
if (!block)
goto fallback;
while (start >= gpu_buddy_block_size(mm, block)) {
start -= gpu_buddy_block_size(mm, block);
next = block->link.next;
if (next != head)
block = list_entry(next, struct gpu_buddy_block,
link);
}
Annotation
- Immediate include surface: `linux/scatterlist.h`, `drm/drm_pagemap.h`, `drm/ttm/ttm_placement.h`, `drm/ttm/ttm_range_manager.h`, `drm/ttm/ttm_resource.h`, `drm/ttm/ttm_tt.h`, `xe_bo.h`, `xe_device.h`.
- Detected declarations: `struct xe_res_cursor`, `function xe_res_first`, `function __xe_res_sg_next`, `function __xe_res_dma_next`, `function xe_res_first_sg`, `function xe_res_first_dma`, `function xe_res_next`, `function xe_res_dma`, `function xe_res_is_vram`.
- 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.