arch/mips/jazz/jazzdma.c
Source file repositories/reference/linux-study-clean/arch/mips/jazz/jazzdma.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/jazz/jazzdma.c- Extension
.c- Size
- 15670 bytes
- Lines
- 630
- Domain
- Architecture Layer
- Bucket
- arch/mips
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- 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/kernel.hlinux/init.hlinux/export.hlinux/errno.hlinux/mm.hlinux/memblock.hlinux/spinlock.hlinux/gfp.hlinux/dma-map-ops.hasm/mipsregs.hasm/jazz.hasm/io.hlinux/uaccess.hasm/dma.hasm/jazzdma.h
Detected Declarations
function vdma_pgtbl_initfunction vdma_initfunction vdma_allocfunction vdma_freefunction vdma_phys2logfunction vdma_log2physfunction vdma_statsfunction vdma_enablefunction vdma_disablefunction vdma_set_modefunction vdma_set_addrfunction vdma_set_countfunction vdma_get_residuefunction vdma_get_enablefunction jazz_dma_freefunction jazz_dma_map_physfunction jazz_dma_unmap_physfunction jazz_dma_map_sgfunction for_each_sgfunction jazz_dma_unmap_sgfunction for_each_sgfunction jazz_dma_sync_single_for_devicefunction jazz_dma_sync_single_for_cpufunction jazz_dma_sync_sg_for_devicefunction jazz_dma_sync_sg_for_cpuexport vdma_allocexport vdma_freeexport vdma_phys2logexport vdma_log2physexport vdma_enableexport vdma_disableexport vdma_set_modeexport vdma_set_addrexport vdma_set_countexport jazz_dma_ops
Annotated Snippet
if (first + pages > VDMA_PGTBL_ENTRIES) { /* nothing free */
spin_unlock_irqrestore(&vdma_lock, flags);
return DMA_MAPPING_ERROR;
}
last = first + 1;
while (pgtbl[last].owner == VDMA_PAGE_EMPTY
&& last - first < pages)
last++;
if (last - first == pages)
break; /* found */
first = last + 1;
}
/*
* Mark pages as allocated
*/
laddr = (first << 12) + (paddr & (VDMA_PAGESIZE - 1));
frame = paddr & ~(VDMA_PAGESIZE - 1);
for (i = first; i < last; i++) {
pgtbl[i].frame = frame;
pgtbl[i].owner = laddr;
frame += VDMA_PAGESIZE;
}
/*
* Update translation table and return logical start address
*/
r4030_write_reg32(JAZZ_R4030_TRSTBL_INV, 0);
if (vdma_debug > 1)
printk("vdma_alloc: Allocated %d pages starting from %08lx\n",
pages, laddr);
if (vdma_debug > 2) {
printk("LADDR: ");
for (i = first; i < last; i++)
printk("%08x ", i << 12);
printk("\nPADDR: ");
for (i = first; i < last; i++)
printk("%08x ", pgtbl[i].frame);
printk("\nOWNER: ");
for (i = first; i < last; i++)
printk("%08x ", pgtbl[i].owner);
printk("\n");
}
spin_unlock_irqrestore(&vdma_lock, flags);
return laddr;
}
EXPORT_SYMBOL(vdma_alloc);
/*
* Free previously allocated dma translation pages
* Note that this does NOT change the translation table,
* it just marks the free'd pages as unused!
*/
int vdma_free(unsigned long laddr)
{
int i;
i = laddr >> 12;
if (pgtbl[i].owner != laddr) {
printk
("vdma_free: trying to free other's dma pages, laddr=%8lx\n",
laddr);
return -1;
}
while (i < VDMA_PGTBL_ENTRIES && pgtbl[i].owner == laddr) {
pgtbl[i].owner = VDMA_PAGE_EMPTY;
i++;
}
if (vdma_debug > 1)
printk("vdma_free: freed %ld pages starting from %08lx\n",
i - (laddr >> 12), laddr);
return 0;
}
EXPORT_SYMBOL(vdma_free);
/*
* Translate a physical address to a logical address.
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/export.h`, `linux/errno.h`, `linux/mm.h`, `linux/memblock.h`, `linux/spinlock.h`, `linux/gfp.h`.
- Detected declarations: `function vdma_pgtbl_init`, `function vdma_init`, `function vdma_alloc`, `function vdma_free`, `function vdma_phys2log`, `function vdma_log2phys`, `function vdma_stats`, `function vdma_enable`, `function vdma_disable`, `function vdma_set_mode`.
- Atlas domain: Architecture Layer / arch/mips.
- 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.