drivers/gpu/drm/i915/i915_dsb_buffer.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/i915_dsb_buffer.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/i915_dsb_buffer.c- Extension
.c- Size
- 2719 bytes
- Lines
- 118
- 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
drm/intel/display_parent_interface.hgem/i915_gem_internal.hgem/i915_gem_lmem.hi915_drv.hi915_dsb_buffer.hi915_vma.h
Detected Declarations
struct intel_dsb_bufferfunction intel_dsb_buffer_ggtt_offsetfunction intel_dsb_buffer_writefunction intel_dsb_buffer_readfunction intel_dsb_buffer_fillfunction intel_dsb_buffer_cleanupfunction intel_dsb_buffer_flush_map
Annotated Snippet
struct intel_dsb_buffer {
u32 *cmd_buf;
struct i915_vma *vma;
size_t buf_size;
};
static u32 intel_dsb_buffer_ggtt_offset(struct intel_dsb_buffer *dsb_buf)
{
return i915_ggtt_offset(dsb_buf->vma);
}
static void intel_dsb_buffer_write(struct intel_dsb_buffer *dsb_buf, u32 idx, u32 val)
{
dsb_buf->cmd_buf[idx] = val;
}
static u32 intel_dsb_buffer_read(struct intel_dsb_buffer *dsb_buf, u32 idx)
{
return dsb_buf->cmd_buf[idx];
}
static void intel_dsb_buffer_fill(struct intel_dsb_buffer *dsb_buf, u32 idx, u32 val, size_t size)
{
WARN_ON(idx > (dsb_buf->buf_size - size) / sizeof(*dsb_buf->cmd_buf));
memset(&dsb_buf->cmd_buf[idx], val, size);
}
static struct intel_dsb_buffer *intel_dsb_buffer_create(struct drm_device *drm, size_t size)
{
struct drm_i915_private *i915 = to_i915(drm);
struct intel_dsb_buffer *dsb_buf;
struct drm_i915_gem_object *obj;
struct i915_vma *vma;
u32 *buf;
int ret;
dsb_buf = kzalloc_obj(*dsb_buf);
if (!dsb_buf)
return ERR_PTR(-ENOMEM);
if (HAS_LMEM(i915)) {
obj = i915_gem_object_create_lmem(i915, PAGE_ALIGN(size),
I915_BO_ALLOC_CONTIGUOUS);
if (IS_ERR(obj)) {
ret = PTR_ERR(obj);
goto err;
}
} else {
obj = i915_gem_object_create_internal(i915, PAGE_ALIGN(size));
if (IS_ERR(obj)) {
ret = PTR_ERR(obj);
goto err;
}
i915_gem_object_set_cache_coherency(obj, I915_CACHE_NONE);
}
vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0, 0);
if (IS_ERR(vma)) {
ret = PTR_ERR(vma);
i915_gem_object_put(obj);
goto err;
}
buf = i915_gem_object_pin_map_unlocked(vma->obj, I915_MAP_WC);
if (IS_ERR(buf)) {
ret = PTR_ERR(buf);
i915_vma_unpin_and_release(&vma, I915_VMA_RELEASE_MAP);
goto err;
}
dsb_buf->vma = vma;
dsb_buf->cmd_buf = buf;
dsb_buf->buf_size = size;
return dsb_buf;
err:
kfree(dsb_buf);
return ERR_PTR(ret);
}
static void intel_dsb_buffer_cleanup(struct intel_dsb_buffer *dsb_buf)
{
i915_vma_unpin_and_release(&dsb_buf->vma, I915_VMA_RELEASE_MAP);
kfree(dsb_buf);
}
Annotation
- Immediate include surface: `drm/intel/display_parent_interface.h`, `gem/i915_gem_internal.h`, `gem/i915_gem_lmem.h`, `i915_drv.h`, `i915_dsb_buffer.h`, `i915_vma.h`.
- Detected declarations: `struct intel_dsb_buffer`, `function intel_dsb_buffer_ggtt_offset`, `function intel_dsb_buffer_write`, `function intel_dsb_buffer_read`, `function intel_dsb_buffer_fill`, `function intel_dsb_buffer_cleanup`, `function intel_dsb_buffer_flush_map`.
- 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.