drivers/gpu/drm/i915/selftests/igt_mmap.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/selftests/igt_mmap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/selftests/igt_mmap.c- Extension
.c- Size
- 1519 bytes
- Lines
- 66
- 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
drm/drm_file.hi915_drv.higt_mmap.h
Detected Declarations
function igt_mmap_offset_with_filefunction igt_mmap_offset
Annotated Snippet
#include <drm/drm_file.h>
#include "i915_drv.h"
#include "igt_mmap.h"
unsigned long igt_mmap_offset_with_file(struct drm_i915_private *i915,
u64 offset,
unsigned long size,
unsigned long prot,
unsigned long flags,
struct file *file)
{
struct drm_vma_offset_node *node;
unsigned long addr;
int err;
/* no need to refcount, we own this object */
drm_vma_offset_lock_lookup(i915->drm.vma_offset_manager);
node = drm_vma_offset_exact_lookup_locked(i915->drm.vma_offset_manager,
offset / PAGE_SIZE, size / PAGE_SIZE);
drm_vma_offset_unlock_lookup(i915->drm.vma_offset_manager);
if (GEM_WARN_ON(!node)) {
pr_info("Failed to lookup %llx\n", offset);
return -ENOENT;
}
err = drm_vma_node_allow(node, file->private_data);
if (err) {
return err;
}
addr = vm_mmap(file, 0, drm_vma_node_size(node) << PAGE_SHIFT,
prot, flags, drm_vma_node_offset_addr(node));
drm_vma_node_revoke(node, file->private_data);
return addr;
}
unsigned long igt_mmap_offset(struct drm_i915_private *i915,
u64 offset,
unsigned long size,
unsigned long prot,
unsigned long flags)
{
struct file *file;
unsigned long addr;
/* Pretend to open("/dev/dri/card0") */
file = mock_drm_getfile(i915->drm.primary, O_RDWR);
if (IS_ERR(file))
return PTR_ERR(file);
addr = igt_mmap_offset_with_file(i915, offset, size, prot, flags, file);
fput(file);
return addr;
}
Annotation
- Immediate include surface: `drm/drm_file.h`, `i915_drv.h`, `igt_mmap.h`.
- Detected declarations: `function igt_mmap_offset_with_file`, `function igt_mmap_offset`.
- 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.