From: Dmitry Safonov via iommu Subject: [PATCHv4 2/2] iommu/vt-d: Limit number of faults to clear in irq handler Date: Sat, 31 Mar 2018 01:33:12 +0100 Message-ID: <20180331003312.6390-2-dima@arista.com> References: <20180331003312.6390-1-dima@arista.com> Reply-To: Dmitry Safonov Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20180331003312.6390-1-dima-nzgTgzXrdUbQT0dZR+AlfA@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org Cc: Dmitry Safonov , 0x7f454c46-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, David Woodhouse , Ingo Molnar List-Id: iommu@lists.linux-foundation.org Theoretically, on some machines faults might be generated faster than they're cleared by CPU. Let's limit the cleaning-loop by number of hw fault registers. Cc: Alex Williamson Cc: David Woodhouse Cc: Ingo Molnar Cc: Joerg Roedel Cc: Lu Baolu Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Signed-off-by: Dmitry Safonov --- drivers/iommu/dmar.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c index 6c4ea32ee6a9..cf1105111209 100644 --- a/drivers/iommu/dmar.c +++ b/drivers/iommu/dmar.c @@ -1615,7 +1615,7 @@ static int dmar_fault_do_one(struct intel_iommu *iommu, int type, irqreturn_t dmar_fault(int irq, void *dev_id) { struct intel_iommu *iommu = dev_id; - int reg, fault_index; + int reg, fault_index, i; u32 fault_status; unsigned long flag; static DEFINE_RATELIMIT_STATE(rs, @@ -1633,7 +1633,7 @@ irqreturn_t dmar_fault(int irq, void *dev_id) fault_index = dma_fsts_fault_record_index(fault_status); reg = cap_fault_reg_offset(iommu->cap); - while (1) { + for (i = 0; i < cap_num_fault_regs(iommu->cap); i++) { /* Disable printing, simply clear the fault when ratelimited */ bool ratelimited = !__ratelimit(&rs); u8 fault_reason; -- 2.13.6