aboutsummaryrefslogtreecommitdiff
path: root/target/linux/d1/patches-6.1/0010-riscv-mm-Use-IOMMU-for-DMA-when-available.patch
blob: 18dfa573e3a6aab590f1484817e56c4e1b063b81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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)