aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/samsung/mali/common/mali_memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/samsung/mali/common/mali_memory.c')
-rw-r--r--drivers/media/video/samsung/mali/common/mali_memory.c118
1 files changed, 58 insertions, 60 deletions
diff --git a/drivers/media/video/samsung/mali/common/mali_memory.c b/drivers/media/video/samsung/mali/common/mali_memory.c
index 7a11d1a..75506ed 100644
--- a/drivers/media/video/samsung/mali/common/mali_memory.c
+++ b/drivers/media/video/samsung/mali/common/mali_memory.c
@@ -146,6 +146,11 @@ static mali_physical_memory_allocator * physical_memory_allocators = NULL;
static dedicated_memory_info * mem_region_registrations = NULL;
+mali_allocation_engine mali_mem_get_memory_engine(void)
+{
+ return memory_engine;
+}
+
/* called during module init */
_mali_osk_errcode_t mali_memory_initialize(void)
{
@@ -239,6 +244,8 @@ static void descriptor_table_cleanup_callback(int descriptor_id, void* map_targe
void mali_memory_session_end(struct mali_session_data *session_data)
{
+ _mali_osk_errcode_t err = _MALI_OSK_ERR_BUSY;
+
MALI_DEBUG_PRINT(3, ("MMU session end\n"));
if (NULL == session_data)
@@ -247,76 +254,63 @@ void mali_memory_session_end(struct mali_session_data *session_data)
return;
}
-#ifndef MALI_UKK_HAS_IMPLICIT_MMAP_CLEANUP
-#if _MALI_OSK_SPECIFIC_INDIRECT_MMAP
-#error Indirect MMAP specified, but UKK does not have implicit MMAP cleanup. Current implementation does not handle this.
-#else
+ while (err == _MALI_OSK_ERR_BUSY)
{
- _mali_osk_errcode_t err;
- err = _MALI_OSK_ERR_BUSY;
- while (err == _MALI_OSK_ERR_BUSY)
- {
- /* Lock the session so we can modify the memory list */
- _mali_osk_lock_wait( session_data->memory_lock, _MALI_OSK_LOCKMODE_RW );
- err = _MALI_OSK_ERR_OK;
+ /* Lock the session so we can modify the memory list */
+ _mali_osk_lock_wait( session_data->memory_lock, _MALI_OSK_LOCKMODE_RW );
+ err = _MALI_OSK_ERR_OK;
- /* Free all memory engine allocations */
- if (0 == _mali_osk_list_empty(&session_data->memory_head))
- {
- mali_memory_allocation *descriptor;
- mali_memory_allocation *temp;
- _mali_uk_mem_munmap_s unmap_args;
+ /* Free all memory engine allocations */
+ if (0 == _mali_osk_list_empty(&session_data->memory_head))
+ {
+ mali_memory_allocation *descriptor;
+ mali_memory_allocation *temp;
+ _mali_uk_mem_munmap_s unmap_args;
- MALI_DEBUG_PRINT(1, ("Memory found on session usage list during session termination\n"));
+ MALI_DEBUG_PRINT(1, ("Memory found on session usage list during session termination\n"));
- unmap_args.ctx = session_data;
+ unmap_args.ctx = session_data;
- /* use the 'safe' list iterator, since freeing removes the active block from the list we're iterating */
- _MALI_OSK_LIST_FOREACHENTRY(descriptor, temp, &session_data->memory_head, mali_memory_allocation, list)
+ /* use the 'safe' list iterator, since freeing removes the active block from the list we're iterating */
+ _MALI_OSK_LIST_FOREACHENTRY(descriptor, temp, &session_data->memory_head, mali_memory_allocation, list)
+ {
+ MALI_DEBUG_PRINT(4, ("Freeing block with mali address 0x%x size %d mapped in user space at 0x%x\n",
+ descriptor->mali_address, descriptor->size, descriptor->size, descriptor->mapping)
+ );
+ /* ASSERT that the descriptor's lock references the correct thing */
+ MALI_DEBUG_ASSERT( descriptor->lock == session_data->memory_lock );
+ /* Therefore, we have already locked the descriptor */
+
+ unmap_args.size = descriptor->size;
+ unmap_args.mapping = descriptor->mapping;
+ unmap_args.cookie = (u32)descriptor;
+
+ /*
+ * This removes the descriptor from the list, and frees the descriptor
+ *
+ * Does not handle the _MALI_OSK_SPECIFIC_INDIRECT_MMAP case, since
+ * the only OS we are aware of that requires indirect MMAP also has
+ * implicit mmap cleanup.
+ */
+ err = _mali_ukk_mem_munmap_internal( &unmap_args );
+
+ if (err == _MALI_OSK_ERR_BUSY)
{
- MALI_DEBUG_PRINT(4, ("Freeing block with mali address 0x%x size %d mapped in user space at 0x%x\n",
- descriptor->mali_address, descriptor->size, descriptor->size, descriptor->mapping)
- );
- /* ASSERT that the descriptor's lock references the correct thing */
- MALI_DEBUG_ASSERT( descriptor->lock == session_data->memory_lock );
- /* Therefore, we have already locked the descriptor */
-
- unmap_args.size = descriptor->size;
- unmap_args.mapping = descriptor->mapping;
- unmap_args.cookie = (u32)descriptor;
-
+ _mali_osk_lock_signal( session_data->memory_lock, _MALI_OSK_LOCKMODE_RW );
/*
- * This removes the descriptor from the list, and frees the descriptor
- *
- * Does not handle the _MALI_OSK_SPECIFIC_INDIRECT_MMAP case, since
- * the only OS we are aware of that requires indirect MMAP also has
- * implicit mmap cleanup.
- */
- err = _mali_ukk_mem_munmap_internal( &unmap_args );
-
- if (err == _MALI_OSK_ERR_BUSY)
- {
- _mali_osk_lock_signal( session_data->memory_lock, _MALI_OSK_LOCKMODE_RW );
- /*
- * Reason for this;
- * We where unable to stall the MMU, probably because we are in page fault handling.
- * Sleep for a while with the session lock released, then try again.
- * Abnormal termination of programs with running Mali jobs is a normal reason for this.
- */
- _mali_osk_time_ubusydelay(10);
- break; /* Will jump back into: "while (err == _MALI_OSK_ERR_BUSY)" */
- }
+ * Reason for this;
+ * We where unable to stall the MMU, probably because we are in page fault handling.
+ * Sleep for a while with the session lock released, then try again.
+ * Abnormal termination of programs with running Mali jobs is a normal reason for this.
+ */
+ _mali_osk_time_ubusydelay(10);
+ break; /* Will jump back into: "while (err == _MALI_OSK_ERR_BUSY)" */
}
}
}
- /* Assert that we really did free everything */
- MALI_DEBUG_ASSERT( _mali_osk_list_empty(&session_data->memory_head) );
}
-#endif /* _MALI_OSK_SPECIFIC_INDIRECT_MMAP */
-#else
- /* Lock the session so we can modify the memory list */
- _mali_osk_lock_wait( session_data->memory_lock, _MALI_OSK_LOCKMODE_RW );
-#endif /* MALI_UKK_HAS_IMPLICIT_MMAP_CLEANUP */
+ /* Assert that we really did free everything */
+ MALI_DEBUG_ASSERT( _mali_osk_list_empty(&session_data->memory_head) );
if (NULL != session_data->descriptor_mapping)
{
@@ -601,7 +595,9 @@ _mali_osk_errcode_t _mali_ukk_attach_ump_mem( _mali_uk_attach_ump_mem_s *args )
descriptor->mali_address = args->mali_address;
descriptor->mali_addr_mapping_info = (void*)session_data;
descriptor->process_addr_mapping_info = NULL; /* do not map to process address space */
+ descriptor->cache_settings = (u32) MALI_CACHE_STANDARD;
descriptor->lock = session_data->memory_lock;
+
if (args->flags & _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE)
{
descriptor->flags = MALI_MEMORY_ALLOCATION_FLAG_MAP_GUARD_PAGE;
@@ -812,6 +808,7 @@ _mali_osk_errcode_t _mali_ukk_map_external_mem( _mali_uk_map_external_mem_s *arg
descriptor->mali_address = args->mali_address;
descriptor->mali_addr_mapping_info = (void*)session_data;
descriptor->process_addr_mapping_info = NULL; /* do not map to process address space */
+ descriptor->cache_settings = (u32)MALI_CACHE_STANDARD;
descriptor->lock = session_data->memory_lock;
if (args->flags & _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE)
{
@@ -947,7 +944,7 @@ static _mali_osk_errcode_t mali_address_manager_map(mali_memory_allocation * des
MALI_DEBUG_PRINT(7, ("Mali map: mapping 0x%08X to Mali address 0x%08X length 0x%08X\n", *phys_addr, mali_address, size));
- mali_mmu_pagedir_update(session_data->page_directory, mali_address, *phys_addr, size);
+ mali_mmu_pagedir_update(session_data->page_directory, mali_address, *phys_addr, size, descriptor->cache_settings);
MALI_SUCCESS;
}
@@ -976,6 +973,7 @@ _mali_osk_errcode_t _mali_ukk_mem_mmap( _mali_uk_mem_mmap_s *args )
descriptor->process_addr_mapping_info = args->ukk_private; /* save to be used during physical manager callback */
descriptor->flags = MALI_MEMORY_ALLOCATION_FLAG_MAP_INTO_USERSPACE;
+ descriptor->cache_settings = (u32) args->cache_settings ;
descriptor->lock = session_data->memory_lock;
_mali_osk_list_init( &descriptor->list );