s390x/pci: Honor DMA limits set by vfio

When an s390 guest is using lazy unmapping, it can result in a very
large number of oustanding DMA requests, far beyond the default
limit configured for vfio.  Let's track DMA usage similar to vfio
in the host, and trigger the guest to flush their DMA mappings
before vfio runs out.

Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
[aw: non-Linux build fixes]
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
Matthew Rosato 2020-10-26 11:34:35 -04:00 committed by Alex Williamson
parent cd7498d07f
commit 37fa32de70
6 changed files with 117 additions and 12 deletions

View file

@ -262,6 +262,13 @@ typedef struct S390IOTLBEntry {
uint64_t perm;
} S390IOTLBEntry;
typedef struct S390PCIDMACount {
int id;
int users;
uint32_t avail;
QTAILQ_ENTRY(S390PCIDMACount) link;
} S390PCIDMACount;
struct S390PCIIOMMU {
Object parent_obj;
S390PCIBusDevice *pbdev;
@ -273,6 +280,7 @@ struct S390PCIIOMMU {
uint64_t pba;
uint64_t pal;
GHashTable *iotlb;
S390PCIDMACount *dma_limit;
};
typedef struct S390PCIIOMMUTable {
@ -348,6 +356,7 @@ struct S390pciState {
GHashTable *zpci_table;
QTAILQ_HEAD(, SeiContainer) pending_sei;
QTAILQ_HEAD(, S390PCIBusDevice) zpci_devs;
QTAILQ_HEAD(, S390PCIDMACount) zpci_dma_limit;
};
S390pciState *s390_get_phb(void);