drivers/gpu/drm/xe/xe_migrate.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_migrate.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_migrate.c- Extension
.c- Size
- 75513 bytes
- Lines
- 2634
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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_migrate.hlinux/bitfield.hlinux/sizes.hdrm/drm_managed.hdrm/drm_pagemap.hdrm/ttm/ttm_tt.huapi/drm/xe_drm.hgenerated/xe_wa_oob.hinstructions/xe_gpu_commands.hinstructions/xe_mi_commands.hregs/xe_gtt_defs.htests/xe_test.hxe_assert.hxe_bb.hxe_bo.hxe_exec_queue.hxe_ggtt.hxe_gt.hxe_gt_printk.hxe_hw_engine.hxe_lrc.hxe_map.hxe_mem_pool.hxe_mocs.hxe_pat.hxe_printk.hxe_pt.hxe_res_cursor.hxe_sa.hxe_sched_job.hxe_sriov_vf_ccs.hxe_svm.h
Detected Declarations
struct xe_migratestruct migrate_test_paramsfunction addressfunction xe_migrate_vm_addrfunction xe_migrate_vram_ofsfunction xe_migrate_program_identityfunction xe_migrate_pt_bo_allocfunction xe_migrate_prepare_vmfunction xe_migrate_suballoc_manager_initfunction xe_migrate_usm_logical_maskfunction for_each_hw_enginefunction xe_migrate_needs_ccs_emitfunction xe_migrate_lock_prepare_vmfunction xe_validation_guardfunction xe_migrate_initfunction max_mem_transfer_per_passfunction xe_migrate_res_sizesfunction xe_migrate_allow_identityfunction pte_update_sizefunction emit_ptefunction emit_copy_ccsfunction blt_fast_copy_cmd_lenfunction blt_mem_copy_cmd_lenfunction emit_copy_cmd_lenfunction emit_xy_fast_copyfunction emit_mem_copyfunction emit_copyfunction xe_migrate_batch_basefunction xe_migrate_ccs_copyfunction xe_migrate_copyfunction xe_migrate_resolvefunction xe_migrate_lrcfunction migrate_vm_ppgtt_addr_tlb_invalfunction emit_flush_invalidatefunction xe_migrate_ccs_rw_copyfunction xe_migrate_ccs_rw_copy_clearfunction scoped_guardfunction xe_migrate_exec_queuefunction xe_migrate_vram_copy_chunkfunction scoped_guardfunction blt_mem_set_cmd_lenfunction emit_clear_link_copyfunction blt_fast_color_cmd_lenfunction emit_clear_main_copyfunction emit_clear_cmd_lenfunction emit_clearfunction xe_migrate_clearfunction write_pgtable
Annotated Snippet
struct xe_migrate {
/** @q: Default exec queue used for migration */
struct xe_exec_queue *q;
/** @tile: Backpointer to the tile this struct xe_migrate belongs to. */
struct xe_tile *tile;
/** @job_mutex: Timeline mutex for @eng. */
struct mutex job_mutex;
/** @pt_bo: Page-table buffer object. */
struct xe_bo *pt_bo;
/** @batch_base_ofs: VM offset of the migration batch buffer */
u64 batch_base_ofs;
/** @usm_batch_base_ofs: VM offset of the usm batch buffer */
u64 usm_batch_base_ofs;
/** @cleared_mem_ofs: VM offset of @cleared_bo. */
u64 cleared_mem_ofs;
/** @large_page_copy_ofs: VM offset of 2M pages used for large copies */
u64 large_page_copy_ofs;
/**
* @large_page_copy_pdes: BO offset to writeout 2M pages (PDEs) used for
* large copies
*/
u64 large_page_copy_pdes;
/**
* @fence: dma-fence representing the last migration job batch.
* Protected by @job_mutex.
*/
struct dma_fence *fence;
/**
* @vm_update_sa: For integrated, used to suballocate page-tables
* out of the pt_bo.
*/
struct drm_suballoc_manager vm_update_sa;
/** @min_chunk_size: For dgfx, Minimum chunk size */
u64 min_chunk_size;
};
#define MAX_PREEMPTDISABLE_TRANSFER SZ_8M /* Around 1ms. */
#define MAX_CCS_LIMITED_TRANSFER SZ_4M /* XE_PAGE_SIZE * (FIELD_MAX(XE2_CCS_SIZE_MASK) + 1) */
#define NUM_KERNEL_PDE 15
#define NUM_PT_SLOTS 32
#define LEVEL0_PAGE_TABLE_ENCODE_SIZE SZ_2M
#define MAX_NUM_PTE 512
#define IDENTITY_OFFSET 256ULL
/*
* Although MI_STORE_DATA_IMM's "length" field is 10-bits, 0x3FE is the largest
* legal value accepted. Since that instruction field is always stored in
* (val-2) format, this translates to 0x400 dwords for the true maximum length
* of the instruction. Subtracting the instruction header (1 dword) and
* address (2 dwords), that leaves 0x3FD dwords (0x1FE qwords) for PTE values.
*/
#define MAX_PTE_PER_SDI 0x1FEU
static void xe_migrate_fini(void *arg)
{
struct xe_migrate *m = arg;
xe_vm_lock(m->q->vm, false);
xe_bo_unpin(m->pt_bo);
xe_vm_unlock(m->q->vm);
dma_fence_put(m->fence);
xe_bo_put(m->pt_bo);
drm_suballoc_manager_fini(&m->vm_update_sa);
mutex_destroy(&m->job_mutex);
xe_vm_close_and_put(m->q->vm);
xe_exec_queue_put(m->q);
}
static u64 xe_migrate_vm_addr(u64 slot, u32 level)
{
XE_WARN_ON(slot >= NUM_PT_SLOTS);
/* First slot is reserved for mapping of PT bo and bb, start from 1 */
return (slot + 1ULL) << xe_pt_shift(level + 1);
}
static u64 xe_migrate_vram_ofs(struct xe_device *xe, u64 addr, bool is_comp_pte)
{
/*
* Remove the DPA to get a correct offset into identity table for the
* migrate offset
*/
u64 identity_offset = IDENTITY_OFFSET;
if (GRAPHICS_VER(xe) >= 20 && is_comp_pte)
identity_offset += DIV_ROUND_UP_ULL(xe_vram_region_actual_physical_size
(xe->mem.vram), SZ_1G);
addr -= xe_vram_region_dpa_base(xe->mem.vram);
Annotation
- Immediate include surface: `xe_migrate.h`, `linux/bitfield.h`, `linux/sizes.h`, `drm/drm_managed.h`, `drm/drm_pagemap.h`, `drm/ttm/ttm_tt.h`, `uapi/drm/xe_drm.h`, `generated/xe_wa_oob.h`.
- Detected declarations: `struct xe_migrate`, `struct migrate_test_params`, `function address`, `function xe_migrate_vm_addr`, `function xe_migrate_vram_ofs`, `function xe_migrate_program_identity`, `function xe_migrate_pt_bo_alloc`, `function xe_migrate_prepare_vm`, `function xe_migrate_suballoc_manager_init`, `function xe_migrate_usm_logical_mask`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.