MALI: utgard: upgrade DDK to r6p1-01rel0
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / mali400 / mali / linux / mali_memory.c
index 1e57bd6740429520e39dfceeb0c59e3c7a6f6854..95f04ed0223664f30460520bdcb39dc053e1822a 100755 (executable)
@@ -30,6 +30,9 @@
 #include "mali_memory_cow.h"
 #include "mali_memory_swap_alloc.h"
 #include "mali_memory_defer_bind.h"
+#if defined(CONFIG_DMA_SHARED_BUFFER)
+#include "mali_memory_secure.h"
+#endif
 
 extern unsigned int mali_dedicated_mem_size;
 extern unsigned int mali_shared_mem_size;
@@ -121,6 +124,8 @@ static int mali_mem_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
                }
        } else {
                MALI_PRINT_ERROR(("Mali vma fault! It never happen, indicating some logic errors in caller.\n"));
+               /*NOT support yet or OOM*/
+               return VM_FAULT_OOM;
        }
        return VM_FAULT_NOPAGE;
 }
@@ -244,6 +249,13 @@ int mali_mmap(struct file *filp, struct vm_area_struct *vma)
                        (MALI_MEM_BACKEND_FLAG_SWAP_COWED == (mem_bkend->flags & MALI_MEM_BACKEND_FLAG_SWAP_COWED)))) {
                /*For swappable memory, CPU page table will be created by page fault handler. */
                ret = 0;
+       } else if (mem_bkend->type == MALI_MEM_SECURE) {
+#if defined(CONFIG_DMA_SHARED_BUFFER)
+               ret = mali_mem_secure_cpu_map(mem_bkend, vma);
+#else
+               MALI_DEBUG_PRINT(1, ("DMA not supported for mali secure memory\n"));
+               return -EFAULT;
+#endif
        } else {
                /* Not support yet*/
                MALI_DEBUG_PRINT_ERROR(("Invalid type of backend memory! \n"));