--- zzzz-none-000/linux-4.19.183/kernel/dma/swiotlb.c 2021-03-24 10:07:39.000000000 +0000 +++ bcm63-7530ax-756/linux-4.19.183/kernel/dma/swiotlb.c 2023-06-28 08:54:21.000000000 +0000 @@ -34,6 +34,9 @@ #include #include #include +#if defined CONFIG_BCM_KF_ARM64_BCM963XX && defined(CONFIG_BCM94908) && defined(CONFIG_BCM_HND_EAP) +#include +#endif #include #include @@ -259,6 +262,23 @@ unsigned char *vstart; unsigned long bytes; +#if defined CONFIG_BCM_KF_ARM64_BCM963XX +#if defined(CONFIG_BCM94908) && defined(CONFIG_BCM_HND_EAP) + /* + * ZONE_DMA is restricted to 1GB due to a runner HW limitation. We + * still don't need swiotlb in this case though so check against the + * 4GB boundary here rather than zone_dma. + */ + if (!swiotlb_force && + (max_pfn <= ((min((memblock_start_of_DRAM() & GENMASK_ULL(63, 32)) + + (1ULL << 32), + memblock_end_of_DRAM())) >> PAGE_SHIFT))) + return; +#elif defined CONFIG_ARM64 + if(!swiotlb_force && (max_pfn <= (arm64_dma_phys_limit >> PAGE_SHIFT))) + return; +#endif +#endif if (!io_tlb_nslabs) { io_tlb_nslabs = (default_size >> IO_TLB_SHIFT); io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE); @@ -1010,6 +1030,23 @@ int swiotlb_dma_supported(struct device *hwdev, u64 mask) { +#if defined CONFIG_BCM_KF_ARM64_BCM963XX +#if defined(CONFIG_BCM94908) && defined(CONFIG_BCM_HND_EAP) + /* + * ZONE_DMA is restricted to 1GB due to a runner HW limitation. We + * still don't need swiotlb in this case though so check against the + * 4GB boundary here rather than zone_dma. + */ + if (!swiotlb_force && + (max_pfn <= ((min((memblock_start_of_DRAM() & GENMASK_ULL(63, 32)) + + (1ULL << 32), + memblock_end_of_DRAM())) >> PAGE_SHIFT))) + return 1; +#elif defined CONFIG_ARM64 + if(!swiotlb_force && (max_pfn <= (arm64_dma_phys_limit >> PAGE_SHIFT))) + return 1; +#endif +#endif return __phys_to_dma(hwdev, io_tlb_end - 1) <= mask; }