drivers/gpu/drm/drm_pagemap.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_pagemap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_pagemap.c- Extension
.c- Size
- 43537 bytes
- Lines
- 1481
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/dma-fence.hlinux/dma-mapping.hlinux/migrate.hlinux/pagemap.hdrm/drm_drv.hdrm/drm_pagemap.hdrm/drm_pagemap_util.hdrm/drm_print.h
Detected Declarations
struct drm_pagemap_zddstruct drm_pagemap_iova_statestruct migrate_range_locstruct drm_pagemap_dev_holdfunction drm_pagemap_zdd_allocfunction drm_pagemap_zdd_getfunction drm_pagemap_zdd_destroyfunction drm_pagemap_zdd_putfunction drm_pagemap_migration_unlock_put_foliofunction drm_pagemap_migration_unlock_put_pagesfunction drm_pagemap_get_devmem_pagefunction drm_pagemap_migrate_map_device_private_pagesfunction drm_pagemap_migrate_map_system_pagesfunction drm_pagemap_migrate_unmap_pagesfunction npages_in_rangefunction drm_pagemap_migrate_remote_to_localfunction drm_pagemap_migrate_sys_to_devfunction drm_pagemap_migrate_rangefunction drm_pagemap_cpagesfunction drm_pagemap_migrate_to_devmemfunction drm_pagemap_migrate_populate_ram_pfnfunction drm_pagemap_releasefunction page_freefunction flush_workfunction drm_pagemap_dev_holdfunction drm_pagemap_reinitfunction drm_pagemap_initfunction drm_pagemap_putfunction drm_pagemap_evict_to_ramfunction __drm_pagemap_migrate_to_ramfunction drm_pagemap_folio_freefunction drm_pagemap_migrate_to_ramfunction drm_pagemap_folio_splitfunction drm_pagemap_pagemap_ops_getfunction drm_pagemap_devmem_initfunction drm_pagemap_page_to_dpagemapfunction drm_pagemap_populate_mmfunction drm_pagemap_destroyfunction drm_pagemap_exitexport drm_pagemap_migrate_to_devmemexport drm_pagemap_reinitexport drm_pagemap_initexport drm_pagemap_putexport drm_pagemap_evict_to_ramexport drm_pagemap_pagemap_ops_getexport drm_pagemap_devmem_initexport drm_pagemap_page_to_dpagemapexport drm_pagemap_populate_mm
Annotated Snippet
struct drm_pagemap_zdd {
struct kref refcount;
struct drm_pagemap_devmem *devmem_allocation;
struct drm_pagemap *dpagemap;
};
/**
* drm_pagemap_zdd_alloc() - Allocate a zdd structure.
* @dpagemap: Pointer to the underlying struct drm_pagemap.
*
* This function allocates and initializes a new zdd structure. It sets up the
* reference count and initializes the destroy work.
*
* Return: Pointer to the allocated zdd on success, ERR_PTR() on failure.
*/
static struct drm_pagemap_zdd *
drm_pagemap_zdd_alloc(struct drm_pagemap *dpagemap)
{
struct drm_pagemap_zdd *zdd;
zdd = kmalloc_obj(*zdd);
if (!zdd)
return NULL;
kref_init(&zdd->refcount);
zdd->devmem_allocation = NULL;
zdd->dpagemap = drm_pagemap_get(dpagemap);
return zdd;
}
/**
* drm_pagemap_zdd_get() - Get a reference to a zdd structure.
* @zdd: Pointer to the zdd structure.
*
* This function increments the reference count of the provided zdd structure.
*
* Return: Pointer to the zdd structure.
*/
static struct drm_pagemap_zdd *drm_pagemap_zdd_get(struct drm_pagemap_zdd *zdd)
{
kref_get(&zdd->refcount);
return zdd;
}
/**
* drm_pagemap_zdd_destroy() - Destroy a zdd structure.
* @ref: Pointer to the reference count structure.
*
* This function queues the destroy_work of the zdd for asynchronous destruction.
*/
static void drm_pagemap_zdd_destroy(struct kref *ref)
{
struct drm_pagemap_zdd *zdd =
container_of(ref, struct drm_pagemap_zdd, refcount);
struct drm_pagemap_devmem *devmem = zdd->devmem_allocation;
struct drm_pagemap *dpagemap = zdd->dpagemap;
if (devmem) {
complete_all(&devmem->detached);
if (devmem->ops->devmem_release)
devmem->ops->devmem_release(devmem);
}
kfree(zdd);
drm_pagemap_put(dpagemap);
}
/**
* drm_pagemap_zdd_put() - Put a zdd reference.
* @zdd: Pointer to the zdd structure.
*
* This function decrements the reference count of the provided zdd structure
* and schedules its destruction if the count drops to zero.
*/
static void drm_pagemap_zdd_put(struct drm_pagemap_zdd *zdd)
{
kref_put(&zdd->refcount, drm_pagemap_zdd_destroy);
}
/**
* drm_pagemap_migration_unlock_put_folio() - Put a migration folio
* @folio: Pointer to the folio to put
*
* This function unlocks and puts a folio.
*/
static void drm_pagemap_migration_unlock_put_folio(struct folio *folio)
{
folio_unlock(folio);
folio_put(folio);
}
Annotation
- Immediate include surface: `linux/dma-fence.h`, `linux/dma-mapping.h`, `linux/migrate.h`, `linux/pagemap.h`, `drm/drm_drv.h`, `drm/drm_pagemap.h`, `drm/drm_pagemap_util.h`, `drm/drm_print.h`.
- Detected declarations: `struct drm_pagemap_zdd`, `struct drm_pagemap_iova_state`, `struct migrate_range_loc`, `struct drm_pagemap_dev_hold`, `function drm_pagemap_zdd_alloc`, `function drm_pagemap_zdd_get`, `function drm_pagemap_zdd_destroy`, `function drm_pagemap_zdd_put`, `function drm_pagemap_migration_unlock_put_folio`, `function drm_pagemap_migration_unlock_put_pages`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.