drivers/gpu/drm/i915/i915_bo.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/i915_bo.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/i915_bo.c- Extension
.c- Size
- 7227 bytes
- Lines
- 271
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fb.hdrm/drm_panic.hdrm/drm_print.hdrm/intel/display_parent_interface.hdisplay/intel_fb.hgem/i915_gem_lmem.hgem/i915_gem_mman.hgem/i915_gem_object.hgem/i915_gem_object_frontbuffer.hpxp/intel_pxp.hi915_bo.hi915_debugfs.hi915_drv.h
Detected Declarations
function i915_bo_is_tiledfunction i915_bo_is_userptrfunction i915_bo_is_shmemfunction i915_bo_is_protectedfunction i915_bo_key_checkfunction i915_bo_fb_mmapfunction i915_bo_read_from_pagefunction i915_bo_describefunction i915_bo_framebuffer_initfunction i915_bo_framebuffer_finifunction i915_bo_fbdev_pitch_alignfunction i915_bo_fbdev_prefer_stolenfunction i915_bo_fbdev_destroyfunction i915_bo_fbdev_fill_infofunction for_i915_gem_ww
Annotated Snippet
if (tiling == I915_TILING_X) {
mode_cmd->modifier[0] = I915_FORMAT_MOD_X_TILED;
} else if (tiling == I915_TILING_Y) {
drm_dbg_kms(&i915->drm,
"No Y tiling for legacy addfb\n");
return -EINVAL;
}
}
/*
* gen2/3 display engine uses the fence if present,
* so the tiling mode must match the fb modifier exactly.
*/
if (GRAPHICS_VER(i915) < 4 &&
tiling != intel_fb_modifier_to_tiling(mode_cmd->modifier[0])) {
drm_dbg_kms(&i915->drm,
"tiling_mode must match fb modifier exactly on gen2/3\n");
return -EINVAL;
}
/*
* If there's a fence, enforce that
* the fb pitch and fence stride match.
*/
if (tiling != I915_TILING_NONE && mode_cmd->pitches[0] != stride) {
drm_dbg_kms(&i915->drm,
"pitch (%d) must match tiling stride (%d)\n",
mode_cmd->pitches[0], stride);
return -EINVAL;
}
return 0;
}
static void i915_bo_framebuffer_fini(struct drm_gem_object *obj)
{
/* Nothing to do for i915 */
}
static struct drm_gem_object *
i915_bo_framebuffer_lookup(struct drm_device *drm,
struct drm_file *filp,
const struct drm_mode_fb_cmd2 *mode_cmd)
{
struct drm_i915_private *i915 = to_i915(drm);
struct drm_i915_gem_object *obj;
obj = i915_gem_object_lookup(filp, mode_cmd->handles[0]);
if (!obj)
return ERR_PTR(-ENOENT);
/* object is backed with LMEM for discrete */
if (HAS_LMEM(i915) && !i915_gem_object_can_migrate(obj, INTEL_REGION_LMEM_0)) {
/* object is "remote", not in local memory */
i915_gem_object_put(obj);
drm_dbg_kms(&i915->drm, "framebuffer must reside in local memory\n");
return ERR_PTR(-EREMOTE);
}
return intel_bo_to_drm_bo(obj);
}
#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
static u32 i915_bo_fbdev_pitch_align(u32 stride)
{
return ALIGN(stride, 64);
}
bool i915_bo_fbdev_prefer_stolen(struct drm_i915_private *i915, unsigned int size)
{
/* Skip stolen on MTL as Wa_22018444074 mitigation. */
if (IS_METEORLAKE(i915))
return false;
/*
* If the FB is too big, just don't use it since fbdev is not very
* important and we should probably use that space with FBC or other
* features.
*/
return i915->dsm.usable_size >= size * 2;
}
static struct drm_gem_object *i915_bo_fbdev_create(struct drm_device *drm, int size)
{
struct drm_i915_private *i915 = to_i915(drm);
struct drm_i915_gem_object *obj;
obj = ERR_PTR(-ENODEV);
if (HAS_LMEM(i915)) {
obj = i915_gem_object_create_lmem(i915, size,
Annotation
- Immediate include surface: `linux/fb.h`, `drm/drm_panic.h`, `drm/drm_print.h`, `drm/intel/display_parent_interface.h`, `display/intel_fb.h`, `gem/i915_gem_lmem.h`, `gem/i915_gem_mman.h`, `gem/i915_gem_object.h`.
- Detected declarations: `function i915_bo_is_tiled`, `function i915_bo_is_userptr`, `function i915_bo_is_shmem`, `function i915_bo_is_protected`, `function i915_bo_key_check`, `function i915_bo_fb_mmap`, `function i915_bo_read_from_page`, `function i915_bo_describe`, `function i915_bo_framebuffer_init`, `function i915_bo_framebuffer_fini`.
- 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.