• Niklas Schnelle's avatar
    iommu/dma: Allow a single FQ in addition to per-CPU FQs · 32d5bc8b
    Niklas Schnelle authored
    In some virtualized environments, including s390 paged memory guests,
    IOTLB flushes are used to update IOMMU shadow tables. Due to this, they
    are much more expensive than in typical bare metal environments or
    non-paged s390 guests. In addition they may parallelize poorly in
    virtualized environments. This changes the trade off for flushing IOVAs
    such that minimizing the number of IOTLB flushes trumps any benefit of
    cheaper queuing operations or increased paralellism.
    
    In this scenario per-CPU flush queues pose several problems. Firstly
    per-CPU memory is often quite limited prohibiting larger queues.
    Secondly collecting IOVAs per-CPU but flushing via a global timeout
    reduces the number of IOVAs flushed for each timeout especially on s390
    where PCI interrupts may not be bound to a specific CPU.
    
    Let's introduce a single flush queue mode that reuses the same queue
    logic but only allocates a single global queue. This mode is selected by
    dma-iommu if a newly introduced .shadow_on_flush flag is set in struct
    dev_iommu. As a first user the s390 IOMMU driver sets this flag during
    probe_device. With the unchanged small FQ size and timeouts this setting
    is worse than per-CPU queues but a follow up patch will make the FQ size
    and timeout variable. Together this allows the common IOVA flushing code
    to more closely resemble the global flush behavior used on s390's
    previous internal DMA API implementation.
    
    Link: https://lore.kernel.org/all/9a466109-01c5-96b0-bf03-304123f435ee@arm.com/Acked-by: default avatarRobin Murphy <robin.murphy@arm.com>
    Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com> #s390
    Signed-off-by: default avatarNiklas Schnelle <schnelle@linux.ibm.com>
    Link: https://lore.kernel.org/r/20230928-dma_iommu-v13-5-9e5fc4dacc36@linux.ibm.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
    32d5bc8b
s390-iommu.c 18.9 KB