drivers/gpu/drm/imagination/pvr_mmu.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/imagination/pvr_mmu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/imagination/pvr_mmu.c- Extension
.c- Size
- 82508 bytes
- Lines
- 2644
- 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.
- 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
pvr_mmu.hpvr_ccb.hpvr_device.hpvr_fw.hpvr_gem.hpvr_power.hpvr_rogue_fwif.hpvr_rogue_mmu_defs.hdrm/drm_drv.hlinux/atomic.hlinux/bitops.hlinux/dma-mapping.hlinux/kmemleak.hlinux/minmax.hlinux/property.hlinux/sizes.h
Detected Declarations
struct pvr_mmu_backing_pagestruct pvr_page_table_l2_entry_rawstruct pvr_page_table_l1_entry_rawstruct pvr_page_table_l0_entry_rawstruct pvr_page_flags_rawstruct pvr_page_table_l2_rawstruct pvr_page_table_l1_rawstruct pvr_page_table_l0_rawstruct pvr_page_table_l1struct pvr_page_table_l0struct pvr_page_table_l2struct pvr_page_table_l1struct pvr_page_table_l0struct pvr_mmu_contextstruct pvr_page_table_ptrstruct pvr_mmu_op_contextenum pvr_mmu_sync_levelfunction pvr_mmu_set_flush_flagsfunction pvr_mmu_flush_request_allfunction pvr_mmu_flush_execfunction pvr_mmu_backing_page_initfunction pvr_mmu_backing_page_finifunction pvr_mmu_backing_page_syncfunction pvr_page_table_l2_entry_raw_is_validfunction pvr_page_table_l2_entry_raw_setfunction pvr_page_table_l2_entry_raw_clearfunction pvr_page_table_l1_entry_raw_is_validfunction pvr_page_table_l1_entry_raw_setfunction pvr_page_table_l1_entry_raw_clearfunction pvr_page_table_l0_entry_raw_is_validfunction pvr_page_table_l0_entry_raw_setfunction pvr_page_table_l0_entry_raw_clearfunction pvr_page_flags_raw_createfunction pvr_page_table_l2_initfunction pvr_page_table_l2_finifunction pvr_page_table_l2_syncfunction pvr_page_table_l2_get_rawfunction pvr_page_table_l2_get_entry_rawfunction pvr_page_table_l2_entry_is_validfunction pvr_page_table_l1_initfunction pvr_page_table_l1_freefunction pvr_page_table_l1_syncfunction pvr_page_table_l1_get_rawfunction pvr_page_table_l1_get_entry_rawfunction pvr_page_table_l1_entry_is_validfunction pvr_page_table_l0_initfunction pvr_page_table_l0_freefunction pvr_page_table_l0_sync
Annotated Snippet
struct pvr_mmu_backing_page {
dma_addr_t dma_addr;
void *host_ptr;
/* private: internal use only */
struct page *raw_page;
struct pvr_device *pvr_dev;
};
/**
* pvr_mmu_backing_page_init() - Initialize a MMU backing page.
* @page: Target backing page.
* @pvr_dev: Target PowerVR device.
*
* This function performs three distinct operations:
*
* 1. Allocate a single page,
* 2. Map the page to the CPU, and
* 3. Map the page to DMA-space.
*
* It is expected that @page be zeroed (e.g. from kzalloc()) before calling
* this function.
*
* Return:
* * 0 on success, or
* * -%ENOMEM if allocation of the backing page or mapping of the backing
* page to DMA fails.
*/
static int
pvr_mmu_backing_page_init(struct pvr_mmu_backing_page *page,
struct pvr_device *pvr_dev)
{
struct device *dev = from_pvr_device(pvr_dev)->dev;
struct page *raw_page;
pgprot_t prot;
int err;
dma_addr_t dma_addr;
void *host_ptr;
raw_page = alloc_page(__GFP_ZERO | GFP_KERNEL);
if (!raw_page)
return -ENOMEM;
prot = PAGE_KERNEL;
if (device_get_dma_attr(dev) != DEV_DMA_COHERENT)
prot = pgprot_writecombine(prot);
host_ptr = vmap(&raw_page, 1, VM_MAP, prot);
if (!host_ptr) {
err = -ENOMEM;
goto err_free_page;
}
dma_addr = dma_map_page(dev, raw_page, 0, PVR_MMU_BACKING_PAGE_SIZE,
DMA_TO_DEVICE);
if (dma_mapping_error(dev, dma_addr)) {
err = -ENOMEM;
goto err_unmap_page;
}
page->dma_addr = dma_addr;
page->host_ptr = host_ptr;
page->pvr_dev = pvr_dev;
page->raw_page = raw_page;
kmemleak_alloc(page->host_ptr, PAGE_SIZE, 1, GFP_KERNEL);
return 0;
err_unmap_page:
vunmap(host_ptr);
err_free_page:
__free_page(raw_page);
return err;
}
/**
* pvr_mmu_backing_page_fini() - Teardown a MMU backing page.
* @page: Target backing page.
*
* This function performs the mirror operations to pvr_mmu_backing_page_init(),
* in reverse order:
*
* 1. Unmap the page from DMA-space,
* 2. Unmap the page from the CPU, and
* 3. Free the page.
*
* It also zeros @page.
Annotation
- Immediate include surface: `pvr_mmu.h`, `pvr_ccb.h`, `pvr_device.h`, `pvr_fw.h`, `pvr_gem.h`, `pvr_power.h`, `pvr_rogue_fwif.h`, `pvr_rogue_mmu_defs.h`.
- Detected declarations: `struct pvr_mmu_backing_page`, `struct pvr_page_table_l2_entry_raw`, `struct pvr_page_table_l1_entry_raw`, `struct pvr_page_table_l0_entry_raw`, `struct pvr_page_flags_raw`, `struct pvr_page_table_l2_raw`, `struct pvr_page_table_l1_raw`, `struct pvr_page_table_l0_raw`, `struct pvr_page_table_l1`, `struct pvr_page_table_l0`.
- 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.
- 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.