drivers/gpu/drm/i915/i915_vma.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/i915_vma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/i915_vma.c- Extension
.c- Size
- 60143 bytes
- Lines
- 2335
- 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
linux/sched/mm.hlinux/dma-fence-array.hdrm/drm_gem.hdrm/drm_print.hdisplay/intel_fb.hdisplay/intel_frontbuffer.hgem/i915_gem_lmem.hgem/i915_gem_object_frontbuffer.hgem/i915_gem_tiling.hgt/intel_engine.hgt/intel_engine_heartbeat.hgt/intel_gt.hgt/intel_gt_pm.hgt/intel_gt_requests.hgt/intel_tlb.hi915_drv.hi915_gem_evict.hi915_sw_fence_work.hi915_trace.hi915_vma.hi915_vma_resource.hlinux/stackdepot.hselftests/i915_vma.c
Detected Declarations
struct i915_vma_workfunction filesfunction i915_vma_freefunction vma_print_allocatorfunction vma_print_allocatorfunction __i915_vma_activefunction __i915_vma_retirefunction vma_createfunction i915_vma_lookupfunction i915_vma_instancefunction __vma_bindfunction __vma_releasefunction i915_vma_wait_for_bindfunction i915_vma_verify_bind_completefunction i915_vma_resource_init_from_vmafunction i915_vma_bindfunction i915_vma_flush_writesfunction i915_vma_unpin_iomapfunction i915_vma_unpin_and_releasefunction i915_vma_misplacedfunction __i915_vma_set_map_and_fenceablefunction i915_gem_valid_gtt_spacefunction i915_vma_insertfunction i915_vma_detachfunction try_qad_pinfunction rotate_pagesfunction intel_rotate_pagesfunction add_padding_pagesfunction remap_tiled_color_plane_pagesfunction remap_contiguous_pagesfunction remap_linear_color_plane_pagesfunction remap_color_plane_pagesfunction intel_remap_pagesfunction intel_partial_pagesfunction __i915_vma_get_pagesfunction i915_vma_get_pagesfunction vma_invalidate_tlbfunction __vma_put_pagesfunction i915_vma_put_pagesfunction vma_unbind_pagesfunction i915_vma_pin_wwfunction i915_vma_pinfunction flush_idle_contextsfunction __i915_ggtt_pinfunction i915_ggtt_pinfunction for_i915_gem_wwfunction i915_ggtt_clear_scanoutfunction __vma_close
Annotated Snippet
struct i915_vma_work {
struct dma_fence_work base;
struct i915_address_space *vm;
struct i915_vm_pt_stash stash;
struct i915_vma_resource *vma_res;
struct drm_i915_gem_object *obj;
struct i915_sw_dma_fence_cb cb;
unsigned int pat_index;
unsigned int flags;
};
static void __vma_bind(struct dma_fence_work *work)
{
struct i915_vma_work *vw = container_of(work, typeof(*vw), base);
struct i915_vma_resource *vma_res = vw->vma_res;
/*
* We are about the bind the object, which must mean we have already
* signaled the work to potentially clear/move the pages underneath. If
* something went wrong at that stage then the object should have
* unknown_state set, in which case we need to skip the bind.
*/
if (i915_gem_object_has_unknown_state(vw->obj))
return;
vma_res->ops->bind_vma(vma_res->vm, &vw->stash,
vma_res, vw->pat_index, vw->flags);
}
static void __vma_release(struct dma_fence_work *work)
{
struct i915_vma_work *vw = container_of(work, typeof(*vw), base);
if (vw->obj)
i915_gem_object_put(vw->obj);
i915_vm_free_pt_stash(vw->vm, &vw->stash);
if (vw->vma_res)
i915_vma_resource_put(vw->vma_res);
}
static const struct dma_fence_work_ops bind_ops = {
.name = "bind",
.work = __vma_bind,
.release = __vma_release,
};
struct i915_vma_work *i915_vma_work(void)
{
struct i915_vma_work *vw;
vw = kzalloc_obj(*vw);
if (!vw)
return NULL;
dma_fence_work_init(&vw->base, &bind_ops);
vw->base.dma.error = -EAGAIN; /* disable the worker by default */
return vw;
}
int i915_vma_wait_for_bind(struct i915_vma *vma)
{
int err = 0;
if (rcu_access_pointer(vma->active.excl.fence)) {
struct dma_fence *fence;
rcu_read_lock();
fence = dma_fence_get_rcu_safe(&vma->active.excl.fence);
rcu_read_unlock();
if (fence) {
err = dma_fence_wait(fence, true);
dma_fence_put(fence);
}
}
return err;
}
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM)
static int i915_vma_verify_bind_complete(struct i915_vma *vma)
{
struct dma_fence *fence = i915_active_fence_get(&vma->active.excl);
int err;
if (!fence)
return 0;
if (dma_fence_is_signaled(fence))
Annotation
- Immediate include surface: `linux/sched/mm.h`, `linux/dma-fence-array.h`, `drm/drm_gem.h`, `drm/drm_print.h`, `display/intel_fb.h`, `display/intel_frontbuffer.h`, `gem/i915_gem_lmem.h`, `gem/i915_gem_object_frontbuffer.h`.
- Detected declarations: `struct i915_vma_work`, `function files`, `function i915_vma_free`, `function vma_print_allocator`, `function vma_print_allocator`, `function __i915_vma_active`, `function __i915_vma_retire`, `function vma_create`, `function i915_vma_lookup`, `function i915_vma_instance`.
- 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.