iommu/amd: Fix printing of IOMMU events when rate limiting kicks in
authorLennert Buytenhek <buytenh@wantstofly.org>
Wed, 21 Jul 2021 13:44:53 +0000 (16:44 +0300)
committerJoerg Roedel <jroedel@suse.de>
Mon, 26 Jul 2021 12:22:40 +0000 (14:22 +0200)
commitee974d9625c405977ef5d9aedc476be1d0362ebf
tree191967d2d34f9b1bac66684c8fe5ea198c7a3adc
parent8bc54824da4e8fcf0ed679cf09ac32f23d83254a
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 <suravee.suthikulpanit@amd.com>
Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
Reviewed-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Link: https://lore.kernel.org/r/YPgk1dD1gPMhJXgY@wantstofly.org
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd/iommu.c