drivers/gpu/drm/xe/xe_bo_evict.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_bo_evict.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_bo_evict.c- Extension
.c- Size
- 9199 bytes
- Lines
- 353
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
xe_bo_evict.hxe_bo.hxe_device.hxe_ggtt.hxe_tile.h
Detected Declarations
function xe_bo_apply_to_pinnedfunction xe_bo_notifier_prepare_all_pinnedfunction xe_bo_notifier_unprepare_all_pinnedfunction xe_bo_evict_all_userfunction xe_bo_evict_allfunction xe_bo_restore_and_map_ggttfunction for_each_tilefunction temporaryfunction xe_bo_restore_latefunction xe_bo_pci_dev_remove_pinnedfunction xe_bo_pci_dev_remove_allfunction xe_bo_pinned_finifunction xe_bo_pinned_init
Annotated Snippet
if (ret && pinned_list != new_list) {
spin_lock(&xe->pinned.lock);
/*
* We might no longer be pinned, since PM notifier can
* call this. If the pinned link is now empty, keep it
* that way.
*/
if (!list_empty(&bo->pinned_link))
list_move(&bo->pinned_link, pinned_list);
spin_unlock(&xe->pinned.lock);
}
xe_bo_put(bo);
spin_lock(&xe->pinned.lock);
}
list_splice_tail(&still_in_list, new_list);
spin_unlock(&xe->pinned.lock);
return ret;
}
/**
* xe_bo_notifier_prepare_all_pinned() - Pre-allocate the backing pages for all
* pinned VRAM objects which need to be saved.
* @xe: xe device
*
* Should be called from PM notifier when preparing for s3/s4.
*
* Return: 0 on success, negative error code on error.
*/
int xe_bo_notifier_prepare_all_pinned(struct xe_device *xe)
{
int ret;
ret = xe_bo_apply_to_pinned(xe, &xe->pinned.early.kernel_bo_present,
&xe->pinned.early.kernel_bo_present,
xe_bo_notifier_prepare_pinned);
if (!ret)
ret = xe_bo_apply_to_pinned(xe, &xe->pinned.late.kernel_bo_present,
&xe->pinned.late.kernel_bo_present,
xe_bo_notifier_prepare_pinned);
if (!ret)
ret = xe_bo_apply_to_pinned(xe, &xe->pinned.late.external,
&xe->pinned.late.external,
xe_bo_notifier_prepare_pinned);
return ret;
}
/**
* xe_bo_notifier_unprepare_all_pinned() - Remove the backing pages for all
* pinned VRAM objects which have been restored.
* @xe: xe device
*
* Should be called from PM notifier after exiting s3/s4 (either on success or
* failure).
*/
void xe_bo_notifier_unprepare_all_pinned(struct xe_device *xe)
{
(void)xe_bo_apply_to_pinned(xe, &xe->pinned.early.kernel_bo_present,
&xe->pinned.early.kernel_bo_present,
xe_bo_notifier_unprepare_pinned);
(void)xe_bo_apply_to_pinned(xe, &xe->pinned.late.kernel_bo_present,
&xe->pinned.late.kernel_bo_present,
xe_bo_notifier_unprepare_pinned);
(void)xe_bo_apply_to_pinned(xe, &xe->pinned.late.external,
&xe->pinned.late.external,
xe_bo_notifier_unprepare_pinned);
}
/**
* xe_bo_evict_all_user - evict all non-pinned user BOs from VRAM
* @xe: xe device
*
* Evict non-pinned user BOs (via GPU).
*
* Evict == move VRAM BOs to temporary (typically system) memory.
*/
int xe_bo_evict_all_user(struct xe_device *xe)
{
struct ttm_device *bdev = &xe->ttm;
u32 mem_type;
int ret;
/* User memory */
for (mem_type = XE_PL_TT; mem_type <= XE_PL_VRAM1; ++mem_type) {
struct ttm_resource_manager *man =
ttm_manager_type(bdev, mem_type);
Annotation
- Immediate include surface: `xe_bo_evict.h`, `xe_bo.h`, `xe_device.h`, `xe_ggtt.h`, `xe_tile.h`.
- Detected declarations: `function xe_bo_apply_to_pinned`, `function xe_bo_notifier_prepare_all_pinned`, `function xe_bo_notifier_unprepare_all_pinned`, `function xe_bo_evict_all_user`, `function xe_bo_evict_all`, `function xe_bo_restore_and_map_ggtt`, `function for_each_tile`, `function temporary`, `function xe_bo_restore_late`, `function xe_bo_pci_dev_remove_pinned`.
- 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.
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.