drivers/gpu/drm/i915/selftests/intel_memory_region.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/selftests/intel_memory_region.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/selftests/intel_memory_region.c- Extension
.c- Size
- 31356 bytes
- Lines
- 1406
- 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.hlinux/sort.hlinux/gpu_buddy.h../i915_selftest.hmock_drm.hmock_gem_device.hmock_region.hgem/i915_gem_context.hgem/i915_gem_lmem.hgem/i915_gem_region.hgem/i915_gem_ttm.hgem/selftests/igt_gem_utils.hgem/selftests/mock_context.hgt/intel_engine_pm.hgt/intel_engine_user.hgt/intel_gt.hgt/intel_migrate.hi915_memcpy.hi915_ttm_buddy_manager.hselftests/igt_flush_test.hselftests/i915_random.h
Detected Declarations
function close_objectsfunction list_for_each_entry_safefunction igt_mock_fillfunction for_each_prime_number_fromfunction igt_object_createfunction igt_object_releasefunction is_contiguousfunction igt_mock_reservefunction igt_mock_contiguousfunction igt_mock_splintered_regionfunction igt_mock_max_segmentfunction igt_object_mappable_totalfunction igt_mock_io_sizefunction igt_gpu_write_dwfunction igt_cpu_checkfunction igt_gpu_writefunction igt_lmem_createfunction igt_lmem_create_with_psfunction igt_lmem_create_cleared_cpufunction igt_lmem_write_gpufunction random_engine_classfunction igt_lmem_write_cpufunction create_region_for_mappingfunction wrap_ktime_comparefunction igt_memcpy_longfunction igt_memcpyfunction igt_memcpy_from_wcfunction _perf_memcpyfunction perf_memcpyfunction for_each_memory_regionfunction intel_memory_region_mock_selftestsfunction intel_memory_region_live_selftestsfunction intel_memory_region_perf_selftests
Annotated Snippet
if (IS_ERR(obj)) {
err = PTR_ERR(obj);
break;
}
err = i915_gem_object_pin_pages_unlocked(obj);
if (err) {
i915_gem_object_put(obj);
break;
}
list_add(&obj->st_link, &objects);
rem -= size;
}
if (err == -ENOMEM)
err = 0;
if (err == -ENXIO) {
if (page_num * page_size <= rem) {
pr_err("%s failed, space still left in region\n",
__func__);
err = -EINVAL;
} else {
err = 0;
}
}
close_objects(mem, &objects);
return err;
}
static struct drm_i915_gem_object *
igt_object_create(struct intel_memory_region *mem,
struct list_head *objects,
u64 size,
unsigned int flags)
{
struct drm_i915_gem_object *obj;
int err;
obj = i915_gem_object_create_region(mem, size, 0, flags);
if (IS_ERR(obj))
return obj;
err = i915_gem_object_pin_pages_unlocked(obj);
if (err)
goto put;
list_add(&obj->st_link, objects);
return obj;
put:
i915_gem_object_put(obj);
return ERR_PTR(err);
}
static void igt_object_release(struct drm_i915_gem_object *obj)
{
i915_gem_object_lock(obj, NULL);
i915_gem_object_unpin_pages(obj);
__i915_gem_object_put_pages(obj);
i915_gem_object_unlock(obj);
list_del(&obj->st_link);
i915_gem_object_put(obj);
}
static bool is_contiguous(struct drm_i915_gem_object *obj)
{
struct scatterlist *sg;
dma_addr_t addr = -1;
for (sg = obj->mm.pages->sgl; sg; sg = sg_next(sg)) {
if (addr != -1 && sg_dma_address(sg) != addr)
return false;
addr = sg_dma_address(sg) + sg_dma_len(sg);
}
return true;
}
static int igt_mock_reserve(void *arg)
{
struct intel_memory_region *mem = arg;
struct drm_i915_private *i915 = mem->i915;
resource_size_t avail = resource_size(&mem->region);
struct drm_i915_gem_object *obj;
const u32 chunk_size = SZ_32M;
u32 i, offset, count, *order;
Annotation
- Immediate include surface: `linux/prime_numbers.h`, `linux/sort.h`, `linux/gpu_buddy.h`, `../i915_selftest.h`, `mock_drm.h`, `mock_gem_device.h`, `mock_region.h`, `gem/i915_gem_context.h`.
- Detected declarations: `function close_objects`, `function list_for_each_entry_safe`, `function igt_mock_fill`, `function for_each_prime_number_from`, `function igt_object_create`, `function igt_object_release`, `function is_contiguous`, `function igt_mock_reserve`, `function igt_mock_contiguous`, `function igt_mock_splintered_region`.
- 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.