mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iommu/intel: Enable pci capabilities before assigning cache tags
@ 2024-06-25 13:49 Joel Granados via B4 Relay
  2024-06-26  1:09 ` Baolu Lu
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Granados via B4 Relay @ 2024-06-25 13:49 UTC (permalink / raw)
  To: David Woodhouse, Lu Baolu, Joerg Roedel, Will Deacon, Robin Murphy
  Cc: iommu, linux-kernel, Joel Granados

From: Joel Granados <j.granados@samsung.com>

Enable the pci capabilities by calling iommu_enable_pci_caps before we
assign a cache tag. The cache_tag_assign_domain call in
dmar_domain_attach_device uses the device_domain_info->ats_enabled
element to decide on the cache_tag_type value. Therefore ats_enabled
needs to be evaluated before the call to the tag cache assignment.

Signed-off-by: Joel Granados <j.granados@samsung.com>
---
The "what" and "why" are included in the commit message.

Tried to place cache_tag_assign_domain before the early return in
"if(dev_is_real_dma_subdevice(dev))". This means that the call to
iommu_enable_pci_caps landed before the setup functions [1] which is not
an issue as they seem to be orthogonal (I would like to be proven wrong
here).

An alternative to this patch would be to use a different way of checking
if the device is ATS enabled in __cache_tag_assign_domain.

Comments greatly appreciated

Best

joel

[1] setup functions: domain_context_mapping,
    intel_pasid_setup_pass_through, domain_setup_first_level and
    intel_pasid_setup_second_level.
---
 drivers/iommu/intel/iommu.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 2e9811bf2a4e..ecd79741e67c 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -2114,17 +2114,20 @@ static int dmar_domain_attach_device(struct dmar_domain *domain,
 	if (ret)
 		return ret;
 
-	ret = cache_tag_assign_domain(domain, dev, IOMMU_NO_PASID);
-	if (ret) {
-		domain_detach_iommu(domain, iommu);
-		return ret;
-	}
-
 	info->domain = domain;
 	spin_lock_irqsave(&domain->lock, flags);
 	list_add(&info->link, &domain->devices);
 	spin_unlock_irqrestore(&domain->lock, flags);
 
+	if (sm_supported(info->iommu) || !domain_type_is_si(info->domain))
+		iommu_enable_pci_caps(info);
+
+	ret = cache_tag_assign_domain(domain, dev, IOMMU_NO_PASID);
+	if (ret) {
+		domain_detach_iommu(domain, iommu);
+		return ret;
+	}
+
 	if (dev_is_real_dma_subdevice(dev))
 		return 0;
 
@@ -2142,9 +2145,6 @@ static int dmar_domain_attach_device(struct dmar_domain *domain,
 		return ret;
 	}
 
-	if (sm_supported(info->iommu) || !domain_type_is_si(info->domain))
-		iommu_enable_pci_caps(info);
-
 	return 0;
 }
 

---
base-commit: f2661062f16b2de5d7b6a5c42a9a5c96326b8454
change-id: 20240625-jag-ats_cache_tag_fix-d747bb0f5d48

Best regards,
-- 
Joel Granados <j.granados@samsung.com>



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

end of thread, other threads:[~2024-06-26 13:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-25 13:49 [PATCH] iommu/intel: Enable pci capabilities before assigning cache tags Joel Granados via B4 Relay
2024-06-26  1:09 ` Baolu Lu
2024-06-26 13:43   ` Joel Granados

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®