arch/powerpc/sysdev/dart_iommu.c
Source file repositories/reference/linux-study-clean/arch/powerpc/sysdev/dart_iommu.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/sysdev/dart_iommu.c- Extension
.c- Size
- 11113 bytes
- Lines
- 441
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: implementation source
- Status
- source 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.
- 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/init.hlinux/types.hlinux/mm.hlinux/spinlock.hlinux/string.hlinux/pci.hlinux/dma-mapping.hlinux/vmalloc.hlinux/suspend.hlinux/memblock.hlinux/gfp.hlinux/of_address.hasm/io.hasm/iommu.hasm/pci-bridge.hasm/machdep.hasm/cacheflush.hasm/ppc-pci.hdart.h
Detected Declarations
function dart_tlb_invalidate_allfunction dart_tlb_invalidate_onefunction dart_cache_syncfunction dart_flushfunction dart_buildfunction dart_freefunction allocate_dartfunction dart_initfunction iommu_table_dart_setupfunction pci_dma_bus_setup_dartfunction dart_device_on_pciefunction pci_dma_dev_setup_dartfunction iommu_bypass_supported_dartfunction iommu_init_early_dartfunction iommu_dart_restorefunction iommu_init_late_dart
Annotated Snippet
if (limit < 4) {
limit++;
reg = DART_IN(DART_CNTL);
reg &= ~inv_bit;
DART_OUT(DART_CNTL, reg);
goto retry;
} else
panic("DART: TLB did not flush after waiting a long "
"time. Buggy U3 ?");
}
spin_unlock_irqrestore(&invalidate_lock, flags);
}
static inline void dart_tlb_invalidate_one(unsigned long bus_rpn)
{
unsigned int reg;
unsigned int l, limit;
unsigned long flags;
spin_lock_irqsave(&invalidate_lock, flags);
reg = DART_CNTL_U4_ENABLE | DART_CNTL_U4_IONE |
(bus_rpn & DART_CNTL_U4_IONE_MASK);
DART_OUT(DART_CNTL, reg);
limit = 0;
wait_more:
l = 0;
while ((DART_IN(DART_CNTL) & DART_CNTL_U4_IONE) && l < (1L << limit)) {
rmb();
l++;
}
if (l == (1L << limit)) {
if (limit < 4) {
limit++;
goto wait_more;
} else
panic("DART: TLB did not flush after waiting a long "
"time. Buggy U4 ?");
}
spin_unlock_irqrestore(&invalidate_lock, flags);
}
static void dart_cache_sync(unsigned int *base, unsigned int count)
{
/*
* We add 1 to the number of entries to flush, following a
* comment in Darwin indicating that the memory controller
* can prefetch unmapped memory under some circumstances.
*/
unsigned long start = (unsigned long)base;
unsigned long end = start + (count + 1) * sizeof(unsigned int);
unsigned int tmp;
/* Perform a standard cache flush */
flush_dcache_range(start, end);
/*
* Perform the sequence described in the CPC925 manual to
* ensure all the data gets to a point the cache incoherent
* DART hardware will see.
*/
asm volatile(" sync;"
" isync;"
" dcbf 0,%1;"
" sync;"
" isync;"
" lwz %0,0(%1);"
" isync" : "=r" (tmp) : "r" (end) : "memory");
}
static void dart_flush(struct iommu_table *tbl)
{
mb();
if (dart_dirty) {
dart_tlb_invalidate_all();
dart_dirty = 0;
}
}
static int dart_build(struct iommu_table *tbl, long index,
long npages, unsigned long uaddr,
enum dma_data_direction direction,
unsigned long attrs)
{
unsigned int *dp, *orig_dp;
unsigned int rpn;
Annotation
- Immediate include surface: `linux/init.h`, `linux/types.h`, `linux/mm.h`, `linux/spinlock.h`, `linux/string.h`, `linux/pci.h`, `linux/dma-mapping.h`, `linux/vmalloc.h`.
- Detected declarations: `function dart_tlb_invalidate_all`, `function dart_tlb_invalidate_one`, `function dart_cache_sync`, `function dart_flush`, `function dart_build`, `function dart_free`, `function allocate_dart`, `function dart_init`, `function iommu_table_dart_setup`, `function pci_dma_bus_setup_dart`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.