gpu: fix GL 0x505 issue for utgard r8p0
authorbinqi.zhang <binqi.zhang@amlogic.com>
Thu, 25 Jan 2018 11:58:11 +0000 (19:58 +0800)
committerbinqi.zhang <binqi.zhang@amlogic.com>
Fri, 26 Jan 2018 11:39:11 +0000 (19:39 +0800)
PD#157391

Change-Id: I3a9138667fe0f55083915c561115a665919eb620

mali/common/mali_mmu_page_directory.c [changed mode: 0755->0644]
mali/linux/mali_memory_manager.c [changed mode: 0755->0644]
mali/linux/mali_memory_os_alloc.c [changed mode: 0755->0644]
mali/linux/mali_ukk_mem.c

old mode 100755 (executable)
new mode 100644 (file)
index 74d8cc8..a752f5c
@@ -122,8 +122,10 @@ _mali_osk_errcode_t mali_mmu_pagedir_map(struct mali_page_directory *pagedir, u3
        mali_dma_addr pde_phys;
        int i, page_count;
        u32 start_address;
-       if (last_pde < first_pde)
+       if (last_pde < first_pde) {
+               MALI_PRINT_ERROR((" last_pde < first_pde\n"));
                return _MALI_OSK_ERR_INVALID_ARGS;
+       }
 
        for (i = first_pde; i <= last_pde; i++) {
                if (0 == (_mali_osk_mem_ioread32(pagedir->page_directory_mapped,
old mode 100755 (executable)
new mode 100644 (file)
index afbcf78..10d367e
@@ -94,11 +94,7 @@ static mali_mem_allocation *mali_mem_allocation_struct_create(struct mali_sessio
        /* Allocate memory */
        mali_allocation = (mali_mem_allocation *)kzalloc(sizeof(mali_mem_allocation), GFP_KERNEL);
        if (NULL == mali_allocation) {
-#ifdef AML_MALI_DEBUG
                MALI_PRINT_ERROR(("mali_mem_allocation_struct_create: descriptor was NULL\n"));
-               show_mem(SHOW_MEM_FILTER_NODES);
-#endif
-
                return NULL;
        }
 
@@ -141,10 +137,7 @@ int mali_mem_backend_struct_create(mali_mem_backend **backend, u32 psize)
        s32 index = -1;
        *backend = (mali_mem_backend *)kzalloc(sizeof(mali_mem_backend), GFP_KERNEL);
        if (NULL == *backend) {
-#ifdef AML_MALI_DEBUG
-               MALI_PRINT_ERROR(("mali_mem_backend_struct_create: backend descriptor was NULL\n"));
-               show_mem(SHOW_MEM_FILTER_NODES);
-#endif
+               MALI_PRINT_ERROR( ("mali_mem_backend_struct_create: backend descriptor was NULL\n"));
                return -1;
        }
        mem_backend = *backend;
@@ -177,7 +170,7 @@ again:
        mutex_unlock(&mali_idr_mutex);
        index = ret;
        if (ret < 0) {
-               MALI_DEBUG_PRINT(1, ("mali_mem_backend_struct_create: Can't allocate idr for backend! \n"));
+               MALI_PRINT_ERROR(("mali_mem_backend_struct_create: Can't allocate idr for backend! \n"));
                kfree(mem_backend);
                return -ENOSPC;
        }
@@ -419,7 +412,6 @@ _mali_osk_errcode_t _mali_ukk_mem_allocate(_mali_uk_alloc_mem_s *args)
        int retval = 0;
        mali_mem_allocation *mali_allocation = NULL;
        struct mali_vma_node *mali_vma_node = NULL;
-
        MALI_DEBUG_PRINT(4, (" _mali_ukk_mem_allocate, vaddr=0x%x, size =0x%x! \n", args->gpu_vaddr, args->psize));
 
        if (args->vsize < args->psize) {
@@ -438,7 +430,7 @@ _mali_osk_errcode_t _mali_ukk_mem_allocate(_mali_uk_alloc_mem_s *args)
        mali_vma_node = mali_vma_offset_search(&session->allocation_mgr, args->gpu_vaddr, 0);
 
        if (unlikely(mali_vma_node)) {
-               MALI_DEBUG_PRINT_ERROR(("The mali virtual address has already been used ! \n"));
+               MALI_PRINT_ERROR(("The mali virtual address has already been used ! \n"));
                return _MALI_OSK_ERR_FAULT;
        }
        /**
@@ -448,7 +440,8 @@ _mali_osk_errcode_t _mali_ukk_mem_allocate(_mali_uk_alloc_mem_s *args)
        mali_allocation = mali_mem_allocation_struct_create(session);
 
        if (mali_allocation == NULL) {
-               MALI_DEBUG_PRINT(1, ("_mali_ukk_mem_allocate: Failed to create allocation struct! \n"));
+               MALI_PRINT_ERROR((" _mali_ukk_mem_allocate, vaddr=0x%x, size =0x%x! %s, %d\n", args->gpu_vaddr, args->psize, __FILE__, __LINE__));
+               MALI_PRINT_ERROR(("_mali_ukk_mem_allocate: Failed to create allocation struct! \n"));
                return _MALI_OSK_ERR_NOMEM;
        }
        mali_allocation->psize = args->psize;
@@ -479,11 +472,11 @@ _mali_osk_errcode_t _mali_ukk_mem_allocate(_mali_uk_alloc_mem_s *args)
        mali_allocation->mali_vma_node.vm_node.size = args->vsize;
 
        mali_vma_offset_add(&session->allocation_mgr, &mali_allocation->mali_vma_node);
-
        mali_allocation->backend_handle = mali_mem_backend_struct_create(&mem_backend, args->psize);
        if (mali_allocation->backend_handle < 0) {
                ret = _MALI_OSK_ERR_NOMEM;
-               MALI_DEBUG_PRINT(1, ("mali_allocation->backend_handle < 0! \n"));
+               MALI_PRINT_ERROR(("mali_allocation->psize = %d mali_allocation->vsize = %d mali_allocation->type = %d \n",  mali_allocation->psize, mali_allocation->vsize, mali_allocation->type));
+               MALI_PRINT_ERROR(("mali_allocation->backend_handle < 0! \n"));
                goto failed_alloc_backend;
        }
 
@@ -502,6 +495,8 @@ _mali_osk_errcode_t _mali_ukk_mem_allocate(_mali_uk_alloc_mem_s *args)
                ret = mali_mem_mali_map_prepare(mali_allocation);
                if (0 != ret) {
                        _mali_osk_mutex_signal(session->memory_lock);
+                       MALI_PRINT_ERROR(("mali_allocation->psize = %d mali_allocation->vsize = %d mali_allocation->type = %d \n",  mali_allocation->psize, mali_allocation->vsize, mali_allocation->type));
+                       MALI_PRINT_ERROR(("Aml-------%s, %d\n", __FILE__, __LINE__));
                        goto failed_prepare_map;
                }
                _mali_osk_mutex_signal(session->memory_lock);
@@ -529,12 +524,12 @@ _mali_osk_errcode_t _mali_ukk_mem_allocate(_mali_uk_alloc_mem_s *args)
 #if defined(CONFIG_DMA_SHARED_BUFFER)
                        ret = mali_mem_secure_attach_dma_buf(&mem_backend->secure_mem, mem_backend->size, args->secure_shared_fd);
                        if (_MALI_OSK_ERR_OK != ret) {
-                               MALI_DEBUG_PRINT(1, ("Failed to attach dma buf for secure memory! \n"));
+                               MALI_PRINT_ERROR(("Failed to attach dma buf for secure memory! \n"));
                                goto failed_alloc_pages;
                        }
 #else
                        ret = _MALI_OSK_ERR_UNSUPPORTED;
-                       MALI_DEBUG_PRINT(1, ("DMA not supported for mali secure memory! \n"));
+                       MALI_PRINT_ERROR(("DMA not supported for mali secure memory! \n"));
                        goto failed_alloc_pages;
 #endif
                } else {
@@ -560,7 +555,8 @@ _mali_osk_errcode_t _mali_ukk_mem_allocate(_mali_uk_alloc_mem_s *args)
 
                        if (retval) {
                                ret = _MALI_OSK_ERR_NOMEM;
-                               MALI_DEBUG_PRINT(1, (" can't allocate enough pages! \n"));
+                               MALI_PRINT_ERROR(("mali_allocation->psize = %d mali_allocation->vsize = %d mali_allocation->type = %d \n",  mali_allocation->psize, mali_allocation->vsize, mali_allocation->type));
+                               MALI_PRINT_ERROR((" can't allocate enough pages! \n"));
                                goto failed_alloc_pages;
                        }
                }
old mode 100755 (executable)
new mode 100644 (file)
index cf037aa..73ca64b
@@ -168,7 +168,7 @@ int mali_mem_os_alloc_pages(mali_mem_os_mem *os_mem, u32 size)
        MALI_DEBUG_ASSERT_POINTER(os_mem);
 
        if (atomic_read(&mali_mem_os_allocator.allocated_pages) * _MALI_OSK_MALI_PAGE_SIZE + size > mali_mem_os_allocator.allocation_limit) {
-               MALI_DEBUG_PRINT(2, ("Mali Mem: Unable to allocate %u bytes. Currently allocated: %lu, max limit %lu\n",
+               MALI_PRINT_ERROR( ("Mali Mem: Unable to allocate %u bytes. Currently allocated: %lu, max limit %lu\n",
                                     size,
                                     atomic_read(&mali_mem_os_allocator.allocated_pages) * _MALI_OSK_MALI_PAGE_SIZE,
                                     mali_mem_os_allocator.allocation_limit));
@@ -224,8 +224,11 @@ int mali_mem_os_alloc_pages(mali_mem_os_mem *os_mem, u32 size)
 #endif
 
                new_page = alloc_page(flags);
-
+               if (new_page == NULL) {
+                       new_page = alloc_page(flags | GFP_KERNEL);
+               }
                if (unlikely(NULL == new_page)) {
+                       MALI_PRINT_ERROR(("alloc_page() return NULL at last! Please check kernel memory!"));
                        /* Calculate the number of pages actually allocated, and free them. */
 #ifdef AML_MALI_DEBUG
                        MALI_PRINT_ERROR(("alloc_page() return NULL\n"));
@@ -247,7 +250,7 @@ int mali_mem_os_alloc_pages(mali_mem_os_mem *os_mem, u32 size)
 
                err = dma_mapping_error(&mali_platform_device->dev, dma_addr);
                if (unlikely(err)) {
-                       MALI_DEBUG_PRINT_ERROR(("OS Mem: Failed to DMA map page %p: %u",
+                       MALI_PRINT_ERROR(("OS Mem: Failed to DMA map page %p: %u",
                                                new_page, err));
                        __free_page(new_page);
                        os_mem->count = (page_count - remaining) + i;
@@ -283,7 +286,7 @@ int mali_mem_os_alloc_pages(mali_mem_os_mem *os_mem, u32 size)
        atomic_add(page_count, &mali_mem_os_allocator.allocated_pages);
 
        if (MALI_OS_MEMORY_KERNEL_BUFFER_SIZE_IN_PAGES > mali_mem_os_allocator.pool_count) {
-               MALI_DEBUG_PRINT(4, ("OS Mem: Stopping pool trim timer, only %u pages on pool\n", mali_mem_os_allocator.pool_count));
+//             MALI_PRINT_ERROR( ("OS Mem: Stopping pool trim timer, only %u pages on pool\n", mali_mem_os_allocator.pool_count));
                cancel_delayed_work(&mali_mem_os_allocator.timed_shrinker);
        }
 
index ea21147bd69e48eb17b1d106e81983c738aed324..440b4777c4446a85168b2a0ecf8841c029948460 100755 (executable)
@@ -37,6 +37,7 @@ int mem_alloc_wrapper(struct mali_session_data *session_data, _mali_uk_alloc_mem
        err = _mali_ukk_mem_allocate(&kargs);
 
        if (_MALI_OSK_ERR_OK != err) {
+               MALI_PRINT_ERROR(("_mali_ukk_mem_allocate return ERROR\n"));
                return map_errcode(err);
        }