[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240625-jag-ats_cache_tag_fix-v1-1-67f956e3fa93@samsung.com>
Date: Tue, 25 Jun 2024 15:49:31 +0200
From: Joel Granados via B4 Relay <devnull+j.granados.samsung.com@...nel.org>
To: David Woodhouse <dwmw2@...radead.org>,
Lu Baolu <baolu.lu@...ux.intel.com>, Joerg Roedel <joro@...tes.org>,
Will Deacon <will@...nel.org>, Robin Murphy <robin.murphy@....com>
Cc: iommu@...ts.linux.dev, linux-kernel@...r.kernel.org,
Joel Granados <j.granados@...sung.com>
Subject: [PATCH] iommu/intel: Enable pci capabilities before assigning
cache tags
From: Joel Granados <j.granados@...sung.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@...sung.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@...sung.com>
Powered by blists - more mailing lists