drivers/gpu/drm/i915/i915_vma_resource.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/i915_vma_resource.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/i915_vma_resource.c- Extension
.c- Size
- 12052 bytes
- Lines
- 426
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/interval_tree_generic.hlinux/sched/mm.hi915_sw_fence.hi915_vma_resource.hi915_drv.hintel_memory_region.hgt/intel_gtt.h
Detected Declarations
function i915_vma_resource_freefunction unbind_fence_free_rcufunction unbind_fence_releasefunction __i915_vma_resource_unholdfunction i915_vma_resource_unholdfunction i915_vma_resource_holdfunction i915_vma_resource_unbind_workfunction i915_vma_resource_fence_notifyfunction __i915_vma_resource_initfunction i915_vma_resource_color_adjust_rangefunction i915_vma_resource_bind_dep_syncfunction i915_vma_resource_bind_dep_sync_allfunction i915_vma_resource_bind_dep_awaitfunction i915_vma_resource_module_exitfunction i915_vma_resource_module_init
Annotated Snippet
if (vma_res->immediate_unbind) {
i915_vma_resource_unbind_work(&vma_res->work);
} else {
INIT_WORK(&vma_res->work, i915_vma_resource_unbind_work);
queue_work(system_dfl_wq, &vma_res->work);
}
break;
case FENCE_FREE:
i915_vma_resource_put(vma_res);
break;
}
return NOTIFY_DONE;
}
/**
* i915_vma_resource_unbind - Unbind a vma resource
* @vma_res: The vma resource to unbind.
* @tlb: pointer to vma->obj->mm.tlb associated with the resource
* to be stored at vma_res->tlb. When not-NULL, it will be used
* to do TLB cache invalidation before freeing a VMA resource.
* Used only for async unbind.
*
* At this point this function does little more than publish a fence that
* signals immediately unless signaling is held back.
*
* Return: A refcounted pointer to a dma-fence that signals when unbinding is
* complete.
*/
struct dma_fence *i915_vma_resource_unbind(struct i915_vma_resource *vma_res,
u32 *tlb)
{
struct i915_address_space *vm = vma_res->vm;
vma_res->tlb = tlb;
/* Reference for the sw fence */
i915_vma_resource_get(vma_res);
/* Caller must already have a wakeref in this case. */
if (vma_res->needs_wakeref)
vma_res->wakeref = intel_runtime_pm_get_if_in_use(&vm->i915->runtime_pm);
if (atomic_read(&vma_res->chain.pending) <= 1) {
RB_CLEAR_NODE(&vma_res->rb);
vma_res->immediate_unbind = 1;
} else {
vma_res_itree_insert(vma_res, &vma_res->vm->pending_unbind);
}
i915_sw_fence_commit(&vma_res->chain);
return &vma_res->unbind_fence;
}
/**
* __i915_vma_resource_init - Initialize a vma resource.
* @vma_res: The vma resource to initialize
*
* Initializes the private members of a vma resource.
*/
void __i915_vma_resource_init(struct i915_vma_resource *vma_res)
{
spin_lock_init(&vma_res->lock);
dma_fence_init(&vma_res->unbind_fence, &unbind_fence_ops,
&vma_res->lock, 0, 0);
refcount_set(&vma_res->hold_count, 1);
i915_sw_fence_init(&vma_res->chain, i915_vma_resource_fence_notify);
}
static void
i915_vma_resource_color_adjust_range(struct i915_address_space *vm,
u64 *start,
u64 *end)
{
if (i915_vm_has_cache_coloring(vm)) {
if (*start)
*start -= I915_GTT_PAGE_SIZE;
*end += I915_GTT_PAGE_SIZE;
}
}
/**
* i915_vma_resource_bind_dep_sync - Wait for / sync all unbinds touching a
* certain vm range.
* @vm: The vm to look at.
* @offset: The range start.
* @size: The range size.
* @intr: Whether to wait interrubtible.
*
Annotation
- Immediate include surface: `linux/interval_tree_generic.h`, `linux/sched/mm.h`, `i915_sw_fence.h`, `i915_vma_resource.h`, `i915_drv.h`, `intel_memory_region.h`, `gt/intel_gtt.h`.
- Detected declarations: `function i915_vma_resource_free`, `function unbind_fence_free_rcu`, `function unbind_fence_release`, `function __i915_vma_resource_unhold`, `function i915_vma_resource_unhold`, `function i915_vma_resource_hold`, `function i915_vma_resource_unbind_work`, `function i915_vma_resource_fence_notify`, `function __i915_vma_resource_init`, `function i915_vma_resource_color_adjust_range`.
- 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.