Skip to content

Commit 1c48db4

Browse files
Jacob Panjoergroedel
authored andcommitted
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 <[email protected]> Cc: [email protected] Cc: "Ashok Raj" <[email protected]> Cc: "Lu Baolu" <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 0f72556 commit 1c48db4

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

drivers/iommu/dmar.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,8 +1339,8 @@ void qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr,
13391339
qi_submit_sync(&desc, iommu);
13401340
}
13411341

1342-
void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep,
1343-
u64 addr, unsigned mask)
1342+
void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 pfsid,
1343+
u16 qdep, u64 addr, unsigned mask)
13441344
{
13451345
struct qi_desc desc;
13461346

@@ -1355,7 +1355,7 @@ void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep,
13551355
qdep = 0;
13561356

13571357
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);
13591359

13601360
qi_submit_sync(&desc, iommu);
13611361
}

drivers/iommu/intel-iommu.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,20 @@ static void iommu_enable_dev_iotlb(struct device_domain_info *info)
14751475
return;
14761476

14771477
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+
}
14781492

14791493
#ifdef CONFIG_INTEL_IOMMU_SVM
14801494
/* 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,
15401554

15411555
sid = info->bus << 8 | info->devfn;
15421556
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);
15441559
}
15451560
spin_unlock_irqrestore(&device_domain_lock, flags);
15461561
}

include/linux/intel-iommu.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,8 @@ extern void qi_flush_context(struct intel_iommu *iommu, u16 did, u16 sid,
455455
u8 fm, u64 type);
456456
extern void qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr,
457457
unsigned int size_order, u64 type);
458-
extern void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep,
459-
u64 addr, unsigned mask);
460-
458+
extern void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 pfsid,
459+
u16 qdep, u64 addr, unsigned mask);
461460
extern int qi_submit_sync(struct qi_desc *desc, struct intel_iommu *iommu);
462461

463462
extern int dmar_ir_support(void);

0 commit comments

Comments
 (0)