drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
Source file repositories/reference/linux-study-clean/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c- Extension
.c- Size
- 161117 bytes
- Lines
- 5558
- Domain
- Driver Families
- Bucket
- drivers/iommu
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- 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/acpi.hlinux/acpi_iort.hlinux/bitops.hlinux/crash_dump.hlinux/delay.hlinux/err.hlinux/interrupt.hlinux/io-pgtable.hlinux/iopoll.hlinux/module.hlinux/msi.hlinux/of.hlinux/of_address.hlinux/of_platform.hlinux/pci.hlinux/pci-ats.hlinux/platform_device.hlinux/sort.hlinux/string_choices.hkunit/visibility.huapi/linux/iommufd.harm-smmu-v3.h../../dma-iommu.h
Detected Declarations
struct arm_smmu_option_propstruct arm_smmu_cd_writerstruct arm_smmu_ste_writerenum arm_smmu_msi_indexfunction parse_driver_optionsfunction queue_has_spacefunction queue_fullfunction queue_emptyfunction queue_consumedfunction queue_sync_cons_outfunction queue_inc_consfunction queue_sync_cons_ovffunction queue_sync_prod_infunction queue_inc_prod_nfunction queue_poll_initfunction queue_pollfunction queue_writefunction queue_readfunction queue_remove_rawfunction arm_smmu_cmdq_needs_busy_pollingfunction arm_smmu_cmdq_build_sync_cmdfunction __arm_smmu_cmdq_skip_errfunction arm_smmu_cmdq_skip_errfunction holderfunction arm_smmu_cmdq_shared_unlockfunction arm_smmu_cmdq_shared_tryunlockfunction __arm_smmu_cmdq_poll_set_valid_mapfunction arm_smmu_cmdq_set_valid_mapfunction arm_smmu_cmdq_poll_valid_mapfunction arm_smmu_cmdq_poll_until_not_fullfunction __arm_smmu_cmdq_poll_until_msifunction __arm_smmu_cmdq_poll_until_consumedfunction arm_smmu_cmdq_poll_until_syncfunction arm_smmu_cmdq_write_entriesfunction memoryfunction arm_smmu_cmdq_issue_cmd_pfunction arm_smmu_cmdq_batch_init_cmdfunction arm_smmu_cmdq_batch_add_cmd_pfunction arm_smmu_cmdq_batch_submitfunction arm_smmu_page_responsefunction arm_smmu_invs_iter_nextfunction arm_smmu_inv_cmpfunction arm_smmu_invs_iter_next_cmpfunction arm_smmu_invs_mergefunction arm_smmu_invs_unreffunction arm_smmu_invs_for_each_cmpfunction arm_smmu_invs_purgefunction arm_smmu_invs_for_each_entry
Annotated Snippet
struct arm_smmu_option_prop {
u32 opt;
const char *prop;
};
DEFINE_XARRAY_ALLOC1(arm_smmu_asid_xa);
DEFINE_MUTEX(arm_smmu_asid_lock);
static struct arm_smmu_option_prop arm_smmu_options[] = {
{ ARM_SMMU_OPT_SKIP_PREFETCH, "hisilicon,broken-prefetch-cmd" },
{ ARM_SMMU_OPT_PAGE0_REGS_ONLY, "cavium,cn9900-broken-page1-regspace"},
{ 0, NULL},
};
static const char * const event_str[] = {
[EVT_ID_BAD_STREAMID_CONFIG] = "C_BAD_STREAMID",
[EVT_ID_STE_FETCH_FAULT] = "F_STE_FETCH",
[EVT_ID_BAD_STE_CONFIG] = "C_BAD_STE",
[EVT_ID_STREAM_DISABLED_FAULT] = "F_STREAM_DISABLED",
[EVT_ID_BAD_SUBSTREAMID_CONFIG] = "C_BAD_SUBSTREAMID",
[EVT_ID_CD_FETCH_FAULT] = "F_CD_FETCH",
[EVT_ID_BAD_CD_CONFIG] = "C_BAD_CD",
[EVT_ID_TRANSLATION_FAULT] = "F_TRANSLATION",
[EVT_ID_ADDR_SIZE_FAULT] = "F_ADDR_SIZE",
[EVT_ID_ACCESS_FAULT] = "F_ACCESS",
[EVT_ID_PERMISSION_FAULT] = "F_PERMISSION",
[EVT_ID_VMS_FETCH_FAULT] = "F_VMS_FETCH",
};
static const char * const event_class_str[] = {
[0] = "CD fetch",
[1] = "Stage 1 translation table fetch",
[2] = "Input address caused fault",
[3] = "Reserved",
};
static int arm_smmu_alloc_cd_tables(struct arm_smmu_master *master);
static bool arm_smmu_ats_supported(struct arm_smmu_master *master);
static void parse_driver_options(struct arm_smmu_device *smmu)
{
int i = 0;
do {
if (of_property_read_bool(smmu->dev->of_node,
arm_smmu_options[i].prop)) {
smmu->options |= arm_smmu_options[i].opt;
dev_notice(smmu->dev, "option %s\n",
arm_smmu_options[i].prop);
}
} while (arm_smmu_options[++i].opt);
}
/* Low-level queue manipulation functions */
static bool queue_has_space(struct arm_smmu_ll_queue *q, u32 n)
{
u32 space, prod, cons;
prod = Q_IDX(q, q->prod);
cons = Q_IDX(q, q->cons);
if (Q_WRP(q, q->prod) == Q_WRP(q, q->cons))
space = (1 << q->max_n_shift) - (prod - cons);
else
space = cons - prod;
return space >= n;
}
static bool queue_full(struct arm_smmu_ll_queue *q)
{
return Q_IDX(q, q->prod) == Q_IDX(q, q->cons) &&
Q_WRP(q, q->prod) != Q_WRP(q, q->cons);
}
static bool queue_empty(struct arm_smmu_ll_queue *q)
{
return Q_IDX(q, q->prod) == Q_IDX(q, q->cons) &&
Q_WRP(q, q->prod) == Q_WRP(q, q->cons);
}
static bool queue_consumed(struct arm_smmu_ll_queue *q, u32 prod)
{
return ((Q_WRP(q, q->cons) == Q_WRP(q, prod)) &&
(Q_IDX(q, q->cons) > Q_IDX(q, prod))) ||
((Q_WRP(q, q->cons) != Q_WRP(q, prod)) &&
(Q_IDX(q, q->cons) <= Q_IDX(q, prod)));
}
static void queue_sync_cons_out(struct arm_smmu_queue *q)
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/acpi_iort.h`, `linux/bitops.h`, `linux/crash_dump.h`, `linux/delay.h`, `linux/err.h`, `linux/interrupt.h`, `linux/io-pgtable.h`.
- Detected declarations: `struct arm_smmu_option_prop`, `struct arm_smmu_cd_writer`, `struct arm_smmu_ste_writer`, `enum arm_smmu_msi_index`, `function parse_driver_options`, `function queue_has_space`, `function queue_full`, `function queue_empty`, `function queue_consumed`, `function queue_sync_cons_out`.
- Atlas domain: Driver Families / drivers/iommu.
- 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.