drivers/gpu/drm/xe/xe_mmio_gem.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_mmio_gem.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_mmio_gem.c- Extension
.c- Size
- 6050 bytes
- Lines
- 227
- 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.
- 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
xe_mmio_gem.hdrm/drm_drv.hdrm/drm_gem.hdrm/drm_managed.hxe_device_types.h
Detected Declarations
struct xe_mmio_gemfunction xe_mmio_gem_createfunction xe_mmio_gem_freefunction xe_mmio_gem_createfunction xe_mmio_gem_mmapfunction xe_mmio_gem_release_dummy_pagefunction xe_mmio_gem_vm_fault_dummy_pagefunction xe_mmio_gem_vm_fault
Annotated Snippet
struct xe_mmio_gem {
struct drm_gem_object base;
phys_addr_t phys_addr;
};
static const struct vm_operations_struct vm_ops = {
.open = drm_gem_vm_open,
.close = drm_gem_vm_close,
.fault = xe_mmio_gem_vm_fault,
};
static const struct drm_gem_object_funcs xe_mmio_gem_funcs = {
.free = xe_mmio_gem_free,
.mmap = xe_mmio_gem_mmap,
.vm_ops = &vm_ops,
};
static inline struct xe_mmio_gem *to_xe_mmio_gem(struct drm_gem_object *obj)
{
return container_of(obj, struct xe_mmio_gem, base);
}
/**
* xe_mmio_gem_create - Expose an MMIO region to userspace
* @xe: The xe device
* @file: DRM file descriptor
* @phys_addr: Start of the exposed MMIO region
* @size: The size of the exposed MMIO region
*
* This function creates a GEM object that exposes an MMIO region with an mmap-able
* fake offset.
*
* See: "Exposing MMIO regions to userspace"
*/
struct xe_mmio_gem *xe_mmio_gem_create(struct xe_device *xe, struct drm_file *file,
phys_addr_t phys_addr, size_t size)
{
struct xe_mmio_gem *obj;
struct drm_gem_object *base;
int err;
if ((phys_addr % PAGE_SIZE != 0) || (size % PAGE_SIZE != 0))
return ERR_PTR(-EINVAL);
obj = kzalloc_obj(*obj);
if (!obj)
return ERR_PTR(-ENOMEM);
base = &obj->base;
base->funcs = &xe_mmio_gem_funcs;
obj->phys_addr = phys_addr;
drm_gem_private_object_init(&xe->drm, base, size);
err = drm_gem_create_mmap_offset(base);
if (err)
goto free_gem;
err = drm_vma_node_allow(&base->vma_node, file);
if (err)
goto free_gem;
return obj;
free_gem:
xe_mmio_gem_free(base);
return ERR_PTR(err);
}
/**
* xe_mmio_gem_mmap_offset - Return the mmap-able fake offset
* @gem: the GEM object created with xe_mmio_gem_create()
*
* This function returns the mmap-able fake offset allocated during
* xe_mmio_gem_create().
*
* See: "Exposing MMIO regions to userspace"
*/
u64 xe_mmio_gem_mmap_offset(struct xe_mmio_gem *gem)
{
return drm_vma_node_offset_addr(&gem->base.vma_node);
}
static void xe_mmio_gem_free(struct drm_gem_object *base)
{
struct xe_mmio_gem *obj = to_xe_mmio_gem(base);
drm_gem_object_release(base);
kfree(obj);
}
Annotation
- Immediate include surface: `xe_mmio_gem.h`, `drm/drm_drv.h`, `drm/drm_gem.h`, `drm/drm_managed.h`, `xe_device_types.h`.
- Detected declarations: `struct xe_mmio_gem`, `function xe_mmio_gem_create`, `function xe_mmio_gem_free`, `function xe_mmio_gem_create`, `function xe_mmio_gem_mmap`, `function xe_mmio_gem_release_dummy_page`, `function xe_mmio_gem_vm_fault_dummy_page`, `function xe_mmio_gem_vm_fault`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
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.