diff options
author | Jacob Pan <jacob.jun.pan@linux.intel.com> | 2018-06-07 12:57:00 -0400 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2018-07-06 07:26:10 -0400 |
commit | 1c48db44924298ad0cb5a6386b88017539be8822 (patch) | |
tree | 30ddae718fb18732f7cbd18db1a3956e0e54dafa | |
parent | 0f725561e168485eff7277d683405c05b192f537 (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>
-rw-r--r-- | drivers/iommu/dmar.c | 6 | ||||
-rw-r--r-- | drivers/iommu/intel-iommu.c | 17 | ||||
-rw-r--r-- | include/linux/intel-iommu.h | 5 |
3 files changed, 21 insertions, 7 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 | ||
1342 | void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep, | 1342 | void 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 | } |
diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h index 3b1c37155572..6692b40ca814 100644 --- a/include/linux/intel-iommu.h +++ b/include/linux/intel-iommu.h | |||
@@ -455,9 +455,8 @@ extern void qi_flush_context(struct intel_iommu *iommu, u16 did, u16 sid, | |||
455 | u8 fm, u64 type); | 455 | u8 fm, u64 type); |
456 | extern void qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr, | 456 | extern void qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr, |
457 | unsigned int size_order, u64 type); | 457 | unsigned int size_order, u64 type); |
458 | extern void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep, | 458 | extern void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 pfsid, |
459 | u64 addr, unsigned mask); | 459 | u16 qdep, u64 addr, unsigned mask); |
460 | |||
461 | extern int qi_submit_sync(struct qi_desc *desc, struct intel_iommu *iommu); | 460 | extern int qi_submit_sync(struct qi_desc *desc, struct intel_iommu *iommu); |
462 | 461 | ||
463 | extern int dmar_ir_support(void); | 462 | extern int dmar_ir_support(void); |