drivers/iommu/amd/debugfs.c
Source file repositories/reference/linux-study-clean/drivers/iommu/amd/debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iommu/amd/debugfs.c- Extension
.c- Size
- 9725 bytes
- Lines
- 393
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/debugfs.hlinux/pci.hamd_iommu.h../irq_remapping.h
Detected Declarations
function iommu_mmio_writefunction iommu_mmio_showfunction iommu_capability_writefunction iommu_capability_showfunction iommu_cmdbuf_showfunction devid_writefunction devid_showfunction dump_dtefunction iommu_devtbl_showfunction for_each_pci_segmentfunction dump_128_irtefunction dump_32_irtefunction dump_irtefunction iommu_irqtbl_showfunction for_each_pci_segmentfunction amd_iommu_debugfs_setupfunction for_each_iommu
Annotated Snippet
if (i != 3) {
kfree(srcid_ptr);
return -EINVAL;
}
seg = 0;
}
devid = PCI_DEVID(bus, PCI_DEVFN(slot, func));
/* Check if user device id input is a valid input */
for_each_pci_segment(pci_seg) {
if (pci_seg->id != seg)
continue;
if (devid > pci_seg->last_bdf) {
kfree(srcid_ptr);
return -EINVAL;
}
iommu = pci_seg->rlookup_table[devid];
if (!iommu) {
kfree(srcid_ptr);
return -ENODEV;
}
break;
}
if (pci_seg->id != seg) {
kfree(srcid_ptr);
return -EINVAL;
}
sbdf = PCI_SEG_DEVID_TO_SBDF(seg, devid);
kfree(srcid_ptr);
return cnt;
}
static int devid_show(struct seq_file *m, void *unused)
{
u16 devid;
int sbdf_shadow = sbdf;
if (sbdf_shadow >= 0) {
devid = PCI_SBDF_TO_DEVID(sbdf_shadow);
seq_printf(m, "%04x:%02x:%02x.%x\n", PCI_SBDF_TO_SEGID(sbdf_shadow),
PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid));
} else
seq_puts(m, "No or Invalid input provided\n");
return 0;
}
DEFINE_SHOW_STORE_ATTRIBUTE(devid);
static void dump_dte(struct seq_file *m, struct amd_iommu_pci_seg *pci_seg, u16 devid)
{
struct dev_table_entry *dev_table;
struct amd_iommu *iommu;
iommu = pci_seg->rlookup_table[devid];
if (!iommu)
return;
dev_table = get_dev_table(iommu);
if (!dev_table) {
seq_puts(m, "Device table not found");
return;
}
seq_printf(m, "%-12s %16s %16s %16s %16s iommu\n", "DeviceId",
"QWORD[3]", "QWORD[2]", "QWORD[1]", "QWORD[0]");
seq_printf(m, "%04x:%02x:%02x.%x ", pci_seg->id, PCI_BUS_NUM(devid),
PCI_SLOT(devid), PCI_FUNC(devid));
for (int i = 3; i >= 0; --i)
seq_printf(m, "%016llx ", dev_table[devid].data[i]);
seq_printf(m, "iommu%d\n", iommu->index);
}
static int iommu_devtbl_show(struct seq_file *m, void *unused)
{
struct amd_iommu_pci_seg *pci_seg;
u16 seg, devid;
int sbdf_shadow = sbdf;
if (sbdf_shadow < 0) {
seq_puts(m, "Enter a valid device ID to 'devid' file\n");
return 0;
}
seg = PCI_SBDF_TO_SEGID(sbdf_shadow);
devid = PCI_SBDF_TO_DEVID(sbdf_shadow);
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/pci.h`, `amd_iommu.h`, `../irq_remapping.h`.
- Detected declarations: `function iommu_mmio_write`, `function iommu_mmio_show`, `function iommu_capability_write`, `function iommu_capability_show`, `function iommu_cmdbuf_show`, `function devid_write`, `function devid_show`, `function dump_dte`, `function iommu_devtbl_show`, `function for_each_pci_segment`.
- 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.
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.