Skip to content

Commit c2ea292

Browse files
Jacob Pangregkh
authored andcommitted
iommu/vt-d: Fix dev iotlb pfsid use
commit 1c48db4 upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent eb58c40 commit c2ea292

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
@@ -1336,8 +1336,8 @@ void qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr,
13361336
qi_submit_sync(&desc, iommu);
13371337
}
13381338

1339-
void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep,
1340-
u64 addr, unsigned mask)
1339+
void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 pfsid,
1340+
u16 qdep, u64 addr, unsigned mask)
13411341
{
13421342
struct qi_desc desc;
13431343

@@ -1352,7 +1352,7 @@ void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep,
13521352
qdep = 0;
13531353

13541354
desc.low = QI_DEV_IOTLB_SID(sid) | QI_DEV_IOTLB_QDEP(qdep) |
1355-
QI_DIOTLB_TYPE;
1355+
QI_DIOTLB_TYPE | QI_DEV_IOTLB_PFSID(pfsid);
13561356

13571357
qi_submit_sync(&desc, iommu);
13581358
}

drivers/iommu/intel-iommu.c

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

15051505
pdev = to_pci_dev(info->dev);
1506+
/* For IOMMU that supports device IOTLB throttling (DIT), we assign
1507+
* PFSID to the invalidation desc of a VF such that IOMMU HW can gauge
1508+
* queue depth at PF level. If DIT is not set, PFSID will be treated as
1509+
* reserved, which should be set to 0.
1510+
*/
1511+
if (!ecap_dit(info->iommu->ecap))
1512+
info->pfsid = 0;
1513+
else {
1514+
struct pci_dev *pf_pdev;
1515+
1516+
/* pdev will be returned if device is not a vf */
1517+
pf_pdev = pci_physfn(pdev);
1518+
info->pfsid = PCI_DEVID(pf_pdev->bus->number, pf_pdev->devfn);
1519+
}
15061520

15071521
#ifdef CONFIG_INTEL_IOMMU_SVM
15081522
/* The PCIe spec, in its wisdom, declares that the behaviour of
@@ -1568,7 +1582,8 @@ static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
15681582

15691583
sid = info->bus << 8 | info->devfn;
15701584
qdep = info->ats_qdep;
1571-
qi_flush_dev_iotlb(info->iommu, sid, qdep, addr, mask);
1585+
qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
1586+
qdep, addr, mask);
15721587
}
15731588
spin_unlock_irqrestore(&device_domain_lock, flags);
15741589
}

include/linux/intel-iommu.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,8 @@ extern void qi_flush_context(struct intel_iommu *iommu, u16 did, u16 sid,
453453
u8 fm, u64 type);
454454
extern void qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr,
455455
unsigned int size_order, u64 type);
456-
extern void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep,
457-
u64 addr, unsigned mask);
458-
456+
extern void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 pfsid,
457+
u16 qdep, u64 addr, unsigned mask);
459458
extern int qi_submit_sync(struct qi_desc *desc, struct intel_iommu *iommu);
460459

461460
extern int dmar_ir_support(void);

0 commit comments

Comments
 (0)