drivers/iommu/ipmmu-vmsa.c
Source file repositories/reference/linux-study-clean/drivers/iommu/ipmmu-vmsa.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iommu/ipmmu-vmsa.c- Extension
.c- Size
- 30604 bytes
- Lines
- 1161
- Domain
- Driver Families
- Bucket
- drivers/iommu
- 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.
- 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/bitmap.hlinux/delay.hlinux/dma-mapping.hlinux/err.hlinux/export.hlinux/init.hlinux/interrupt.hlinux/io.hlinux/iopoll.hlinux/io-pgtable.hlinux/iommu.hlinux/of.hlinux/of_platform.hlinux/pci.hlinux/platform_device.hlinux/sizes.hlinux/slab.hlinux/sys_soc.hasm/dma-iommu.h
Detected Declarations
struct ipmmu_featuresstruct ipmmu_vmsa_devicestruct ipmmu_vmsa_domainfunction ipmmu_is_rootfunction __ipmmu_check_devicefunction ipmmu_readfunction ipmmu_writefunction ipmmu_ctx_regfunction ipmmu_ctx_readfunction ipmmu_ctx_writefunction ipmmu_ctx_read_rootfunction ipmmu_ctx_write_rootfunction ipmmu_ctx_write_allfunction ipmmu_utlb_regfunction ipmmu_imuasid_writefunction ipmmu_imuctr_writefunction ipmmu_tlb_syncfunction ipmmu_tlb_invalidatefunction ipmmu_utlb_enablefunction ipmmu_utlb_disablefunction ipmmu_tlb_flush_allfunction ipmmu_tlb_flushfunction ipmmu_domain_allocate_contextfunction ipmmu_domain_free_contextfunction ipmmu_domain_setup_contextfunction ipmmu_domain_init_contextfunction ipmmu_domain_destroy_contextfunction ipmmu_domain_irqfunction ipmmu_irqfunction ipmmu_domain_freefunction ipmmu_attach_devicefunction ipmmu_iommu_identity_attachfunction ipmmu_mapfunction ipmmu_unmapfunction ipmmu_flush_iotlb_allfunction ipmmu_iotlb_syncfunction ipmmu_iova_to_physfunction ipmmu_init_platform_devicefunction ipmmu_device_is_allowedfunction ipmmu_of_xlatefunction ipmmu_init_arm_mappingfunction ipmmu_probe_finalizefunction ipmmu_release_devicefunction ipmmu_device_resetfunction ipmmu_probefunction ipmmu_removefunction ipmmu_resume_noirq
Annotated Snippet
struct ipmmu_features {
bool use_ns_alias_offset;
bool has_cache_leaf_nodes;
unsigned int number_of_contexts;
unsigned int num_utlbs;
bool setup_imbuscr;
bool twobit_imttbcr_sl0;
bool reserved_context;
bool cache_snoop;
unsigned int ctx_offset_base;
unsigned int ctx_offset_stride;
unsigned int utlb_offset_base;
};
struct ipmmu_vmsa_device {
struct device *dev;
void __iomem *base;
struct iommu_device iommu;
struct ipmmu_vmsa_device *root;
const struct ipmmu_features *features;
unsigned int num_ctx;
spinlock_t lock; /* Protects ctx and domains[] */
DECLARE_BITMAP(ctx, IPMMU_CTX_MAX);
struct ipmmu_vmsa_domain *domains[IPMMU_CTX_MAX];
s8 utlb_ctx[IPMMU_UTLB_MAX];
struct dma_iommu_mapping *mapping;
};
struct ipmmu_vmsa_domain {
struct ipmmu_vmsa_device *mmu;
struct iommu_domain io_domain;
struct io_pgtable_cfg cfg;
struct io_pgtable_ops *iop;
unsigned int context_id;
struct mutex mutex; /* Protects mappings */
};
static struct ipmmu_vmsa_domain *to_vmsa_domain(struct iommu_domain *dom)
{
return container_of(dom, struct ipmmu_vmsa_domain, io_domain);
}
static struct ipmmu_vmsa_device *to_ipmmu(struct device *dev)
{
return dev_iommu_priv_get(dev);
}
#define TLB_LOOP_TIMEOUT 100 /* 100us */
/* -----------------------------------------------------------------------------
* Registers Definition
*/
#define IM_NS_ALIAS_OFFSET 0x800
/* MMU "context" registers */
#define IMCTR 0x0000 /* R-Car Gen2/3 */
#define IMCTR_INTEN (1 << 2) /* R-Car Gen2/3 */
#define IMCTR_FLUSH (1 << 1) /* R-Car Gen2/3 */
#define IMCTR_MMUEN (1 << 0) /* R-Car Gen2/3 */
#define IMTTBCR 0x0008 /* R-Car Gen2/3 */
#define IMTTBCR_EAE (1 << 31) /* R-Car Gen2/3 */
#define IMTTBCR_SH0_INNER_SHAREABLE (3 << 12) /* R-Car Gen2 only */
#define IMTTBCR_ORGN0_WB_WA (1 << 10) /* R-Car Gen2 only */
#define IMTTBCR_IRGN0_WB_WA (1 << 8) /* R-Car Gen2 only */
#define IMTTBCR_SL0_TWOBIT_LVL_1 (2 << 6) /* R-Car Gen3 only */
#define IMTTBCR_SL0_LVL_1 (1 << 4) /* R-Car Gen2 only */
#define IMBUSCR 0x000c /* R-Car Gen2 only */
#define IMBUSCR_DVM (1 << 2) /* R-Car Gen2 only */
#define IMBUSCR_BUSSEL_MASK (3 << 0) /* R-Car Gen2 only */
#define IMTTLBR0 0x0010 /* R-Car Gen2/3 */
#define IMTTUBR0 0x0014 /* R-Car Gen2/3 */
#define IMSTR 0x0020 /* R-Car Gen2/3 */
#define IMSTR_MHIT (1 << 4) /* R-Car Gen2/3 */
#define IMSTR_ABORT (1 << 2) /* R-Car Gen2/3 */
#define IMSTR_PF (1 << 1) /* R-Car Gen2/3 */
#define IMSTR_TF (1 << 0) /* R-Car Gen2/3 */
#define IMMAIR0 0x0028 /* R-Car Gen2/3 */
#define IMELAR 0x0030 /* R-Car Gen2/3, IMEAR on R-Car Gen2 */
#define IMEUAR 0x0034 /* R-Car Gen3 only */
Annotation
- Immediate include surface: `linux/bitmap.h`, `linux/delay.h`, `linux/dma-mapping.h`, `linux/err.h`, `linux/export.h`, `linux/init.h`, `linux/interrupt.h`, `linux/io.h`.
- Detected declarations: `struct ipmmu_features`, `struct ipmmu_vmsa_device`, `struct ipmmu_vmsa_domain`, `function ipmmu_is_root`, `function __ipmmu_check_device`, `function ipmmu_read`, `function ipmmu_write`, `function ipmmu_ctx_reg`, `function ipmmu_ctx_read`, `function ipmmu_ctx_write`.
- Atlas domain: Driver Families / drivers/iommu.
- Implementation status: source 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.