drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c- Extension
.c- Size
- 95736 bytes
- Lines
- 3643
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/dma-resv.hlinux/highmem.hlinux/sync_file.hlinux/uaccess.hdrm/drm_auth.hdrm/drm_print.hdrm/drm_syncobj.hgem/i915_gem_ioctls.hgt/intel_context.hgt/intel_gpu_commands.hgt/intel_gt.hgt/intel_gt_buffer_pool.hgt/intel_gt_pm.hgt/intel_ring.hpxp/intel_pxp.hi915_cmd_parser.hi915_drv.hi915_file_private.hi915_gem_clflush.hi915_gem_context.hi915_gem_evict.hi915_gem_ioctls.hi915_reg.hi915_trace.hi915_user_extensions.h
Detected Declarations
struct eb_vmastruct eb_fencestruct i915_execbufferstruct reloc_cachefunction eb_use_cmdparserfunction eb_createfunction eb_vma_misplacedfunction eb_pin_flagsfunction eb_pin_vmafunction eb_unreserve_vmafunction eb_validate_vmafunction is_batch_bufferfunction eb_add_vmafunction use_cpu_relocfunction eb_reserve_vmafunction eb_unbindfunction eb_reservefunction list_for_each_entryfunction eb_select_contextfunction __eb_add_lutfunction eb_lookup_vmasfunction eb_lock_vmasfunction eb_validate_vmasfunction eb_get_vmafunction hlist_for_each_entryfunction eb_release_vmasfunction eb_destroyfunction relocation_targetfunction reloc_cache_initfunction unmask_flagsfunction reloc_cache_unmapfunction reloc_cache_remapfunction reloc_cache_resetfunction clflush_write32function relocate_entryfunction eb_relocate_entryfunction eb_relocate_vmafunction eb_relocate_vma_slowfunction check_relocationsfunction eb_copy_relocationsfunction eb_prefault_relocationsfunction eb_reinit_userptrfunction eb_relocate_parse_slowfunction interruptedfunction list_for_each_entryfunction eb_relocate_parsefunction list_for_each_entryfunction eb_find_first_request_added
Annotated Snippet
struct eb_vma {
struct i915_vma *vma;
unsigned int flags;
/** This vma's place in the execbuf reservation list */
struct drm_i915_gem_exec_object2 *exec;
struct list_head bind_link;
struct list_head reloc_link;
struct hlist_node node;
u32 handle;
};
enum {
FORCE_CPU_RELOC = 1,
FORCE_GTT_RELOC,
FORCE_GPU_RELOC,
#define DBG_FORCE_RELOC 0 /* choose one of the above! */
};
/* __EXEC_OBJECT_ flags > BIT(29) defined in i915_vma.h */
#define __EXEC_OBJECT_HAS_PIN BIT(29)
#define __EXEC_OBJECT_HAS_FENCE BIT(28)
#define __EXEC_OBJECT_USERPTR_INIT BIT(27)
#define __EXEC_OBJECT_NEEDS_MAP BIT(26)
#define __EXEC_OBJECT_NEEDS_BIAS BIT(25)
#define __EXEC_OBJECT_INTERNAL_FLAGS (~0u << 25) /* all of the above + */
#define __EXEC_OBJECT_RESERVED (__EXEC_OBJECT_HAS_PIN | __EXEC_OBJECT_HAS_FENCE)
#define __EXEC_HAS_RELOC BIT(31)
#define __EXEC_ENGINE_PINNED BIT(30)
#define __EXEC_USERPTR_USED BIT(29)
#define __EXEC_INTERNAL_FLAGS (~0u << 29)
#define UPDATE PIN_OFFSET_FIXED
#define BATCH_OFFSET_BIAS (256*1024)
#define __I915_EXEC_ILLEGAL_FLAGS \
(__I915_EXEC_UNKNOWN_FLAGS | \
I915_EXEC_CONSTANTS_MASK | \
I915_EXEC_RESOURCE_STREAMER)
/* Catch emission of unexpected errors for CI! */
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM)
#undef EINVAL
#define EINVAL ({ \
DRM_DEBUG_DRIVER("EINVAL at %s:%d\n", __func__, __LINE__); \
22; \
})
#endif
/**
* DOC: User command execution
*
* Userspace submits commands to be executed on the GPU as an instruction
* stream within a GEM object we call a batchbuffer. This instructions may
* refer to other GEM objects containing auxiliary state such as kernels,
* samplers, render targets and even secondary batchbuffers. Userspace does
* not know where in the GPU memory these objects reside and so before the
* batchbuffer is passed to the GPU for execution, those addresses in the
* batchbuffer and auxiliary objects are updated. This is known as relocation,
* or patching. To try and avoid having to relocate each object on the next
* execution, userspace is told the location of those objects in this pass,
* but this remains just a hint as the kernel may choose a new location for
* any object in the future.
*
* At the level of talking to the hardware, submitting a batchbuffer for the
* GPU to execute is to add content to a buffer from which the HW
* command streamer is reading.
*
* 1. Add a command to load the HW context. For Logical Ring Contexts, i.e.
* Execlists, this command is not placed on the same buffer as the
* remaining items.
*
* 2. Add a command to invalidate caches to the buffer.
*
* 3. Add a batchbuffer start command to the buffer; the start command is
* essentially a token together with the GPU address of the batchbuffer
* to be executed.
*
* 4. Add a pipeline flush to the buffer.
*
* 5. Add a memory write command to the buffer to record when the GPU
* is done executing the batchbuffer. The memory write writes the
* global sequence number of the request, ``i915_request::global_seqno``;
* the i915 driver uses the current value in the register to determine
* if the GPU has completed the batchbuffer.
*
* 6. Add a user interrupt command to the buffer. This command instructs
* the GPU to issue an interrupt when the command, pipeline flush and
Annotation
- Immediate include surface: `linux/dma-resv.h`, `linux/highmem.h`, `linux/sync_file.h`, `linux/uaccess.h`, `drm/drm_auth.h`, `drm/drm_print.h`, `drm/drm_syncobj.h`, `gem/i915_gem_ioctls.h`.
- Detected declarations: `struct eb_vma`, `struct eb_fence`, `struct i915_execbuffer`, `struct reloc_cache`, `function eb_use_cmdparser`, `function eb_create`, `function eb_vma_misplaced`, `function eb_pin_flags`, `function eb_pin_vma`, `function eb_unreserve_vma`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.