• Leonardo Bras's avatar
    powerpc/pseries/iommu: Make use of DDW for indirect mapping · 381ceda8
    Leonardo Bras authored
    So far it's assumed possible to map the guest RAM 1:1 to the bus, which
    works with a small number of devices. SRIOV changes it as the user can
    configure hundreds VFs and since phyp preallocates TCEs and does not
    allow IOMMU pages bigger than 64K, it has to limit the number of TCEs
    per a PE to limit waste of physical pages.
    
    As of today, if the assumed direct mapping is not possible, DDW creation
    is skipped and the default DMA window "ibm,dma-window" is used instead.
    
    By using DDW, indirect mapping  can get more TCEs than available for the
    default DMA window, and also get access to using much larger pagesizes
    (16MB as implemented in qemu vs 4k from default DMA window), causing a
    significant increase on the maximum amount of memory that can be IOMMU
    mapped at the same time.
    
    Indirect mapping will only be used if direct mapping is not a
    possibility.
    
    For indirect mapping, it's necessary to re-create the iommu_table with
    the new DMA window parameters, so iommu_alloc() can use it.
    
    Removing the default DMA window for using DDW with indirect mapping
    is only allowed if there is no current IOMMU memory allocated in
    the iommu_table. enable_ddw() is aborted otherwise.
    
    Even though there won't be both direct and indirect mappings at the
    same time, we can't reuse the DIRECT64_PROPNAME property name, or else
    an older kexec()ed kernel can assume direct mapping, and skip
    iommu_alloc(), causing undesirable behavior.
    So a new property name DMA64_PROPNAME "linux,dma64-ddr-window-info"
    was created to represent a DDW that does not allow direct mapping.
    Signed-off-by: default avatarLeonardo Bras <leobras.c@gmail.com>
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20210817063929.38701-11-leobras.c@gmail.com
    381ceda8
iommu.c 45.2 KB