[PATCH v2 1/3] iommu/rockchip: Rate-limit the page fault reports

From: Arun Iyengar via B4 Relay

Date: Wed Dec 02 2026 - 21:38:25 EST


From: Arun Iyengar <aiyengar1990@xxxxxxxxx>

rk_iommu_irq() prints three lines per page fault from the hard
interrupt handler, now with iommu->lock held. A VEPU121 core on RK3588
that kept faulting took 149 faults in its 2 s timeout, and a 115200
baud console kept the CPU in the handler for about all of it.

Print at most DEFAULT_RATELIMIT_BURST reports per
DEFAULT_RATELIMIT_INTERVAL and IOMMU, BUS_ERROR included.
report_iommu_fault() is still called for every fault.

Signed-off-by: Arun Iyengar <aiyengar1990@xxxxxxxxx>
---
drivers/iommu/rockchip-iommu.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
index 45d78fca6758..1509b4527be9 100644
--- a/drivers/iommu/rockchip-iommu.c
+++ b/drivers/iommu/rockchip-iommu.c
@@ -23,6 +23,7 @@
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
+#include <linux/ratelimit.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/string_choices.h>
@@ -117,6 +118,7 @@ struct rk_iommu {
struct iommu_domain *domain; /* domain to which iommu is attached */
spinlock_t lock;
const struct rk_iommu_ops *rk_ops;
+ struct ratelimit_state fault_rs; /* for the fault reports */
};

struct rk_iommudata {
@@ -606,6 +608,7 @@ static irqreturn_t rk_iommu_irq(int irq, void *dev_id)
u32 int_status;
dma_addr_t iova;
irqreturn_t ret = IRQ_NONE;
+ bool print;
int i, err;

err = pm_runtime_get_if_in_use(iommu->dev);
@@ -632,11 +635,14 @@ static irqreturn_t rk_iommu_irq(int irq, void *dev_id)
flags = (status & RK_MMU_STATUS_PAGE_FAULT_IS_WRITE) ?
IOMMU_FAULT_WRITE : IOMMU_FAULT_READ;

- dev_err(iommu->dev, "Page fault at %pad of type %s\n",
- &iova,
- str_write_read(flags == IOMMU_FAULT_WRITE));
-
- log_iova(iommu, domain, i, iova);
+ /* A faulting master faults again at once; don't print every time */
+ print = __ratelimit(&iommu->fault_rs);
+ if (print) {
+ dev_err(iommu->dev, "Page fault at %pad of type %s\n",
+ &iova,
+ str_write_read(flags == IOMMU_FAULT_WRITE));
+ log_iova(iommu, domain, i, iova);
+ }

/*
* Report page fault to any installed handlers.
@@ -646,14 +652,15 @@ static irqreturn_t rk_iommu_irq(int irq, void *dev_id)
if (domain != &rk_identity_domain)
report_iommu_fault(domain, iommu->dev, iova,
flags);
- else
+ else if (print)
dev_err(iommu->dev, "Page fault while iommu not attached to domain?\n");

rk_iommu_base_command(iommu->bases[i], RK_MMU_CMD_ZAP_CACHE);
rk_iommu_base_command(iommu->bases[i], RK_MMU_CMD_PAGE_FAULT_DONE);
}

- if (int_status & RK_MMU_IRQ_BUS_ERROR)
+ if ((int_status & RK_MMU_IRQ_BUS_ERROR) &&
+ __ratelimit(&iommu->fault_rs))
dev_err(iommu->dev, "BUS_ERROR occurred at %pad\n", &iova);

if (int_status & ~RK_MMU_IRQ_MASK)
@@ -1278,6 +1285,8 @@ static int rk_iommu_probe(struct platform_device *pdev)

iommu->reset_disabled = device_property_read_bool(dev,
"rockchip,disable-mmu-reset");
+ ratelimit_state_init(&iommu->fault_rs, DEFAULT_RATELIMIT_INTERVAL,
+ DEFAULT_RATELIMIT_BURST);

/*
* Take every clock the devicetree provides. Most IOMMU instances

--
2.55.0