drivers/gpu/drm/i915/selftests/i915_vma.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/selftests/i915_vma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/selftests/i915_vma.c- Extension
.c- Size
- 28802 bytes
- Lines
- 1113
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/prime_numbers.hgem/i915_gem_context.hgem/i915_gem_internal.hgem/selftests/mock_context.hi915_scatterlist.hi915_selftest.hmock_gem_device.hmock_gtt.h
Detected Declarations
struct pin_modefunction filesfunction checked_vma_instancefunction create_vmasfunction list_for_each_entryfunction list_for_each_entryfunction igt_vma_createfunction for_each_prime_numberfunction list_for_each_entry_safefunction assert_pin_validfunction assert_pin_enospcfunction assert_pin_einvalfunction igt_vma_pin1function rotated_indexfunction assert_rotatedfunction remapped_indexfunction assert_remappedfunction remapped_sizefunction igt_vma_rotate_remapfunction for_each_prime_number_fromfunction assert_partialfunction for_each_sgt_daddrfunction assert_pinfunction igt_vma_partialfunction for_each_prime_number_fromfunction i915_vma_mock_selftestsfunction igt_vma_remapped_gttfunction i915_vma_live_selftests
Annotated Snippet
struct pin_mode {
u64 size;
u64 flags;
bool (*assert)(const struct i915_vma *,
const struct pin_mode *mode,
int result);
const char *string;
};
static bool assert_pin_valid(const struct i915_vma *vma,
const struct pin_mode *mode,
int result)
{
if (result)
return false;
if (i915_vma_misplaced(vma, mode->size, 0, mode->flags))
return false;
return true;
}
__maybe_unused
static bool assert_pin_enospc(const struct i915_vma *vma,
const struct pin_mode *mode,
int result)
{
return result == -ENOSPC;
}
__maybe_unused
static bool assert_pin_einval(const struct i915_vma *vma,
const struct pin_mode *mode,
int result)
{
return result == -EINVAL;
}
static int igt_vma_pin1(void *arg)
{
struct i915_ggtt *ggtt = arg;
const struct pin_mode modes[] = {
#define VALID(sz, fl) { .size = (sz), .flags = (fl), .assert = assert_pin_valid, .string = #sz ", " #fl ", (valid) " }
#define __INVALID(sz, fl, check, eval) { .size = (sz), .flags = (fl), .assert = (check), .string = #sz ", " #fl ", (invalid " #eval ")" }
#define INVALID(sz, fl) __INVALID(sz, fl, assert_pin_einval, EINVAL)
#define NOSPACE(sz, fl) __INVALID(sz, fl, assert_pin_enospc, ENOSPC)
VALID(0, PIN_GLOBAL),
VALID(0, PIN_GLOBAL | PIN_MAPPABLE),
VALID(0, PIN_GLOBAL | PIN_OFFSET_BIAS | 4096),
VALID(0, PIN_GLOBAL | PIN_OFFSET_BIAS | 8192),
VALID(0, PIN_GLOBAL | PIN_OFFSET_BIAS | (ggtt->mappable_end - 4096)),
VALID(0, PIN_GLOBAL | PIN_MAPPABLE | PIN_OFFSET_BIAS | (ggtt->mappable_end - 4096)),
VALID(0, PIN_GLOBAL | PIN_OFFSET_BIAS | (ggtt->vm.total - 4096)),
VALID(0, PIN_GLOBAL | PIN_MAPPABLE | PIN_OFFSET_FIXED | (ggtt->mappable_end - 4096)),
INVALID(0, PIN_GLOBAL | PIN_MAPPABLE | PIN_OFFSET_FIXED | ggtt->mappable_end),
VALID(0, PIN_GLOBAL | PIN_OFFSET_FIXED | (ggtt->vm.total - 4096)),
INVALID(0, PIN_GLOBAL | PIN_OFFSET_FIXED | ggtt->vm.total),
INVALID(0, PIN_GLOBAL | PIN_OFFSET_FIXED | round_down(U64_MAX, PAGE_SIZE)),
VALID(4096, PIN_GLOBAL),
VALID(8192, PIN_GLOBAL),
VALID(ggtt->mappable_end - 4096, PIN_GLOBAL | PIN_MAPPABLE),
VALID(ggtt->mappable_end, PIN_GLOBAL | PIN_MAPPABLE),
NOSPACE(ggtt->mappable_end + 4096, PIN_GLOBAL | PIN_MAPPABLE),
VALID(ggtt->vm.total - 4096, PIN_GLOBAL),
VALID(ggtt->vm.total, PIN_GLOBAL),
NOSPACE(ggtt->vm.total + 4096, PIN_GLOBAL),
NOSPACE(round_down(U64_MAX, PAGE_SIZE), PIN_GLOBAL),
INVALID(8192, PIN_GLOBAL | PIN_MAPPABLE | PIN_OFFSET_FIXED | (ggtt->mappable_end - 4096)),
INVALID(8192, PIN_GLOBAL | PIN_OFFSET_FIXED | (ggtt->vm.total - 4096)),
INVALID(8192, PIN_GLOBAL | PIN_OFFSET_FIXED | (round_down(U64_MAX, PAGE_SIZE) - 4096)),
VALID(8192, PIN_GLOBAL | PIN_OFFSET_BIAS | (ggtt->mappable_end - 4096)),
#if !IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM)
/*
* Misusing BIAS is a programming error (it is not controllable
* from userspace) so when debugging is enabled, it explodes.
* However, the tests are still quite interesting for checking
* variable start, end and size.
*/
NOSPACE(0, PIN_GLOBAL | PIN_MAPPABLE | PIN_OFFSET_BIAS | ggtt->mappable_end),
NOSPACE(0, PIN_GLOBAL | PIN_OFFSET_BIAS | ggtt->vm.total),
NOSPACE(8192, PIN_GLOBAL | PIN_MAPPABLE | PIN_OFFSET_BIAS | (ggtt->mappable_end - 4096)),
NOSPACE(8192, PIN_GLOBAL | PIN_OFFSET_BIAS | (ggtt->vm.total - 4096)),
#endif
{ },
#undef NOSPACE
Annotation
- Immediate include surface: `linux/prime_numbers.h`, `gem/i915_gem_context.h`, `gem/i915_gem_internal.h`, `gem/selftests/mock_context.h`, `i915_scatterlist.h`, `i915_selftest.h`, `mock_gem_device.h`, `mock_gtt.h`.
- Detected declarations: `struct pin_mode`, `function files`, `function checked_vma_instance`, `function create_vmas`, `function list_for_each_entry`, `function list_for_each_entry`, `function igt_vma_create`, `function for_each_prime_number`, `function list_for_each_entry_safe`, `function assert_pin_valid`.
- 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.