Skip to content

Commit ee974d9

Browse files
buytenhjoergroedel
authored andcommitted
iommu/amd: Fix printing of IOMMU events when rate limiting kicks in
For the printing of RMP_HW_ERROR / RMP_PAGE_FAULT / IO_PAGE_FAULT events, the AMD IOMMU code uses such logic: if (pdev) dev_data = dev_iommu_priv_get(&pdev->dev); if (dev_data && __ratelimit(&dev_data->rs)) { pci_err(pdev, ... } else { printk_ratelimit() / pr_err{,_ratelimited}(... } This means that if we receive an event for a PCI devid which actually does have a struct pci_dev and an attached struct iommu_dev_data, but rate limiting kicks in, we'll fall back to the non-PCI branch of the test, and print the event in a different format. Fix this by changing the logic to: if (dev_data) { if (__ratelimit(&dev_data->rs)) { pci_err(pdev, ... } } else { pr_err_ratelimited(... } Suggested-by: Suravee Suthikulpanit <[email protected]> Signed-off-by: Lennert Buytenhek <[email protected]> Reviewed-by: Suravee Suthikulpanit <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 8bc5482 commit ee974d9

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

drivers/iommu/amd/iommu.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,11 @@ static void amd_iommu_report_rmp_hw_error(volatile u32 *event)
425425
if (pdev)
426426
dev_data = dev_iommu_priv_get(&pdev->dev);
427427

428-
if (dev_data && __ratelimit(&dev_data->rs)) {
429-
pci_err(pdev, "Event logged [RMP_HW_ERROR vmg_tag=0x%04x, spa=0x%llx, flags=0x%04x]\n",
430-
vmg_tag, spa, flags);
428+
if (dev_data) {
429+
if (__ratelimit(&dev_data->rs)) {
430+
pci_err(pdev, "Event logged [RMP_HW_ERROR vmg_tag=0x%04x, spa=0x%llx, flags=0x%04x]\n",
431+
vmg_tag, spa, flags);
432+
}
431433
} else {
432434
pr_err_ratelimited("Event logged [RMP_HW_ERROR device=%02x:%02x.%x, vmg_tag=0x%04x, spa=0x%llx, flags=0x%04x]\n",
433435
PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
@@ -456,9 +458,11 @@ static void amd_iommu_report_rmp_fault(volatile u32 *event)
456458
if (pdev)
457459
dev_data = dev_iommu_priv_get(&pdev->dev);
458460

459-
if (dev_data && __ratelimit(&dev_data->rs)) {
460-
pci_err(pdev, "Event logged [RMP_PAGE_FAULT vmg_tag=0x%04x, gpa=0x%llx, flags_rmp=0x%04x, flags=0x%04x]\n",
461-
vmg_tag, gpa, flags_rmp, flags);
461+
if (dev_data) {
462+
if (__ratelimit(&dev_data->rs)) {
463+
pci_err(pdev, "Event logged [RMP_PAGE_FAULT vmg_tag=0x%04x, gpa=0x%llx, flags_rmp=0x%04x, flags=0x%04x]\n",
464+
vmg_tag, gpa, flags_rmp, flags);
465+
}
462466
} else {
463467
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",
464468
PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
@@ -480,11 +484,13 @@ static void amd_iommu_report_page_fault(u16 devid, u16 domain_id,
480484
if (pdev)
481485
dev_data = dev_iommu_priv_get(&pdev->dev);
482486

483-
if (dev_data && __ratelimit(&dev_data->rs)) {
484-
pci_err(pdev, "Event logged [IO_PAGE_FAULT domain=0x%04x address=0x%llx flags=0x%04x]\n",
485-
domain_id, address, flags);
486-
} else if (printk_ratelimit()) {
487-
pr_err("Event logged [IO_PAGE_FAULT device=%02x:%02x.%x domain=0x%04x address=0x%llx flags=0x%04x]\n",
487+
if (dev_data) {
488+
if (__ratelimit(&dev_data->rs)) {
489+
pci_err(pdev, "Event logged [IO_PAGE_FAULT domain=0x%04x address=0x%llx flags=0x%04x]\n",
490+
domain_id, address, flags);
491+
}
492+
} else {
493+
pr_err_ratelimited("Event logged [IO_PAGE_FAULT device=%02x:%02x.%x domain=0x%04x address=0x%llx flags=0x%04x]\n",
488494
PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
489495
domain_id, address, flags);
490496
}

0 commit comments

Comments
 (0)