]> mj.ucw.cz Git - pciutils.git/commitdiff
lspci: Print IOMMU groups with -v
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>
Fri, 28 Feb 2020 20:57:01 +0000 (15:57 -0500)
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>
Tue, 26 May 2020 15:33:38 +0000 (11:33 -0400)
lib/pci.h
lib/sysfs.c
lspci.c
lspci.man

index f5274dffe0da64350b0c8f8aff38578fa33b6e46..f2ebccd338bf1ee6f12dbc8aee05873f86120b25 100644 (file)
--- a/lib/pci.h
+++ b/lib/pci.h
@@ -204,6 +204,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;
index c302cbfc985eb38377fad710662ab4ec047f7fd6..47e1e8062723a4e171183a23da574f881bdaeeb4 100644 (file)
@@ -354,6 +354,16 @@ sysfs_fill_info(struct pci_dev *d, unsigned int flags)
       done |= PCI_FILL_NUMA_NODE;
     }
 
+  if (flags & 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)
     {
       char *node = sysfs_deref_link(d, "of_node");
diff --git a/lspci.c b/lspci.c
index 4e6196e2277332c747d123915011c62098ad6eb0..aba2745a919262f25c9127d27fcc97c09230bbe4 100644 (file)
--- a/lspci.c
+++ b/lspci.c
@@ -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
     {
index 8f456323ee7284aa9f3d3c2a2793e4565b6ac9d7..255a13a3f76e1ba0a9c03ec2ec0dbcb23712a981 100644 (file)
--- a/lspci.man
+++ b/lspci.man
@@ -316,6 +316,10 @@ Kernel module reporting that it is capable of handling the device
 .B NUMANode
 NUMA node this device is connected to (optional, Linux only).
 
+.TP
+.B IOMMUGroup
+IOMMU group that this device is part of (optional, Linux only).
+
 .P
 New tags can be added in future versions, so you should silently ignore any tags you don't recognize.