mirror of https://github.com/OpenIPC/firmware.git
121 lines
3.5 KiB
Diff
121 lines
3.5 KiB
Diff
diff -drupN a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
|
||
--- a/arch/mips/mm/dma-default.c 2017-10-21 18:09:07.000000000 +0300
|
||
+++ b/arch/mips/mm/dma-default.c 2022-06-09 05:02:27.000000000 +0300
|
||
@@ -72,7 +72,8 @@ static inline int cpu_needs_post_dma_flu
|
||
return !plat_device_is_coherent(dev) &&
|
||
(boot_cpu_type() == CPU_R10000 ||
|
||
boot_cpu_type() == CPU_R12000 ||
|
||
- boot_cpu_type() == CPU_BMIPS5000);
|
||
+ boot_cpu_type() == CPU_BMIPS5000 ||
|
||
+ boot_cpu_type() == CPU_JZRISC);
|
||
}
|
||
|
||
static gfp_t massage_gfp_flags(const struct device *dev, gfp_t gfp)
|
||
@@ -112,22 +113,6 @@ static gfp_t massage_gfp_flags(const str
|
||
return gfp | dma_flag;
|
||
}
|
||
|
||
-static void *mips_dma_alloc_noncoherent(struct device *dev, size_t size,
|
||
- dma_addr_t * dma_handle, gfp_t gfp)
|
||
-{
|
||
- void *ret;
|
||
-
|
||
- gfp = massage_gfp_flags(dev, gfp);
|
||
-
|
||
- ret = (void *) __get_free_pages(gfp, get_order(size));
|
||
-
|
||
- if (ret != NULL) {
|
||
- memset(ret, 0, size);
|
||
- *dma_handle = plat_map_dma_mem(dev, ret, size);
|
||
- }
|
||
-
|
||
- return ret;
|
||
-}
|
||
|
||
static void *mips_dma_alloc_coherent(struct device *dev, size_t size,
|
||
dma_addr_t * dma_handle, gfp_t gfp, struct dma_attrs *attrs)
|
||
@@ -136,12 +121,6 @@ static void *mips_dma_alloc_coherent(str
|
||
struct page *page = NULL;
|
||
unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
|
||
|
||
- /*
|
||
- * XXX: seems like the coherent and non-coherent implementations could
|
||
- * be consolidated.
|
||
- */
|
||
- if (dma_get_attr(DMA_ATTR_NON_CONSISTENT, attrs))
|
||
- return mips_dma_alloc_noncoherent(dev, size, dma_handle, gfp);
|
||
|
||
gfp = massage_gfp_flags(dev, gfp);
|
||
|
||
@@ -157,6 +136,13 @@ static void *mips_dma_alloc_coherent(str
|
||
ret = page_address(page);
|
||
memset(ret, 0, size);
|
||
*dma_handle = plat_map_dma_mem(dev, ret, size);
|
||
+
|
||
+ /* non coherent memory.*/
|
||
+ if(dma_get_attr(DMA_ATTR_NON_CONSISTENT, attrs)) {
|
||
+ return ret;
|
||
+ }
|
||
+
|
||
+ /* coherent memory. */
|
||
if (!plat_device_is_coherent(dev)) {
|
||
dma_cache_wback_inv((unsigned long) ret, size);
|
||
if (!hw_coherentio)
|
||
@@ -167,12 +153,6 @@ static void *mips_dma_alloc_coherent(str
|
||
}
|
||
|
||
|
||
-static void mips_dma_free_noncoherent(struct device *dev, size_t size,
|
||
- void *vaddr, dma_addr_t dma_handle)
|
||
-{
|
||
- plat_unmap_dma_mem(dev, dma_handle, size, DMA_BIDIRECTIONAL);
|
||
- free_pages((unsigned long) vaddr, get_order(size));
|
||
-}
|
||
|
||
static void mips_dma_free_coherent(struct device *dev, size_t size, void *vaddr,
|
||
dma_addr_t dma_handle, struct dma_attrs *attrs)
|
||
@@ -181,15 +161,13 @@ static void mips_dma_free_coherent(struc
|
||
unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
|
||
struct page *page = NULL;
|
||
|
||
- if (dma_get_attr(DMA_ATTR_NON_CONSISTENT, attrs)) {
|
||
- mips_dma_free_noncoherent(dev, size, vaddr, dma_handle);
|
||
- return;
|
||
- }
|
||
-
|
||
plat_unmap_dma_mem(dev, dma_handle, size, DMA_BIDIRECTIONAL);
|
||
|
||
- if (!plat_device_is_coherent(dev) && !hw_coherentio)
|
||
- addr = CAC_ADDR(addr);
|
||
+ if (!dma_get_attr(DMA_ATTR_NON_CONSISTENT, attrs)) {
|
||
+ /* coherent dma memory.*/
|
||
+ if (!plat_device_is_coherent(dev) && !hw_coherentio)
|
||
+ addr = CAC_ADDR(addr);
|
||
+ }
|
||
|
||
page = virt_to_page((void *) addr);
|
||
|
||
@@ -273,8 +251,22 @@ static inline void __dma_sync(struct pag
|
||
if (offset >= PAGE_SIZE) {
|
||
page += offset >> PAGE_SHIFT;
|
||
offset &= ~PAGE_MASK;
|
||
+#ifdef CONFIG_DMA_INGENIC_HIGHMEM_FLUSH
|
||
+ /**
|
||
+ * Explain:
|
||
+ * When offset + len is less than PAGE_SIZE,
|
||
+ * only need to flush the length of len;
|
||
+ * Rather than flush PAGE_SIZE
|
||
+ */
|
||
+ len = PAGE_SIZE - offset;
|
||
+ len = min(left, len);
|
||
+ } else {
|
||
+ len = PAGE_SIZE - offset;
|
||
+ }
|
||
+#else
|
||
}
|
||
len = PAGE_SIZE - offset;
|
||
+#endif
|
||
}
|
||
|
||
addr = kmap_atomic(page);
|