drivers/gpu/drm/i915/selftests/i915_gem.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/selftests/i915_gem.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/selftests/i915_gem.c- Extension
.c- Size
- 5553 bytes
- Lines
- 263
- 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
linux/prandom.hgem/i915_gem_internal.hgem/i915_gem_pm.hgem/selftests/igt_gem_utils.hgem/selftests/mock_context.hgt/intel_gt.hgt/intel_gt_pm.hi915_selftest.higt_flush_test.hmock_drm.h
Detected Declarations
function switch_to_contextfunction for_each_gem_enginefunction trash_stolenfunction simulate_hibernatefunction igt_pm_preparefunction igt_pm_suspendfunction with_intel_runtime_pmfunction igt_pm_hibernatefunction with_intel_runtime_pmfunction igt_pm_resumefunction igt_gem_suspendfunction igt_gem_hibernatefunction igt_gem_ww_ctxfunction i915_gem_live_selftests
Annotated Snippet
if (IS_ERR(rq)) {
err = PTR_ERR(rq);
break;
}
i915_request_add(rq);
}
i915_gem_context_unlock_engines(ctx);
return err;
}
static void trash_stolen(struct drm_i915_private *i915)
{
struct i915_ggtt *ggtt = to_gt(i915)->ggtt;
const u64 slot = ggtt->error_capture.start;
const resource_size_t size = resource_size(&i915->dsm.stolen);
struct rnd_state prng;
unsigned long page;
/* XXX: fsck. needs some more thought... */
if (!i915_ggtt_has_aperture(ggtt))
return;
prandom_seed_state(&prng, 0x12345678);
for (page = 0; page < size; page += PAGE_SIZE) {
const dma_addr_t dma = i915->dsm.stolen.start + page;
u32 __iomem *s;
int x;
ggtt->vm.insert_page(&ggtt->vm, dma, slot,
i915_gem_get_pat_index(i915,
I915_CACHE_NONE),
0);
s = io_mapping_map_atomic_wc(&ggtt->iomap, slot);
for (x = 0; x < PAGE_SIZE / sizeof(u32); x++) {
iowrite32(prandom_u32_state(&prng), &s[x]);
}
io_mapping_unmap_atomic(s);
}
ggtt->vm.clear_range(&ggtt->vm, slot, PAGE_SIZE);
}
static void simulate_hibernate(struct drm_i915_private *i915)
{
intel_wakeref_t wakeref;
wakeref = intel_runtime_pm_get(&i915->runtime_pm);
/*
* As a final string in the tail, invalidate stolen. Under a real S4,
* stolen is lost and needs to be refilled on resume. However, under
* CI we merely do S4-device testing (as full S4 is too unreliable
* for automated testing across a cluster), so to simulate the effect
* of stolen being trashed across S4, we trash it ourselves.
*/
trash_stolen(i915);
intel_runtime_pm_put(&i915->runtime_pm, wakeref);
}
static int igt_pm_prepare(struct drm_i915_private *i915)
{
i915_gem_suspend(i915);
return 0;
}
static void igt_pm_suspend(struct drm_i915_private *i915)
{
intel_wakeref_t wakeref;
with_intel_runtime_pm(&i915->runtime_pm, wakeref) {
i915_ggtt_suspend(to_gt(i915)->ggtt);
i915_gem_suspend_late(i915);
}
}
static void igt_pm_hibernate(struct drm_i915_private *i915)
{
intel_wakeref_t wakeref;
with_intel_runtime_pm(&i915->runtime_pm, wakeref) {
i915_ggtt_suspend(to_gt(i915)->ggtt);
i915_gem_freeze(i915);
i915_gem_freeze_late(i915);
Annotation
- Immediate include surface: `linux/prandom.h`, `gem/i915_gem_internal.h`, `gem/i915_gem_pm.h`, `gem/selftests/igt_gem_utils.h`, `gem/selftests/mock_context.h`, `gt/intel_gt.h`, `gt/intel_gt_pm.h`, `i915_selftest.h`.
- Detected declarations: `function switch_to_context`, `function for_each_gem_engine`, `function trash_stolen`, `function simulate_hibernate`, `function igt_pm_prepare`, `function igt_pm_suspend`, `function with_intel_runtime_pm`, `function igt_pm_hibernate`, `function with_intel_runtime_pm`, `function igt_pm_resume`.
- 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.