drivers/gpu/drm/i915/gem/selftests/i915_gem_coherency.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gem/selftests/i915_gem_coherency.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/gem/selftests/i915_gem_coherency.c- Extension
.c- Size
- 9890 bytes
- Lines
- 435
- 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
linux/prime_numbers.hgt/intel_engine_pm.hgt/intel_gpu_commands.hgt/intel_gt.hgt/intel_gt_pm.hgt/intel_ring.hi915_selftest.hselftests/i915_random.h
Detected Declarations
struct contextfunction cpu_setfunction cpu_getfunction gtt_setfunction gtt_getfunction wc_setfunction wc_getfunction gpu_setfunction always_validfunction needs_fence_registersfunction needs_mi_store_dwordfunction random_enginefunction igt_gem_coherencyfunction for_each_prime_number_fromfunction i915_gem_coherency_live_selftests
Annotated Snippet
struct context {
struct drm_i915_gem_object *obj;
struct intel_engine_cs *engine;
};
static int cpu_set(struct context *ctx, unsigned long offset, u32 v)
{
unsigned int needs_clflush;
struct page *page;
u32 *cpu;
int err;
i915_gem_object_lock(ctx->obj, NULL);
err = i915_gem_object_prepare_write(ctx->obj, &needs_clflush);
if (err)
goto out;
page = i915_gem_object_get_page(ctx->obj, offset >> PAGE_SHIFT);
cpu = kmap_local_page(page) + offset_in_page(offset);
if (needs_clflush & CLFLUSH_BEFORE)
drm_clflush_virt_range(cpu, sizeof(*cpu));
*cpu = v;
if (needs_clflush & CLFLUSH_AFTER)
drm_clflush_virt_range(cpu, sizeof(*cpu));
kunmap_local(cpu);
i915_gem_object_finish_access(ctx->obj);
out:
i915_gem_object_unlock(ctx->obj);
return err;
}
static int cpu_get(struct context *ctx, unsigned long offset, u32 *v)
{
unsigned int needs_clflush;
struct page *page;
u32 *cpu;
int err;
i915_gem_object_lock(ctx->obj, NULL);
err = i915_gem_object_prepare_read(ctx->obj, &needs_clflush);
if (err)
goto out;
page = i915_gem_object_get_page(ctx->obj, offset >> PAGE_SHIFT);
cpu = kmap_local_page(page) + offset_in_page(offset);
if (needs_clflush & CLFLUSH_BEFORE)
drm_clflush_virt_range(cpu, sizeof(*cpu));
*v = *cpu;
kunmap_local(cpu);
i915_gem_object_finish_access(ctx->obj);
out:
i915_gem_object_unlock(ctx->obj);
return err;
}
static int gtt_set(struct context *ctx, unsigned long offset, u32 v)
{
intel_wakeref_t wakeref;
struct i915_vma *vma;
u32 __iomem *map;
int err = 0;
i915_gem_object_lock(ctx->obj, NULL);
err = i915_gem_object_set_to_gtt_domain(ctx->obj, true);
i915_gem_object_unlock(ctx->obj);
if (err)
return err;
vma = i915_gem_object_ggtt_pin(ctx->obj, NULL, 0, 0, PIN_MAPPABLE);
if (IS_ERR(vma))
return PTR_ERR(vma);
wakeref = intel_gt_pm_get(vma->vm->gt);
map = i915_vma_pin_iomap(vma);
i915_vma_unpin(vma);
if (IS_ERR(map)) {
err = PTR_ERR(map);
goto out_rpm;
}
Annotation
- Immediate include surface: `linux/prime_numbers.h`, `gt/intel_engine_pm.h`, `gt/intel_gpu_commands.h`, `gt/intel_gt.h`, `gt/intel_gt_pm.h`, `gt/intel_ring.h`, `i915_selftest.h`, `selftests/i915_random.h`.
- Detected declarations: `struct context`, `function cpu_set`, `function cpu_get`, `function gtt_set`, `function gtt_get`, `function wc_set`, `function wc_get`, `function gpu_set`, `function always_valid`, `function needs_fence_registers`.
- 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.