summaryrefslogtreecommitdiff
path: root/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump')
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/Makefile6
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_kernel_api.c45
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_kernel_common.c8
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_kernel_memory_backend.h1
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_osk.h4
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_uk_types.h2
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_ukk.h2
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ioctl.h2
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_linux.c36
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_dedicated.c12
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_dedicated.h2
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_os.c10
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_os.h2
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_memory_backend.c2
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_osk_atomics.c2
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_osk_low_level_mem.c117
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_osk_misc.c2
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_ref_wrappers.c2
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_ref_wrappers.h2
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_wrappers.c4
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_wrappers.h2
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/readme.txt19
22 files changed, 230 insertions, 54 deletions
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/Makefile b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/Makefile
index 97225bbbf0b..c42eb937e72 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/Makefile
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/Makefile
@@ -20,8 +20,12 @@ endif
# For each arch check: CROSS_COMPILE , KDIR , CFLAGS += -DARCH
ARCH ?= arm
-## @note Should allow overriding of building UMP for non-debug:
+BUILD ?= debug
+
EXTRA_CFLAGS += -DDEBUG -DMALI_STATE_TRACKING=0
+ifeq ($(BUILD), debug)
+EXTRA_CFLAGS += -DDEBUG
+endif
# linux build system integration
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_kernel_api.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_kernel_api.c
index 719370c3de7..083910f5af9 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_kernel_api.c
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_kernel_api.c
@@ -296,15 +296,21 @@ _mali_osk_errcode_t _ump_ukk_size_get( _ump_uk_size_get_s *user_interaction )
void _ump_ukk_msync( _ump_uk_msync_s *args )
{
ump_dd_mem * mem = NULL;
+ void *virtual = NULL;
+ u32 size = 0;
+ u32 offset = 0;
_mali_osk_lock_wait(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
ump_descriptor_mapping_get(device.secure_id_map, (int)args->secure_id, (void**)&mem);
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
- if (NULL==mem)
+ if (NULL == mem)
{
+ _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
DBG_MSG(1, ("Failed to look up mapping in _ump_ukk_msync(). ID: %u\n", (ump_secure_id)args->secure_id));
return;
}
+ /* Ensure the memory doesn't dissapear when we are flushing it. */
+ ump_dd_reference_add(mem);
+ _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
/* Returns the cache settings back to Userspace */
args->is_cached=mem->is_cached;
@@ -313,17 +319,44 @@ void _ump_ukk_msync( _ump_uk_msync_s *args )
if ( _UMP_UK_MSYNC_READOUT_CACHE_ENABLED==args->op )
{
DBG_MSG(3, ("_ump_ukk_msync READOUT ID: %u Enabled: %d\n", (ump_secure_id)args->secure_id, mem->is_cached));
- return;
+ goto msync_release_and_return;
}
/* Nothing to do if the memory is not caches */
if ( 0==mem->is_cached )
{
DBG_MSG(3, ("_ump_ukk_msync IGNORING ID: %u Enabled: %d OP: %d\n", (ump_secure_id)args->secure_id, mem->is_cached, args->op));
- return ;
+ goto msync_release_and_return;
+ }
+ DBG_MSG(3, ("_ump_ukk_msync FLUSHING ID: %u Enabled: %d OP: %d Address: 0x%08x Mapping: 0x%08x\n",
+ (ump_secure_id)args->secure_id, mem->is_cached, args->op, args->address, args->mapping));
+
+ if ( args->address )
+ {
+ virtual = (void *)((u32)args->address);
+ offset = (u32)((args->address) - (args->mapping));
+ } else {
+ /* Flush entire mapping when no address is specified. */
+ virtual = args->mapping;
+ }
+ if ( args->size )
+ {
+ size = args->size;
+ } else {
+ /* Flush entire mapping when no size is specified. */
+ size = mem->size_bytes - offset;
+ }
+
+ if ( (offset + size) > mem->size_bytes )
+ {
+ DBG_MSG(1, ("Trying to flush more than the entire UMP allocation: offset: %u + size: %u > %u\n", offset, size, mem->size_bytes));
+ goto msync_release_and_return;
}
- DBG_MSG(3, ("_ump_ukk_msync FLUSHING ID: %u Enabled: %d OP: %d\n", (ump_secure_id)args->secure_id, mem->is_cached, args->op));
/* The actual cache flush - Implemented for each OS*/
- _ump_osk_msync( mem , args->op);
+ _ump_osk_msync( mem, virtual, offset, size, args->op);
+
+msync_release_and_return:
+ ump_dd_reference_release(mem);
+ return;
}
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_kernel_common.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_kernel_common.c
index b99c3e7c7d2..602e0bad340 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_kernel_common.c
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_kernel_common.c
@@ -385,3 +385,11 @@ void _ump_ukk_unmap_mem( _ump_uk_unmap_mem_s *args )
_ump_osk_mem_mapregion_term( descriptor );
_mali_osk_free(descriptor);
}
+
+u32 _ump_ukk_report_memory_usage( void )
+{
+ if(device.backend->stat)
+ return device.backend->stat(device.backend);
+ else
+ return 0;
+}
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_kernel_memory_backend.h b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_kernel_memory_backend.h
index 02a64707036..f45783d25bd 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_kernel_memory_backend.h
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_kernel_memory_backend.h
@@ -37,6 +37,7 @@ typedef struct ump_memory_backend
int (*allocate)(void* ctx, ump_dd_mem * descriptor);
void (*release)(void* ctx, ump_dd_mem * descriptor);
void (*shutdown)(struct ump_memory_backend * backend);
+ u32 (*stat)(struct ump_memory_backend *backend);
int (*pre_allocate_physical_check)(void *ctx, u32 size);
u32 (*adjust_to_mali_phys)(void *ctx, u32 cpu_phys);
void * ctx;
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_osk.h b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_osk.h
index 73284f02b47..7022da1fc79 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_osk.h
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_osk.h
@@ -18,7 +18,7 @@
#include <mali_osk.h>
#include <ump_kernel_memory_backend.h>
-#include <ump_uk_types.h>
+#include "ump_uk_types.h"
#ifdef __cplusplus
extern "C"
@@ -39,7 +39,7 @@ _mali_osk_errcode_t _ump_osk_mem_mapregion_map( ump_memory_allocation * descript
void _ump_osk_mem_mapregion_term( ump_memory_allocation * descriptor );
-void _ump_osk_msync( ump_dd_mem * mem, ump_uk_msync_op op );
+void _ump_osk_msync( ump_dd_mem * mem, void * virt, u32 offset, u32 size, ump_uk_msync_op op );
#ifdef __cplusplus
}
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_uk_types.h b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_uk_types.h
index b08335f61f1..9e61b26a64f 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_uk_types.h
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_uk_types.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ * Copyright (C) 2010 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_ukk.h b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_ukk.h
index a3317fc7b21..1867cf4431f 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_ukk.h
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/common/ump_ukk.h
@@ -44,6 +44,8 @@ void _ump_ukk_unmap_mem( _ump_uk_unmap_mem_s *args );
void _ump_ukk_msync( _ump_uk_msync_s *args );
+u32 _ump_ukk_report_memory_usage( void );
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ioctl.h b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ioctl.h
index b11429816ab..0c0ff6f6272 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ioctl.h
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ioctl.h
@@ -19,7 +19,7 @@ extern "C"
#include <linux/types.h>
#include <linux/ioctl.h>
-#include "../common/ump_uk_types.h"
+#include <ump_uk_types.h>
#ifndef __user
#define __user
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_linux.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_linux.c
index 76d6b2f913a..5465c70ed77 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_linux.c
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_linux.c
@@ -16,6 +16,8 @@
#include <asm/uaccess.h> /* user space access */
#include <asm/atomic.h>
#include <linux/device.h>
+#include <linux/debugfs.h>
+
#include "arch/config.h" /* Configuration for current platform. The symlinc for arch is set by Makefile */
#include "ump_ioctl.h"
#include "ump_kernel_common.h"
@@ -48,6 +50,9 @@ MODULE_PARM_DESC(ump_major, "Device major number");
static char ump_dev_name[] = "ump"; /* should be const, but the functions we call requires non-cost */
+#if UMP_LICENSE_IS_GPL
+static struct dentry *ump_debugfs_dir = NULL;
+#endif
/*
* The data which we attached to each virtual memory mapping request we get.
@@ -133,6 +138,21 @@ static void ump_cleanup_module(void)
+static ssize_t ump_memory_used_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
+{
+ char buf[64];
+ size_t r;
+ u32 mem = _ump_ukk_report_memory_usage();
+
+ r = snprintf(buf, 64, "%u\n", mem);
+ return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
+}
+
+static const struct file_operations ump_memory_usage_fops = {
+ .owner = THIS_MODULE,
+ .read = ump_memory_used_read,
+};
+
/*
* Initialize the UMP device driver.
*/
@@ -140,6 +160,17 @@ int ump_kernel_device_initialize(void)
{
int err;
dev_t dev = 0;
+#if UMP_LICENSE_IS_GPL
+ ump_debugfs_dir = debugfs_create_dir(ump_dev_name, NULL);
+ if (ERR_PTR(-ENODEV) == ump_debugfs_dir)
+ {
+ ump_debugfs_dir = NULL;
+ }
+ else
+ {
+ debugfs_create_file("memory_usage", 0400, ump_debugfs_dir, NULL, &ump_memory_usage_fops);
+ }
+#endif
if (0 == ump_major)
{
@@ -216,6 +247,11 @@ void ump_kernel_device_terminate(void)
/* free major */
unregister_chrdev_region(dev, 1);
+
+#if UMP_LICENSE_IS_GPL
+ if(ump_debugfs_dir)
+ debugfs_remove_recursive(ump_debugfs_dir);
+#endif
}
/*
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_dedicated.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_dedicated.c
index 5c8a7f3783f..cdcf19bc13d 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_dedicated.c
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_dedicated.c
@@ -52,6 +52,7 @@ static void block_allocator_shutdown(ump_memory_backend * backend);
static int block_allocator_allocate(void* ctx, ump_dd_mem * mem);
static void block_allocator_release(void * ctx, ump_dd_mem * handle);
static inline u32 get_phys(block_allocator * allocator, block_info * block);
+static u32 block_allocator_stat(struct ump_memory_backend *backend);
@@ -104,6 +105,7 @@ ump_memory_backend * ump_block_allocator_create(u32 base_address, u32 size)
backend->allocate = block_allocator_allocate;
backend->release = block_allocator_release;
backend->shutdown = block_allocator_shutdown;
+ backend->stat = block_allocator_stat;
backend->pre_allocate_physical_check = NULL;
backend->adjust_to_mali_phys = NULL;
@@ -271,3 +273,13 @@ static inline u32 get_phys(block_allocator * allocator, block_info * block)
{
return allocator->base + ((block - allocator->all_blocks) * UMP_BLOCK_SIZE);
}
+
+static u32 block_allocator_stat(struct ump_memory_backend *backend)
+{
+ block_allocator *allocator;
+ BUG_ON(!backend);
+ allocator = (block_allocator*)backend->ctx;
+ BUG_ON(!allocator);
+
+ return (allocator->num_blocks - allocator->num_free)* UMP_BLOCK_SIZE;
+}
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_dedicated.h b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_dedicated.h
index 58ebe15e5a2..fa4bdccfe32 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_dedicated.h
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_dedicated.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ * Copyright (C) 2010 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_os.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_os.c
index 99c9c223036..cb557cfebc1 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_os.c
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_os.c
@@ -40,6 +40,7 @@ typedef struct os_allocator
static void os_free(void* ctx, ump_dd_mem * descriptor);
static int os_allocate(void* ctx, ump_dd_mem * descriptor);
static void os_memory_backend_destroy(ump_memory_backend * backend);
+static u32 os_stat(struct ump_memory_backend *backend);
@@ -73,6 +74,7 @@ ump_memory_backend * ump_os_memory_backend_create(const int max_allocation)
backend->allocate = os_allocate;
backend->release = os_free;
backend->shutdown = os_memory_backend_destroy;
+ backend->stat = os_stat;
backend->pre_allocate_physical_check = NULL;
backend->adjust_to_mali_phys = NULL;
@@ -243,3 +245,11 @@ static void os_free(void* ctx, ump_dd_mem * descriptor)
vfree(descriptor->block_array);
}
+
+
+static u32 os_stat(struct ump_memory_backend *backend)
+{
+ os_allocator *info;
+ info = (os_allocator*)backend->ctx;
+ return info->num_pages_allocated * _MALI_OSK_MALI_PAGE_SIZE;
+}
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_os.h b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_os.h
index d6083477d72..f924705cf74 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_os.h
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_kernel_memory_backend_os.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ * Copyright (C) 2010 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_memory_backend.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_memory_backend.c
index 1c1190a537f..37a0fccd7d0 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_memory_backend.c
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_memory_backend.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ * Copyright (C) 2010 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_osk_atomics.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_osk_atomics.c
index b3300ab691a..ef1902e5391 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_osk_atomics.c
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_osk_atomics.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ * Copyright (C) 2010 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_osk_low_level_mem.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_osk_low_level_mem.c
index 7a1c5e97886..43183225d9c 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_osk_low_level_mem.c
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_osk_low_level_mem.c
@@ -26,6 +26,7 @@
#include <linux/slab.h>
#include <asm/memory.h>
+#include <asm/uaccess.h> /* to verify pointers from user space */
#include <asm/cacheflush.h>
#include <linux/dma-mapping.h>
@@ -139,7 +140,11 @@ _mali_osk_errcode_t _ump_osk_mem_mapregion_init( ump_memory_allocation * descrip
}
vma = (struct vm_area_struct*)descriptor->process_mapping_info;
- if (NULL == vma ) return _MALI_OSK_ERR_FAULT;
+ if (NULL == vma )
+ {
+ kfree(vma_usage_tracker);
+ return _MALI_OSK_ERR_FAULT;
+ }
vma->vm_private_data = vma_usage_tracker;
vma->vm_flags |= VM_IO;
@@ -206,38 +211,92 @@ _mali_osk_errcode_t _ump_osk_mem_mapregion_map( ump_memory_allocation * descript
}
-void _ump_osk_msync( ump_dd_mem * mem, ump_uk_msync_op op )
+void _ump_osk_msync( ump_dd_mem * mem, void * virt, u32 offset, u32 size, ump_uk_msync_op op )
{
int i;
- DBG_MSG(3, ("Flushing nr of blocks: %u. First: paddr: 0x%08x vaddr: 0x%08x size:%dB\n", mem->nr_blocks, mem->block_array[0].addr, phys_to_virt(mem->block_array[0].addr), mem->block_array[0].size));
+ const void *start_v, *end_v;
+
+ DBG_MSG(3, ("Flushing nr of blocks: %u, size: %u. First: paddr: 0x%08x vaddr: 0x%08x offset: 0x%08x size:%uB\n",
+ mem->nr_blocks, mem->size_bytes, mem->block_array[0].addr, virt, offset, size));
+
+ /* Flush L1 using virtual address, the entire range in one go.
+ * Only flush if user space process has a valid write mapping on given address. */
+ if(access_ok(VERIFY_WRITE, virt, size))
+ {
+ start_v = (void *)virt;
+ end_v = (void *)(start_v + size - 1);
+ /* There is no dmac_clean_range, so the L1 is always flushed,
+ * also for UMP_MSYNC_CLEAN. */
+ dmac_flush_range(start_v, end_v);
+ }
+ else
+ {
+ DBG_MSG(1, ("Attempt to flush %d@%x as part of ID %u rejected: there is no valid mapping.\n",
+ size, virt, mem->secure_id));
+ return;
+ }
- /* TODO: Use args->size and args->address to select a subrange of this allocation to flush */
- for (i=0 ; i<mem->nr_blocks; i++)
+ /* Flush L2 using physical addresses, block for block. */
+ for (i=0 ; i < mem->nr_blocks; i++)
{
- /* TODO: Find out which flush method is best of 1)Dma OR 2)Normal flush functions */
- /* TODO: Use args->op to select the flushing method: CLEAN_AND_INVALIDATE or CLEAN */
- /*#define USING_DMA_FLUSH*/
- #ifdef USING_DMA_FLUSH
- DEBUG_ASSERT( (PAGE_SIZE==mem->block_array[i].size));
- dma_map_page(NULL, pfn_to_page(mem->block_array[i].addr >> PAGE_SHIFT), 0, PAGE_SIZE, DMA_BIDIRECTIONAL );
- /*dma_unmap_page(NULL, mem->block_array[i].addr, PAGE_SIZE, DMA_BIDIRECTIONAL);*/
- #else
- /* Normal style flush */
- ump_dd_physical_block *block;
- u32 start_p, end_p;
- const void *start_v, *end_v;
- block = &mem->block_array[i];
-
- start_p = (u32)block->addr;
- start_v = phys_to_virt( start_p ) ;
-
- end_p = start_p + block->size-1;
- end_v = phys_to_virt( end_p ) ;
-
- dmac_flush_range(start_v, end_v);
- outer_flush_range(start_p, end_p);
- #endif
+ u32 start_p, end_p;
+ ump_dd_physical_block *block;
+ block = &mem->block_array[i];
+
+ if(offset >= block->size)
+ {
+ offset -= block->size;
+ continue;
+ }
+
+ if(offset)
+ {
+ start_p = (u32)block->addr + offset;
+ /* We'll zero the offset later, after using it to calculate end_p. */
+ }
+ else
+ {
+ start_p = (u32)block->addr;
+ }
+
+ if(size < block->size - offset)
+ {
+ end_p = start_p + size - 1;
+ size = 0;
+ }
+ else
+ {
+ if(offset)
+ {
+ end_p = start_p + (block->size - offset - 1);
+ size -= block->size - offset;
+ offset = 0;
+ }
+ else
+ {
+ end_p = start_p + block->size - 1;
+ size -= block->size;
+ }
+ }
+
+ switch(op)
+ {
+ case _UMP_UK_MSYNC_CLEAN:
+ outer_clean_range(start_p, end_p);
+ break;
+ case _UMP_UK_MSYNC_CLEAN_AND_INVALIDATE:
+ outer_flush_range(start_p, end_p);
+ break;
+ default:
+ break;
+ }
+
+ if(0 == size)
+ {
+ /* Nothing left to flush. */
+ break;
+ }
}
- return ;
+ return;
}
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_osk_misc.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_osk_misc.c
index 78569c4457b..12066eb7630 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_osk_misc.c
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_osk_misc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ * Copyright (C) 2010 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_ref_wrappers.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_ref_wrappers.c
index 155635026aa..e701f1bc9ee 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_ref_wrappers.c
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_ref_wrappers.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ * Copyright (C) 2010 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_ref_wrappers.h b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_ref_wrappers.h
index b2bef1152c3..9ebc3553397 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_ref_wrappers.h
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_ref_wrappers.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ * Copyright (C) 2010 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_wrappers.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_wrappers.c
index d14b631246c..d986e9f51d6 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_wrappers.c
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_wrappers.c
@@ -138,9 +138,9 @@ int ump_size_get_wrapper(u32 __user * argument, struct ump_session_data * sessi
}
/*
- * IOCTL operation; Return size for specified UMP memory.
+ * IOCTL operation; Do cache maintenance on specified UMP memory.
*/
- int ump_msync_wrapper(u32 __user * argument, struct ump_session_data * session_data)
+int ump_msync_wrapper(u32 __user * argument, struct ump_session_data * session_data)
{
_ump_uk_msync_s user_interaction;
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_wrappers.h b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_wrappers.h
index 31afe2dca56..4892c31327e 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_wrappers.h
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/linux/ump_ukk_wrappers.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ * Copyright (C) 2010 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/readme.txt b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/readme.txt
index bf1bf61d60e..c238cf0f2b1 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/readme.txt
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/ump/readme.txt
@@ -3,15 +3,26 @@ Building the UMP Device Driver for Linux
Build the UMP Device Driver for Linux by running the following make command:
-KDIR=<kdir_path> CONFIG=<your_config> make
+KDIR=<kdir_path> CONFIG=<your_config> BUILD=<build_option> make
where
kdir_path: Path to your Linux Kernel directory
your_config: Name of the sub-folder to find the required config.h file
("arch-" will be prepended)
+ build_option: debug or release. Debug is default.
-The config.h file contains the configuration parameters needed, like the
-memory backend to use, and the amount of memory.
+The config.h contains following configuration parameters:
+
+ARCH_UMP_BACKEND_DEFAULT
+ 0 specifies the dedicated memory allocator.
+ 1 specifies the OS memory allocator.
+ARCH_UMP_MEMORY_ADDRESS_DEFAULT
+ This is only required for the dedicated memory allocator, and specifies
+ the physical start address of the memory block reserved for UMP.
+ARCH_UMP_MEMORY_SIZE_DEFAULT
+ This specified the size of the memory block reserved for UMP, or the
+ maximum limit for allocations from the OS.
The result will be a ump.ko file, which can be loaded into the Linux kernel
-by using the insmod command.
+by using the insmod command. The driver can also be built as a part of the
+kernel itself.