linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] [PULL REQUEST] iommu/vt-d: Fixes for v6.16-rc
@ 2025-06-28 10:03 Lu Baolu
  2025-06-28 10:03 ` [PATCH 1/1] iommu/vt-d: Assign devtlb cache tag on ATS enablement Lu Baolu
  2025-07-04  8:34 ` [PATCH 0/1] [PULL REQUEST] iommu/vt-d: Fixes for v6.16-rc Joerg Roedel
  0 siblings, 2 replies; 3+ messages in thread
From: Lu Baolu @ 2025-06-28 10:03 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu, linux-kernel

Hi Joerg,

The following fix has been queued for v6.16-rc4:

- Assign devtlb cache tag on ATS enablement

It fixes a critical cache invalidation issue for ATS-capable devices. It
has been reviewed and is ready for merge. Can you please consider it?

Best regards,
baolu


Lu Baolu (1):
  iommu/vt-d: Assign devtlb cache tag on ATS enablement

 drivers/iommu/intel/cache.c |  5 ++---
 drivers/iommu/intel/iommu.c | 11 ++++++++++-
 drivers/iommu/intel/iommu.h |  2 ++
 3 files changed, 14 insertions(+), 4 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] iommu/vt-d: Assign devtlb cache tag on ATS enablement
  2025-06-28 10:03 [PATCH 0/1] [PULL REQUEST] iommu/vt-d: Fixes for v6.16-rc Lu Baolu
@ 2025-06-28 10:03 ` Lu Baolu
  2025-07-04  8:34 ` [PATCH 0/1] [PULL REQUEST] iommu/vt-d: Fixes for v6.16-rc Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Lu Baolu @ 2025-06-28 10:03 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu, linux-kernel

Commit <4f1492efb495> ("iommu/vt-d: Revert ATS timing change to fix boot
failure") placed the enabling of ATS in the probe_finalize callback. This
occurs after the default domain attachment, which is when the ATS cache
tag is assigned. Consequently, the device TLB cache tag is missed when the
domain is attached, leading to the device TLB not being invalidated in the
iommu_unmap paths.

Fix this by assigning the CACHE_TAG_DEVTLB cache tag when ATS is enabled.

Fixes: 4f1492efb495 ("iommu/vt-d: Revert ATS timing change to fix boot failure")
Cc: stable@vger.kernel.org
Suggested-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Tested-by: Shuicheng Lin <shuicheng.lin@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Link: https://lore.kernel.org/r/20250625050135.3129955-1-baolu.lu@linux.intel.com
---
 drivers/iommu/intel/cache.c |  5 ++---
 drivers/iommu/intel/iommu.c | 11 ++++++++++-
 drivers/iommu/intel/iommu.h |  2 ++
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/iommu/intel/cache.c b/drivers/iommu/intel/cache.c
index fc35cba59145..47692cbfaabd 100644
--- a/drivers/iommu/intel/cache.c
+++ b/drivers/iommu/intel/cache.c
@@ -40,9 +40,8 @@ static bool cache_tage_match(struct cache_tag *tag, u16 domain_id,
 }
 
 /* Assign a cache tag with specified type to domain. */
-static int cache_tag_assign(struct dmar_domain *domain, u16 did,
-			    struct device *dev, ioasid_t pasid,
-			    enum cache_tag_type type)
+int cache_tag_assign(struct dmar_domain *domain, u16 did, struct device *dev,
+		     ioasid_t pasid, enum cache_tag_type type)
 {
 	struct device_domain_info *info = dev_iommu_priv_get(dev);
 	struct intel_iommu *iommu = info->iommu;
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 7aa3932251b2..148b944143b8 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -3780,8 +3780,17 @@ static void intel_iommu_probe_finalize(struct device *dev)
 	    !pci_enable_pasid(to_pci_dev(dev), info->pasid_supported & ~1))
 		info->pasid_enabled = 1;
 
-	if (sm_supported(iommu) && !dev_is_real_dma_subdevice(dev))
+	if (sm_supported(iommu) && !dev_is_real_dma_subdevice(dev)) {
 		iommu_enable_pci_ats(info);
+		/* Assign a DEVTLB cache tag to the default domain. */
+		if (info->ats_enabled && info->domain) {
+			u16 did = domain_id_iommu(info->domain, iommu);
+
+			if (cache_tag_assign(info->domain, did, dev,
+					     IOMMU_NO_PASID, CACHE_TAG_DEVTLB))
+				iommu_disable_pci_ats(info);
+		}
+	}
 	iommu_enable_pci_pri(info);
 }
 
diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h
index 3ddbcc603de2..2d1afab5eedc 100644
--- a/drivers/iommu/intel/iommu.h
+++ b/drivers/iommu/intel/iommu.h
@@ -1289,6 +1289,8 @@ struct cache_tag {
 	unsigned int users;
 };
 
+int cache_tag_assign(struct dmar_domain *domain, u16 did, struct device *dev,
+		     ioasid_t pasid, enum cache_tag_type type);
 int cache_tag_assign_domain(struct dmar_domain *domain,
 			    struct device *dev, ioasid_t pasid);
 void cache_tag_unassign_domain(struct dmar_domain *domain,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 0/1] [PULL REQUEST] iommu/vt-d: Fixes for v6.16-rc
  2025-06-28 10:03 [PATCH 0/1] [PULL REQUEST] iommu/vt-d: Fixes for v6.16-rc Lu Baolu
  2025-06-28 10:03 ` [PATCH 1/1] iommu/vt-d: Assign devtlb cache tag on ATS enablement Lu Baolu
@ 2025-07-04  8:34 ` Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2025-07-04  8:34 UTC (permalink / raw)
  To: Lu Baolu; +Cc: iommu, linux-kernel

On Sat, Jun 28, 2025 at 06:03:50PM +0800, Lu Baolu wrote:
> Hi Joerg,
> 
> The following fix has been queued for v6.16-rc4:
> 
> - Assign devtlb cache tag on ATS enablement
> 
> It fixes a critical cache invalidation issue for ATS-capable devices. It
> has been reviewed and is ready for merge. Can you please consider it?
> 
> Best regards,
> baolu
> 
> 
> Lu Baolu (1):
>   iommu/vt-d: Assign devtlb cache tag on ATS enablement
> 
>  drivers/iommu/intel/cache.c |  5 ++---
>  drivers/iommu/intel/iommu.c | 11 ++++++++++-
>  drivers/iommu/intel/iommu.h |  2 ++
>  3 files changed, 14 insertions(+), 4 deletions(-)

Applied, thanks Baolu.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-07-04  8:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-28 10:03 [PATCH 0/1] [PULL REQUEST] iommu/vt-d: Fixes for v6.16-rc Lu Baolu
2025-06-28 10:03 ` [PATCH 1/1] iommu/vt-d: Assign devtlb cache tag on ATS enablement Lu Baolu
2025-07-04  8:34 ` [PATCH 0/1] [PULL REQUEST] iommu/vt-d: Fixes for v6.16-rc Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).