• Huacai Chen's avatar
    MIPS: Loongson: Add swiotlb to support All-Memory DMA · 1299b0e0
    Huacai Chen authored
    Loongson doesn't support DMA address above 4GB traditionally. If memory
    is more than 4GB, CONFIG_SWIOTLB and ZONE_DMA32 should be selected. In
    this way, DMA pages are allocated below 4GB preferably. However, if low
    memory is not enough, high pages are allocated and swiotlb is used for
    bouncing.
    
    Moreover, we provide a platform-specific dma_map_ops::set_dma_mask() to
    set a device's dma_mask and coherent_dma_mask. We use these masks to
    distinguishes an allocated page can be used for DMA directly, or need
    swiotlb to bounce.
    
    Recently, we found that 32-bit DMA isn't a hardware bug, but a hardware
    configuration issue. So, latest firmware has enable the DMA support as
    high as 40-bit. To support all-memory DMA for all devices (besides the
    Loongson platform limit, there are still some devices have their own
    DMA32 limit), and also to be compatible with old firmware, we keep use
    swiotlb.
    Signed-off-by: default avatarHuacai Chen <chenhc@lemote.com>
    Signed-off-by: default avatarHongliang Tao <taohl@lemote.com>
    Signed-off-by: default avatarHua Yan <yanh@lemote.com>
    Tested-by: default avatarAlex Smith <alex.smith@imgtec.com>
    Reviewed-by: default avatarAlex Smith <alex.smith@imgtec.com>
    Cc: John Crispin <john@phrozen.org>
    Cc: Steven J. Hill <Steven.Hill@imgtec.com>
    Cc: Aurelien Jarno <aurelien@aurel32.net>
    Cc: linux-mips@linux-mips.org
    Cc: Fuxin Zhang <zhangfx@lemote.com>
    Cc: Zhangjin Wu <wuzhangjin@gmail.com>
    Patchwork: https://patchwork.linux-mips.org/patch/6636Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
    1299b0e0
Makefile 669 Bytes