drivers/iommu/apple-dart.c
Source file repositories/reference/linux-study-clean/drivers/iommu/apple-dart.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iommu/apple-dart.c- Extension
.c- Size
- 38317 bytes
- Lines
- 1391
- 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/atomic.hlinux/bitfield.hlinux/clk.hlinux/dev_printk.hlinux/dma-mapping.hlinux/err.hlinux/interrupt.hlinux/io-pgtable.hlinux/iommu.hlinux/iopoll.hlinux/module.hlinux/of.hlinux/of_address.hlinux/of_iommu.hlinux/of_platform.hlinux/pci.hlinux/platform_device.hlinux/slab.hlinux/swab.hlinux/types.hdma-iommu.h
Detected Declarations
struct apple_dart_stream_mapstruct apple_dart_hwstruct apple_dartstruct apple_dart_stream_mapstruct apple_dart_atomic_stream_mapstruct apple_dart_domainstruct apple_dart_master_cfgenum dart_typefunction apple_dart_hw_enable_translationfunction apple_dart_hw_disable_dmafunction apple_dart_hw_enable_bypassfunction apple_dart_hw_set_ttbrfunction apple_dart_hw_clear_ttbrfunction apple_dart_hw_clear_all_ttbrsfunction apple_dart_t8020_hw_stream_commandfunction apple_dart_t8110_hw_tlb_commandfunction for_each_set_bitfunction apple_dart_t8020_hw_invalidate_tlbfunction apple_dart_t8110_hw_invalidate_tlbfunction apple_dart_hw_resetfunction apple_dart_domain_flush_tlbfunction for_each_stream_mapfunction apple_dart_flush_iotlb_allfunction apple_dart_iotlb_syncfunction apple_dart_iotlb_sync_mapfunction apple_dart_iova_to_physfunction apple_dart_map_pagesfunction apple_dart_unmap_pagesfunction apple_dart_setup_translationfunction apple_dart_finalize_domainfunction apple_dart_mod_streamsfunction apple_dart_domain_add_streamsfunction apple_dart_attach_dev_pagingfunction apple_dart_attach_dev_identityfunction apple_dart_attach_dev_blockedfunction apple_dart_release_devicefunction apple_dart_domain_freefunction apple_dart_of_xlatefunction apple_dart_release_groupfunction apple_dart_merge_master_cfgfunction for_each_stream_mapfunction apple_dart_def_domain_typefunction apple_dart_get_resv_regionsfunction apple_dart_t8020_irqfunction apple_dart_t8110_irqfunction apple_dart_probefunction apple_dart_removefunction apple_dart_suspend
Annotated Snippet
struct apple_dart_hw {
enum dart_type type;
irqreturn_t (*irq_handler)(int irq, void *dev);
int (*invalidate_tlb)(struct apple_dart_stream_map *stream_map);
u32 oas;
enum io_pgtable_fmt fmt;
int max_sid_count;
u32 lock;
u32 lock_bit;
u32 error;
u32 enable_streams;
u32 tcr;
u32 tcr_enabled;
u32 tcr_disabled;
u32 tcr_bypass;
u32 tcr_4level;
u32 ttbr;
u32 ttbr_valid;
u32 ttbr_addr_field_shift;
u32 ttbr_shift;
int ttbr_count;
};
/*
* Private structure associated with each DART device.
*
* @dev: device struct
* @hw: SoC-specific hardware data
* @regs: mapped MMIO region
* @irq: interrupt number, can be shared with other DARTs
* @clks: clocks associated with this DART
* @num_clks: number of @clks
* @lock: lock for hardware operations involving this dart
* @pgsize: pagesize supported by this DART
* @supports_bypass: indicates if this DART supports bypass mode
* @sid2group: maps stream ids to iommu_groups
* @iommu: iommu core device
*/
struct apple_dart {
struct device *dev;
const struct apple_dart_hw *hw;
void __iomem *regs;
int irq;
struct clk_bulk_data *clks;
int num_clks;
spinlock_t lock;
u32 ias;
u32 oas;
u32 pgsize;
u32 num_streams;
u32 supports_bypass : 1;
u32 four_level : 1;
struct iommu_group *sid2group[DART_MAX_STREAMS];
struct iommu_device iommu;
u32 save_tcr[DART_MAX_STREAMS];
u32 save_ttbr[DART_MAX_STREAMS][DART_MAX_TTBR];
};
/*
* Convenience struct to identify streams.
*
* The normal variant is used inside apple_dart_master_cfg which isn't written
* to concurrently.
* The atomic variant is used inside apple_dart_domain where we have to guard
* against races from potential parallel calls to attach/detach_device.
* Note that even inside the atomic variant the apple_dart pointer is not
* protected: This pointer is initialized once under the domain init mutex
* and never changed again afterwards. Devices with different dart pointers
* cannot be attached to the same domain.
*
* @dart dart pointer
* @sid stream id bitmap
*/
struct apple_dart_stream_map {
struct apple_dart *dart;
DECLARE_BITMAP(sidmap, DART_MAX_STREAMS);
};
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/bitfield.h`, `linux/clk.h`, `linux/dev_printk.h`, `linux/dma-mapping.h`, `linux/err.h`, `linux/interrupt.h`, `linux/io-pgtable.h`.
- Detected declarations: `struct apple_dart_stream_map`, `struct apple_dart_hw`, `struct apple_dart`, `struct apple_dart_stream_map`, `struct apple_dart_atomic_stream_map`, `struct apple_dart_domain`, `struct apple_dart_master_cfg`, `enum dart_type`, `function apple_dart_hw_enable_translation`, `function apple_dart_hw_disable_dma`.
- 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.