openwrt/target/linux/d1/patches-6.1/0010-riscv-mm-Use-IOMMU-for-DMA-when-available.patch

31 lines
850 B
Diff
Raw Normal View History

From 02a412de18479449c87ed7a332e3fe33d2eff3a4 Mon Sep 17 00:00:00 2001
From: Samuel Holland <samuel@sholland.org>
Date: Wed, 27 Apr 2022 18:47:53 -0500
Subject: [PATCH 010/117] riscv: mm: Use IOMMU for DMA when available
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
arch/riscv/mm/dma-noncoherent.c | 4 ++++
1 file changed, 4 insertions(+)
--- a/arch/riscv/mm/dma-noncoherent.c
+++ b/arch/riscv/mm/dma-noncoherent.c
@@ -7,6 +7,7 @@
#include <linux/dma-direct.h>
#include <linux/dma-map-ops.h>
+#include <linux/iommu.h>
#include <linux/mm.h>
#include <asm/cacheflush.h>
@@ -70,6 +71,9 @@ void arch_setup_dma_ops(struct device *d
dev_driver_string(dev), dev_name(dev));
dev->dma_coherent = coherent;
+
+ if (iommu)
+ iommu_setup_dma_ops(dev, dma_base, dma_base + size - 1);
}
void riscv_noncoherent_supported(void)