drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.c- Extension
.c- Size
- 4143 bytes
- Lines
- 173
- 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
drm/intel/display_parent_interface.hi915_drv.hi915_gem_object_frontbuffer.h
Detected Declarations
function frontbuffer_activefunction frontbuffer_retirefunction i915_gem_object_frontbuffer_getfunction i915_gem_object_frontbuffer_reffunction frontbuffer_releasefunction i915_gem_object_frontbuffer_putfunction __i915_gem_object_frontbuffer_flushfunction __i915_gem_object_frontbuffer_invalidatefunction i915_frontbuffer_reffunction i915_frontbuffer_putfunction i915_frontbuffer_flush_for_display
Annotated Snippet
// SPDX-License-Identifier: MIT
/* Copyright © 2025 Intel Corporation */
#include <drm/intel/display_parent_interface.h>
#include "i915_drv.h"
#include "i915_gem_object_frontbuffer.h"
static int frontbuffer_active(struct i915_active *ref)
{
struct i915_frontbuffer *front =
container_of(ref, typeof(*front), write);
kref_get(&front->ref);
return 0;
}
static void frontbuffer_retire(struct i915_active *ref)
{
struct i915_frontbuffer *front =
container_of(ref, typeof(*front), write);
intel_frontbuffer_flush(&front->base, ORIGIN_CS);
i915_gem_object_frontbuffer_put(front);
}
struct i915_frontbuffer *
i915_gem_object_frontbuffer_get(struct drm_i915_gem_object *obj)
{
struct drm_i915_private *i915 = to_i915(obj->base.dev);
struct i915_frontbuffer *front, *cur;
front = i915_gem_object_frontbuffer_lookup(obj);
if (front)
return front;
front = kmalloc_obj(*front);
if (!front)
return NULL;
intel_frontbuffer_init(&front->base, &i915->drm);
kref_init(&front->ref);
i915_gem_object_get(obj);
front->obj = obj;
i915_active_init(&front->write,
frontbuffer_active,
frontbuffer_retire,
I915_ACTIVE_RETIRE_SLEEPS);
spin_lock(&i915->frontbuffer_lock);
if (rcu_access_pointer(obj->frontbuffer)) {
cur = rcu_dereference_protected(obj->frontbuffer, true);
kref_get(&cur->ref);
} else {
cur = front;
rcu_assign_pointer(obj->frontbuffer, front);
}
spin_unlock(&i915->frontbuffer_lock);
if (cur != front) {
i915_gem_object_put(obj);
intel_frontbuffer_fini(&front->base);
kfree(front);
}
return cur;
}
void i915_gem_object_frontbuffer_ref(struct i915_frontbuffer *front)
{
kref_get(&front->ref);
}
static void frontbuffer_release(struct kref *ref)
__releases(&i915->frontbuffer_lock)
{
struct i915_frontbuffer *front =
container_of(ref, typeof(*front), ref);
struct drm_i915_gem_object *obj = front->obj;
struct drm_i915_private *i915 = to_i915(obj->base.dev);
i915_ggtt_clear_scanout(obj);
RCU_INIT_POINTER(obj->frontbuffer, NULL);
spin_unlock(&i915->frontbuffer_lock);
i915_active_fini(&front->write);
Annotation
- Immediate include surface: `drm/intel/display_parent_interface.h`, `i915_drv.h`, `i915_gem_object_frontbuffer.h`.
- Detected declarations: `function frontbuffer_active`, `function frontbuffer_retire`, `function i915_gem_object_frontbuffer_get`, `function i915_gem_object_frontbuffer_ref`, `function frontbuffer_release`, `function i915_gem_object_frontbuffer_put`, `function __i915_gem_object_frontbuffer_flush`, `function __i915_gem_object_frontbuffer_invalidate`, `function i915_frontbuffer_ref`, `function i915_frontbuffer_put`.
- 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.