Skip to content

Commit 53f8e9a

Browse files
niklas88joergroedel
authored andcommitted
iommu/s390: Disable deferred flush for ISM devices
ISM devices are virtual PCI devices used for cross-LPAR communication. Unlike real PCI devices ISM devices do not use the hardware IOMMU but inspects IOMMU translation tables directly on IOTLB flush (s390 RPCIT instruction). ISM devices keep their DMA allocations static and only very rarely DMA unmap at all. For each IOTLB flush that occurs after unmap the ISM devices will however inspect the area of the IOVA space indicated by the flush. This means that for the global IOTLB flushes used by the flush queue mechanism the entire IOVA space would be inspected. In principle this would be fine, albeit potentially unnecessarily slow, it turns out however that ISM devices are sensitive to seeing IOVA addresses that are currently in use in the IOVA range being flushed. Seeing such in-use IOVA addresses will cause the ISM device to enter an error state and become unusable. Fix this by claiming IOMMU_CAP_DEFERRED_FLUSH only for non-ISM devices. This makes sure IOTLB flushes only cover IOVAs that have been unmapped and also restricts the range of the IOTLB flush potentially reducing latency spikes. Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com> Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com> Link: https://lore.kernel.org/r/20230928-dma_iommu-v13-4-9e5fc4dacc36@linux.ibm.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent c76c067 commit 53f8e9a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/iommu/s390-iommu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,13 @@ static struct s390_domain *to_s390_domain(struct iommu_domain *dom)
315315

316316
static bool s390_iommu_capable(struct device *dev, enum iommu_cap cap)
317317
{
318+
struct zpci_dev *zdev = to_zpci_dev(dev);
319+
318320
switch (cap) {
319321
case IOMMU_CAP_CACHE_COHERENCY:
320322
return true;
321323
case IOMMU_CAP_DEFERRED_FLUSH:
322-
return true;
324+
return zdev->pft != PCI_FUNC_TYPE_ISM;
323325
default:
324326
return false;
325327
}

0 commit comments

Comments
 (0)