diff options
author | Alex Xu (Hello71) <alex_y_xu@yahoo.ca> | 2020-02-28 15:57:01 -0500 |
---|---|---|
committer | Alex Xu (Hello71) <alex_y_xu@yahoo.ca> | 2020-02-28 16:00:17 -0500 |
commit | 8f8a9ef9cdf2aa6f41b8202adf6b1b4d818ca939 (patch) | |
tree | 6125b8ddf6f957816f8d9c72b2f7ee97a85cf615 | |
parent | 203854ccd133f40b8c121feee681cb9182b90566 (diff) | |
download | pciutils-iommu_group.tar.gz |
lspci: Print IOMMU groups with -viommu_group
-rw-r--r-- | lib/pci.h | 1 | ||||
-rw-r--r-- | lib/sysfs.c | 10 | ||||
-rw-r--r-- | lspci.c | 14 |
3 files changed, 21 insertions, 4 deletions
@@ -194,6 +194,7 @@ char *pci_get_string_property(struct pci_dev *d, u32 prop) PCI_ABI; #define PCI_FILL_NUMA_NODE 0x0800 #define PCI_FILL_IO_FLAGS 0x1000 #define PCI_FILL_DT_NODE 0x2000 /* Device tree node */ +#define PCI_FILL_IOMMU_GROUP 0x4000 #define PCI_FILL_RESCAN 0x00010000 void pci_setup_cache(struct pci_dev *, u8 *cache, int len) PCI_ABI; diff --git a/lib/sysfs.c b/lib/sysfs.c index 42c88c6..538ca60 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -329,6 +329,16 @@ sysfs_fill_info(struct pci_dev *d, int flags) if ((flags & PCI_FILL_NUMA_NODE) && !(d->known_fields & PCI_FILL_NUMA_NODE)) d->numa_node = sysfs_get_value(d, "numa_node", 0); + if ((flags & PCI_FILL_IOMMU_GROUP) && !(d->known_fields & PCI_FILL_IOMMU_GROUP)) + { + char *group_link = sysfs_deref_link(d, "iommu_group"); + if (group_link) + { + pci_set_property(d, PCI_FILL_IOMMU_GROUP, basename(group_link)); + free(group_link); + } + } + if ((flags & PCI_FILL_DT_NODE) && !(d->known_fields & PCI_FILL_DT_NODE)) { char *node = sysfs_deref_link(d, "of_node"); @@ -725,12 +725,12 @@ show_verbose(struct device *d) byte max_lat, min_gnt; byte int_pin = get_conf_byte(d, PCI_INTERRUPT_PIN); unsigned int irq; - char *dt_node; + char *dt_node, *iommu_group; show_terse(d); pci_fill_info(p, PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE | PCI_FILL_SIZES | - PCI_FILL_PHYS_SLOT | PCI_FILL_NUMA_NODE | PCI_FILL_DT_NODE); + PCI_FILL_PHYS_SLOT | PCI_FILL_NUMA_NODE | PCI_FILL_DT_NODE | PCI_FILL_IOMMU_GROUP); irq = p->irq; switch (htype) @@ -814,6 +814,8 @@ show_verbose(struct device *d) (int_pin ? 'A' + int_pin - 1 : '?'), irq); if (p->numa_node != -1) printf("\tNUMA node: %d\n", p->numa_node); + if (iommu_group = pci_get_string_property(p, PCI_FILL_IOMMU_GROUP)) + printf("\tIOMMU group: %s\n", iommu_group); } else { @@ -840,6 +842,8 @@ show_verbose(struct device *d) printf(", IRQ " PCIIRQ_FMT, irq); if (p->numa_node != -1) printf(", NUMA node %d", p->numa_node); + if (iommu_group = pci_get_string_property(p, PCI_FILL_IOMMU_GROUP)) + printf(", IOMMU group %s", iommu_group); putchar('\n'); } @@ -910,13 +914,13 @@ show_machine(struct device *d) int c; word sv_id, sd_id; char classbuf[128], vendbuf[128], devbuf[128], svbuf[128], sdbuf[128]; - char *dt_node; + char *dt_node, *iommu_group; get_subid(d, &sv_id, &sd_id); if (verbose) { - pci_fill_info(p, PCI_FILL_PHYS_SLOT | PCI_FILL_NUMA_NODE | PCI_FILL_DT_NODE); + pci_fill_info(p, PCI_FILL_PHYS_SLOT | PCI_FILL_NUMA_NODE | PCI_FILL_DT_NODE | PCI_FILL_IOMMU_GROUP); printf((opt_machine >= 2) ? "Slot:\t" : "Device:\t"); show_slot_name(d); putchar('\n'); @@ -945,6 +949,8 @@ show_machine(struct device *d) printf("NUMANode:\t%d\n", p->numa_node); if (dt_node = pci_get_string_property(p, PCI_FILL_DT_NODE)) printf("DTNode:\t%s\n", dt_node); + if (iommu_group = pci_get_string_property(p, PCI_FILL_IOMMU_GROUP)) + printf("IOMMUGroup:\t%s\n", iommu_group); } else { |