drivers/gpu/drm/i915/gt/shmem_utils.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gt/shmem_utils.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/gt/shmem_utils.c- Extension
.c- Size
- 3638 bytes
- Lines
- 175
- 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/iosys-map.hlinux/mm.hlinux/pagemap.hlinux/shmem_fs.hlinux/vmalloc.hi915_drv.hgem/i915_gem_object.hgem/i915_gem_lmem.hshmem_utils.hst_shmem_utils.c
Detected Declarations
function shmem_unpin_mapfunction __shmem_rwfunction shmem_read_to_iosys_mapfunction shmem_readfunction shmem_write
Annotated Snippet
if (write) {
memcpy(vaddr + offset_in_page(off), ptr, this);
set_page_dirty(page);
} else {
memcpy(ptr, vaddr + offset_in_page(off), this);
}
mark_page_accessed(page);
kunmap_local(vaddr);
put_page(page);
len -= this;
ptr += this;
off = 0;
}
return 0;
}
int shmem_read_to_iosys_map(struct file *file, loff_t off,
struct iosys_map *map, size_t map_off, size_t len)
{
unsigned long pfn;
for (pfn = off >> PAGE_SHIFT; len; pfn++) {
unsigned int this =
min_t(size_t, PAGE_SIZE - offset_in_page(off), len);
struct page *page;
void *vaddr;
page = shmem_read_mapping_page_gfp(file->f_mapping, pfn,
GFP_KERNEL);
if (IS_ERR(page))
return PTR_ERR(page);
vaddr = kmap_local_page(page);
iosys_map_memcpy_to(map, map_off, vaddr + offset_in_page(off),
this);
mark_page_accessed(page);
kunmap_local(vaddr);
put_page(page);
len -= this;
map_off += this;
off = 0;
}
return 0;
}
int shmem_read(struct file *file, loff_t off, void *dst, size_t len)
{
return __shmem_rw(file, off, dst, len, false);
}
int shmem_write(struct file *file, loff_t off, void *src, size_t len)
{
return __shmem_rw(file, off, src, len, true);
}
#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
#include "st_shmem_utils.c"
#endif
Annotation
- Immediate include surface: `linux/iosys-map.h`, `linux/mm.h`, `linux/pagemap.h`, `linux/shmem_fs.h`, `linux/vmalloc.h`, `i915_drv.h`, `gem/i915_gem_object.h`, `gem/i915_gem_lmem.h`.
- Detected declarations: `function shmem_unpin_map`, `function __shmem_rw`, `function shmem_read_to_iosys_map`, `function shmem_read`, `function shmem_write`.
- 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.