drivers/staging/media/atomisp/pci/mmu/isp_mmu.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/atomisp/pci/mmu/isp_mmu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/atomisp/pci/mmu/isp_mmu.c- Extension
.c- Size
- 12873 bytes
- Lines
- 557
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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/kernel.hlinux/types.hlinux/gfp.hlinux/mm.hlinux/slab.hlinux/list.hlinux/io.hlinux/module.hlinux/moduleparam.hlinux/string.hlinux/errno.hlinux/sizes.hasm/set_memory.hatomisp_internal.hmmu/isp_mmu.h
Detected Declarations
function atomisp_get_ptefunction atomisp_set_ptefunction isp_pte_to_pgaddrfunction isp_pgaddr_to_pte_validfunction alloc_page_tablefunction free_page_tablefunction mmu_remap_errorfunction mmu_unmap_l2_pte_errorfunction mmu_unmap_l1_pte_errorfunction mmu_unmap_l1_pt_errorfunction mmu_l2_mapfunction mmu_l1_mapfunction mmu_mapfunction mmu_l2_unmapfunction mmu_l1_unmapfunction mmu_unmapfunction free_mmu_mapfunction isp_mmu_mapfunction isp_mmu_unmapfunction isp_mmu_flush_tlb_range_defaultfunction isp_mmu_initfunction isp_mmu_exit
Annotated Snippet
if (ISP_PTE_VALID(mmu, pte)) {
mmu_remap_error(mmu, l1_pt, l1_idx,
l2_pt, idx, ptr, pte, phys);
/* free all mapped pages */
free_mmu_map(mmu, start, ptr);
return -EINVAL;
}
pte = isp_pgaddr_to_pte_valid(mmu, phys);
atomisp_set_pte(l2_pt, idx, pte);
mmu->l2_pgt_refcount[l1_idx]++;
ptr += (1U << ISP_L2PT_OFFSET);
phys += (1U << ISP_L2PT_OFFSET);
} while (ptr < end && idx < ISP_L2PT_PTES - 1);
return 0;
}
/*
* Update L1 page table according to isp virtual address and page physical
* address
*/
static int mmu_l1_map(struct isp_mmu *mmu, phys_addr_t l1_pt,
unsigned int start, unsigned int end,
phys_addr_t phys)
{
phys_addr_t l2_pt;
unsigned int ptr, l1_aligned;
unsigned int idx;
unsigned int l2_pte;
int ret;
l1_pt &= ISP_PAGE_MASK;
start = start & ISP_PAGE_MASK;
end = ISP_PAGE_ALIGN(end);
phys &= ISP_PAGE_MASK;
ptr = start;
do {
idx = ISP_PTR_TO_L1_IDX(ptr);
l2_pte = atomisp_get_pte(l1_pt, idx);
if (!ISP_PTE_VALID(mmu, l2_pte)) {
l2_pt = alloc_page_table(mmu);
if (l2_pt == NULL_PAGE) {
dev_err(atomisp_dev,
"alloc page table fail.\n");
/* free all mapped pages */
free_mmu_map(mmu, start, ptr);
return -ENOMEM;
}
l2_pte = isp_pgaddr_to_pte_valid(mmu, l2_pt);
atomisp_set_pte(l1_pt, idx, l2_pte);
mmu->l2_pgt_refcount[idx] = 0;
}
l2_pt = isp_pte_to_pgaddr(mmu, l2_pte);
l1_aligned = (ptr & ISP_PAGE_MASK) + (1U << ISP_L1PT_OFFSET);
if (l1_aligned < end) {
ret = mmu_l2_map(mmu, l1_pt, idx,
l2_pt, ptr, l1_aligned, phys);
phys += (l1_aligned - ptr);
ptr = l1_aligned;
} else {
ret = mmu_l2_map(mmu, l1_pt, idx,
l2_pt, ptr, end, phys);
phys += (end - ptr);
ptr = end;
}
if (ret) {
dev_err(atomisp_dev, "setup mapping in L2PT fail.\n");
/* free all mapped pages */
free_mmu_map(mmu, start, ptr);
return -EINVAL;
}
} while (ptr < end && idx < ISP_L1PT_PTES);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/types.h`, `linux/gfp.h`, `linux/mm.h`, `linux/slab.h`, `linux/list.h`, `linux/io.h`, `linux/module.h`.
- Detected declarations: `function atomisp_get_pte`, `function atomisp_set_pte`, `function isp_pte_to_pgaddr`, `function isp_pgaddr_to_pte_valid`, `function alloc_page_table`, `function free_page_table`, `function mmu_remap_error`, `function mmu_unmap_l2_pte_error`, `function mmu_unmap_l1_pte_error`, `function mmu_unmap_l1_pt_error`.
- Atlas domain: Driver Families / drivers/staging.
- 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.