public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lu Baolu <baolu.lu@linux.intel.com>
To: Joerg Roedel <joro@8bytes.org>
Cc: YueHaibing <yuehaibing@huawei.com>,
	Yanfei Xu <yanfei.xu@intel.com>,
	Jacob Pan <jacob.jun.pan@linux.intel.com>,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH 06/13] iommu/vt-d: Prepare for set_dev_pasid callback
Date: Wed,  9 Aug 2023 20:47:59 +0800	[thread overview]
Message-ID: <20230809124806.45516-7-baolu.lu@linux.intel.com> (raw)
In-Reply-To: <20230809124806.45516-1-baolu.lu@linux.intel.com>

The domain_flush_pasid_iotlb() helper function is used to flush the IOTLB
entries for a given PASID. Previously, this function assumed that
RID2PASID was only used for the first-level DMA translation. However, with
the introduction of the set_dev_pasid callback, this assumption is no
longer valid.

Add a check before using the RID2PASID for PASID invalidation. This check
ensures that the domain has been attached to a physical device before
using RID2PASID.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Link: https://lore.kernel.org/r/20230802212427.1497170-7-jacob.jun.pan@linux.intel.com
---
 drivers/iommu/intel/iommu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index bdde38a5e43a..4a41aca6a2ba 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -1475,7 +1475,8 @@ static void domain_flush_pasid_iotlb(struct intel_iommu *iommu,
 	unsigned long flags;
 
 	spin_lock_irqsave(&domain->lock, flags);
-	qi_flush_piotlb(iommu, did, IOMMU_NO_PASID, addr, npages, ih);
+	if (!list_empty(&domain->devices))
+		qi_flush_piotlb(iommu, did, IOMMU_NO_PASID, addr, npages, ih);
 	spin_unlock_irqrestore(&domain->lock, flags);
 }
 
-- 
2.34.1


  parent reply	other threads:[~2023-08-09 12:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-09 12:47 [PATCH 00/13] [PULL REQUEST] Intel IOMMU updates for Linux v6.6 Lu Baolu
2023-08-09 12:47 ` [PATCH 01/13] iommu: Generalize PASID 0 for normal DMA w/o PASID Lu Baolu
2023-08-09 12:47 ` [PATCH 02/13] iommu: Move global PASID allocation from SVA to core Lu Baolu
2023-08-09 12:47 ` [PATCH 03/13] iommu/vt-d: Add domain_flush_pasid_iotlb() Lu Baolu
2023-08-09 12:47 ` [PATCH 04/13] iommu/vt-d: Remove pasid_mutex Lu Baolu
2023-08-09 12:47 ` [PATCH 05/13] iommu/vt-d: Make prq draining code generic Lu Baolu
2023-08-09 12:47 ` Lu Baolu [this message]
2023-08-09 12:48 ` [PATCH 07/13] iommu/vt-d: Add set_dev_pasid callback for dma domain Lu Baolu
2023-08-09 12:48 ` [PATCH 08/13] dmaengine/idxd: Re-enable kernel workqueue under DMA API Lu Baolu
2023-08-09 12:48 ` [PATCH 09/13] iommu: Prevent RESV_DIRECT devices from blocking domains Lu Baolu
2023-08-09 12:48 ` [PATCH 10/13] iommu/vt-d: Remove rmrr check in domain attaching device path Lu Baolu
2023-08-09 12:48 ` [PATCH 11/13] iommu/vt-d: Fix to flush cache of PASID directory table Lu Baolu
2023-08-09 12:48 ` [PATCH 12/13] iommu/vt-d: Fix to convert mm pfn to dma pfn Lu Baolu
2023-08-09 12:48 ` [PATCH 13/13] iommu/vt-d: Remove unused extern declaration dmar_parse_dev_scope() Lu Baolu
2023-08-09 15:47 ` [PATCH 00/13] [PULL REQUEST] Intel IOMMU updates for Linux v6.6 Joerg Roedel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230809124806.45516-7-baolu.lu@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=jacob.jun.pan@linux.intel.com \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yanfei.xu@intel.com \
    --cc=yuehaibing@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox