drivers/gpu/drm/i915/gem/i915_gem_stolen.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/gem/i915_gem_stolen.c- Extension
.c- Size
- 29623 bytes
- Lines
- 1105
- 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.
- 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/errno.hlinux/mutex.hdrm/drm_mm.hdrm/drm_print.hdrm/intel/display_parent_interface.hdrm/intel/i915_drm.hdrm/intel/mchbar_regs.hdrm/intel/pci_config.hgem/i915_gem_lmem.hgem/i915_gem_region.hgt/intel_gt.hgt/intel_gt_mcr.hgt/intel_gt_regs.hgt/intel_region_lmem.hi915_drv.hi915_gem_stolen.hi915_pci.hi915_reg.hi915_utils.hi915_vgpu.h
Detected Declarations
struct intel_stolen_nodefunction __i915_gem_stolen_insert_node_in_rangefunction i915_gem_stolen_insert_node_in_rangefunction __i915_gem_stolen_insert_nodefunction i915_gem_stolen_insert_nodefunction __i915_gem_stolen_remove_nodefunction i915_gem_stolen_remove_nodefunction valid_stolen_sizefunction adjust_stolenfunction request_smem_stolenfunction i915_gem_cleanup_stolenfunction g4x_get_stolen_reservedfunction gen6_get_stolen_reservedfunction vlv_get_stolen_reservedfunction gen7_get_stolen_reservedfunction chv_get_stolen_reservedfunction bdw_get_stolen_reservedfunction icl_get_stolen_reservedfunction init_reserved_stolenfunction i915_gem_init_stolenfunction dbg_poisonfunction i915_pages_create_for_stolenfunction i915_gem_object_get_pages_stolenfunction i915_gem_object_put_pages_stolenfunction i915_gem_object_release_stolenfunction __i915_gem_object_create_stolenfunction _i915_gem_object_stolen_initfunction i915_gem_object_create_stolenfunction init_stolen_smemfunction release_stolen_smemfunction init_stolen_lmemfunction release_stolen_lmemfunction mtl_get_gms_sizefunction i915_gem_stolen_lmem_setupfunction i915_gem_stolen_smem_setupfunction i915_gem_object_is_stolenfunction i915_gem_stolen_initializedfunction i915_gem_stolen_area_addressfunction i915_gem_stolen_area_sizefunction i915_gem_stolen_node_offsetfunction i915_gem_stolen_node_addressfunction i915_gem_stolen_node_allocatedfunction i915_gem_stolen_node_sizefunction i915_gem_stolen_node_free
Annotated Snippet
struct intel_stolen_node {
struct drm_i915_private *i915;
struct drm_mm_node node;
};
/*
* The BIOS typically reserves some of the system's memory for the exclusive
* use of the integrated graphics. This memory is no longer available for
* use by the OS and so the user finds that his system has less memory
* available than he put in. We refer to this memory as stolen.
*
* The BIOS will allocate its framebuffer from the stolen memory. Our
* goal is try to reuse that object for our own fbcon which must always
* be available for panics. Anything else we can reuse the stolen memory
* for is a boon.
*/
static int __i915_gem_stolen_insert_node_in_range(struct drm_i915_private *i915,
struct drm_mm_node *node, u64 size,
unsigned int alignment, u64 start, u64 end)
{
int ret;
if (!drm_mm_initialized(&i915->mm.stolen))
return -ENODEV;
/* WaSkipStolenMemoryFirstPage:bdw+ */
if (GRAPHICS_VER(i915) >= 8 && start < 4096)
start = 4096;
mutex_lock(&i915->mm.stolen_lock);
ret = drm_mm_insert_node_in_range(&i915->mm.stolen, node,
size, alignment, 0,
start, end, DRM_MM_INSERT_BEST);
mutex_unlock(&i915->mm.stolen_lock);
return ret;
}
static int i915_gem_stolen_insert_node_in_range(struct intel_stolen_node *node, u64 size,
unsigned int alignment, u64 start, u64 end)
{
return __i915_gem_stolen_insert_node_in_range(node->i915, &node->node,
size, alignment,
start, end);
}
static int __i915_gem_stolen_insert_node(struct drm_i915_private *i915,
struct drm_mm_node *node, u64 size,
unsigned int alignment)
{
return __i915_gem_stolen_insert_node_in_range(i915, node,
size, alignment,
I915_GEM_STOLEN_BIAS,
U64_MAX);
}
static int i915_gem_stolen_insert_node(struct intel_stolen_node *node, u64 size,
unsigned int alignment)
{
return __i915_gem_stolen_insert_node(node->i915, &node->node, size, alignment);
}
static void __i915_gem_stolen_remove_node(struct drm_i915_private *i915,
struct drm_mm_node *node)
{
mutex_lock(&i915->mm.stolen_lock);
drm_mm_remove_node(node);
mutex_unlock(&i915->mm.stolen_lock);
}
static void i915_gem_stolen_remove_node(struct intel_stolen_node *node)
{
__i915_gem_stolen_remove_node(node->i915, &node->node);
}
static bool valid_stolen_size(struct drm_i915_private *i915, struct resource *dsm)
{
return (dsm->start != 0 || HAS_LMEMBAR_SMEM_STOLEN(i915)) && dsm->end > dsm->start;
}
static int adjust_stolen(struct drm_i915_private *i915,
struct resource *dsm)
{
struct i915_ggtt *ggtt = to_gt(i915)->ggtt;
struct intel_uncore *uncore = ggtt->vm.gt->uncore;
if (!valid_stolen_size(i915, dsm))
return -EINVAL;
Annotation
- Immediate include surface: `linux/errno.h`, `linux/mutex.h`, `drm/drm_mm.h`, `drm/drm_print.h`, `drm/intel/display_parent_interface.h`, `drm/intel/i915_drm.h`, `drm/intel/mchbar_regs.h`, `drm/intel/pci_config.h`.
- Detected declarations: `struct intel_stolen_node`, `function __i915_gem_stolen_insert_node_in_range`, `function i915_gem_stolen_insert_node_in_range`, `function __i915_gem_stolen_insert_node`, `function i915_gem_stolen_insert_node`, `function __i915_gem_stolen_remove_node`, `function i915_gem_stolen_remove_node`, `function valid_stolen_size`, `function adjust_stolen`, `function request_smem_stolen`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source 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.