drivers/staging/media/ipu3/ipu3-mmu.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/ipu3/ipu3-mmu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/ipu3/ipu3-mmu.c- Extension
.c- Size
- 12519 bytes
- Lines
- 538
- 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/dma-mapping.hlinux/iopoll.hlinux/pm_runtime.hlinux/slab.hlinux/vmalloc.hasm/set_memory.hipu3-mmu.h
Detected Declarations
struct imgu_mmufunction imgu_mmu_tlb_invalidatefunction call_if_imgu_is_poweredfunction imgu_mmu_set_haltfunction imgu_mmu_free_page_tablefunction address_to_pte_idxfunction __imgu_mmu_mapfunction iommu_mapfunction default_iommu_map_sgfunction for_each_sgfunction __imgu_mmu_unmapfunction iommu_unmapfunction alignedfunction imgu_mmu_initfunction imgu_mmu_exitfunction imgu_mmu_suspendfunction imgu_mmu_resume
Annotated Snippet
struct imgu_mmu {
struct device *dev;
void __iomem *base;
/* protect access to l2pts, l1pt */
spinlock_t lock;
void *dummy_page;
u32 dummy_page_pteval;
u32 *dummy_l2pt;
u32 dummy_l2pt_pteval;
u32 **l2pts;
u32 *l1pt;
struct imgu_mmu_info geometry;
};
static inline struct imgu_mmu *to_imgu_mmu(struct imgu_mmu_info *info)
{
return container_of(info, struct imgu_mmu, geometry);
}
/**
* imgu_mmu_tlb_invalidate - invalidate translation look-aside buffer
* @mmu: MMU to perform the invalidate operation on
*
* This function invalidates the whole TLB. Must be called when the hardware
* is powered on.
*/
static void imgu_mmu_tlb_invalidate(struct imgu_mmu *mmu)
{
writel(TLB_INVALIDATE, mmu->base + REG_TLB_INVALIDATE);
}
static void call_if_imgu_is_powered(struct imgu_mmu *mmu,
void (*func)(struct imgu_mmu *mmu))
{
if (!pm_runtime_get_if_in_use(mmu->dev))
return;
func(mmu);
pm_runtime_put(mmu->dev);
}
/**
* imgu_mmu_set_halt - set CIO gate halt bit
* @mmu: MMU to set the CIO gate bit in.
* @halt: Desired state of the gate bit.
*
* This function sets the CIO gate bit that controls whether external memory
* accesses are allowed. Must be called when the hardware is powered on.
*/
static void imgu_mmu_set_halt(struct imgu_mmu *mmu, bool halt)
{
int ret;
u32 val;
writel(halt, mmu->base + REG_GP_HALT);
ret = readl_poll_timeout(mmu->base + REG_GP_HALTED,
val, (val & 1) == halt, 1000, 100000);
if (ret)
dev_err(mmu->dev, "failed to %s CIO gate halt\n",
halt ? "set" : "clear");
}
/**
* imgu_mmu_alloc_page_table - allocate a pre-filled page table
* @pteval: Value to initialize for page table entries with.
*
* Return: Pointer to allocated page table or NULL on failure.
*/
static u32 *imgu_mmu_alloc_page_table(u32 pteval)
{
u32 *pt;
int pte;
pt = (u32 *)__get_free_page(GFP_KERNEL);
if (!pt)
return NULL;
for (pte = 0; pte < IPU3_PT_PTES; pte++)
pt[pte] = pteval;
set_memory_uc((unsigned long)pt, IPU3_PT_ORDER);
return pt;
}
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `linux/iopoll.h`, `linux/pm_runtime.h`, `linux/slab.h`, `linux/vmalloc.h`, `asm/set_memory.h`, `ipu3-mmu.h`.
- Detected declarations: `struct imgu_mmu`, `function imgu_mmu_tlb_invalidate`, `function call_if_imgu_is_powered`, `function imgu_mmu_set_halt`, `function imgu_mmu_free_page_table`, `function address_to_pte_idx`, `function __imgu_mmu_map`, `function iommu_map`, `function default_iommu_map_sg`, `function for_each_sg`.
- 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.