drivers/gpu/drm/i915/gem/i915_gem_pages.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gem/i915_gem_pages.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/gem/i915_gem_pages.c- Extension
.c- Size
- 20875 bytes
- Lines
- 806
- 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.
- 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/vmalloc.hdrm/drm_cache.hdrm/drm_panic.hdrm/drm_print.hdisplay/intel_fb.hdisplay/intel_display_types.hgt/intel_gt.hgt/intel_tlb.hi915_drv.hi915_gem_object.hi915_scatterlist.hi915_gem_lmem.hi915_gem_mman.h
Detected Declarations
struct intel_panicfunction __i915_gem_object_set_pagesfunction ____i915_gem_object_get_pagesfunction i915_gem_object_unpin_pagesfunction i915_gem_object_pin_pages_unlockedfunction i915_gem_object_truncatefunction __i915_gem_object_reset_page_iterfunction unmap_objectfunction flush_tlb_invalidatefunction for_each_gtfunction __i915_gem_object_unset_pagesfunction __i915_gem_object_put_pagesfunction i915_panic_kunmapfunction i915_gem_object_panic_map_set_pixelfunction kmap_local_page_try_from_panicfunction i915_gem_object_panic_setupfunction i915_gem_object_panic_finishfunction __i915_gem_object_flush_mapfunction __i915_gem_object_release_mapfunction __i915_gem_object_page_iter_get_sgfunction __i915_gem_object_get_pagefunction __i915_gem_object_get_dirty_pagefunction __i915_gem_object_get_dma_address_lenfunction __i915_gem_object_get_dma_address
Annotated Snippet
struct intel_panic {
struct page **pages;
int page;
void *vaddr;
};
static void i915_panic_kunmap(struct intel_panic *panic)
{
if (panic->vaddr) {
drm_clflush_virt_range(panic->vaddr, PAGE_SIZE);
kunmap_local(panic->vaddr);
panic->vaddr = NULL;
}
}
static struct page **i915_gem_object_panic_pages(struct drm_i915_gem_object *obj)
{
unsigned long n_pages = obj->base.size >> PAGE_SHIFT, i;
struct page *page;
struct page **pages;
struct sgt_iter iter;
/* For a 3840x2160 32 bits Framebuffer, this should require ~64K */
pages = kmalloc_objs(*pages, n_pages, GFP_ATOMIC);
if (!pages)
return NULL;
i = 0;
for_each_sgt_page(page, iter, obj->mm.pages)
pages[i++] = page;
return pages;
}
static void i915_gem_object_panic_map_set_pixel(struct drm_scanout_buffer *sb, unsigned int x,
unsigned int y, u32 color)
{
struct intel_framebuffer *fb = (struct intel_framebuffer *)sb->private;
unsigned int offset = fb->panic_tiling(sb->width, x, y);
iosys_map_wr(&sb->map[0], offset, u32, color);
}
/*
* The scanout buffer pages are not mapped, so for each pixel,
* use kmap_local_page_try_from_panic() to map the page, and write the pixel.
* Try to keep the map from the previous pixel, to avoid too much map/unmap.
*/
static void i915_gem_object_panic_page_set_pixel(struct drm_scanout_buffer *sb, unsigned int x,
unsigned int y, u32 color)
{
unsigned int new_page;
unsigned int offset;
struct intel_framebuffer *fb = (struct intel_framebuffer *)sb->private;
struct intel_panic *panic = fb->panic;
if (fb->panic_tiling)
offset = fb->panic_tiling(sb->width, x, y);
else
offset = y * sb->pitch[0] + x * sb->format->cpp[0];
new_page = offset >> PAGE_SHIFT;
offset = offset % PAGE_SIZE;
if (new_page != panic->page) {
i915_panic_kunmap(panic);
panic->page = new_page;
panic->vaddr =
kmap_local_page_try_from_panic(panic->pages[panic->page]);
}
if (panic->vaddr) {
u32 *pix = panic->vaddr + offset;
*pix = color;
}
}
struct intel_panic *i915_gem_object_alloc_panic(void)
{
struct intel_panic *panic;
panic = kzalloc_obj(*panic);
return panic;
}
/*
* Setup the gem framebuffer for drm_panic access.
* Use current vaddr if it exists, or setup a list of pages.
* pfn is not supported yet.
*/
int i915_gem_object_panic_setup(struct intel_panic *panic, struct drm_scanout_buffer *sb,
struct drm_gem_object *_obj, bool panic_tiling)
Annotation
- Immediate include surface: `linux/vmalloc.h`, `drm/drm_cache.h`, `drm/drm_panic.h`, `drm/drm_print.h`, `display/intel_fb.h`, `display/intel_display_types.h`, `gt/intel_gt.h`, `gt/intel_tlb.h`.
- Detected declarations: `struct intel_panic`, `function __i915_gem_object_set_pages`, `function ____i915_gem_object_get_pages`, `function i915_gem_object_unpin_pages`, `function i915_gem_object_pin_pages_unlocked`, `function i915_gem_object_truncate`, `function __i915_gem_object_reset_page_iter`, `function unmap_object`, `function flush_tlb_invalidate`, `function for_each_gt`.
- 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.