From: Zqiang <[email protected]>

When a device or driver misbehaves, it is possible to receive events
much faster than we can print them out. Ratelimit the printing of events

During the SVA tests when the device driver didn't properly stop DMA
before unbinding, the event queue thread would almost lock-up the server
with a flood of event 0xa. This patch helped recover from the error.

Tested-by: Aaro Koskinen <[email protected]>
Signed-off-by: Jean-Philippe Brucker <[email protected]>
Signed-off-by: Zqiang <[email protected]>
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c 
b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index 7067b7c11626..583db3dd1465 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -1357,16 +1357,20 @@ static irqreturn_t arm_smmu_evtq_thread(int irq, void 
*dev)
        struct arm_smmu_device *smmu = dev;
        struct arm_smmu_queue *q = &smmu->evtq.q;
        struct arm_smmu_ll_queue *llq = &q->llq;
+       static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL,
+                                       DEFAULT_RATELIMIT_BURST);
        u64 evt[EVTQ_ENT_DWORDS];
 
        do {
                while (!queue_remove_raw(q, evt)) {
                        u8 id = FIELD_GET(EVTQ_0_ID, evt[0]);
 
-                       dev_info(smmu->dev, "event 0x%02x received:\n", id);
-                       for (i = 0; i < ARRAY_SIZE(evt); ++i)
-                               dev_info(smmu->dev, "\t0x%016llx\n",
-                                        (unsigned long long)evt[i]);
+                       if (__ratelimit(&rs)) {
+                               dev_info(smmu->dev, "event 0x%02x received:\n", 
id);
+                               for (i = 0; i < ARRAY_SIZE(evt); ++i)
+                                       dev_info(smmu->dev, "\t0x%016llx\n",
+                                               (unsigned long long)evt[i]);
+                       }
 
                }
 
-- 
2.31.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#9928): 
https://lists.yoctoproject.org/g/linux-yocto/message/9928
Mute This Topic: https://lists.yoctoproject.org/mt/83252521/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to