drivers/gpu/drm/i915/gt/intel_migrate.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gt/intel_migrate.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/gt/intel_migrate.c- Extension
.c- Size
- 29127 bytes
- Lines
- 1165
- 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
i915_drv.hintel_context.hintel_gpu_commands.hintel_gt.hintel_gtt.hintel_migrate.hintel_ring.hgem/i915_gem_lmem.hselftest_migrate.c
Detected Declarations
struct insert_pte_datafunction DIV_ROUND_UPfunction xehp_toggle_pdesfunction xehp_insert_ptefunction insert_ptefunction for_i915_gem_wwfunction intel_migrate_initfunction random_indexfunction sg_sgtfunction emit_no_arbitrationfunction max_pte_pkt_sizefunction emit_ptefunction wa_1209644611_appliesfunction emit_copy_ccsfunction emit_copyfunction scatter_list_lengthfunction calculate_chunk_szfunction get_ccs_sg_sgtfunction intel_context_migrate_copyfunction emit_clearfunction intel_context_migrate_clearfunction intel_migrate_copyfunction intel_migrate_clearfunction intel_migrate_fini
Annotated Snippet
struct insert_pte_data {
u64 offset;
};
#define CHUNK_SZ SZ_8M /* ~1ms at 8GiB/s preemption delay */
#define GET_CCS_BYTES(i915, size) (HAS_FLAT_CCS(i915) ? \
DIV_ROUND_UP(size, NUM_BYTES_PER_CCS_BYTE) : 0)
static bool engine_supports_migration(struct intel_engine_cs *engine)
{
if (!engine)
return false;
/*
* We need the ability to prevent aribtration (MI_ARB_ON_OFF),
* the ability to write PTE using inline data (MI_STORE_DATA)
* and of course the ability to do the block transfer (blits).
*/
GEM_BUG_ON(engine->class != COPY_ENGINE_CLASS);
return true;
}
static void xehp_toggle_pdes(struct i915_address_space *vm,
struct i915_page_table *pt,
void *data)
{
struct insert_pte_data *d = data;
/*
* Insert a dummy PTE into every PT that will map to LMEM to ensure
* we have a correctly setup PDE structure for later use.
*/
vm->insert_page(vm, 0, d->offset,
i915_gem_get_pat_index(vm->i915, I915_CACHE_NONE),
PTE_LM);
GEM_BUG_ON(!pt->is_compact);
d->offset += SZ_2M;
}
static void xehp_insert_pte(struct i915_address_space *vm,
struct i915_page_table *pt,
void *data)
{
struct insert_pte_data *d = data;
/*
* We are playing tricks here, since the actual pt, from the hw
* pov, is only 256bytes with 32 entries, or 4096bytes with 512
* entries, but we are still guaranteed that the physical
* alignment is 64K underneath for the pt, and we are careful
* not to access the space in the void.
*/
vm->insert_page(vm, px_dma(pt), d->offset,
i915_gem_get_pat_index(vm->i915, I915_CACHE_NONE),
PTE_LM);
d->offset += SZ_64K;
}
static void insert_pte(struct i915_address_space *vm,
struct i915_page_table *pt,
void *data)
{
struct insert_pte_data *d = data;
vm->insert_page(vm, px_dma(pt), d->offset,
i915_gem_get_pat_index(vm->i915, I915_CACHE_NONE),
i915_gem_object_is_lmem(pt->base) ? PTE_LM : 0);
d->offset += PAGE_SIZE;
}
static struct i915_address_space *migrate_vm(struct intel_gt *gt)
{
struct i915_vm_pt_stash stash = {};
struct i915_ppgtt *vm;
int err;
int i;
/*
* We construct a very special VM for use by all migration contexts,
* it is kept pinned so that it can be used at any time. As we need
* to pre-allocate the page directories for the migration VM, this
* limits us to only using a small number of prepared vma.
*
* To be able to pipeline and reschedule migration operations while
* avoiding unnecessary contention on the vm itself, the PTE updates
* are inline with the blits. All the blits use the same fixed
* addresses, with the backing store redirection being updated on the
* fly. Only 2 implicit vma are used for all migration operations.
*
Annotation
- Immediate include surface: `i915_drv.h`, `intel_context.h`, `intel_gpu_commands.h`, `intel_gt.h`, `intel_gtt.h`, `intel_migrate.h`, `intel_ring.h`, `gem/i915_gem_lmem.h`.
- Detected declarations: `struct insert_pte_data`, `function DIV_ROUND_UP`, `function xehp_toggle_pdes`, `function xehp_insert_pte`, `function insert_pte`, `function for_i915_gem_ww`, `function intel_migrate_init`, `function random_index`, `function sg_sgt`, `function emit_no_arbitration`.
- 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.