drivers/iommu/mtk_iommu.c
Source file repositories/reference/linux-study-clean/drivers/iommu/mtk_iommu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iommu/mtk_iommu.c- Extension
.c- Size
- 61804 bytes
- Lines
- 1939
- 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/arm-smccc.hlinux/bitfield.hlinux/bug.hlinux/clk.hlinux/component.hlinux/device.hlinux/err.hlinux/interrupt.hlinux/io.hlinux/iommu.hlinux/iopoll.hlinux/io-pgtable.hlinux/list.hlinux/mfd/syscon.hlinux/module.hlinux/of_address.hlinux/of_irq.hlinux/of_platform.hlinux/pci.hlinux/platform_device.hlinux/pm_runtime.hlinux/regmap.hlinux/slab.hlinux/spinlock.hlinux/soc/mediatek/infracfg.hlinux/soc/mediatek/mtk_sip_svc.hlinux/string_choices.hasm/barrier.hsoc/mediatek/smi.hdt-bindings/memory/mtk-memory-port.h
Detected Declarations
struct mtk_iommu_iova_regionstruct mtk_iommu_suspend_regstruct mtk_iommu_plat_datastruct mtk_iommu_bank_datastruct mtk_iommu_datastruct mtk_iommu_domainenum mtk_iommu_platfunction mtk_iommu_bindfunction mtk_iommu_unbindfunction mtk_iommu_tlb_flush_allfunction mtk_iommu_tlb_flush_range_syncfunction for_each_m4ufunction mtk_iommu_isrfunction mtk_iommu_get_bank_idfunction mtk_iommu_get_iova_region_idfunction mtk_iommu_configfunction mtk_iommu_domain_finalisefunction mtk_iommu_domain_freefunction mtk_iommu_attach_devicefunction mtk_iommu_identity_attachfunction mtk_iommu_mapfunction mtk_iommu_unmapfunction mtk_iommu_flush_iotlb_allfunction mtk_iommu_iotlb_syncfunction mtk_iommu_sync_mapfunction mtk_iommu_iova_to_physfunction for_each_set_bitfunction mtk_iommu_release_devicefunction for_each_set_bitfunction mtk_iommu_get_group_idfunction mtk_iommu_of_xlatefunction mtk_iommu_get_resv_regionsfunction mtk_iommu_hw_initfunction mtk_iommu_mm_dts_parsefunction mtk_iommu_probefunction mtk_iommu_removefunction mtk_iommu_runtime_suspendfunction mtk_iommu_runtime_resume
Annotated Snippet
struct mtk_iommu_iova_region {
dma_addr_t iova_base;
unsigned long long size;
};
struct mtk_iommu_suspend_reg {
u32 misc_ctrl;
u32 dcm_dis;
u32 ctrl_reg;
u32 vld_pa_rng;
u32 wr_len_ctrl;
u32 int_control[MTK_IOMMU_BANK_MAX];
u32 int_main_control[MTK_IOMMU_BANK_MAX];
u32 ivrp_paddr[MTK_IOMMU_BANK_MAX];
};
struct mtk_iommu_plat_data {
enum mtk_iommu_plat m4u_plat;
u32 flags;
u32 inv_sel_reg;
char *pericfg_comp_str;
struct list_head *hw_list;
/*
* The IOMMU HW may support 16GB iova. In order to balance the IOVA ranges,
* different masters will be put in different iova ranges, for example vcodec
* is in 4G-8G and cam is in 8G-12G. Meanwhile, some masters may have the
* special IOVA range requirement, like CCU can only support the address
* 0x40000000-0x44000000.
* Here list the iova ranges this SoC supports and which larbs/ports are in
* which region.
*
* 16GB iova all use one pgtable, but each a region is a iommu group.
*/
struct {
unsigned int iova_region_nr;
const struct mtk_iommu_iova_region *iova_region;
/*
* Indicate the correspondance between larbs, ports and regions.
*
* The index is the same as iova_region and larb port numbers are
* described as bit positions.
* For example, storing BIT(0) at index 2,1 means "larb 1, port0 is in region 2".
* [2] = { [1] = BIT(0) }
*/
const u32 (*iova_region_larb_msk)[MTK_LARB_NR_MAX];
};
/*
* The IOMMU HW may have 5 banks. Each bank has a independent pgtable.
* Here list how many banks this SoC supports/enables and which ports are in which bank.
*/
struct {
u8 banks_num;
bool banks_enable[MTK_IOMMU_BANK_MAX];
unsigned int banks_portmsk[MTK_IOMMU_BANK_MAX];
};
unsigned char larbid_remap[MTK_LARB_COM_MAX][MTK_LARB_SUBCOM_MAX];
};
struct mtk_iommu_bank_data {
void __iomem *base;
int irq;
u8 id;
struct device *parent_dev;
struct mtk_iommu_data *parent_data;
spinlock_t tlb_lock; /* lock for tlb range flush */
struct mtk_iommu_domain *m4u_dom; /* Each bank has a domain */
};
struct mtk_iommu_data {
struct device *dev;
struct clk *bclk;
phys_addr_t protect_base; /* protect memory base */
struct mtk_iommu_suspend_reg reg;
struct iommu_group *m4u_group[MTK_IOMMU_GROUP_MAX];
bool enable_4GB;
struct iommu_device iommu;
const struct mtk_iommu_plat_data *plat_data;
struct device *smicomm_dev;
struct mtk_iommu_bank_data *bank;
struct mtk_iommu_domain *share_dom;
struct regmap *pericfg;
struct mutex mutex; /* Protect m4u_group/m4u_dom above */
Annotation
- Immediate include surface: `linux/arm-smccc.h`, `linux/bitfield.h`, `linux/bug.h`, `linux/clk.h`, `linux/component.h`, `linux/device.h`, `linux/err.h`, `linux/interrupt.h`.
- Detected declarations: `struct mtk_iommu_iova_region`, `struct mtk_iommu_suspend_reg`, `struct mtk_iommu_plat_data`, `struct mtk_iommu_bank_data`, `struct mtk_iommu_data`, `struct mtk_iommu_domain`, `enum mtk_iommu_plat`, `function mtk_iommu_bind`, `function mtk_iommu_unbind`, `function mtk_iommu_tlb_flush_all`.
- 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.