drivers/gpu/drm/xe/xe_ggtt.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_ggtt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_ggtt.c- Extension
.c- Size
- 31958 bytes
- Lines
- 1168
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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_ggtt.hkunit/visibility.hlinux/fault-inject.hlinux/io-64-nonatomic-lo-hi.hlinux/sizes.hdrm/drm_drv.hdrm/drm_managed.hdrm/intel/i915_drm.hgenerated/xe_wa_oob.hregs/xe_gt_regs.hregs/xe_gtt_defs.hregs/xe_regs.hxe_assert.hxe_bo.hxe_gt_printk.hxe_gt_types.hxe_map.hxe_mmio.hxe_pat.hxe_pm.hxe_res_cursor.hxe_sriov.hxe_tile_printk.hxe_tile_sriov_vf.hxe_tlb_inval.hxe_wa.hxe_wopcm.h
Detected Declarations
struct xe_ggtt_nodestruct xe_ggtt_pt_opsstruct xe_ggttfunction xelp_ggtt_pte_flagsfunction xelpg_ggtt_pte_flagsfunction probe_gsm_sizefunction ggtt_update_access_counterfunction xe_ggtt_startfunction xe_ggtt_sizefunction xe_ggtt_set_ptefunction xe_ggtt_set_pte_and_flushfunction xe_ggtt_get_ptefunction xe_ggtt_clearfunction primelockdepfunction ggtt_fini_earlyfunction ggtt_finifunction xe_ggtt_might_lockfunction __xe_ggtt_init_earlyfunction xe_ggtt_init_kunitfunction dev_fini_ggttfunction xe_ggtt_init_earlyfunction xe_ggtt_initial_clearfunction ggtt_node_finifunction ggtt_node_removefunction ggtt_node_remove_work_funcfunction xe_ggtt_node_removefunction xe_ggtt_initfunction ggtt_invalidate_gt_tlbfunction xe_ggtt_invalidatefunction xe_ggtt_shift_nodesfunction xe_ggtt_insert_node_lockedfunction xe_ggtt_node_pt_sizefunction xe_ggtt_map_bofunction xe_ggtt_map_bo_unlockedfunction __xe_ggtt_insert_bo_atfunction xe_ggtt_insert_bo_atfunction xe_ggtt_insert_bofunction xe_ggtt_remove_bofunction xe_ggtt_largest_holefunction xe_encode_vfid_ptefunction xe_ggtt_assign_lockedfunction xe_ggtt_assignfunction xe_ggtt_node_savefunction xe_ggtt_node_loadfunction xe_ggtt_dumpfunction xe_ggtt_print_holesfunction xe_ggtt_encode_pte_flagsfunction xe_ggtt_read_pte
Annotated Snippet
struct xe_ggtt_node {
/** @ggtt: Back pointer to xe_ggtt where this region will be inserted at */
struct xe_ggtt *ggtt;
/** @base: A drm_mm_node */
struct drm_mm_node base;
/** @delayed_removal_work: The work struct for the delayed removal */
struct work_struct delayed_removal_work;
/** @invalidate_on_remove: If it needs invalidation upon removal */
bool invalidate_on_remove;
};
/**
* struct xe_ggtt_pt_ops - GGTT Page table operations
* Which can vary from platform to platform.
*/
struct xe_ggtt_pt_ops {
/** @pte_encode_flags: Encode PTE flags for a given BO */
u64 (*pte_encode_flags)(struct xe_bo *bo, u16 pat_index);
/** @ggtt_set_pte: Directly write into GGTT's PTE */
xe_ggtt_set_pte_fn ggtt_set_pte;
/** @ggtt_get_pte: Directly read from GGTT's PTE */
u64 (*ggtt_get_pte)(struct xe_ggtt *ggtt, u64 addr);
};
/**
* struct xe_ggtt - Main GGTT struct
*
* In general, each tile can contains its own Global Graphics Translation Table
* (GGTT) instance.
*/
struct xe_ggtt {
/** @tile: Back pointer to tile where this GGTT belongs */
struct xe_tile *tile;
/** @start: Start offset of GGTT */
u64 start;
/** @size: Total usable size of this GGTT */
u64 size;
/**
* @flags: Flags for this GGTT
* Acceptable flags:
* - %XE_GGTT_FLAGS_64K - if PTE size is 64K. Otherwise, regular is 4K.
* - %XE_GGTT_FLAGS_ONLINE - is GGTT online, protected by ggtt->lock
* after init
*/
unsigned int flags;
/** @scratch: Internal object allocation used as a scratch page */
struct xe_bo *scratch;
/** @lock: Mutex lock to protect GGTT data */
struct mutex lock;
/**
* @gsm: The iomem pointer to the actual location of the translation
* table located in the GSM for easy PTE manipulation
*/
u64 __iomem *gsm;
/** @pt_ops: Page Table operations per platform */
const struct xe_ggtt_pt_ops *pt_ops;
/** @mm: The memory manager used to manage individual GGTT allocations */
struct drm_mm mm;
/** @access_count: counts GGTT writes */
unsigned int access_count;
/** @wq: Dedicated unordered work queue to process node removals */
struct workqueue_struct *wq;
};
static u64 xelp_ggtt_pte_flags(struct xe_bo *bo, u16 pat_index)
{
u64 pte = XE_PAGE_PRESENT;
if (xe_bo_is_vram(bo) || xe_bo_is_stolen_devmem(bo))
pte |= XE_GGTT_PTE_DM;
return pte;
}
static u64 xelpg_ggtt_pte_flags(struct xe_bo *bo, u16 pat_index)
{
struct xe_device *xe = xe_bo_device(bo);
u64 pte;
pte = xelp_ggtt_pte_flags(bo, pat_index);
xe_assert(xe, pat_index <= 3);
if (pat_index & BIT(0))
pte |= XELPG_GGTT_PTE_PAT0;
if (pat_index & BIT(1))
Annotation
- Immediate include surface: `xe_ggtt.h`, `kunit/visibility.h`, `linux/fault-inject.h`, `linux/io-64-nonatomic-lo-hi.h`, `linux/sizes.h`, `drm/drm_drv.h`, `drm/drm_managed.h`, `drm/intel/i915_drm.h`.
- Detected declarations: `struct xe_ggtt_node`, `struct xe_ggtt_pt_ops`, `struct xe_ggtt`, `function xelp_ggtt_pte_flags`, `function xelpg_ggtt_pte_flags`, `function probe_gsm_size`, `function ggtt_update_access_counter`, `function xe_ggtt_start`, `function xe_ggtt_size`, `function xe_ggtt_set_pte`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.