arch/powerpc/platforms/pseries/iommu.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/pseries/iommu.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/pseries/iommu.c- Extension
.c- Size
- 70519 bytes
- Lines
- 2575
- 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/slab.hlinux/mm.hlinux/memblock.hlinux/spinlock.hlinux/string.hlinux/pci.hlinux/dma-mapping.hlinux/crash_dump.hlinux/memory.hlinux/vmalloc.hlinux/of.hlinux/of_address.hlinux/iommu.hlinux/rculist.hasm/io.hasm/prom.hasm/rtas.hasm/iommu.hasm/pci-bridge.hasm/machdep.hasm/firmware.hasm/tce.hasm/ppc-pci.hasm/udbg.hasm/mmzone.hasm/plpar_wrappers.hpseries.h
Detected Declarations
struct dynamic_dma_window_propstruct dma_winstruct ddw_query_responsestruct ddw_create_responsestruct failed_ddw_pdnfunction iommu_pseries_free_groupfunction tce_build_pSeriesfunction tce_clear_pSeriesfunction tce_get_pseriesfunction pseries_tce_iommu_userspace_view_allocfunction tce_iommu_userspace_view_freefunction tce_free_pSeriesfunction tce_build_pSeriesLPfunction tce_buildmulti_pSeriesLPfunction tce_free_pSeriesLPfunction tce_freemulti_pSeriesLPfunction tce_get_pSeriesLPfunction tce_clearrange_multi_pSeriesLPfunction tce_setrange_multi_pSeriesLPfunction tce_setrange_multi_pSeriesLP_walkfunction iommu_table_setparms_commonfunction iommu_table_setparmsfunction pci_dma_bus_setup_pSeriesfunction twofunction tce_exchange_pseriesfunction pci_dma_bus_setup_pSeriesLPfunction pci_dma_dev_setup_pSeriesfunction disable_ddw_setupfunction clean_dma_windowfunction __remove_dma_windowfunction remove_dma_windowfunction copy_propertyfunction remove_dma_window_namedfunction find_existing_ddwfunction find_existing_ddw_windows_namedfunction for_each_node_with_propertyfunction find_existing_ddw_windowsfunction ddw_read_extfunction query_ddwfunction create_ddwfunction ddw_memory_hotplug_maxfunction reset_dma_windowfunction limited_dma_windowfunction iommu_get_page_shiftfunction pagesfunction query_page_size_to_maskfunction spapr_tce_init_table_groupfunction pci_dma_dev_setup_pSeriesLP
Annotated Snippet
struct dynamic_dma_window_prop {
__be32 liobn; /* tce table number */
__be64 dma_base; /* address hi,lo */
__be32 tce_shift; /* ilog2(tce_page_size) */
__be32 window_shift; /* ilog2(tce_window_size) */
};
struct dma_win {
struct device_node *device;
const struct dynamic_dma_window_prop *prop;
bool direct;
struct list_head list;
};
/* Dynamic DMA Window support */
struct ddw_query_response {
u32 windows_available;
u64 largest_available_block;
u32 page_size;
u32 migration_capable;
};
struct ddw_create_response {
u32 liobn;
u32 addr_hi;
u32 addr_lo;
};
static LIST_HEAD(dma_win_list);
/* prevents races between memory on/offline and window creation */
static DEFINE_SPINLOCK(dma_win_list_lock);
/* protects initializing window twice for same device */
static DEFINE_MUTEX(dma_win_init_mutex);
static int tce_clearrange_multi_pSeriesLP(unsigned long start_pfn,
unsigned long num_pfn, const void *arg)
{
const struct dynamic_dma_window_prop *maprange = arg;
int rc;
u64 tce_size, num_tce, dma_offset, next;
u32 tce_shift;
long limit;
tce_shift = be32_to_cpu(maprange->tce_shift);
tce_size = 1ULL << tce_shift;
next = start_pfn << PAGE_SHIFT;
num_tce = num_pfn << PAGE_SHIFT;
/* round back to the beginning of the tce page size */
num_tce += next & (tce_size - 1);
next &= ~(tce_size - 1);
/* covert to number of tces */
num_tce |= tce_size - 1;
num_tce >>= tce_shift;
do {
/*
* Set up the page with TCE data, looping through and setting
* the values.
*/
limit = min_t(long, num_tce, 512);
dma_offset = next + be64_to_cpu(maprange->dma_base);
rc = plpar_tce_stuff((u64)be32_to_cpu(maprange->liobn),
dma_offset,
0, limit);
next += limit * tce_size;
num_tce -= limit;
} while (num_tce > 0 && !rc);
return rc;
}
static int tce_setrange_multi_pSeriesLP(unsigned long start_pfn,
unsigned long num_pfn, const void *arg)
{
const struct dynamic_dma_window_prop *maprange = arg;
u64 tce_size, num_tce, dma_offset, next, proto_tce, liobn;
__be64 *tcep;
u32 tce_shift;
u64 rc = 0;
long l, limit;
if (!firmware_has_feature(FW_FEATURE_PUT_TCE_IND)) {
unsigned long tceshift = be32_to_cpu(maprange->tce_shift);
unsigned long dmastart = (start_pfn << PAGE_SHIFT) +
be64_to_cpu(maprange->dma_base);
unsigned long tcenum = dmastart >> tceshift;
unsigned long npages = num_pfn << PAGE_SHIFT >> tceshift;
Annotation
- Immediate include surface: `linux/init.h`, `linux/types.h`, `linux/slab.h`, `linux/mm.h`, `linux/memblock.h`, `linux/spinlock.h`, `linux/string.h`, `linux/pci.h`.
- Detected declarations: `struct dynamic_dma_window_prop`, `struct dma_win`, `struct ddw_query_response`, `struct ddw_create_response`, `struct failed_ddw_pdn`, `function iommu_pseries_free_group`, `function tce_build_pSeries`, `function tce_clear_pSeries`, `function tce_get_pseries`, `function pseries_tce_iommu_userspace_view_alloc`.
- 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.