echo "make mali module MALI_OUT is ${PRODUCT_OUT}/obj/mali ${MALI_OUT}"
make -C ${KDIR} M=${PRODUCT_OUT}/obj/mali \
ARCH=${KERNEL_ARCH} CROSS_COMPILE=${PREFIX_CROSS_COMPILE} CONFIG_MALI400=m CONFIG_MALI450=m \
- CONFIG_MALI_DMA_BUF_LAZY_MAP=y \
- EXTRA_CFLAGS="-DCONFIG_MALI400=m -DCONFIG_MALI450=m -DCONFIG_MALI_DMA_BUF_LAZY_MAP=y" \
+ EXTRA_CFLAGS="-DCONFIG_MALI400=m -DCONFIG_MALI450=m" \
EXTRA_LDFLAGS+="--strip-debug" \
CONFIG_AM_VDEC_H264_4K2K=y 2>&1 | tee mali.txt
PATH=$$(cd ./$(TARGET_HOST_TOOL_PATH); pwd):$$PATH \
$(MAKE) -C $(shell pwd)/$(PRODUCT_OUT)/obj/KERNEL_OBJ M=$(shell pwd)/$(PRODUCT_OUT)/obj/mali \
ARCH=$(3) CROSS_COMPILE=$(PREFIX_CROSS_COMPILE) CONFIG_MALI400=m CONFIG_MALI450=m \
- CONFIG_MALI_DMA_BUF_LAZY_MAP=y \
- EXTRA_CFLAGS="-DCONFIG_MALI400=m -DCONFIG_MALI450=m -DCONFIG_MALI_DMA_BUF_LAZY_MAP=y" \
+ EXTRA_CFLAGS="-DCONFIG_MALI400=m -DCONFIG_MALI450=m" \
EXTRA_LDFLAGS+="--strip-debug" \
CONFIG_AM_VDEC_H264_4K2K=y
#include "mali_kernel_common.h"
#include "mali_uk_types.h"
#include "mali_executor.h"
-#if defined(CONFIG_DMA_SHARED_BUFFER) && !defined(CONFIG_MALI_DMA_BUF_MAP_ON_ATTACH)
+#if defined(CONFIG_DMA_SHARED_BUFFER)
#include "linux/mali_memory_dma_buf.h"
#endif
#include "mali_memory_swap_alloc.h"
void mali_pp_job_delete(struct mali_pp_job *job)
{
struct mali_session_data *session;
+#if defined(CONFIG_DMA_SHARED_BUFFER) && !defined(CONFIG_MALI_DMA_BUF_LAZY_MAP)
+ u32 i, have_video = 0;
+#endif
MALI_DEBUG_ASSERT_POINTER(job);
MALI_DEBUG_ASSERT(_mali_osk_list_empty(&job->list));
MALI_DEBUG_ASSERT_POINTER(session);
if (NULL != job->memory_cookies) {
-#if defined(CONFIG_DMA_SHARED_BUFFER) && !defined(CONFIG_MALI_DMA_BUF_MAP_ON_ATTACH)
+#if defined(CONFIG_DMA_SHARED_BUFFER) && !defined(CONFIG_MALI_DMA_BUF_LAZY_MAP)
+ if (job)
+ session = job->session;
+ for (i = 0; job && session && i < job->uargs.num_memory_cookies; i++) {
+ mali_mem_backend *mem_backend = NULL;
+ u32 mali_addr = mali_pp_job_get_memory_cookie(job, i);
+
+ mem_backend = __mali_mem_backend_struct_search(session, mali_addr);
+ if (mem_backend &&
+ (mem_backend->flags & MALI_MEM_BACKEND_FLAG_VIDEO_LAZY_MAP)) {
+ have_video = 1;
+ break;
+ } else
+ have_video = 0;
+ }
/* Unmap buffers attached to job */
- mali_dma_buf_unmap_job(job);
+ if (have_video)
#endif
+ mali_dma_buf_unmap_job(job);
+
if (MALI_NO_SWAP_IN != job->swap_status) {
mali_mem_swap_out_pages(job);
}
#include "mali_timeline.h"
#include "mali_scheduler.h"
#include "mali_executor.h"
-#if defined(CONFIG_DMA_SHARED_BUFFER) && !defined(CONFIG_MALI_DMA_BUF_MAP_ON_ATTACH)
+#if defined(CONFIG_DMA_SHARED_BUFFER)
#include "linux/mali_memory_dma_buf.h"
#endif
#if defined(CONFIG_MALI_DMA_BUF_FENCE)
* if in atomic context, since both might sleep.
*/
#if defined(CONFIG_DMA_SHARED_BUFFER)
-#if !defined(CONFIG_MALI_DMA_BUF_MAP_ON_ATTACH)
+#if 1//!defined(CONFIG_MALI_DMA_BUF_MAP_ON_ATTACH)
#define MALI_SCHEDULER_USE_DEFERRED_PP_JOB_QUEUE 1
#endif
#endif
mali_scheduler_mask mali_scheduler_activate_pp_job(struct mali_pp_job *job)
{
+#if defined(MALI_SCHEDULER_USE_DEFERRED_PP_JOB_QUEUE)
+ u32 i, have_video;
+ struct mali_session_data *session;
+#endif
MALI_DEBUG_ASSERT_POINTER(job);
MALI_DEBUG_PRINT(4, ("Mali PP scheduler: Timeline activation for job %u (0x%08X).\n",
}
#if defined(MALI_SCHEDULER_USE_DEFERRED_PP_JOB_QUEUE)
- if (mali_pp_job_needs_dma_buf_mapping(job)) {
+ if (job)
+ session = job->session;
+ for (i = 0; job && session && i < job->uargs.num_memory_cookies; i++) {
+ mali_mem_backend *mem_backend = NULL;
+ u32 mali_addr = mali_pp_job_get_memory_cookie(job, i);
+
+ mem_backend = __mali_mem_backend_struct_search(session, mali_addr);
+ if (mem_backend &&
+ (mem_backend->flags & MALI_MEM_BACKEND_FLAG_VIDEO_LAZY_MAP)) {
+ have_video = 1;
+ break;
+ } else
+ have_video = 0;
+ }
+#if defined(CONFIG_MALI_DMA_BUF_LAZY_MAP)
+ have_video = 1;
+#endif
+ if (have_video && mali_pp_job_needs_dma_buf_mapping(job)) {
mali_scheduler_deferred_pp_job_queue(job);
return MALI_SCHEDULER_MASK_EMPTY;
}
/** Flag for _mali_uk_map_external_mem_s, _mali_uk_attach_ump_mem_s and _mali_uk_attach_dma_buf_s */
#define _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE (1<<0)
-
+#define _MALI_MAP_VIDEO_LAYER (1<<31)
typedef struct {
u64 ctx; /**< [in,out] user-kernel context (trashed on output) */
mem->map_ref++;
MALI_DEBUG_PRINT(5, ("Mali DMA-buf: map attachment %p, new map_ref = %d\n", mem, mem->map_ref));
+ MALI_DEBUG_PRINT(5, ("Mali DMA-buf: is_mapped %d, new map_ref = %d\n", mem->is_mapped, mem_backend->flags));
#if (!defined(CONFIG_MALI_DMA_BUF_MAP_ON_ATTACH)) && (defined(CONFIG_MALI_DMA_BUF_LAZY_MAP))
if (MALI_FALSE == mem->is_mapped)
#else
- if (1 == mem->map_ref)
+ if (1 == mem->map_ref || (MALI_FALSE == mem->is_mapped &&
+ mem_backend->flags & MALI_MEM_BACKEND_FLAG_VIDEO_LAZY_MAP))
#endif
{
/* First reference taken, so we need to map the dma buf */
mem->map_ref--;
MALI_DEBUG_PRINT(5, ("Mali DMA-buf: unmap attachment %p, new map_ref = %d\n", mem, mem->map_ref));
-
+ MALI_DEBUG_PRINT(5, ("Mali DMA-buf: unmap is_mapped %d\n", mem->is_mapped));
if (0 == mem->map_ref) {
if (NULL != mem->sgt) {
dma_buf_unmap_attachment(mem->attachment, mem->sgt, DMA_BIDIRECTIONAL);
mali_session_memory_unlock(alloc->session);
}
-#if !defined(CONFIG_MALI_DMA_BUF_MAP_ON_ATTACH)
+#if 1//!defined(CONFIG_MALI_DMA_BUF_MAP_ON_ATTACH)
int mali_dma_buf_map_job(struct mali_pp_job *job)
{
struct mali_dma_buf_attachment *mem;
#else
dma_mem->map_ref = 0;
#endif
+ if (flags & _MALI_MAP_VIDEO_LAYER)
+ dma_mem->map_ref = 1;
init_waitqueue_head(&dma_mem->wait_queue);
dma_mem->attachment = dma_buf_attach(dma_mem->buf, &mali_platform_device->dev);
alloc->flags |= MALI_MEM_FLAG_MALI_GUARD_PAGE;
}
-
#if defined(CONFIG_MALI_DMA_BUF_MAP_ON_ATTACH)
/* Map memory into session's Mali virtual address space. */
- if (0 != mali_dma_buf_map(mem_backend)) {
+ if (!(flags & _MALI_MAP_VIDEO_LAYER) &&
+ (0 != mali_dma_buf_map(mem_backend))) {
goto Failed_dma_map;
}
#endif
attachment = dma_buf_attach(buf, &mali_platform_device->dev);
if (NULL == attachment) {
+ MALI_DEBUG_PRINT_ERROR(("Failed to attach dma-buf\n"));
ret = _MALI_OSK_ERR_FAULT;
goto failed_dma_attach;
}
sgt = dma_buf_map_attachment(attachment, DMA_BIDIRECTIONAL);
if (IS_ERR_OR_NULL(sgt)) {
- MALI_DEBUG_PRINT_ERROR(("Failed to map dma-buf attachment\n"));
+ MALI_DEBUG_PRINT_ERROR(("Failed to dma-buf-map attachment\n"));
ret = _MALI_OSK_ERR_FAULT;
- return -EFAULT;
+ goto failed_dma_map;
}
dma_buf_unmap_attachment(attachment, sgt, DMA_BIDIRECTIONAL);
sgt = NULL;
+failed_dma_map:
dma_buf_detach(buf, attachment);
failed_dma_attach:
dma_buf_put(buf);
mali_mem_backend *mem_backend,
int fd, u32 flags);
-#if !defined(CONFIG_MALI_DMA_BUF_MAP_ON_ATTACH)
+#if 1//!defined(CONFIG_MALI_DMA_BUF_MAP_ON_ATTACH)
int mali_dma_buf_map_job(struct mali_pp_job *job);
void mali_dma_buf_unmap_job(struct mali_pp_job *job);
#endif
return mem_bkend;
}
+mali_mem_backend *__mali_mem_backend_struct_search(struct mali_session_data *session, u32 mali_address)
+{
+ struct mali_vma_node *mali_vma_node = NULL;
+ mali_mem_backend *mem_bkend = NULL;
+ mali_mem_allocation *mali_alloc = NULL;
+ MALI_DEBUG_ASSERT_POINTER(session);
+ mali_vma_node = __mali_vma_offset_search(&session->allocation_mgr, mali_address, 0);
+ if (NULL == mali_vma_node) {
+ MALI_DEBUG_PRINT(1, ("mali_mem_backend_struct_search:vma node was NULL\n"));
+ return NULL;
+ }
+ mali_alloc = container_of(mali_vma_node, struct mali_mem_allocation, mali_vma_node);
+ /* Get backend memory & Map on CPU */
+ //mutex_lock(&mali_idr_mutex);
+ mem_bkend = idr_find(&mali_backend_idr, mali_alloc->backend_handle);
+ //mutex_unlock(&mali_idr_mutex);
+ MALI_DEBUG_ASSERT(NULL != mem_bkend);
+ return mem_bkend;
+}
+
static _mali_osk_errcode_t mali_mem_resize(struct mali_session_data *session, mali_mem_backend *mem_backend, u32 physical_size)
{
_mali_osk_errcode_t ret = _MALI_OSK_ERR_FAULT;
#if defined(CONFIG_DMA_SHARED_BUFFER)
mali_allocation->type = MALI_MEM_DMA_BUF;
mem_backend->type = MALI_MEM_DMA_BUF;
+ MALI_DEBUG_PRINT(3, (" _mali_ukk_mem_bind, bind_dma_buf.flags=0x%x, size=0x%x \n",
+ args->mem_union.bind_dma_buf.flags, args->size));
+ if (args->mem_union.bind_dma_buf.flags & _MALI_MAP_VIDEO_LAYER)
+ mem_backend->flags |= MALI_MEM_BACKEND_FLAG_VIDEO_LAZY_MAP;
ret = mali_mem_bind_dma_buf(mali_allocation, mem_backend,
args->mem_union.bind_dma_buf.mem_fd, args->mem_union.bind_dma_buf.flags);
if (_MALI_OSK_ERR_OK != ret) {
_mali_osk_errcode_t mali_mem_add_mem_size(struct mali_session_data *session, u32 mali_addr, u32 add_size);
mali_mem_backend *mali_mem_backend_struct_search(struct mali_session_data *session, u32 mali_address);
+mali_mem_backend *__mali_mem_backend_struct_search(struct mali_session_data *session, u32 mali_address);
_mali_osk_errcode_t _mali_ukk_mem_allocate(_mali_uk_alloc_mem_s *args);
_mali_osk_errcode_t _mali_ukk_mem_free(_mali_uk_free_mem_s *args);
_mali_osk_errcode_t _mali_ukk_mem_bind(_mali_uk_bind_mem_s *args);
#define MALI_MEM_BACKEND_FLAG_UNSWAPPED_IN (0x8)
#define MALI_MEM_BACKEND_FLAG_NOT_BINDED (0x1 << 5) /* this backend it not back with physical memory, used for defer bind */
#define MALI_MEM_BACKEND_FLAG_BINDED (0x1 << 6) /* this backend it back with physical memory, used for defer bind */
+#define MALI_MEM_BACKEND_FLAG_VIDEO_LAZY_MAP (0x1 << 7) /* this backend it back with physical memory, used for video layer lazy map */
typedef struct mali_mem_backend {
mali_mem_type type; /**< Type of backend memory */
return best;
}
+/* copy from mali_vma_offset_search, delete the lock operation */
+struct mali_vma_node *__mali_vma_offset_search(struct mali_allocation_manager *mgr,
+ unsigned long start, unsigned long pages)
+{
+ struct mali_vma_node *node, *best;
+ struct rb_node *iter;
+ unsigned long offset;
+ //read_lock(&mgr->vm_lock);
+
+ iter = mgr->allocation_mgr_rb.rb_node;
+ best = NULL;
+
+ while (likely(iter)) {
+ node = rb_entry(iter, struct mali_vma_node, vm_rb);
+ offset = node->vm_node.start;
+ if (start >= offset) {
+ iter = iter->rb_right;
+ best = node;
+ if (start == offset)
+ break;
+ } else {
+ iter = iter->rb_left;
+ }
+ }
+
+ if (best) {
+ offset = best->vm_node.start + best->vm_node.size;
+ if (offset <= start + pages)
+ best = NULL;
+ }
+ //read_unlock(&mgr->vm_lock);
+
+ return best;
+}
struct mali_vma_node *mali_vma_offset_search(struct mali_allocation_manager *mgr,
unsigned long start, unsigned long pages);
-
+struct mali_vma_node *__mali_vma_offset_search(struct mali_allocation_manager *mgr,
+ unsigned long start, unsigned long pages);
#endif