drivers/gpu/drm/i915/gem/i915_gem_mman.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gem/i915_gem_mman.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/gem/i915_gem_mman.c- Extension
.c- Size
- 31119 bytes
- Lines
- 1157
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/anon_inodes.hlinux/mman.hlinux/sizes.hdrm/drm_cache.hgt/intel_gt.hgt/intel_gt_requests.hi915_drv.hi915_gem_evict.hi915_gem_gtt.hi915_gem_ioctls.hi915_gem_mman.hi915_gem_object.hi915_gem_ttm.hi915_jiffies.hi915_mm.hi915_trace.hi915_user_extensions.hi915_vma.hselftests/i915_gem_mman.c
Detected Declarations
function __vma_matchesfunction ioctlfunction tile_row_pagesfunction storagefunction compute_partial_viewfunction i915_error_to_vmf_faultfunction vm_fault_cpufunction set_address_limitsfunction vm_fault_gttfunction i915_gem_object_has_cache_levelfunction vm_accessfunction __i915_gem_object_release_mmap_gttfunction vm_fault_gttfunction i915_gem_object_runtime_pm_release_mmap_offsetfunction i915_gem_object_release_mmap_offsetfunction lookup_mmofunction insert_mmofunction mmap_offset_attachfunction __assign_mmap_offsetfunction __assign_mmap_offset_handlefunction i915_gem_dumb_mmap_offsetfunction drm_gem_mmapfunction vm_openfunction vm_closefunction singleton_releasefunction i915_gem_object_mmapfunction i915_gem_mmapfunction i915_gem_fb_mmap
Annotated Snippet
static const struct file_operations singleton_fops = {
.owner = THIS_MODULE,
.release = singleton_release,
};
static struct file *mmap_singleton(struct drm_i915_private *i915)
{
struct file *file;
file = get_file_active(&i915->gem.mmap_singleton);
if (file)
return file;
file = anon_inode_getfile("i915.gem", &singleton_fops, i915, O_RDWR);
if (IS_ERR(file))
return file;
/* Everyone shares a single global address space */
file->f_mapping = i915->drm.anon_inode->i_mapping;
smp_store_mb(i915->gem.mmap_singleton, file);
drm_dev_get(&i915->drm);
return file;
}
static int
i915_gem_object_mmap(struct drm_i915_gem_object *obj,
struct i915_mmap_offset *mmo,
struct vm_area_struct *vma)
{
struct drm_i915_private *i915 = to_i915(obj->base.dev);
struct drm_device *dev = &i915->drm;
struct file *anon;
if (i915_gem_object_is_readonly(obj)) {
if (vma->vm_flags & VM_WRITE) {
i915_gem_object_put(obj);
return -EINVAL;
}
vm_flags_clear(vma, VM_MAYWRITE);
}
anon = mmap_singleton(to_i915(dev));
if (IS_ERR(anon)) {
i915_gem_object_put(obj);
return PTR_ERR(anon);
}
vm_flags_set(vma, VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP | VM_IO);
/*
* We keep the ref on mmo->obj, not vm_file, but we require
* vma->vm_file->f_mapping, see vma_link(), for later revocation.
* Our userspace is accustomed to having per-file resource cleanup
* (i.e. contexts, objects and requests) on their close(fd), which
* requires avoiding extraneous references to their filp, hence why
* we prefer to use an anonymous file for their mmaps.
*/
vma_set_file(vma, anon);
/* Drop the initial creation reference, the vma is now holding one. */
fput(anon);
if (obj->ops->mmap_ops) {
vma->vm_page_prot = pgprot_decrypted(vm_get_page_prot(vma->vm_flags));
vma->vm_ops = obj->ops->mmap_ops;
vma->vm_private_data = obj->base.vma_node.driver_private;
return 0;
}
vma->vm_private_data = mmo;
switch (mmo->mmap_type) {
case I915_MMAP_TYPE_WC:
vma->vm_page_prot =
pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
vma->vm_ops = &vm_ops_cpu;
break;
case I915_MMAP_TYPE_FIXED:
GEM_WARN_ON(1);
fallthrough;
case I915_MMAP_TYPE_WB:
vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
vma->vm_ops = &vm_ops_cpu;
break;
case I915_MMAP_TYPE_UC:
vma->vm_page_prot =
pgprot_noncached(vm_get_page_prot(vma->vm_flags));
Annotation
- Immediate include surface: `linux/anon_inodes.h`, `linux/mman.h`, `linux/sizes.h`, `drm/drm_cache.h`, `gt/intel_gt.h`, `gt/intel_gt_requests.h`, `i915_drv.h`, `i915_gem_evict.h`.
- Detected declarations: `function __vma_matches`, `function ioctl`, `function tile_row_pages`, `function storage`, `function compute_partial_view`, `function i915_error_to_vmf_fault`, `function vm_fault_cpu`, `function set_address_limits`, `function vm_fault_gtt`, `function i915_gem_object_has_cache_level`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: pattern 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.