drivers/gpu/drm/i915/gem/i915_gem_domain.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gem/i915_gem_domain.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/gem/i915_gem_domain.c- Extension
.c- Size
- 21203 bytes
- Lines
- 771
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
gt/intel_gt.hi915_drv.hi915_gem_clflush.hi915_gem_domain.hi915_gem_gtt.hi915_gem_ioctls.hi915_gem_lmem.hi915_gem_mman.hi915_gem_object.hi915_gem_object_frontbuffer.hi915_vma.h
Detected Declarations
function gpu_write_needs_clflushfunction i915_gem_cpu_write_needs_clflushfunction flush_write_domainfunction __i915_gem_object_flush_for_displayfunction i915_gem_object_flush_if_displayfunction i915_gem_object_flush_if_display_lockedfunction i915_gem_object_set_to_wc_domainfunction i915_gem_object_set_to_gtt_domainfunction uncachedfunction i915_gem_get_caching_ioctlfunction i915_gem_set_caching_ioctlfunction planefunction i915_gem_object_set_to_cpu_domainfunction i915_gem_set_domain_ioctlfunction i915_gem_object_prepare_readfunction i915_gem_object_prepare_writefunction cachelines
Annotated Snippet
// SPDX-License-Identifier: MIT
/*
* Copyright © 2014-2016 Intel Corporation
*/
#include "gt/intel_gt.h"
#include "i915_drv.h"
#include "i915_gem_clflush.h"
#include "i915_gem_domain.h"
#include "i915_gem_gtt.h"
#include "i915_gem_ioctls.h"
#include "i915_gem_lmem.h"
#include "i915_gem_mman.h"
#include "i915_gem_object.h"
#include "i915_gem_object_frontbuffer.h"
#include "i915_vma.h"
static bool gpu_write_needs_clflush(struct drm_i915_gem_object *obj)
{
struct drm_i915_private *i915 = to_i915(obj->base.dev);
if (IS_DGFX(i915))
return false;
/*
* For objects created by userspace through GEM_CREATE with pat_index
* set by set_pat extension, i915_gem_object_has_cache_level() will
* always return true, because the coherency of such object is managed
* by userspace. Othereise the call here would fall back to checking
* whether the object is un-cached or write-through.
*/
return !(i915_gem_object_has_cache_level(obj, I915_CACHE_NONE) ||
i915_gem_object_has_cache_level(obj, I915_CACHE_WT));
}
bool i915_gem_cpu_write_needs_clflush(struct drm_i915_gem_object *obj)
{
struct drm_i915_private *i915 = to_i915(obj->base.dev);
if (obj->cache_dirty)
return false;
if (IS_DGFX(i915))
return false;
if (!(obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_WRITE))
return true;
/* Currently in use by HW (display engine)? Keep flushed. */
return i915_gem_object_is_framebuffer(obj);
}
static void
flush_write_domain(struct drm_i915_gem_object *obj, unsigned int flush_domains)
{
struct i915_vma *vma;
assert_object_held(obj);
if (!(obj->write_domain & flush_domains))
return;
switch (obj->write_domain) {
case I915_GEM_DOMAIN_GTT:
spin_lock(&obj->vma.lock);
for_each_ggtt_vma(vma, obj)
i915_vma_flush_writes(vma);
spin_unlock(&obj->vma.lock);
i915_gem_object_frontbuffer_flush(obj, ORIGIN_CPU);
break;
case I915_GEM_DOMAIN_WC:
wmb();
break;
case I915_GEM_DOMAIN_CPU:
i915_gem_clflush_object(obj, I915_CLFLUSH_SYNC);
break;
case I915_GEM_DOMAIN_RENDER:
if (gpu_write_needs_clflush(obj))
obj->cache_dirty = true;
break;
}
obj->write_domain = 0;
}
Annotation
- Immediate include surface: `gt/intel_gt.h`, `i915_drv.h`, `i915_gem_clflush.h`, `i915_gem_domain.h`, `i915_gem_gtt.h`, `i915_gem_ioctls.h`, `i915_gem_lmem.h`, `i915_gem_mman.h`.
- Detected declarations: `function gpu_write_needs_clflush`, `function i915_gem_cpu_write_needs_clflush`, `function flush_write_domain`, `function __i915_gem_object_flush_for_display`, `function i915_gem_object_flush_if_display`, `function i915_gem_object_flush_if_display_locked`, `function i915_gem_object_set_to_wc_domain`, `function i915_gem_object_set_to_gtt_domain`, `function uncached`, `function i915_gem_get_caching_ioctl`.
- 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.