aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJacob Pan <jacob.jun.pan@linux.intel.com>2018-06-07 12:57:00 -0400
committerJoerg Roedel <jroedel@suse.de>2018-07-06 07:26:10 -0400
commit1c48db44924298ad0cb5a6386b88017539be8822 (patch)
tree30ddae718fb18732f7cbd18db1a3956e0e54dafa /drivers
parent0f725561e168485eff7277d683405c05b192f537 (diff)
iommu/vt-d: Fix dev iotlb pfsid use
PFSID should be used in the invalidation descriptor for flushing device IOTLBs on SRIOV VFs. Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com> Cc: stable@vger.kernel.org Cc: "Ashok Raj" <ashok.raj@intel.com> Cc: "Lu Baolu" <baolu.lu@linux.intel.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/iommu/dmar.c6
-rw-r--r--drivers/iommu/intel-iommu.c17
2 files changed, 19 insertions, 4 deletions
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 75456b5aa825..d9c748b6f9e4 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -1339,8 +1339,8 @@ void qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr,
1339 qi_submit_sync(&desc, iommu); 1339 qi_submit_sync(&desc, iommu);
1340} 1340}
1341 1341
1342void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep, 1342void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 pfsid,
1343 u64 addr, unsigned mask) 1343 u16 qdep, u64 addr, unsigned mask)
1344{ 1344{
1345 struct qi_desc desc; 1345 struct qi_desc desc;
1346 1346
@@ -1355,7 +1355,7 @@ void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep,
1355 qdep = 0; 1355 qdep = 0;
1356 1356
1357 desc.low = QI_DEV_IOTLB_SID(sid) | QI_DEV_IOTLB_QDEP(qdep) | 1357 desc.low = QI_DEV_IOTLB_SID(sid) | QI_DEV_IOTLB_QDEP(qdep) |
1358 QI_DIOTLB_TYPE; 1358 QI_DIOTLB_TYPE | QI_DEV_IOTLB_PFSID(pfsid);
1359 1359
1360 qi_submit_sync(&desc, iommu); 1360 qi_submit_sync(&desc, iommu);
1361} 1361}
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 7f6194ef48f4..497ef94c5a8c 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -1475,6 +1475,20 @@ static void iommu_enable_dev_iotlb(struct device_domain_info *info)
1475 return; 1475 return;
1476 1476
1477 pdev = to_pci_dev(info->dev); 1477 pdev = to_pci_dev(info->dev);
1478 /* For IOMMU that supports device IOTLB throttling (DIT), we assign
1479 * PFSID to the invalidation desc of a VF such that IOMMU HW can gauge
1480 * queue depth at PF level. If DIT is not set, PFSID will be treated as
1481 * reserved, which should be set to 0.
1482 */
1483 if (!ecap_dit(info->iommu->ecap))
1484 info->pfsid = 0;
1485 else {
1486 struct pci_dev *pf_pdev;
1487
1488 /* pdev will be returned if device is not a vf */
1489 pf_pdev = pci_physfn(pdev);
1490 info->pfsid = PCI_DEVID(pf_pdev->bus->number, pf_pdev->devfn);
1491 }
1478 1492
1479#ifdef CONFIG_INTEL_IOMMU_SVM 1493#ifdef CONFIG_INTEL_IOMMU_SVM
1480 /* The PCIe spec, in its wisdom, declares that the behaviour of 1494 /* The PCIe spec, in its wisdom, declares that the behaviour of
@@ -1540,7 +1554,8 @@ static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
1540 1554
1541 sid = info->bus << 8 | info->devfn; 1555 sid = info->bus << 8 | info->devfn;
1542 qdep = info->ats_qdep; 1556 qdep = info->ats_qdep;
1543 qi_flush_dev_iotlb(info->iommu, sid, qdep, addr, mask); 1557 qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
1558 qdep, addr, mask);
1544 } 1559 }
1545 spin_unlock_irqrestore(&device_domain_lock, flags); 1560 spin_unlock_irqrestore(&device_domain_lock, flags);
1546} 1561}