drivers/gpu/drm/i915/gem/i915_gem_object.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gem/i915_gem_object.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/gem/i915_gem_object.c- Extension
.c- Size
- 28867 bytes
- Lines
- 978
- 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/highmem.hlinux/sched/mm.hdrm/drm_cache.hdrm/drm_print.hdisplay/intel_frontbuffer.hpxp/intel_pxp.hi915_drv.hi915_file_private.hi915_gem_clflush.hi915_gem_context.hi915_gem_dmabuf.hi915_gem_mman.hi915_gem_object.hi915_gem_object_frontbuffer.hi915_gem_ttm.hi915_memcpy.hi915_trace.hselftests/huge_gem_object.cselftests/huge_pages.cselftests/i915_gem_migrate.cselftests/i915_gem_object.cselftests/i915_gem_coherency.c
Detected Declarations
function i915_gem_get_pat_indexfunction i915_gem_object_has_cache_levelfunction i915_gem_object_freefunction i915_gem_object_initfunction drm_gem_private_object_initfunction i915_gem_object_set_cache_coherencyfunction i915_gem_object_set_pat_indexfunction i915_gem_object_can_bypass_llcfunction i915_gem_close_objectfunction list_for_each_entry_safefunction __i915_gem_free_object_rcufunction __i915_gem_object_free_mmapsfunction rbtree_postorder_for_each_entry_safefunction __i915_gem_object_pages_finifunction __i915_gem_free_objectfunction __i915_gem_free_objectsfunction llist_for_each_entry_safefunction i915_gem_flush_free_objectsfunction __i915_gem_free_workfunction i915_gem_free_objectfunction i915_gem_object_read_from_page_kmapfunction i915_gem_object_read_from_page_iomapfunction object_has_mappable_iomemfunction i915_gem_object_read_from_pagefunction i915_gem_object_evictablefunction i915_gem_object_migratablefunction i915_gem_object_has_struct_pagefunction i915_gem_object_has_iomemfunction i915_gem_object_migratefunction i915_gem_object_migratefunction __i915_gem_object_migratefunction i915_gem_object_placement_possiblefunction i915_gem_object_needs_ccs_pagesfunction i915_gem_vmap_objectfunction i915_gem_vunmap_objectfunction i915_gem_init__objectsfunction i915_objects_module_exitfunction i915_objects_module_initfunction i915_gem_object_get_moving_fencefunction i915_gem_object_wait_moving_fencefunction i915_gem_object_has_unknown_state
Annotated Snippet
if (ctx && ctx->file_priv == fpriv) {
i915_gem_context_get(ctx);
list_move(&lut->obj_link, &close);
}
/* Break long locks, and carefully continue on from this spot */
if (&ln->obj_link != &obj->lut_list) {
list_add_tail(&bookmark.obj_link, &ln->obj_link);
if (cond_resched_lock(&obj->lut_lock))
list_safe_reset_next(&bookmark, ln, obj_link);
__list_del_entry(&bookmark.obj_link);
}
}
spin_unlock(&obj->lut_lock);
spin_lock(&obj->mmo.lock);
rbtree_postorder_for_each_entry_safe(mmo, mn, &obj->mmo.offsets, offset)
drm_vma_node_revoke(&mmo->vma_node, file);
spin_unlock(&obj->mmo.lock);
list_for_each_entry_safe(lut, ln, &close, obj_link) {
struct i915_gem_context *ctx = lut->ctx;
struct i915_vma *vma;
/*
* We allow the process to have multiple handles to the same
* vma, in the same fd namespace, by virtue of flink/open.
*/
mutex_lock(&ctx->lut_mutex);
vma = radix_tree_delete(&ctx->handles_vma, lut->handle);
if (vma) {
GEM_BUG_ON(vma->obj != obj);
GEM_BUG_ON(!atomic_read(&vma->open_count));
i915_vma_close(vma);
}
mutex_unlock(&ctx->lut_mutex);
i915_gem_context_put(lut->ctx);
i915_lut_handle_free(lut);
i915_gem_object_put(obj);
}
}
void __i915_gem_free_object_rcu(struct rcu_head *head)
{
struct drm_i915_gem_object *obj =
container_of(head, typeof(*obj), rcu);
struct drm_i915_private *i915 = to_i915(obj->base.dev);
/* We need to keep this alive for RCU read access from fdinfo. */
if (obj->mm.n_placements > 1)
kfree(obj->mm.placements);
i915_gem_object_free(obj);
GEM_BUG_ON(!atomic_read(&i915->mm.free_count));
atomic_dec(&i915->mm.free_count);
}
static void __i915_gem_object_free_mmaps(struct drm_i915_gem_object *obj)
{
/* Skip serialisation and waking the device if known to be not used. */
if (obj->userfault_count && !IS_DGFX(to_i915(obj->base.dev)))
i915_gem_object_release_mmap_gtt(obj);
if (!RB_EMPTY_ROOT(&obj->mmo.offsets)) {
struct i915_mmap_offset *mmo, *mn;
i915_gem_object_release_mmap_offset(obj);
rbtree_postorder_for_each_entry_safe(mmo, mn,
&obj->mmo.offsets,
offset) {
drm_vma_offset_remove(obj->base.dev->vma_offset_manager,
&mmo->vma_node);
kfree(mmo);
}
obj->mmo.offsets = RB_ROOT;
}
}
/**
* __i915_gem_object_pages_fini - Clean up pages use of a gem object
* @obj: The gem object to clean up
*
* This function cleans up usage of the object mm.pages member. It
* is intended for backends that need to clean up a gem object in
* separate steps and needs to be called when the object is idle before
Annotation
- Immediate include surface: `linux/highmem.h`, `linux/sched/mm.h`, `drm/drm_cache.h`, `drm/drm_print.h`, `display/intel_frontbuffer.h`, `pxp/intel_pxp.h`, `i915_drv.h`, `i915_file_private.h`.
- Detected declarations: `function i915_gem_get_pat_index`, `function i915_gem_object_has_cache_level`, `function i915_gem_object_free`, `function i915_gem_object_init`, `function drm_gem_private_object_init`, `function i915_gem_object_set_cache_coherency`, `function i915_gem_object_set_pat_index`, `function i915_gem_object_can_bypass_llc`, `function i915_gem_close_object`, `function list_for_each_entry_safe`.
- 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.