From nobody Mon May 11 02:55:34 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9ECC0C433FE for ; Sat, 16 Apr 2022 12:33:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231968AbiDPMgK (ORCPT ); Sat, 16 Apr 2022 08:36:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbiDPMgF (ORCPT ); Sat, 16 Apr 2022 08:36:05 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63BACFE429 for ; Sat, 16 Apr 2022 05:33:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650112413; x=1681648413; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tCjF1I4YjEgxSy7zR9vWw2QROF8JK1qkQd4b3h+ujew=; b=Gnfuz0w0/RFifaqu8RBqzCjaxKrQ5nj+8f/vg+ttI+1vVmaUg/wEsuSM SFcsY7MTbHZVN1IFn6sGJxRKC3yLwQCYdgcURz0ztpavqcTUycOSm4Be+ w88tloGp3usGZSjejW5J2JhIPWHDSfZeyGTpvehkly56lHCIeTr5qwuXO 3mcjzNsp5OTr5WcTAUIcuYcy30oRN9MfD3NxNgMwnT/a7vH/Ys5i4TBg2 MZhWtkiv/KSS6M4v+fbTUUlR/+JNJcVAKyv/NIP+hHGB7o7JrmMj4a2K3 s7K/8r8QW9TaM3Ur8d4urexX8jGH9Zls02d8hlx6viVzUmgM3Mg4flmJD w==; X-IronPort-AV: E=McAfee;i="6400,9594,10318"; a="243221101" X-IronPort-AV: E=Sophos;i="5.90,264,1643702400"; d="scan'208";a="243221101" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2022 05:33:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,264,1643702400"; d="scan'208";a="701332465" Received: from allen-box.sh.intel.com ([10.239.159.48]) by fmsmga001.fm.intel.com with ESMTP; 16 Apr 2022 05:33:31 -0700 From: Lu Baolu To: Jacob jun Pan , Kevin Tian , Ashok Raj , Liu Yi L Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 1/3] iommu/vt-d: Set PGSNP bit in pasid table entry for sva binding Date: Sat, 16 Apr 2022 20:30:47 +0800 Message-Id: <20220416123049.879969-2-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220416123049.879969-1-baolu.lu@linux.intel.com> References: <20220416123049.879969-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This field make the requests snoop processor caches irrespective of other attributes in the request or other fields in paging structure entries used to translate the request. The latest VT-d specification states that this field is treated as Reserved(0) for implementations not supporting Snoop Control (SC=3D0 in the Extended Capability Register). Hence add a check in the code. Signed-off-by: Lu Baolu --- drivers/iommu/intel/pasid.c | 2 +- drivers/iommu/intel/svm.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index f8d215d85695..9ca3c67a2058 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -625,7 +625,7 @@ int intel_pasid_setup_first_level(struct intel_iommu *i= ommu, } } =20 - if (flags & PASID_FLAG_PAGE_SNOOP) + if ((flags & PASID_FLAG_PAGE_SNOOP) && ecap_sc_support(iommu->ecap)) pasid_set_pgsnp(pte); =20 pasid_set_domain_id(pte, did); diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index 23a38763c1d1..d88af37c20ef 100644 --- a/drivers/iommu/intel/svm.c +++ b/drivers/iommu/intel/svm.c @@ -394,6 +394,7 @@ static struct iommu_sva *intel_svm_bind_mm(struct intel= _iommu *iommu, sflags =3D (flags & SVM_FLAG_SUPERVISOR_MODE) ? PASID_FLAG_SUPERVISOR_MODE : 0; sflags |=3D cpu_feature_enabled(X86_FEATURE_LA57) ? PASID_FLAG_FL5LP : 0; + sflags |=3D PASID_FLAG_PAGE_SNOOP; spin_lock_irqsave(&iommu->lock, iflags); ret =3D intel_pasid_setup_first_level(iommu, dev, mm->pgd, mm->pasid, FLPT_DEFAULT_DID, sflags); --=20 2.25.1 From nobody Mon May 11 02:55:34 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0657C433EF for ; Sat, 16 Apr 2022 12:33:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231978AbiDPMgP (ORCPT ); Sat, 16 Apr 2022 08:36:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230055AbiDPMgH (ORCPT ); Sat, 16 Apr 2022 08:36:07 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A27FFE427 for ; Sat, 16 Apr 2022 05:33:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650112415; x=1681648415; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=s/nEvl/+FxcEwkLWfzrwaMLflIe37RdxIWhxas3awd4=; b=gMgABO3sWFlcsHehJ2wVh301+E2HKhX5Q9PDOKPOVQwS6x9YN4Omc5JU DTjvX/gf8UjUMW5mM7w93Z/SuIj7uy3QQJBmX520m0ERyuEO3Wz03fbLy eXlVzdbDJbplwgyCFmE1ZBTixf23hitqtkmefCs3DrDfUosq2sTCKJvsz zKPe6rLzuzgSAq8GlBv/mol2D4hA2Yx7XRH51309sv+RsvneV0WUdOvmF RSqWiMkQAYl321tCkaqGu3QNihzY7q/k36sQTt/YnlnBBPPDaEkGq2+FE etM0qF3VM/iO6H99Adcr2JAcuEyOuUj199QdWj60v5ob69XB/zfGmyyHI w==; X-IronPort-AV: E=McAfee;i="6400,9594,10318"; a="243221102" X-IronPort-AV: E=Sophos;i="5.90,264,1643702400"; d="scan'208";a="243221102" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2022 05:33:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,264,1643702400"; d="scan'208";a="701332474" Received: from allen-box.sh.intel.com ([10.239.159.48]) by fmsmga001.fm.intel.com with ESMTP; 16 Apr 2022 05:33:33 -0700 From: Lu Baolu To: Jacob jun Pan , Kevin Tian , Ashok Raj , Liu Yi L Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu , Jacob Pan Subject: [PATCH 2/3] iommu/vt-d: Drop stop marker messages Date: Sat, 16 Apr 2022 20:30:48 +0800 Message-Id: <20220416123049.879969-3-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220416123049.879969-1-baolu.lu@linux.intel.com> References: <20220416123049.879969-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The VT-d driver explicitly drains the pending page requests when a CPU page table (represented by a mm struct) is unbound from a PASID according to the procedures defined in the VT-d spec. Hence, there's no need to report the stop-marker message in prq_event_thread(). The stop marker messages do not need a response. This drops stop marker messages silently if any of them is found in the page request queue. Signed-off-by: Lu Baolu Reviewed-by: Jacob Pan --- drivers/iommu/intel/svm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index d88af37c20ef..d1c42dfae6ca 100644 --- a/drivers/iommu/intel/svm.c +++ b/drivers/iommu/intel/svm.c @@ -758,6 +758,10 @@ static irqreturn_t prq_event_thread(int irq, void *d) goto bad_req; } =20 + /* Drop Stop Marker message. No need for a response. */ + if (unlikely(req->lpig && !req->rd_req && !req->wr_req)) + goto prq_advance; + if (!svm || svm->pasid !=3D req->pasid) { /* * It can't go away, because the driver is not permitted --=20 2.25.1 From nobody Mon May 11 02:55:34 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4579AC433F5 for ; Sat, 16 Apr 2022 12:33:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231986AbiDPMgU (ORCPT ); Sat, 16 Apr 2022 08:36:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231607AbiDPMgI (ORCPT ); Sat, 16 Apr 2022 08:36:08 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92655FE427 for ; Sat, 16 Apr 2022 05:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650112417; x=1681648417; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bLV46reasuOPuFLE2C3UtgPLXAur55KabjsunKbN5r0=; b=Y8SRLd1Kkr4zOjjXAyGjvRdtMmYtSqspLagYFdqMrNFNNTjVPDPXNG3F kpOr4GqYtpXg/6A9qpjwM1jf//gc0QdH26nny8cYh/QErZE1/NpmJirvd hpeWQnUiE4AzxbxOOUHts8CfeVt4Es9+8Knl4hFnwgKKoAKgQdX5u/146 oSIVvgKSS+18geueBzfW+aA8PDua+FeWCyIQIEbnA59XGHnzqrFfKwkyh Al/SJlb6MJrKOOwsbb4a3oCqIV5tnvQs3EuI7USYU5Lmx9hvQUFG58D2V tdzr1ROLYYHeUFy19tIT6RGyH4kGRY1rlrksjNJTqxaCcisl482cTyWXk w==; X-IronPort-AV: E=McAfee;i="6400,9594,10318"; a="243221104" X-IronPort-AV: E=Sophos;i="5.90,264,1643702400"; d="scan'208";a="243221104" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2022 05:33:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,264,1643702400"; d="scan'208";a="701332481" Received: from allen-box.sh.intel.com ([10.239.159.48]) by fmsmga001.fm.intel.com with ESMTP; 16 Apr 2022 05:33:35 -0700 From: Lu Baolu To: Jacob jun Pan , Kevin Tian , Ashok Raj , Liu Yi L Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 3/3] iommu/vt-d: Size Page Request Queue to avoid overflow condition Date: Sat, 16 Apr 2022 20:30:49 +0800 Message-Id: <20220416123049.879969-4-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220416123049.879969-1-baolu.lu@linux.intel.com> References: <20220416123049.879969-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" PRQ overflow may cause I/O throughput congestion, resulting in unnecessary degradation of IO performance. Appropriately increasing the length of PRQ can greatly reduce the occurrence of PRQ overflow. The count of maximum page requests that can be generated in parallel by a PCIe device is statically defined in the Outstanding Page Request Capacity field of the PCIe ATS configure space. The new lenght of PRQ is calculated by summing up the value of Outstanding Page Request Capacity register across all devices where Page Requests are supported on the real PR-capable platfrom (Intel Sapphire Rapids). The result is round to the nearest higher power of 2. The PRQ length is also double sized as the VT-d IOMMU driver only updates the Page Request Queue Head Register (PQH_REG) after processing the entire queue. Signed-off-by: Lu Baolu --- include/linux/intel-svm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/intel-svm.h b/include/linux/intel-svm.h index b3b125b332aa..207ef06ba3e1 100644 --- a/include/linux/intel-svm.h +++ b/include/linux/intel-svm.h @@ -9,7 +9,7 @@ #define __INTEL_SVM_H__ =20 /* Page Request Queue depth */ -#define PRQ_ORDER 2 +#define PRQ_ORDER 4 #define PRQ_RING_MASK ((0x1000 << PRQ_ORDER) - 0x20) #define PRQ_DEPTH ((0x1000 << PRQ_ORDER) >> 5) =20 --=20 2.25.1