[OpenBIOS] [PATCH 06/15] SPARC32: implement dvma_sync() function for synchronising DMA memory
Mark Cave-Ayland
mark.cave-ayland at ilande.co.uk
Mon May 21 23:33:13 CEST 2018
This is required for ensuring that CPU memory is coherent after DMA operations
have completed.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
---
drivers/iommu.c | 14 ++++++++++++++
include/drivers/drivers.h | 1 +
2 files changed, 15 insertions(+)
diff --git a/drivers/iommu.c b/drivers/iommu.c
index b8ec09e..c414894 100644
--- a/drivers/iommu.c
+++ b/drivers/iommu.c
@@ -10,6 +10,8 @@
#include "drivers/drivers.h"
#include "iommu.h"
#include "arch/sparc32/ofmem_sparc32.h"
+#include "arch/sparc32/asi.h"
+#include "arch/sparc32/pgtsrmmu.h"
#ifdef CONFIG_DEBUG_IOMMU
#define DPRINTF(fmt, args...) \
@@ -81,6 +83,18 @@ dvma_alloc(int size)
return va;
}
+void
+dvma_sync(unsigned char *va, int size)
+{
+ /* Synchronise the VA address region after DMA */
+ unsigned long virt = pointer2cell(va);
+ unsigned long page;
+
+ for (page = (unsigned long)virt; page < virt + size; page += PAGE_SIZE) {
+ srmmu_flush_tlb_page(page);
+ }
+}
+
unsigned int
dvma_map_in(unsigned char *va)
{
diff --git a/include/drivers/drivers.h b/include/drivers/drivers.h
index 85a8db0..64824e4 100644
--- a/include/drivers/drivers.h
+++ b/include/drivers/drivers.h
@@ -74,6 +74,7 @@ void ss5_init(uint64_t base);
/* drivers/iommu.c */
void ob_init_iommu(uint64_t base);
void *dvma_alloc(int size);
+void dvma_sync(unsigned char *va, int size);
unsigned int dvma_map_in(unsigned char *va);
/* drivers/sbus.c */
--
2.11.0
More information about the OpenBIOS
mailing list