drivers/iommu/intel/iommu.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
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>
On 6/25/24 9:49 PM, Joel Granados via B4 Relay wrote: > 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 Thank you very much for the patch. But we already have a similar patch which has been picked by Joerg for 6.10-rc. https://lore.kernel.org/linux-iommu/20240620062940.201786-1-baolu.lu@linux.intel.com/ Can you please check whether above patch works for you? Best regards, baolu
On Wed, Jun 26, 2024 at 09:09:04AM +0800, Baolu Lu wrote: > On 6/25/24 9:49 PM, Joel Granados via B4 Relay wrote: > > 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 > > Thank you very much for the patch. But we already have a similar patch > which has been picked by Joerg for 6.10-rc. > > https://lore.kernel.org/linux-iommu/20240620062940.201786-1-baolu.lu@linux.intel.com/ Completely missed this. I'll give it a try tomorrow and report back. Best -- Joel Granados
© 2016 - 2025 Red Hat, Inc.