From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0975E3C8719 for ; Wed, 5 Aug 2026 04:20:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785903628; cv=none; b=H9Rg50ZS/KwppKg6ZkORUsYp8ETM09HOy8HzIy7IlUS7itj5iHQRCl9jnVeOh0tsgJeNU+/MdEHDnSKG2J/Qk28ooSeUFvAk2brCquntM+RkWB5VNf1t6f1hwRe/jJgA5FimxzaeHqNwmjhe9fcDazDTnQ9WMXwLX3MUV/QY15w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785903628; c=relaxed/simple; bh=2mTxLEZZHRX66QWhlcyMv8CxW70Ble7AYSdF/5GnDSs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=SzNOdeX8Ha/oen7sVU1PnPlGS2OjRc2TFboJ/bQCjl8lusJ59KwqtIAWEMa1QEHaPe0M13XGAxfvPGI8t4xc0ezPxW22Jx7sHlfodgpOuYV4oPMFBSI+NCjhoUv4L0Q6Lno69fLTluVsVhEx0EepowXc4WlzoSPO+pZLeHJzcT0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=socP7tjX; arc=none smtp.client-ip=115.124.30.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="socP7tjX" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1785903621; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=6PbQk7Ljeu2Nh5gx4GLKOoas/XpSlt4pFhaaMaIb66I=; b=socP7tjXS46hERDTXeN2NmG/TvQepf5d8QMqRwb0U10Ec/egQxwhB4KSl3F6BSret6hcfqiE10VCy4NEqYrqpQJdikz9MCvUBDDou6DakSrgo8fF2iXVs5E1gmunoQM83+A1eL7Ktzf8+vcN0dYzKt5P4T57EJI0Vsoh+gsEw6Y= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R361e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037026112;MF=guanghuifeng@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0X8Q-Oda_1785903612; Received: from VM20241011-104.tbsite.net(mailfrom:guanghuifeng@linux.alibaba.com fp:SMTPD_---0X8Q-Oda_1785903612 cluster:ay36) by smtp.aliyun-inc.com; Wed, 05 Aug 2026 12:20:20 +0800 From: Guanghui Feng To: dwmw2@infradead.org, baolu.lu@linux.intel.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] iommu/vt-d: Fix IQE handling to cover all descriptors in submission range Date: Wed, 5 Aug 2026 12:20:12 +0800 Message-ID: <20260805042012.2363698-1-guanghuifeng@linux.alibaba.com> X-Mailer: git-send-email 2.43.7 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Currently, qi_check_fault() only handles IQE (Invalidation Queue Error) when the faulting descriptor index exactly matches the first descriptor of the current submission (head == index). This is too restrictive in multi-descriptor submissions where the error could occur at any descriptor within the batch. If the IQE is triggered by a descriptor that belongs to the current submission but is not at the starting index, the function returns 0 without clearing the IQE fault status. Since hardware stops fetching new descriptors until IQE is cleared, this leads to an indefinite wait on the wait descriptor completion - effectively a deadlock. Fix this by expanding the IQE handling condition to cover all descriptors within the circular range [index, wait_index]. Use explicit bounds checking that properly handles the wrap-around case of the circular queue. Signed-off-by: Guanghui Feng Signed-off-by: bikuan.zbk --- drivers/iommu/intel/dmar.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c index 767ec092accd..8ae513593406 100644 --- a/drivers/iommu/intel/dmar.c +++ b/drivers/iommu/intel/dmar.c @@ -1290,8 +1290,13 @@ static int qi_check_fault(struct intel_iommu *iommu, int index, int wait_index) * is cleared. */ if (fault & DMA_FSTS_IQE) { + int head_idx; + head = readl(iommu->reg + DMAR_IQH_REG); - if ((head >> shift) == index) { + head_idx = head >> shift; + if (index <= wait_index ? + (head_idx >= index && head_idx <= wait_index) : + (head_idx >= index || head_idx <= wait_index)) { struct qi_desc *desc = qi->desc + head; /* -- 2.43.7