iommu/amd: Print PCI segment ID in error log messages
authorVasant Hegde <vasant.hegde@amd.com>
Wed, 6 Jul 2022 11:38:23 +0000 (17:08 +0530)
committerJoerg Roedel <jroedel@suse.de>
Thu, 7 Jul 2022 07:37:53 +0000 (09:37 +0200)
Print pci segment ID along with bdf. Useful for debugging.

Co-developed-by: Suravee Suthikulpaint <suravee.suthikulpanit@amd.com>
Signed-off-by: Suravee Suthikulpaint <suravee.suthikulpanit@amd.com>
Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
Link: https://lore.kernel.org/r/20220706113825.25582-34-vasant.hegde@amd.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd/init.c
drivers/iommu/amd/iommu.c

index 19da19e..a3c4fdd 100644 (file)
@@ -1855,11 +1855,11 @@ static int __init init_iommu_all(struct acpi_table_header *table)
                h = (struct ivhd_header *)p;
                if (*p == amd_iommu_target_ivhd_type) {
 
-                       DUMP_printk("device: %02x:%02x.%01x cap: %04x "
-                                   "seg: %d flags: %01x info %04x\n",
-                                   PCI_BUS_NUM(h->devid), PCI_SLOT(h->devid),
-                                   PCI_FUNC(h->devid), h->cap_ptr,
-                                   h->pci_seg, h->flags, h->info);
+                       DUMP_printk("device: %04x:%02x:%02x.%01x cap: %04x "
+                                   "flags: %01x info %04x\n",
+                                   h->pci_seg, PCI_BUS_NUM(h->devid),
+                                   PCI_SLOT(h->devid), PCI_FUNC(h->devid),
+                                   h->cap_ptr, h->flags, h->info);
                        DUMP_printk("       mmio-addr: %016llx\n",
                                    h->mmio_phys);
 
index 2dbe17e..6a1db8f 100644 (file)
@@ -496,8 +496,8 @@ static void amd_iommu_report_rmp_hw_error(struct amd_iommu *iommu, volatile u32
                                vmg_tag, spa, flags);
                }
        } else {
-               pr_err_ratelimited("Event logged [RMP_HW_ERROR device=%02x:%02x.%x, vmg_tag=0x%04x, spa=0x%llx, flags=0x%04x]\n",
-                       PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+               pr_err_ratelimited("Event logged [RMP_HW_ERROR device=%04x:%02x:%02x.%x, vmg_tag=0x%04x, spa=0x%llx, flags=0x%04x]\n",
+                       iommu->pci_seg->id, PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
                        vmg_tag, spa, flags);
        }
 
@@ -529,8 +529,8 @@ static void amd_iommu_report_rmp_fault(struct amd_iommu *iommu, volatile u32 *ev
                                vmg_tag, gpa, flags_rmp, flags);
                }
        } else {
-               pr_err_ratelimited("Event logged [RMP_PAGE_FAULT device=%02x:%02x.%x, vmg_tag=0x%04x, gpa=0x%llx, flags_rmp=0x%04x, flags=0x%04x]\n",
-                       PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+               pr_err_ratelimited("Event logged [RMP_PAGE_FAULT device=%04x:%02x:%02x.%x, vmg_tag=0x%04x, gpa=0x%llx, flags_rmp=0x%04x, flags=0x%04x]\n",
+                       iommu->pci_seg->id, PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
                        vmg_tag, gpa, flags_rmp, flags);
        }
 
@@ -576,8 +576,8 @@ static void amd_iommu_report_page_fault(struct amd_iommu *iommu,
                                domain_id, address, flags);
                }
        } else {
-               pr_err_ratelimited("Event logged [IO_PAGE_FAULT device=%02x:%02x.%x domain=0x%04x address=0x%llx flags=0x%04x]\n",
-                       PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+               pr_err_ratelimited("Event logged [IO_PAGE_FAULT device=%04x:%02x:%02x.%x domain=0x%04x address=0x%llx flags=0x%04x]\n",
+                       iommu->pci_seg->id, PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
                        domain_id, address, flags);
        }
 
@@ -620,20 +620,20 @@ retry:
 
        switch (type) {
        case EVENT_TYPE_ILL_DEV:
-               dev_err(dev, "Event logged [ILLEGAL_DEV_TABLE_ENTRY device=%02x:%02x.%x pasid=0x%05x address=0x%llx flags=0x%04x]\n",
-                       PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+               dev_err(dev, "Event logged [ILLEGAL_DEV_TABLE_ENTRY device=%04x:%02x:%02x.%x pasid=0x%05x address=0x%llx flags=0x%04x]\n",
+                       iommu->pci_seg->id, PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
                        pasid, address, flags);
                dump_dte_entry(iommu, devid);
                break;
        case EVENT_TYPE_DEV_TAB_ERR:
-               dev_err(dev, "Event logged [DEV_TAB_HARDWARE_ERROR device=%02x:%02x.%x "
+               dev_err(dev, "Event logged [DEV_TAB_HARDWARE_ERROR device=%04x:%02x:%02x.%x "
                        "address=0x%llx flags=0x%04x]\n",
-                       PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+                       iommu->pci_seg->id, PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
                        address, flags);
                break;
        case EVENT_TYPE_PAGE_TAB_ERR:
-               dev_err(dev, "Event logged [PAGE_TAB_HARDWARE_ERROR device=%02x:%02x.%x pasid=0x%04x address=0x%llx flags=0x%04x]\n",
-                       PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+               dev_err(dev, "Event logged [PAGE_TAB_HARDWARE_ERROR device=%04x:%02x:%02x.%x pasid=0x%04x address=0x%llx flags=0x%04x]\n",
+                       iommu->pci_seg->id, PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
                        pasid, address, flags);
                break;
        case EVENT_TYPE_ILL_CMD:
@@ -645,13 +645,13 @@ retry:
                        address, flags);
                break;
        case EVENT_TYPE_IOTLB_INV_TO:
-               dev_err(dev, "Event logged [IOTLB_INV_TIMEOUT device=%02x:%02x.%x address=0x%llx]\n",
-                       PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+               dev_err(dev, "Event logged [IOTLB_INV_TIMEOUT device=%04x:%02x:%02x.%x address=0x%llx]\n",
+                       iommu->pci_seg->id, PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
                        address);
                break;
        case EVENT_TYPE_INV_DEV_REQ:
-               dev_err(dev, "Event logged [INVALID_DEVICE_REQUEST device=%02x:%02x.%x pasid=0x%05x address=0x%llx flags=0x%04x]\n",
-                       PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+               dev_err(dev, "Event logged [INVALID_DEVICE_REQUEST device=%04x:%02x:%02x.%x pasid=0x%05x address=0x%llx flags=0x%04x]\n",
+                       iommu->pci_seg->id, PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
                        pasid, address, flags);
                break;
        case EVENT_TYPE_RMP_FAULT:
@@ -663,8 +663,8 @@ retry:
        case EVENT_TYPE_INV_PPR_REQ:
                pasid = PPR_PASID(*((u64 *)__evt));
                tag = event[1] & 0x03FF;
-               dev_err(dev, "Event logged [INVALID_PPR_REQUEST device=%02x:%02x.%x pasid=0x%05x address=0x%llx flags=0x%04x tag=0x%03x]\n",
-                       PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+               dev_err(dev, "Event logged [INVALID_PPR_REQUEST device=%04x:%02x:%02x.%x pasid=0x%05x address=0x%llx flags=0x%04x tag=0x%03x]\n",
+                       iommu->pci_seg->id, PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
                        pasid, address, flags, tag);
                break;
        default: