Joerg Roedel 0a9521
From: Jean-Philippe Brucker <jean-philippe@linaro.org>
Joerg Roedel 0a9521
Date: Wed, 20 May 2020 17:22:03 +0200
Joerg Roedel 0a9521
Subject: iommu/vt-d: Use pci_ats_supported()
Joerg Roedel 0a9521
Git-commit: da656a042568ffbc30881c43a832277f275eea4a
Joerg Roedel 0a9521
Patch-mainline: v5.8-rc1
Joerg Roedel 0a9521
References: bsc#1175713
Joerg Roedel 0a9521
Joerg Roedel 0a9521
The pci_ats_supported() helper checks if a device supports ATS and is
Joerg Roedel 0a9521
allowed to use it. By checking the ATS capability it also integrates the
Joerg Roedel 0a9521
pci_ats_disabled() check from pci_ats_init(). Simplify the vt-d checks.
Joerg Roedel 0a9521
Joerg Roedel 0a9521
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Joerg Roedel 0a9521
Acked-by: Lu Baolu <baolu.lu@linux.intel.com>
Joerg Roedel 0a9521
Link: https://lore.kernel.org/r/20200520152201.3309416-5-jean-philippe@linaro.org
Joerg Roedel 0a9521
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Joerg Roedel 0a9521
---
Joerg Roedel 0a9521
 drivers/iommu/intel-iommu.c | 9 +++------
Joerg Roedel 0a9521
 1 file changed, 3 insertions(+), 6 deletions(-)
Joerg Roedel 0a9521
Joerg Roedel 0a9521
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
Joerg Roedel 0a9521
index 34e08fa2ce3a..5dea3042820b 100644
Joerg Roedel 0a9521
--- a/drivers/iommu/intel-iommu.c
Joerg Roedel 0a9521
+++ b/drivers/iommu/intel-iommu.c
Joerg Roedel 0a9521
@@ -1454,8 +1454,7 @@ static void iommu_enable_dev_iotlb(struct device_domain_info *info)
Joerg Roedel 0a9521
 	    !pci_reset_pri(pdev) && !pci_enable_pri(pdev, 32))
Joerg Roedel 0a9521
 		info->pri_enabled = 1;
Joerg Roedel 0a9521
 #endif
Joerg Roedel 0a9521
-	if (!pdev->untrusted && info->ats_supported &&
Joerg Roedel 0a9521
-	    pci_ats_page_aligned(pdev) &&
Joerg Roedel 0a9521
+	if (info->ats_supported && pci_ats_page_aligned(pdev) &&
Joerg Roedel 0a9521
 	    !pci_enable_ats(pdev, VTD_PAGE_SHIFT)) {
Joerg Roedel 0a9521
 		info->ats_enabled = 1;
Joerg Roedel 0a9521
 		domain_update_iotlb(info->domain);
Joerg Roedel 0a9521
@@ -2611,10 +2610,8 @@ static struct dmar_domain *dmar_insert_one_dev_info(struct intel_iommu *iommu,
Joerg Roedel 0a9521
 	if (dev && dev_is_pci(dev)) {
Joerg Roedel 0a9521
 		struct pci_dev *pdev = to_pci_dev(info->dev);
Joerg Roedel 0a9521
 
Joerg Roedel 0a9521
-		if (!pdev->untrusted &&
Joerg Roedel 0a9521
-		    !pci_ats_disabled() &&
Joerg Roedel 0a9521
-		    ecap_dev_iotlb_support(iommu->ecap) &&
Joerg Roedel 0a9521
-		    pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ATS) &&
Joerg Roedel 0a9521
+		if (ecap_dev_iotlb_support(iommu->ecap) &&
Joerg Roedel 0a9521
+		    pci_ats_supported(pdev) &&
Joerg Roedel 0a9521
 		    dmar_find_matched_atsr_unit(pdev))
Joerg Roedel 0a9521
 			info->ats_supported = 1;
Joerg Roedel 0a9521
 
Joerg Roedel 0a9521