drivers/iommu/intel/debugfs.c
Source file repositories/reference/linux-study-clean/drivers/iommu/intel/debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iommu/intel/debugfs.c- Extension
.c- Size
- 22577 bytes
- Lines
- 816
- Domain
- Driver Families
- Bucket
- drivers/iommu
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/debugfs.hlinux/dmar.hlinux/pci.hasm/irq_remapping.hiommu.hpasid.hperf.h
Detected Declarations
struct tbl_walkstruct iommu_regsetfunction iommu_regset_showfunction print_tbl_walkfunction pasid_tbl_walkfunction pasid_dir_walkfunction ctx_tbl_walkfunction root_tbl_walkfunction dmar_translation_struct_showfunction level_to_directory_sizefunction dump_page_infofunction pgtable_walk_levelfunction domain_translation_struct_showfunction Typefunction dev_domain_translation_struct_showfunction pasid_domain_translation_struct_showfunction invalidation_queue_entry_showfunction invalidation_queue_showfunction ir_tbl_remap_entry_showfunction ir_tbl_posted_entry_showfunction ir_translation_struct_showfunction for_each_active_iommufunction latency_show_onefunction latency_showfunction dmar_perf_latency_openfunction dmar_perf_latency_writefunction for_each_active_iommufunction intel_iommu_debugfs_initfunction intel_iommu_debugfs_create_devfunction intel_iommu_debugfs_remove_devfunction intel_iommu_debugfs_create_dev_pasidfunction intel_iommu_debugfs_remove_dev_pasid
Annotated Snippet
static const struct file_operations dmar_perf_latency_fops = {
.open = dmar_perf_latency_open,
.write = dmar_perf_latency_write,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
void __init intel_iommu_debugfs_init(void)
{
intel_iommu_debug = debugfs_create_dir("intel", iommu_debugfs_dir);
debugfs_create_file("iommu_regset", 0444, intel_iommu_debug, NULL,
&iommu_regset_fops);
debugfs_create_file("dmar_translation_struct", 0444, intel_iommu_debug,
NULL, &dmar_translation_struct_fops);
debugfs_create_file("invalidation_queue", 0444, intel_iommu_debug,
NULL, &invalidation_queue_fops);
#ifdef CONFIG_IRQ_REMAP
debugfs_create_file("ir_translation_struct", 0444, intel_iommu_debug,
NULL, &ir_translation_struct_fops);
#endif
debugfs_create_file("dmar_perf_latency", 0644, intel_iommu_debug,
NULL, &dmar_perf_latency_fops);
}
/*
* Create a debugfs directory for each device, and then create a
* debugfs file in this directory for users to dump the page table
* of the default domain. e.g.
* /sys/kernel/debug/iommu/intel/0000:00:01.0/domain_translation_struct
*/
void intel_iommu_debugfs_create_dev(struct device_domain_info *info)
{
info->debugfs_dentry = debugfs_create_dir(dev_name(info->dev), intel_iommu_debug);
debugfs_create_file("domain_translation_struct", 0444, info->debugfs_dentry,
info, &dev_domain_translation_struct_fops);
}
/* Remove the device debugfs directory. */
void intel_iommu_debugfs_remove_dev(struct device_domain_info *info)
{
debugfs_remove_recursive(info->debugfs_dentry);
}
/*
* Create a debugfs directory per pair of {device, pasid}, then create the
* corresponding debugfs file in this directory for users to dump its page
* table. e.g.
* /sys/kernel/debug/iommu/intel/0000:00:01.0/1/domain_translation_struct
*
* The debugfs only dumps the page tables whose mappings are created and
* destroyed by the iommu_map/unmap() interfaces. Check the mapping type
* of the domain before creating debugfs directory.
*/
void intel_iommu_debugfs_create_dev_pasid(struct dev_pasid_info *dev_pasid)
{
struct device_domain_info *info = dev_iommu_priv_get(dev_pasid->dev);
char dir_name[10];
sprintf(dir_name, "%x", dev_pasid->pasid);
dev_pasid->debugfs_dentry = debugfs_create_dir(dir_name, info->debugfs_dentry);
debugfs_create_file("domain_translation_struct", 0444, dev_pasid->debugfs_dentry,
dev_pasid, &pasid_domain_translation_struct_fops);
}
/* Remove the device pasid debugfs directory. */
void intel_iommu_debugfs_remove_dev_pasid(struct dev_pasid_info *dev_pasid)
{
debugfs_remove_recursive(dev_pasid->debugfs_dentry);
}
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/dmar.h`, `linux/pci.h`, `asm/irq_remapping.h`, `iommu.h`, `pasid.h`, `perf.h`.
- Detected declarations: `struct tbl_walk`, `struct iommu_regset`, `function iommu_regset_show`, `function print_tbl_walk`, `function pasid_tbl_walk`, `function pasid_dir_walk`, `function ctx_tbl_walk`, `function root_tbl_walk`, `function dmar_translation_struct_show`, `function level_to_directory_size`.
- Atlas domain: Driver Families / drivers/iommu.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.