diff options
author | mcampbellsmith <mcampbellsmith@gmail.com> | 2013-11-20 22:34:44 +1100 |
---|---|---|
committer | sbrissen <sbrissen@hotmail.com> | 2013-12-10 14:54:28 -0500 |
commit | 74bcc029c6ab942f252477a74102877f7d093388 (patch) | |
tree | 044bd97b98693c073841663c62f57e1520509109 /drivers/media/video/samsung/mali/linux | |
parent | 2a6649bf6aa50c44a05fc02e1efb8b788c58e82b (diff) | |
download | kernel_samsung_smdk4412-74bcc029c6ab942f252477a74102877f7d093388.zip kernel_samsung_smdk4412-74bcc029c6ab942f252477a74102877f7d093388.tar.gz kernel_samsung_smdk4412-74bcc029c6ab942f252477a74102877f7d093388.tar.bz2 |
mali: bulk import of r3p2-01rel3 drivers from i9300-update12
Courtesy of a similar commit from OMNI ROM. Requires updated mali blobs
Change-Id: I9ee55b653b57b7c390f8e0e8cd4fc068f1c751c3
Diffstat (limited to 'drivers/media/video/samsung/mali/linux')
38 files changed, 0 insertions, 6571 deletions
diff --git a/drivers/media/video/samsung/mali/linux/license/gpl/mali_kernel_license.h b/drivers/media/video/samsung/mali/linux/license/gpl/mali_kernel_license.h deleted file mode 100644 index 52bb5e0..0000000 --- a/drivers/media/video/samsung/mali/linux/license/gpl/mali_kernel_license.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2010, 2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file mali_kernel_license.h - * Defines for the macro MODULE_LICENSE. - */ - -#ifndef __MALI_KERNEL_LICENSE_H__ -#define __MALI_KERNEL_LICENSE_H__ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#define MALI_KERNEL_LINUX_LICENSE "GPL" -#define MALI_LICENSE_IS_GPL 1 - -#ifdef __cplusplus -} -#endif - -#endif /* __MALI_KERNEL_LICENSE_H__ */ diff --git a/drivers/media/video/samsung/mali/linux/mali_dma_buf.c b/drivers/media/video/samsung/mali/linux/mali_dma_buf.c deleted file mode 100644 index 4dd711f..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_dma_buf.c +++ /dev/null @@ -1,392 +0,0 @@ -/* - * Copyright (C) 2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include <linux/fs.h> /* file system operations */ -#include <asm/uaccess.h> /* user space access */ -#include <linux/dma-buf.h> -#include <linux/scatterlist.h> -#include <linux/rbtree.h> - -#include "mali_ukk.h" -#include "mali_osk.h" -#include "mali_kernel_common.h" -#include "mali_session.h" -#include "mali_kernel_linux.h" - -#include "mali_kernel_memory_engine.h" -#include "mali_memory.h" - -#include "mali_kernel_sysfs.h" - - -struct mali_dma_buf_attachment { - struct dma_buf *buf; - struct dma_buf_attachment *attachment; - struct sg_table *sgt; - _mali_osk_atomic_t ref; - struct rb_node rb_node; -}; - -static struct rb_root mali_dma_bufs = RB_ROOT; -static DEFINE_SPINLOCK(mali_dma_bufs_lock); - -static inline struct mali_dma_buf_attachment *mali_dma_buf_lookup(struct rb_root *root, struct dma_buf *target) -{ - struct rb_node *node = root->rb_node; - struct mali_dma_buf_attachment *res; - - spin_lock(&mali_dma_bufs_lock); - while (node) - { - res = rb_entry(node, struct mali_dma_buf_attachment, rb_node); - - if (target < res->buf) node = node->rb_left; - else if (target > res->buf) node = node->rb_right; - else - { - _mali_osk_atomic_inc(&res->ref); - spin_unlock(&mali_dma_bufs_lock); - return res; - } - } - spin_unlock(&mali_dma_bufs_lock); - - return NULL; -} - -static void mali_dma_buf_add(struct rb_root *root, struct mali_dma_buf_attachment *new) -{ - struct rb_node **node = &root->rb_node; - struct rb_node *parent = NULL; - struct mali_dma_buf_attachment *res; - - spin_lock(&mali_dma_bufs_lock); - while (*node) - { - parent = *node; - res = rb_entry(*node, struct mali_dma_buf_attachment, rb_node); - - if (new->buf < res->buf) node = &(*node)->rb_left; - else node = &(*node)->rb_right; - } - - rb_link_node(&new->rb_node, parent, node); - rb_insert_color(&new->rb_node, &mali_dma_bufs); - - spin_unlock(&mali_dma_bufs_lock); - - return; -} - - -static void mali_dma_buf_release(void *ctx, void *handle) -{ - struct mali_dma_buf_attachment *mem; - u32 ref; - - mem = (struct mali_dma_buf_attachment *)handle; - - MALI_DEBUG_ASSERT_POINTER(mem); - MALI_DEBUG_ASSERT_POINTER(mem->attachment); - MALI_DEBUG_ASSERT_POINTER(mem->buf); - - spin_lock(&mali_dma_bufs_lock); - ref = _mali_osk_atomic_dec_return(&mem->ref); - - MALI_DEBUG_ASSERT(ref >= 0); - - if (0 == ref) - { - rb_erase(&mem->rb_node, &mali_dma_bufs); - spin_unlock(&mali_dma_bufs_lock); - - MALI_DEBUG_ASSERT(0 == _mali_osk_atomic_read(&mem->ref)); - - dma_buf_unmap_attachment(mem->attachment, mem->sgt, DMA_BIDIRECTIONAL); - - dma_buf_detach(mem->buf, mem->attachment); - dma_buf_put(mem->buf); - - _mali_osk_free(mem); - } - else - { - spin_unlock(&mali_dma_bufs_lock); - } -} - -/* Callback from memory engine which will map into Mali virtual address space */ -static mali_physical_memory_allocation_result mali_dma_buf_commit(void* ctx, mali_allocation_engine * engine, mali_memory_allocation * descriptor, u32* offset, mali_physical_memory_allocation * alloc_info) -{ - struct mali_session_data *session; - struct mali_page_directory *pagedir; - struct mali_dma_buf_attachment *mem; - struct scatterlist *sg; - int i; - u32 virt; - - MALI_DEBUG_ASSERT_POINTER(ctx); - MALI_DEBUG_ASSERT_POINTER(engine); - MALI_DEBUG_ASSERT_POINTER(descriptor); - MALI_DEBUG_ASSERT_POINTER(offset); - MALI_DEBUG_ASSERT_POINTER(alloc_info); - - /* Mapping dma-buf with an offset is not supported. */ - MALI_DEBUG_ASSERT(0 == *offset); - - virt = descriptor->mali_address; - session = (struct mali_session_data *)descriptor->mali_addr_mapping_info; - pagedir = mali_session_get_page_directory(session); - - MALI_DEBUG_ASSERT_POINTER(session); - - mem = (struct mali_dma_buf_attachment *)ctx; - - MALI_DEBUG_ASSERT_POINTER(mem); - - mem->sgt = dma_buf_map_attachment(mem->attachment, DMA_BIDIRECTIONAL); - if (IS_ERR_OR_NULL(mem->sgt)) - { - MALI_PRINT_ERROR(("Failed to map dma-buf attachment\n")); - return MALI_MEM_ALLOC_INTERNAL_FAILURE; - } - - for_each_sg(mem->sgt->sgl, sg, mem->sgt->nents, i) - { - u32 size = sg_dma_len(sg); - dma_addr_t phys = sg_dma_address(sg); - - /* sg must be page aligned. */ - MALI_DEBUG_ASSERT(0 == size % MALI_MMU_PAGE_SIZE); - - mali_mmu_pagedir_update(pagedir, virt, phys, size, MALI_CACHE_STANDARD); - - virt += size; - *offset += size; - } - - if (descriptor->flags & MALI_MEMORY_ALLOCATION_FLAG_MAP_GUARD_PAGE) - { - u32 guard_phys; - MALI_DEBUG_PRINT(7, ("Mapping in extra guard page\n")); - - guard_phys = sg_dma_address(mem->sgt->sgl); - mali_mmu_pagedir_update(mali_session_get_page_directory(session), virt, guard_phys, MALI_MMU_PAGE_SIZE, MALI_CACHE_STANDARD); - } - - MALI_DEBUG_ASSERT(*offset == descriptor->size); - - alloc_info->ctx = NULL; - alloc_info->handle = mem; - alloc_info->next = NULL; - alloc_info->release = mali_dma_buf_release; - - return MALI_MEM_ALLOC_FINISHED; -} - -int mali_attach_dma_buf(struct mali_session_data *session, _mali_uk_attach_dma_buf_s __user *user_arg) -{ - mali_physical_memory_allocator external_memory_allocator; - struct dma_buf *buf; - struct mali_dma_buf_attachment *mem; - _mali_uk_attach_dma_buf_s args; - mali_memory_allocation *descriptor; - int md; - int fd; - - /* Get call arguments from user space. copy_from_user returns how many bytes which where NOT copied */ - if (0 != copy_from_user(&args, (void __user *)user_arg, sizeof(_mali_uk_attach_dma_buf_s))) - { - return -EFAULT; - } - - - fd = args.mem_fd; - - buf = dma_buf_get(fd); - if (IS_ERR_OR_NULL(buf)) - { - MALI_DEBUG_PRINT(2, ("Failed to get dma-buf from fd: %d\n", fd)); - return PTR_RET(buf); - } - - /* Currently, mapping of the full buffer are supported. */ - if (args.size != buf->size) - { - MALI_DEBUG_PRINT(2, ("dma-buf size doesn't match mapping size.\n")); - dma_buf_put(buf); - return -EINVAL; - } - - - mem = mali_dma_buf_lookup(&mali_dma_bufs, buf); - if (NULL == mem) - { - /* dma-buf is not already attached to Mali */ - mem = _mali_osk_calloc(1, sizeof(struct mali_dma_buf_attachment)); - if (NULL == mem) - { - MALI_PRINT_ERROR(("Failed to allocate dma-buf tracing struct\n")); - dma_buf_put(mem->buf); - return -ENOMEM; - } - _mali_osk_atomic_init(&mem->ref, 1); - mem->buf = buf; - - mem->attachment = dma_buf_attach(mem->buf, mali_device); - if (NULL == mem->attachment) - { - MALI_DEBUG_PRINT(2, ("Failed to attach to dma-buf %d\n", fd)); - dma_buf_put(mem->buf); - _mali_osk_free(mem); - return -EFAULT; - } - - mali_dma_buf_add(&mali_dma_bufs, mem); - } - else - { - /* dma-buf is already attached to Mali */ - /* Give back the reference we just took, mali_dma_buf_lookup grabbed a new reference for us. */ - dma_buf_put(buf); - } - - /* Map dma-buf into this session's page tables */ - - /* Set up Mali memory descriptor */ - descriptor = _mali_osk_calloc(1, sizeof(mali_memory_allocation)); - if (NULL == descriptor) - { - MALI_PRINT_ERROR(("Failed to allocate descriptor dma-buf %d\n", fd)); - mali_dma_buf_release(NULL, mem); - return -ENOMEM; - } - - descriptor->size = args.size; - descriptor->mapping = NULL; - descriptor->mali_address = args.mali_address; - descriptor->mali_addr_mapping_info = (void*)session; - descriptor->process_addr_mapping_info = NULL; /* do not map to process address space */ - descriptor->lock = session->memory_lock; - - if (args.flags & _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE) - { - descriptor->flags = MALI_MEMORY_ALLOCATION_FLAG_MAP_GUARD_PAGE; - } - _mali_osk_list_init( &descriptor->list ); - - /* Get descriptor mapping for memory. */ - if (_MALI_OSK_ERR_OK != mali_descriptor_mapping_allocate_mapping(session->descriptor_mapping, descriptor, &md)) - { - MALI_PRINT_ERROR(("Failed to create descriptor mapping for dma-buf %d\n", fd)); - _mali_osk_free(descriptor); - mali_dma_buf_release(NULL, mem); - return -EFAULT; - } - - external_memory_allocator.allocate = mali_dma_buf_commit; - external_memory_allocator.allocate_page_table_block = NULL; - external_memory_allocator.ctx = mem; - external_memory_allocator.name = "DMA-BUF Memory"; - external_memory_allocator.next = NULL; - - /* Map memory into session's Mali virtual address space. */ - _mali_osk_lock_wait(session->memory_lock, _MALI_OSK_LOCKMODE_RW); - if (_MALI_OSK_ERR_OK != mali_allocation_engine_allocate_memory(mali_mem_get_memory_engine(), descriptor, &external_memory_allocator, NULL)) - { - _mali_osk_lock_signal(session->memory_lock, _MALI_OSK_LOCKMODE_RW); - - MALI_PRINT_ERROR(("Failed to map dma-buf %d into Mali address space\n", fd)); - mali_descriptor_mapping_free(session->descriptor_mapping, md); - mali_dma_buf_release(NULL, mem); - return -ENOMEM; - } - _mali_osk_lock_signal(session->memory_lock, _MALI_OSK_LOCKMODE_RW); - - /* Return stuff to user space */ - if (0 != put_user(md, &user_arg->cookie)) - { - /* Roll back */ - MALI_PRINT_ERROR(("Failed to return descriptor to user space for dma-buf %d\n", fd)); - mali_descriptor_mapping_free(session->descriptor_mapping, md); - mali_dma_buf_release(NULL, mem); - return -EFAULT; - } - - return 0; -} - -int mali_release_dma_buf(struct mali_session_data *session, _mali_uk_release_dma_buf_s __user *user_arg) -{ - _mali_uk_release_dma_buf_s args; - mali_memory_allocation *descriptor; - - /* get call arguments from user space. copy_from_user returns how many bytes which where NOT copied */ - if ( 0 != copy_from_user(&args, (void __user *)user_arg, sizeof(_mali_uk_release_dma_buf_s)) ) - { - return -EFAULT; - } - - if (_MALI_OSK_ERR_OK != mali_descriptor_mapping_get(session->descriptor_mapping, args.cookie, (void**)&descriptor)) - { - MALI_DEBUG_PRINT(1, ("Invalid memory descriptor %d used to release dma-buf\n", args.cookie)); - return -EINVAL; - } - - descriptor = mali_descriptor_mapping_free(session->descriptor_mapping, args.cookie); - - if (NULL != descriptor) - { - _mali_osk_lock_wait( session->memory_lock, _MALI_OSK_LOCKMODE_RW ); - - /* Will call back to mali_dma_buf_release() which will release the dma-buf attachment. */ - mali_allocation_engine_release_memory(mali_mem_get_memory_engine(), descriptor); - - _mali_osk_lock_signal( session->memory_lock, _MALI_OSK_LOCKMODE_RW ); - - _mali_osk_free(descriptor); - } - - /* Return the error that _mali_ukk_map_external_ump_mem produced */ - return 0; -} - -int mali_dma_buf_get_size(struct mali_session_data *session, _mali_uk_dma_buf_get_size_s __user *user_arg) -{ - _mali_uk_dma_buf_get_size_s args; - int fd; - struct dma_buf *buf; - - /* get call arguments from user space. copy_from_user returns how many bytes which where NOT copied */ - if ( 0 != copy_from_user(&args, (void __user *)user_arg, sizeof(_mali_uk_dma_buf_get_size_s)) ) - { - return -EFAULT; - } - - /* Do DMA-BUF stuff */ - fd = args.mem_fd; - - buf = dma_buf_get(fd); - if (IS_ERR_OR_NULL(buf)) - { - MALI_DEBUG_PRINT(2, ("Failed to get dma-buf from fd: %d\n", fd)); - return PTR_RET(buf); - } - - if (0 != put_user(buf->size, &user_arg->size)) - { - dma_buf_put(buf); - return -EFAULT; - } - - dma_buf_put(buf); - - return 0; -} diff --git a/drivers/media/video/samsung/mali/linux/mali_dma_buf.h b/drivers/media/video/samsung/mali/linux/mali_dma_buf.h deleted file mode 100644 index ee9a0ed..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_dma_buf.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2011-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef __MALI_DMA_BUF_H__ -#define __MALI_DMA_BUF_H__ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include "mali_osk.h" - -int mali_attach_dma_buf(struct mali_session_data *session, _mali_uk_attach_dma_buf_s __user *arg); -int mali_release_dma_buf(struct mali_session_data *session, _mali_uk_release_dma_buf_s __user *arg); -int mali_dma_buf_get_size(struct mali_session_data *session, _mali_uk_dma_buf_get_size_s __user *arg); - -#ifdef __cplusplus -} -#endif - -#endif /* __MALI_KERNEL_LINUX_H__ */ diff --git a/drivers/media/video/samsung/mali/linux/mali_kernel_linux.c b/drivers/media/video/samsung/mali/linux/mali_kernel_linux.c deleted file mode 100644 index 233c0ca..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_kernel_linux.c +++ /dev/null @@ -1,634 +0,0 @@ -/** - * Copyright (C) 2010-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file mali_kernel_linux.c - * Implementation of the Linux device driver entrypoints - */ -#include <linux/module.h> /* kernel module definitions */ -#include <linux/fs.h> /* file system operations */ -#include <linux/cdev.h> /* character device definitions */ -#include <linux/mm.h> /* memory manager definitions */ -#include <linux/mali/mali_utgard_ioctl.h> -#include "mali_kernel_common.h" -#include "mali_session.h" -#include "mali_kernel_core.h" -#include "mali_osk.h" -#include "mali_kernel_linux.h" -#include "mali_ukk.h" -#include "mali_ukk_wrappers.h" -#include "mali_kernel_pm.h" -#include "mali_kernel_sysfs.h" -#include "mali_platform.h" -#include "mali_kernel_license.h" -#include "mali_dma_buf.h" - -/* Streamline support for the Mali driver */ -#if defined(CONFIG_TRACEPOINTS) && MALI_TIMELINE_PROFILING_ENABLED -/* Ask Linux to create the tracepoints */ -#define CREATE_TRACE_POINTS -#include "mali_linux_trace.h" -#endif /* CONFIG_TRACEPOINTS */ - -static _mali_osk_errcode_t initialize_kernel_device(void); -static int initialize_sysfs(void); -static void terminate_kernel_device(void); - - -/* from the __malidrv_build_info.c file that is generated during build */ -extern const char *__malidrv_build_info(void); - -/* Module parameter to control log level */ -int mali_debug_level = 2; -module_param(mali_debug_level, int, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP | S_IROTH); /* rw-rw-r-- */ -MODULE_PARM_DESC(mali_debug_level, "Higher number, more dmesg output"); - -/* By default the module uses any available major, but it's possible to set it at load time to a specific number */ -#if MALI_MAJOR_PREDEFINE -int mali_major = 244; -#else -int mali_major = 0; -#endif -module_param(mali_major, int, S_IRUGO); /* r--r--r-- */ -MODULE_PARM_DESC(mali_major, "Device major number"); - -module_param(mali_hang_check_interval, int, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP | S_IROTH); -MODULE_PARM_DESC(mali_hang_check_interval, "Interval at which to check for progress after the hw watchdog has been triggered"); - -module_param(mali_max_job_runtime, int, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP | S_IROTH); -MODULE_PARM_DESC(mali_max_job_runtime, "Maximum allowed job runtime in msecs.\nJobs will be killed after this no matter what"); - -extern int mali_l2_max_reads; -module_param(mali_l2_max_reads, int, S_IRUSR | S_IRGRP | S_IROTH); -MODULE_PARM_DESC(mali_l2_max_reads, "Maximum reads for Mali L2 cache"); - -#if MALI_TIMELINE_PROFILING_ENABLED -extern int mali_boot_profiling; -module_param(mali_boot_profiling, int, S_IRUSR | S_IRGRP | S_IROTH); -MODULE_PARM_DESC(mali_boot_profiling, "Start profiling as a part of Mali driver initialization"); -#endif - -/* Export symbols from common code: mali_user_settings.c */ -#include "mali_user_settings_db.h" -EXPORT_SYMBOL(mali_set_user_setting); -EXPORT_SYMBOL(mali_get_user_setting); -#if MALI_DVFS_ENABLED -extern int mali_dvfs_control; -module_param(mali_dvfs_control, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH); /* rw-rw-r-- */ -MODULE_PARM_DESC(mali_dvfs_control, "Mali Current DVFS"); -#if defined(CONFIG_CPU_EXYNOS4210) -#else -extern int step0_clk; -module_param(step0_clk, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH); /* rw-rw-r-- */ -MODULE_PARM_DESC(step0_clk, "Mali Current step0_clk"); -#ifdef DEBUG -extern int step0_vol; -module_param(step0_vol, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH); /* rw-rw-r-- */ -MODULE_PARM_DESC(step0_vol, "Mali Current step0_vol"); -#endif - -#if (MALI_DVFS_STEPS > 1) -extern int step1_clk; -module_param(step1_clk, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH); /* rw-rw-r-- */ -MODULE_PARM_DESC(step1_clk, "Mali Current step1_clk"); - -extern int step0_up; -module_param(step0_up, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH); /* rw-rw-r-- */ -MODULE_PARM_DESC(step0_up, "Mali Current step0_up"); - -extern int step1_down; -module_param(step1_down, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH); /* rw-rw-r-- */ -MODULE_PARM_DESC(step1_down, "Mali Current step1_down"); -#ifdef DEBUG -extern int step1_vol; -module_param(step1_vol, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH); /* rw-rw-r-- */ -MODULE_PARM_DESC(step1_vol, "Mali Current step1_vol"); -#endif - -#if (MALI_DVFS_STEPS > 2) -extern int step2_clk; -module_param(step2_clk, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH); /* rw-rw-r-- */ -MODULE_PARM_DESC(step2_clk, "Mali Current step2_clk"); - -extern int step1_up; -module_param(step1_up, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH); /* rw-rw-r-- */ -MODULE_PARM_DESC(step1_up, "Mali Current step1_up"); - -extern int step2_down; -module_param(step2_down, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH); /* rw-rw-r-- */ -MODULE_PARM_DESC(step2_down, "Mali Current step2_down"); -#ifdef DEBUG -extern int step2_vol; -module_param(step2_vol, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH); /* rw-rw-r-- */ -MODULE_PARM_DESC(step2_vol, "Mali Current step2_vol"); -#endif - -#if (MALI_DVFS_STEPS > 3) -extern int step3_clk; -module_param(step3_clk, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH); /* rw-rw-r-- */ -MODULE_PARM_DESC(step3_clk, "Mali Current step3_clk"); - -extern int step2_up; -module_param(step2_up, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH); /* rw-rw-r-- */ -MODULE_PARM_DESC(step2_up, "Mali Current step2_up"); - -extern int step3_down; -module_param(step3_down, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH); /* rw-rw-r-- */ -MODULE_PARM_DESC(step3_down, "Mali Current step3_down"); -#ifdef DEBUG -extern int step3_vol; -module_param(step3_vol, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH); /* rw-rw-r-- */ -MODULE_PARM_DESC(step3_vol, "Mali Current step3_vol"); -#endif -#endif -#endif -#endif -#endif - -extern int mali_gpu_clk; -module_param(mali_gpu_clk, int, S_IRUSR | S_IRGRP | S_IROTH); /* r--r--r-- */ -MODULE_PARM_DESC(mali_gpu_clk, "Mali Current Clock"); - -extern int mali_gpu_vol; -module_param(mali_gpu_vol, int, S_IRUSR | S_IRGRP | S_IROTH); /* r--r--r-- */ -MODULE_PARM_DESC(mali_gpu_vol, "Mali Current Voltage"); - -extern int gpu_power_state; -module_param(gpu_power_state, int, S_IRUSR | S_IRGRP | S_IROTH); /* r--r--r-- */ -MODULE_PARM_DESC(gpu_power_state, "Mali Power State"); -#endif - - -static char mali_dev_name[] = "mali"; /* should be const, but the functions we call requires non-cost */ - -/* the mali device */ -static struct mali_dev device; - - -static int mali_open(struct inode *inode, struct file *filp); -static int mali_release(struct inode *inode, struct file *filp); -#ifdef HAVE_UNLOCKED_IOCTL -static long mali_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); -#else -static int mali_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -#endif - -static int mali_mmap(struct file * filp, struct vm_area_struct * vma); - -/* Linux char file operations provided by the Mali module */ -struct file_operations mali_fops = -{ - .owner = THIS_MODULE, - .open = mali_open, - .release = mali_release, -#ifdef HAVE_UNLOCKED_IOCTL - .unlocked_ioctl = mali_ioctl, -#else - .ioctl = mali_ioctl, -#endif - .mmap = mali_mmap -}; - - -int mali_driver_init(void) -{ - int ret = 0; - - MALI_DEBUG_PRINT(2, ("\n")); - MALI_DEBUG_PRINT(2, ("Inserting Mali v%d device driver. \n",_MALI_API_VERSION)); - MALI_DEBUG_PRINT(2, ("Compiled: %s, time: %s.\n", __DATE__, __TIME__)); - MALI_DEBUG_PRINT(2, ("Driver revision: %s\n", SVN_REV_STRING)); - - ret = _mali_dev_platform_register(); - if (0 != ret) goto platform_register_failed; - ret = map_errcode(initialize_kernel_device()); - if (0 != ret) goto initialize_kernel_device_failed; - - ret = map_errcode(mali_platform_init()); - if (0 != ret) goto platform_init_failed; - - mali_osk_low_level_mem_init(); - - ret = map_errcode(mali_initialize_subsystems()); - if (0 != ret) goto initialize_subsystems_failed; - - ret = initialize_sysfs(); - if (0 != ret) goto initialize_sysfs_failed; - - MALI_PRINT(("Mali device driver loaded\n")); - - return 0; /* Success */ - - /* Error handling */ -initialize_sysfs_failed: - mali_terminate_subsystems(); -initialize_subsystems_failed: - mali_osk_low_level_mem_term(); - mali_platform_deinit(); -platform_init_failed: - terminate_kernel_device(); -initialize_kernel_device_failed: - _mali_dev_platform_unregister(); -platform_register_failed: - return ret; -} - -void mali_driver_exit(void) -{ - MALI_DEBUG_PRINT(2, ("\n")); - MALI_DEBUG_PRINT(2, ("Unloading Mali v%d device driver.\n",_MALI_API_VERSION)); - - /* No need to terminate sysfs, this will be done automatically along with device termination */ - - mali_terminate_subsystems(); - - mali_osk_low_level_mem_term(); - - mali_platform_deinit(); - - terminate_kernel_device(); - _mali_dev_platform_unregister(); - -#if MALI_LICENSE_IS_GPL - /* @@@@ clean up the work queues! This should not be terminated here, since it isn't inited in the function above! */ - flush_workqueue(mali_wq); - destroy_workqueue(mali_wq); - mali_wq = NULL; -#endif - - MALI_PRINT(("Mali device driver unloaded\n")); -} - -static int initialize_kernel_device(void) -{ - int err; - dev_t dev = 0; - if (0 == mali_major) - { - /* auto select a major */ - err = alloc_chrdev_region(&dev, 0/*first minor*/, 1/*count*/, mali_dev_name); - mali_major = MAJOR(dev); - } - else - { - /* use load time defined major number */ - dev = MKDEV(mali_major, 0); - err = register_chrdev_region(dev, 1/*count*/, mali_dev_name); - } - - if (err) - { - goto init_chrdev_err; - } - - memset(&device, 0, sizeof(device)); - - /* initialize our char dev data */ - cdev_init(&device.cdev, &mali_fops); - device.cdev.owner = THIS_MODULE; - device.cdev.ops = &mali_fops; - - /* register char dev with the kernel */ - err = cdev_add(&device.cdev, dev, 1/*count*/); - if (err) - { - goto init_cdev_err; - } - - /* Success! */ - return 0; - -init_cdev_err: - unregister_chrdev_region(dev, 1/*count*/); -init_chrdev_err: - return err; -} - -static int initialize_sysfs(void) -{ - dev_t dev = MKDEV(mali_major, 0); - return mali_sysfs_register(&device, dev, mali_dev_name); -} - -static void terminate_kernel_device(void) -{ - dev_t dev = MKDEV(mali_major, 0); - - mali_sysfs_unregister(&device, dev, mali_dev_name); - - /* unregister char device */ - cdev_del(&device.cdev); - /* free major */ - unregister_chrdev_region(dev, 1/*count*/); - return; -} - -/** @note munmap handler is done by vma close handler */ -static int mali_mmap(struct file * filp, struct vm_area_struct * vma) -{ - struct mali_session_data * session_data; - _mali_uk_mem_mmap_s args = {0, }; - - session_data = (struct mali_session_data *)filp->private_data; - if (NULL == session_data) - { - MALI_PRINT_ERROR(("mmap called without any session data available\n")); - return -EFAULT; - } - - MALI_DEBUG_PRINT(4, ("MMap() handler: start=0x%08X, phys=0x%08X, size=0x%08X vma->flags 0x%08x\n", (unsigned int)vma->vm_start, (unsigned int)(vma->vm_pgoff << PAGE_SHIFT), (unsigned int)(vma->vm_end - vma->vm_start), vma->vm_flags)); - - /* Re-pack the arguments that mmap() packed for us */ - args.ctx = session_data; - args.phys_addr = vma->vm_pgoff << PAGE_SHIFT; - args.size = vma->vm_end - vma->vm_start; - args.ukk_private = vma; - - if ( VM_SHARED== (VM_SHARED & vma->vm_flags)) - { - args.cache_settings = MALI_CACHE_STANDARD ; - MALI_DEBUG_PRINT(3,("Allocate - Standard - Size: %d kb\n", args.size/1024)); - } - else - { - args.cache_settings = MALI_CACHE_GP_READ_ALLOCATE; - MALI_DEBUG_PRINT(3,("Allocate - GP Cached - Size: %d kb\n", args.size/1024)); - } - /* Setting it equal to VM_SHARED and not Private, which would have made the later io_remap fail for MALI_CACHE_GP_READ_ALLOCATE */ - vma->vm_flags = 0x000000fb; - - /* Call the common mmap handler */ - MALI_CHECK(_MALI_OSK_ERR_OK ==_mali_ukk_mem_mmap( &args ), -EFAULT); - - return 0; -} - -static int mali_open(struct inode *inode, struct file *filp) -{ - struct mali_session_data * session_data; - _mali_osk_errcode_t err; - - /* input validation */ - if (0 != MINOR(inode->i_rdev)) return -ENODEV; - - /* allocated struct to track this session */ - err = _mali_ukk_open((void **)&session_data); - if (_MALI_OSK_ERR_OK != err) return map_errcode(err); - - /* initialize file pointer */ - filp->f_pos = 0; - - /* link in our session data */ - filp->private_data = (void*)session_data; - - return 0; -} - -static int mali_release(struct inode *inode, struct file *filp) -{ - _mali_osk_errcode_t err; - - /* input validation */ - if (0 != MINOR(inode->i_rdev)) return -ENODEV; - - err = _mali_ukk_close((void **)&filp->private_data); - if (_MALI_OSK_ERR_OK != err) return map_errcode(err); - - return 0; -} - -int map_errcode( _mali_osk_errcode_t err ) -{ - switch(err) - { - case _MALI_OSK_ERR_OK : return 0; - case _MALI_OSK_ERR_FAULT: return -EFAULT; - case _MALI_OSK_ERR_INVALID_FUNC: return -ENOTTY; - case _MALI_OSK_ERR_INVALID_ARGS: return -EINVAL; - case _MALI_OSK_ERR_NOMEM: return -ENOMEM; - case _MALI_OSK_ERR_TIMEOUT: return -ETIMEDOUT; - case _MALI_OSK_ERR_RESTARTSYSCALL: return -ERESTARTSYS; - case _MALI_OSK_ERR_ITEM_NOT_FOUND: return -ENOENT; - default: return -EFAULT; - } -} - -#ifdef HAVE_UNLOCKED_IOCTL -static long mali_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) -#else -static int mali_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) -#endif -{ - int err; - struct mali_session_data *session_data; - -#ifndef HAVE_UNLOCKED_IOCTL - /* inode not used */ - (void)inode; -#endif - - MALI_DEBUG_PRINT(7, ("Ioctl received 0x%08X 0x%08lX\n", cmd, arg)); - - session_data = (struct mali_session_data *)filp->private_data; - if (NULL == session_data) - { - MALI_DEBUG_PRINT(7, ("filp->private_data was NULL\n")); - return -ENOTTY; - } - - if (NULL == (void *)arg) - { - MALI_DEBUG_PRINT(7, ("arg was NULL\n")); - return -ENOTTY; - } - - switch(cmd) - { - case MALI_IOC_WAIT_FOR_NOTIFICATION: - err = wait_for_notification_wrapper(session_data, (_mali_uk_wait_for_notification_s __user *)arg); - break; - - case MALI_IOC_GET_API_VERSION: - err = get_api_version_wrapper(session_data, (_mali_uk_get_api_version_s __user *)arg); - break; - - case MALI_IOC_POST_NOTIFICATION: - err = post_notification_wrapper(session_data, (_mali_uk_post_notification_s __user *)arg); - break; - - case MALI_IOC_GET_USER_SETTINGS: - err = get_user_settings_wrapper(session_data, (_mali_uk_get_user_settings_s __user *)arg); - break; - -#if MALI_TIMELINE_PROFILING_ENABLED - case MALI_IOC_PROFILING_START: - err = profiling_start_wrapper(session_data, (_mali_uk_profiling_start_s __user *)arg); - break; - - case MALI_IOC_PROFILING_ADD_EVENT: - err = profiling_add_event_wrapper(session_data, (_mali_uk_profiling_add_event_s __user *)arg); - break; - - case MALI_IOC_PROFILING_STOP: - err = profiling_stop_wrapper(session_data, (_mali_uk_profiling_stop_s __user *)arg); - break; - - case MALI_IOC_PROFILING_GET_EVENT: - err = profiling_get_event_wrapper(session_data, (_mali_uk_profiling_get_event_s __user *)arg); - break; - - case MALI_IOC_PROFILING_CLEAR: - err = profiling_clear_wrapper(session_data, (_mali_uk_profiling_clear_s __user *)arg); - break; - - case MALI_IOC_PROFILING_GET_CONFIG: - /* Deprecated: still compatible with get_user_settings */ - err = get_user_settings_wrapper(session_data, (_mali_uk_get_user_settings_s __user *)arg); - break; - - case MALI_IOC_PROFILING_REPORT_SW_COUNTERS: - err = profiling_report_sw_counters_wrapper(session_data, (_mali_uk_sw_counters_report_s __user *)arg); - break; - -#else - - case MALI_IOC_PROFILING_START: /* FALL-THROUGH */ - case MALI_IOC_PROFILING_ADD_EVENT: /* FALL-THROUGH */ - case MALI_IOC_PROFILING_STOP: /* FALL-THROUGH */ - case MALI_IOC_PROFILING_GET_EVENT: /* FALL-THROUGH */ - case MALI_IOC_PROFILING_CLEAR: /* FALL-THROUGH */ - case MALI_IOC_PROFILING_GET_CONFIG: /* FALL-THROUGH */ - case MALI_IOC_PROFILING_REPORT_SW_COUNTERS: /* FALL-THROUGH */ - MALI_DEBUG_PRINT(2, ("Profiling not supported\n")); - err = -ENOTTY; - break; - -#endif - - case MALI_IOC_MEM_INIT: - err = mem_init_wrapper(session_data, (_mali_uk_init_mem_s __user *)arg); - break; - - case MALI_IOC_MEM_TERM: - err = mem_term_wrapper(session_data, (_mali_uk_term_mem_s __user *)arg); - break; - - case MALI_IOC_MEM_MAP_EXT: - err = mem_map_ext_wrapper(session_data, (_mali_uk_map_external_mem_s __user *)arg); - break; - - case MALI_IOC_MEM_UNMAP_EXT: - err = mem_unmap_ext_wrapper(session_data, (_mali_uk_unmap_external_mem_s __user *)arg); - break; - - case MALI_IOC_MEM_QUERY_MMU_PAGE_TABLE_DUMP_SIZE: - err = mem_query_mmu_page_table_dump_size_wrapper(session_data, (_mali_uk_query_mmu_page_table_dump_size_s __user *)arg); - break; - - case MALI_IOC_MEM_DUMP_MMU_PAGE_TABLE: - err = mem_dump_mmu_page_table_wrapper(session_data, (_mali_uk_dump_mmu_page_table_s __user *)arg); - break; - -#if MALI_USE_UNIFIED_MEMORY_PROVIDER != 0 - - case MALI_IOC_MEM_ATTACH_UMP: - err = mem_attach_ump_wrapper(session_data, (_mali_uk_attach_ump_mem_s __user *)arg); - break; - - case MALI_IOC_MEM_RELEASE_UMP: - err = mem_release_ump_wrapper(session_data, (_mali_uk_release_ump_mem_s __user *)arg); - break; - -#else - - case MALI_IOC_MEM_ATTACH_UMP: - case MALI_IOC_MEM_RELEASE_UMP: /* FALL-THROUGH */ - MALI_DEBUG_PRINT(2, ("UMP not supported\n")); - err = -ENOTTY; - break; -#endif - -#ifdef CONFIG_DMA_SHARED_BUFFER - case MALI_IOC_MEM_ATTACH_DMA_BUF: - err = mali_attach_dma_buf(session_data, (_mali_uk_attach_dma_buf_s __user *)arg); - break; - - case MALI_IOC_MEM_RELEASE_DMA_BUF: - err = mali_release_dma_buf(session_data, (_mali_uk_release_dma_buf_s __user *)arg); - break; - - case MALI_IOC_MEM_DMA_BUF_GET_SIZE: - err = mali_dma_buf_get_size(session_data, (_mali_uk_dma_buf_get_size_s __user *)arg); - break; -#else - - case MALI_IOC_MEM_DMA_BUF_GET_SIZE: /* FALL-THROUGH */ - MALI_DEBUG_PRINT(2, ("DMA-BUF not supported\n")); - err = -ENOTTY; - break; -#endif - - case MALI_IOC_PP_START_JOB: - err = pp_start_job_wrapper(session_data, (_mali_uk_pp_start_job_s __user *)arg); - break; - - case MALI_IOC_PP_NUMBER_OF_CORES_GET: - err = pp_get_number_of_cores_wrapper(session_data, (_mali_uk_get_pp_number_of_cores_s __user *)arg); - break; - - case MALI_IOC_PP_CORE_VERSION_GET: - err = pp_get_core_version_wrapper(session_data, (_mali_uk_get_pp_core_version_s __user *)arg); - break; - - case MALI_IOC_PP_DISABLE_WB: - err = pp_disable_wb_wrapper(session_data, (_mali_uk_pp_disable_wb_s __user *)arg); - break; - - case MALI_IOC_GP2_START_JOB: - err = gp_start_job_wrapper(session_data, (_mali_uk_gp_start_job_s __user *)arg); - break; - - case MALI_IOC_GP2_NUMBER_OF_CORES_GET: - err = gp_get_number_of_cores_wrapper(session_data, (_mali_uk_get_gp_number_of_cores_s __user *)arg); - break; - - case MALI_IOC_GP2_CORE_VERSION_GET: - err = gp_get_core_version_wrapper(session_data, (_mali_uk_get_gp_core_version_s __user *)arg); - break; - - case MALI_IOC_GP2_SUSPEND_RESPONSE: - err = gp_suspend_response_wrapper(session_data, (_mali_uk_gp_suspend_response_s __user *)arg); - break; - - case MALI_IOC_VSYNC_EVENT_REPORT: - err = vsync_event_report_wrapper(session_data, (_mali_uk_vsync_event_report_s __user *)arg); - break; - - case MALI_IOC_MEM_GET_BIG_BLOCK: /* Fallthrough */ - case MALI_IOC_MEM_FREE_BIG_BLOCK: - MALI_PRINT_ERROR(("Non-MMU mode is no longer supported.\n")); - err = -ENOTTY; - break; - - default: - MALI_DEBUG_PRINT(2, ("No handler for ioctl 0x%08X 0x%08lX\n", cmd, arg)); - err = -ENOTTY; - }; - - return err; -} - - -module_init(mali_driver_init); -module_exit(mali_driver_exit); - -MODULE_LICENSE(MALI_KERNEL_LINUX_LICENSE); -MODULE_AUTHOR("ARM Ltd."); -MODULE_VERSION(SVN_REV_STRING); diff --git a/drivers/media/video/samsung/mali/linux/mali_kernel_linux.h b/drivers/media/video/samsung/mali/linux/mali_kernel_linux.h deleted file mode 100644 index 22dc9a4..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_kernel_linux.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2010-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef __MALI_KERNEL_LINUX_H__ -#define __MALI_KERNEL_LINUX_H__ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include <linux/cdev.h> /* character device definitions */ -#include "mali_kernel_license.h" -#include "mali_osk.h" - -struct mali_dev -{ - struct cdev cdev; -#if MALI_LICENSE_IS_GPL - struct class * mali_class; -#endif -}; - -#if MALI_LICENSE_IS_GPL -/* Defined in mali_osk_irq.h */ -extern struct workqueue_struct * mali_wq; -#endif - -void mali_osk_low_level_mem_init(void); -void mali_osk_low_level_mem_term(void); - -#ifdef __cplusplus -} -#endif - -#endif /* __MALI_KERNEL_LINUX_H__ */ diff --git a/drivers/media/video/samsung/mali/linux/mali_kernel_pm.c b/drivers/media/video/samsung/mali/linux/mali_kernel_pm.c deleted file mode 100644 index 4639d55..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_kernel_pm.c +++ /dev/null @@ -1,268 +0,0 @@ -/** - * Copyright (C) 2010-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file mali_kernel_pm.c - * Linux Power Management integration - */ - -#include <linux/sched.h> -#include <linux/platform_device.h> -#include <linux/version.h> -#include <asm/current.h> -#include <linux/suspend.h> -#include <linux/module.h> -#ifdef CONFIG_PM_RUNTIME -#include <linux/pm_runtime.h> -#endif -#include "mali_osk.h" -#include "mali_uk_types.h" -#include "mali_kernel_common.h" -#include "mali_kernel_license.h" -#include "mali_linux_pm.h" -#include "mali_pm.h" -#include "mali_platform.h" - -#if ! MALI_LICENSE_IS_GPL -#undef CONFIG_PM_RUNTIME -#endif - -#if MALI_PMM_RUNTIME_JOB_CONTROL_ON -extern void set_mali_parent_power_domain(struct platform_device* dev); -#endif /* MALI_PMM_RUNTIME_JOB_CONTROL_ON */ -static int mali_probe(struct platform_device *pdev); -static int mali_remove(struct platform_device *pdev); - -#ifdef CONFIG_PM_RUNTIME -static int mali_runtime_suspend(struct device *dev); -static int mali_runtime_resume(struct device *dev); -#endif - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) -static int mali_os_suspend(struct platform_device *pdev, pm_message_t state); -static int mali_os_resume(struct platform_device *pdev); -#else -static int mali_os_suspend(struct device *dev); -static int mali_os_resume(struct device *dev); -#endif - - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) -static const struct dev_pm_ops mali_dev_pm_ops = -{ -#ifdef CONFIG_PM_RUNTIME - .runtime_suspend = mali_runtime_suspend, - .runtime_resume = mali_runtime_resume, - .runtime_idle = NULL, -#else - .suspend = mali_os_suspend, - .resume = mali_os_resume, -#endif - .freeze = mali_os_suspend, - .poweroff = mali_os_suspend, - .thaw = mali_os_resume, - .restore = mali_os_resume, -}; -#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) -struct pm_ext_ops mali_ext_pm_operations = -{ - .base = - { - .freeze = mali_os_suspend, - .thaw = mali_os_resume, - .poweroff = mali_os_suspend, - .restore = mali_os_resume, - }, -}; -#endif - - -static struct platform_driver mali_plat_driver = -{ - .probe = mali_probe, - .remove = mali_remove, -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) - .suspend = mali_os_suspend, - .resume = mali_os_resume, - .pm = &mali_ext_pm_operations, -#endif - - .driver = - { - .name = "mali_dev", - .owner = THIS_MODULE, -#if MALI_LICENSE_IS_GPL - .bus = &platform_bus_type, -#endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) - .pm = &mali_dev_pm_ops, -#endif - }, -}; - -#ifdef CONFIG_PM_RUNTIME -static int mali_pwr_suspend_notifier(struct notifier_block *nb,unsigned long event,void* dummy); - -static struct notifier_block mali_pwr_notif_block = -{ - .notifier_call = mali_pwr_suspend_notifier -}; -#endif - -/** This function is called when platform device is unregistered. This function - * is necessary when the platform device is unregistered. - */ -static void _mali_release_pm(struct device *device) -{ -} -struct platform_device mali_gpu_device = -{ - .name = "mali_dev", - .id = 0, - .dev.release = _mali_release_pm -}; - -/** This function is called when the device is probed */ -static int mali_probe(struct platform_device *pdev) -{ - return 0; -} - -static int mali_remove(struct platform_device *pdev) -{ -#ifdef CONFIG_PM_RUNTIME - pm_runtime_disable(&pdev->dev); -#endif - return 0; -} - -#ifdef CONFIG_PM_RUNTIME -static int mali_pwr_suspend_notifier(struct notifier_block *nb,unsigned long event,void* dummy) -{ - switch (event) - { - case PM_SUSPEND_PREPARE: - MALI_DEBUG_PRINT(2, ("mali_pwr_suspend_notifier(PM_SUSPEND_PREPARE) called\n")); - mali_pm_os_suspend(); - break; - case PM_POST_SUSPEND: - MALI_DEBUG_PRINT(2, ("mali_pwr_suspend_notifier(PM_SUSPEND_PREPARE) called\n")); - mali_pm_os_resume(); - break; - default: - break; - } - return 0; -} -#endif - - -#ifdef CONFIG_PM_RUNTIME - -static int mali_runtime_suspend(struct device *dev) -{ - MALI_DEBUG_PRINT(3, ("mali_runtime_suspend() called\n")); - mali_pm_runtime_suspend(); - return 0; /* all ok */ -} - -static int mali_runtime_resume(struct device *dev) -{ - MALI_DEBUG_PRINT(3, ("mali_runtime_resume() called\n")); - mali_pm_runtime_resume(); - return 0; /* all ok */ -} - -#endif - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) - -static int mali_os_suspend(struct platform_device *pdev, pm_message_t state) -{ - MALI_DEBUG_PRINT(3, ("mali_os_suspend(old) called\n")); - mali_pm_os_suspend(); - return 0; /* all ok */ -} - -static int mali_os_resume(struct platform_device *pdev) -{ - MALI_DEBUG_PRINT(3, ("mali_os_resume(old) called\n")); - mali_pm_os_resume(); - return 0; /* all ok */ -} - -#else - -static int mali_os_suspend(struct device *dev) -{ - MALI_DEBUG_PRINT(3, ("mali_os_suspend(new) called\n")); - mali_pm_os_suspend(); - return 0; /* all ok */ -} - -static int mali_os_resume(struct device *dev) -{ - MALI_DEBUG_PRINT(3, ("mali_os_resume(new) called\n")); - mali_pm_os_resume(); - return 0; /* all ok */ -} - -#endif - -/** This function is called when Mali GPU device is initialized - */ -int _mali_dev_platform_register(void) -{ - int err; - -#ifdef CONFIG_PM_RUNTIME - set_mali_parent_power_domain((void *)&mali_gpu_device); -#endif - -#ifdef CONFIG_PM_RUNTIME - err = register_pm_notifier(&mali_pwr_notif_block); - if (err) - { - return err; - } -#endif - -#if MALI_LICENSE_IS_GPL - err = platform_device_register(&mali_gpu_device); - if (!err) - { - err = platform_driver_register(&mali_plat_driver); - if (err) - { -#ifdef CONFIG_PM_RUNTIME - unregister_pm_notifier(&mali_pwr_notif_block); -#endif - platform_device_unregister(&mali_gpu_device); - } - } -#endif - - return err; -} - -/** This function is called when Mali GPU device is unloaded - */ -void _mali_dev_platform_unregister(void) -{ -#ifdef CONFIG_PM_RUNTIME - unregister_pm_notifier(&mali_pwr_notif_block); -#endif - -#if MALI_LICENSE_IS_GPL - platform_driver_unregister(&mali_plat_driver); - platform_device_unregister(&mali_gpu_device); -#endif -} - diff --git a/drivers/media/video/samsung/mali/linux/mali_kernel_pm.h b/drivers/media/video/samsung/mali/linux/mali_kernel_pm.h deleted file mode 100644 index 6ef7270..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_kernel_pm.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (C) 2010, 2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef __MALI_KERNEL_PM_H__ -#define __MALI_KERNEL_PM_H__ - -int _mali_dev_platform_register(void); -void _mali_dev_platform_unregister(void); - -#endif /* __MALI_KERNEL_PM_H__ */ diff --git a/drivers/media/video/samsung/mali/linux/mali_kernel_sysfs.c b/drivers/media/video/samsung/mali/linux/mali_kernel_sysfs.c deleted file mode 100644 index e2dc17b..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_kernel_sysfs.c +++ /dev/null @@ -1,1280 +0,0 @@ -/** - * Copyright (C) 2011-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -/** - * @file mali_kernel_sysfs.c - * Implementation of some sysfs data exports - */ - -#include <linux/kernel.h> -#include <linux/fs.h> -#include <linux/device.h> -#include <linux/module.h> -#include "mali_kernel_license.h" -#include "mali_kernel_common.h" -#include "mali_kernel_linux.h" -#include "mali_ukk.h" - -#if MALI_LICENSE_IS_GPL - -#include <linux/seq_file.h> -#include <linux/debugfs.h> -#include <asm/uaccess.h> -#include <linux/module.h> -#include "mali_kernel_sysfs.h" -#if MALI_INTERNAL_TIMELINE_PROFILING_ENABLED -#include <linux/slab.h> -#include "mali_osk_profiling.h" -#endif -#include "mali_pm.h" -#include "mali_cluster.h" -#include "mali_group.h" -#include "mali_gp.h" -#include "mali_pp.h" -#include "mali_l2_cache.h" -#include "mali_hw_core.h" -#include "mali_kernel_core.h" -#include "mali_user_settings_db.h" -#include "mali_device_pause_resume.h" - -#define POWER_BUFFER_SIZE 3 - -struct device *mali_device; -static struct dentry *mali_debugfs_dir = NULL; - -typedef enum -{ - _MALI_DEVICE_SUSPEND, - _MALI_DEVICE_RESUME, - _MALI_DEVICE_DVFS_PAUSE, - _MALI_DEVICE_DVFS_RESUME, - _MALI_MAX_EVENTS -} _mali_device_debug_power_events; - -static const char* const mali_power_events[_MALI_MAX_EVENTS] = { - [_MALI_DEVICE_SUSPEND] = "suspend", - [_MALI_DEVICE_RESUME] = "resume", - [_MALI_DEVICE_DVFS_PAUSE] = "dvfs_pause", - [_MALI_DEVICE_DVFS_RESUME] = "dvfs_resume", -}; - -static u32 virtual_power_status_register=0; -static char pwr_buf[POWER_BUFFER_SIZE]; - -static int open_copy_private_data(struct inode *inode, struct file *filp) -{ - filp->private_data = inode->i_private; - return 0; -} - -static ssize_t gp_gpx_counter_srcx_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *gpos, u32 src_id) -{ - char buf[64]; - int r; - u32 val; - struct mali_gp_core *gp_core = (struct mali_gp_core *)filp->private_data; - - if (0 == src_id) - { - val = mali_gp_core_get_counter_src0(gp_core); - } - else - { - val = mali_gp_core_get_counter_src1(gp_core); - } - - if (MALI_HW_CORE_NO_COUNTER == val) - { - r = sprintf(buf, "-1\n"); - } - else - { - r = sprintf(buf, "%u\n", val); - } - return simple_read_from_buffer(ubuf, cnt, gpos, buf, r); -} - -static ssize_t gp_gpx_counter_srcx_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *gpos, u32 src_id) -{ - struct mali_gp_core *gp_core = (struct mali_gp_core *)filp->private_data; - char buf[64]; - long val; - int ret; - - if (cnt >= sizeof(buf)) - { - return -EINVAL; - } - - if (copy_from_user(&buf, ubuf, cnt)) - { - return -EFAULT; - } - - buf[cnt] = 0; - - ret = strict_strtol(buf, 10, &val); - if (ret < 0) - { - return ret; - } - - if (val < 0) - { - /* any negative input will disable counter */ - val = MALI_HW_CORE_NO_COUNTER; - } - - if (0 == src_id) - { - if (MALI_TRUE != mali_gp_core_set_counter_src0(gp_core, (u32)val)) - { - return 0; - } - } - else - { - if (MALI_TRUE != mali_gp_core_set_counter_src1(gp_core, (u32)val)) - { - return 0; - } - } - - *gpos += cnt; - return cnt; -} - -static ssize_t gp_all_counter_srcx_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *gpos, u32 src_id) -{ - char buf[64]; - long val; - int ret; - u32 ci; - struct mali_cluster *cluster; - - if (cnt >= sizeof(buf)) - { - return -EINVAL; - } - - if (copy_from_user(&buf, ubuf, cnt)) - { - return -EFAULT; - } - - buf[cnt] = 0; - - ret = strict_strtol(buf, 10, &val); - if (ret < 0) - { - return ret; - } - - if (val < 0) - { - /* any negative input will disable counter */ - val = MALI_HW_CORE_NO_COUNTER; - } - - ci = 0; - cluster = mali_cluster_get_global_cluster(ci); - while (NULL != cluster) - { - u32 gi = 0; - struct mali_group *group = mali_cluster_get_group(cluster, gi); - while (NULL != group) - { - struct mali_gp_core *gp_core = mali_group_get_gp_core(group); - if (NULL != gp_core) - { - if (0 == src_id) - { - if (MALI_TRUE != mali_gp_core_set_counter_src0(gp_core, (u32)val)) - { - return 0; - } - } - else - { - if (MALI_TRUE != mali_gp_core_set_counter_src1(gp_core, (u32)val)) - { - return 0; - } - } - } - - /* try next group */ - gi++; - group = mali_cluster_get_group(cluster, gi); - } - - /* try next cluster */ - ci++; - cluster = mali_cluster_get_global_cluster(ci); - } - - *gpos += cnt; - return cnt; -} - -static ssize_t gp_gpx_counter_src0_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *gpos) -{ - return gp_gpx_counter_srcx_read(filp, ubuf, cnt, gpos, 0); -} - -static ssize_t gp_gpx_counter_src1_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *gpos) -{ - return gp_gpx_counter_srcx_read(filp, ubuf, cnt, gpos, 1); -} - -static ssize_t gp_gpx_counter_src0_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *gpos) -{ - return gp_gpx_counter_srcx_write(filp, ubuf, cnt, gpos, 0); -} - -static ssize_t gp_gpx_counter_src1_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *gpos) -{ - return gp_gpx_counter_srcx_write(filp, ubuf, cnt, gpos, 1); -} - -static ssize_t gp_all_counter_src0_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *gpos) -{ - return gp_all_counter_srcx_write(filp, ubuf, cnt, gpos, 0); -} - -static ssize_t gp_all_counter_src1_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *gpos) -{ - return gp_all_counter_srcx_write(filp, ubuf, cnt, gpos, 1); -} - -static const struct file_operations gp_gpx_counter_src0_fops = { - .owner = THIS_MODULE, - .open = open_copy_private_data, - .read = gp_gpx_counter_src0_read, - .write = gp_gpx_counter_src0_write, -}; - -static const struct file_operations gp_gpx_counter_src1_fops = { - .owner = THIS_MODULE, - .open = open_copy_private_data, - .read = gp_gpx_counter_src1_read, - .write = gp_gpx_counter_src1_write, -}; - -static const struct file_operations gp_all_counter_src0_fops = { - .owner = THIS_MODULE, - .write = gp_all_counter_src0_write, -}; - -static const struct file_operations gp_all_counter_src1_fops = { - .owner = THIS_MODULE, - .write = gp_all_counter_src1_write, -}; - -static ssize_t pp_ppx_counter_srcx_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos, u32 src_id) -{ - char buf[64]; - int r; - u32 val; - struct mali_pp_core *pp_core = (struct mali_pp_core *)filp->private_data; - - if (0 == src_id) - { - val = mali_pp_core_get_counter_src0(pp_core); - } - else - { - val = mali_pp_core_get_counter_src1(pp_core); - } - - if (MALI_HW_CORE_NO_COUNTER == val) - { - r = sprintf(buf, "-1\n"); - } - else - { - r = sprintf(buf, "%u\n", val); - } - return simple_read_from_buffer(ubuf, cnt, ppos, buf, r); -} - -static ssize_t pp_ppx_counter_srcx_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos, u32 src_id) -{ - struct mali_pp_core *pp_core = (struct mali_pp_core *)filp->private_data; - char buf[64]; - long val; - int ret; - - if (cnt >= sizeof(buf)) - { - return -EINVAL; - } - - if (copy_from_user(&buf, ubuf, cnt)) - { - return -EFAULT; - } - - buf[cnt] = 0; - - ret = strict_strtol(buf, 10, &val); - if (ret < 0) - { - return ret; - } - - if (val < 0) - { - /* any negative input will disable counter */ - val = MALI_HW_CORE_NO_COUNTER; - } - - if (0 == src_id) - { - if (MALI_TRUE != mali_pp_core_set_counter_src0(pp_core, (u32)val)) - { - return 0; - } - } - else - { - if (MALI_TRUE != mali_pp_core_set_counter_src1(pp_core, (u32)val)) - { - return 0; - } - } - - *ppos += cnt; - return cnt; -} - -static ssize_t pp_all_counter_srcx_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos, u32 src_id) -{ - char buf[64]; - long val; - int ret; - u32 ci; - struct mali_cluster *cluster; - - if (cnt >= sizeof(buf)) - { - return -EINVAL; - } - - if (copy_from_user(&buf, ubuf, cnt)) - { - return -EFAULT; - } - - buf[cnt] = 0; - - ret = strict_strtol(buf, 10, &val); - if (ret < 0) - { - return ret; - } - - if (val < 0) - { - /* any negative input will disable counter */ - val = MALI_HW_CORE_NO_COUNTER; - } - - ci = 0; - cluster = mali_cluster_get_global_cluster(ci); - while (NULL != cluster) - { - u32 gi = 0; - struct mali_group *group = mali_cluster_get_group(cluster, gi); - while (NULL != group) - { - struct mali_pp_core *pp_core = mali_group_get_pp_core(group); - if (NULL != pp_core) - { - if (0 == src_id) - { - if (MALI_TRUE != mali_pp_core_set_counter_src0(pp_core, (u32)val)) - { - return 0; - } - } - else - { - if (MALI_TRUE != mali_pp_core_set_counter_src1(pp_core, (u32)val)) - { - return 0; - } - } - } - - /* try next group */ - gi++; - group = mali_cluster_get_group(cluster, gi); - } - - /* try next cluster */ - ci++; - cluster = mali_cluster_get_global_cluster(ci); - } - - *ppos += cnt; - return cnt; -} - -static ssize_t pp_ppx_counter_src0_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos) -{ - return pp_ppx_counter_srcx_read(filp, ubuf, cnt, ppos, 0); -} - -static ssize_t pp_ppx_counter_src1_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos) -{ - return pp_ppx_counter_srcx_read(filp, ubuf, cnt, ppos, 1); -} - -static ssize_t pp_ppx_counter_src0_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) -{ - return pp_ppx_counter_srcx_write(filp, ubuf, cnt, ppos, 0); -} - -static ssize_t pp_ppx_counter_src1_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) -{ - return pp_ppx_counter_srcx_write(filp, ubuf, cnt, ppos, 1); -} - -static ssize_t pp_all_counter_src0_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) -{ - return pp_all_counter_srcx_write(filp, ubuf, cnt, ppos, 0); -} - -static ssize_t pp_all_counter_src1_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) -{ - return pp_all_counter_srcx_write(filp, ubuf, cnt, ppos, 1); -} - -static const struct file_operations pp_ppx_counter_src0_fops = { - .owner = THIS_MODULE, - .open = open_copy_private_data, - .read = pp_ppx_counter_src0_read, - .write = pp_ppx_counter_src0_write, -}; - -static const struct file_operations pp_ppx_counter_src1_fops = { - .owner = THIS_MODULE, - .open = open_copy_private_data, - .read = pp_ppx_counter_src1_read, - .write = pp_ppx_counter_src1_write, -}; - -static const struct file_operations pp_all_counter_src0_fops = { - .owner = THIS_MODULE, - .write = pp_all_counter_src0_write, -}; - -static const struct file_operations pp_all_counter_src1_fops = { - .owner = THIS_MODULE, - .write = pp_all_counter_src1_write, -}; - - - - - - -static ssize_t l2_l2x_counter_srcx_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos, u32 src_id) -{ - char buf[64]; - int r; - u32 val; - struct mali_l2_cache_core *l2_core = (struct mali_l2_cache_core *)filp->private_data; - - if (0 == src_id) - { - val = mali_l2_cache_core_get_counter_src0(l2_core); - } - else - { - val = mali_l2_cache_core_get_counter_src1(l2_core); - } - - if (MALI_HW_CORE_NO_COUNTER == val) - { - r = sprintf(buf, "-1\n"); - } - else - { - r = sprintf(buf, "%u\n", val); - } - return simple_read_from_buffer(ubuf, cnt, ppos, buf, r); -} - -static ssize_t l2_l2x_counter_srcx_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos, u32 src_id) -{ - struct mali_l2_cache_core *l2_core = (struct mali_l2_cache_core *)filp->private_data; - char buf[64]; - long val; - int ret; - - if (cnt >= sizeof(buf)) - { - return -EINVAL; - } - - if (copy_from_user(&buf, ubuf, cnt)) - { - return -EFAULT; - } - - buf[cnt] = 0; - - ret = strict_strtol(buf, 10, &val); - if (ret < 0) - { - return ret; - } - - if (val < 0) - { - /* any negative input will disable counter */ - val = MALI_HW_CORE_NO_COUNTER; - } - - if (0 == src_id) - { - if (MALI_TRUE != mali_l2_cache_core_set_counter_src0(l2_core, (u32)val)) - { - return 0; - } - } - else - { - if (MALI_TRUE != mali_l2_cache_core_set_counter_src1(l2_core, (u32)val)) - { - return 0; - } - } - - *ppos += cnt; - return cnt; -} - -static ssize_t l2_all_counter_srcx_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos, u32 src_id) -{ - char buf[64]; - long val; - int ret; - u32 l2_id; - struct mali_l2_cache_core *l2_cache; - - if (cnt >= sizeof(buf)) - { - return -EINVAL; - } - - if (copy_from_user(&buf, ubuf, cnt)) - { - return -EFAULT; - } - - buf[cnt] = 0; - - ret = strict_strtol(buf, 10, &val); - if (ret < 0) - { - return ret; - } - - if (val < 0) - { - /* any negative input will disable counter */ - val = MALI_HW_CORE_NO_COUNTER; - } - - l2_id = 0; - l2_cache = mali_l2_cache_core_get_glob_l2_core(l2_id); - while (NULL != l2_cache) - { - if (0 == src_id) - { - if (MALI_TRUE != mali_l2_cache_core_set_counter_src0(l2_cache, (u32)val)) - { - return 0; - } - } - else - { - if (MALI_TRUE != mali_l2_cache_core_set_counter_src1(l2_cache, (u32)val)) - { - return 0; - } - } - - /* try next L2 */ - l2_id++; - l2_cache = mali_l2_cache_core_get_glob_l2_core(l2_id); - } - - *ppos += cnt; - return cnt; -} - -static ssize_t l2_l2x_counter_src0_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos) -{ - return l2_l2x_counter_srcx_read(filp, ubuf, cnt, ppos, 0); -} - -static ssize_t l2_l2x_counter_src1_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos) -{ - return l2_l2x_counter_srcx_read(filp, ubuf, cnt, ppos, 1); -} - -static ssize_t l2_l2x_counter_src0_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) -{ - return l2_l2x_counter_srcx_write(filp, ubuf, cnt, ppos, 0); -} - -static ssize_t l2_l2x_counter_src1_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) -{ - return l2_l2x_counter_srcx_write(filp, ubuf, cnt, ppos, 1); -} - -static ssize_t l2_all_counter_src0_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) -{ - return l2_all_counter_srcx_write(filp, ubuf, cnt, ppos, 0); -} - -static ssize_t l2_all_counter_src1_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) -{ - return l2_all_counter_srcx_write(filp, ubuf, cnt, ppos, 1); -} - -static const struct file_operations l2_l2x_counter_src0_fops = { - .owner = THIS_MODULE, - .open = open_copy_private_data, - .read = l2_l2x_counter_src0_read, - .write = l2_l2x_counter_src0_write, -}; - -static const struct file_operations l2_l2x_counter_src1_fops = { - .owner = THIS_MODULE, - .open = open_copy_private_data, - .read = l2_l2x_counter_src1_read, - .write = l2_l2x_counter_src1_write, -}; - -static const struct file_operations l2_all_counter_src0_fops = { - .owner = THIS_MODULE, - .write = l2_all_counter_src0_write, -}; - -static const struct file_operations l2_all_counter_src1_fops = { - .owner = THIS_MODULE, - .write = l2_all_counter_src1_write, -}; - -static ssize_t power_events_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) -{ - - memset(pwr_buf,0,POWER_BUFFER_SIZE); - virtual_power_status_register = 0; - if (!strncmp(ubuf,mali_power_events[_MALI_DEVICE_SUSPEND],strlen(mali_power_events[_MALI_DEVICE_SUSPEND]))) - { - mali_pm_os_suspend(); - /* @@@@ assuming currently suspend is successful later on to tune as per previous*/ - virtual_power_status_register =1; - - } - else if (!strncmp(ubuf,mali_power_events[_MALI_DEVICE_RESUME],strlen(mali_power_events[_MALI_DEVICE_RESUME]))) - { - mali_pm_os_resume(); - - /* @@@@ assuming currently resume is successful later on to tune as per previous */ - virtual_power_status_register = 1; - } - else if (!strncmp(ubuf,mali_power_events[_MALI_DEVICE_DVFS_PAUSE],strlen(mali_power_events[_MALI_DEVICE_DVFS_PAUSE]))) - { - mali_bool power_on; - mali_dev_pause(&power_on); - if (!power_on) - { - virtual_power_status_register = 2; - mali_dev_resume(); - } - else - { - /* @@@@ assuming currently resume is successful later on to tune as per previous */ - virtual_power_status_register =1; - } - } - else if (!strncmp(ubuf,mali_power_events[_MALI_DEVICE_DVFS_RESUME],strlen(mali_power_events[_MALI_DEVICE_DVFS_RESUME]))) - { - mali_dev_resume(); - /* @@@@ assuming currently resume is successful later on to tune as per previous */ - virtual_power_status_register = 1; - - } - *ppos += cnt; - sprintf(pwr_buf, "%d",virtual_power_status_register); - return cnt; -} - -static ssize_t power_events_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos) -{ - return simple_read_from_buffer(ubuf, cnt, ppos, pwr_buf, POWER_BUFFER_SIZE); -} - -static loff_t power_events_seek(struct file *file, loff_t offset, int orig) -{ - file->f_pos = offset; - return 0; -} - -static const struct file_operations power_events_fops = { - .owner = THIS_MODULE, - .read = power_events_read, - .write = power_events_write, - .llseek = power_events_seek, -}; - - -#if MALI_STATE_TRACKING -static int mali_seq_internal_state_show(struct seq_file *seq_file, void *v) -{ - u32 len = 0; - u32 size; - char *buf; - - size = seq_get_buf(seq_file, &buf); - - if(!size) - { - return -ENOMEM; - } - - /* Create the internal state dump. */ - len = snprintf(buf+len, size-len, "Mali device driver %s\n", SVN_REV_STRING); - len += snprintf(buf+len, size-len, "License: %s\n\n", MALI_KERNEL_LINUX_LICENSE); - - len += _mali_kernel_core_dump_state(buf + len, size - len); - - seq_commit(seq_file, len); - - return 0; -} - -static int mali_seq_internal_state_open(struct inode *inode, struct file *file) -{ - return single_open(file, mali_seq_internal_state_show, NULL); -} - -static const struct file_operations mali_seq_internal_state_fops = { - .owner = THIS_MODULE, - .open = mali_seq_internal_state_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; -#endif /* MALI_STATE_TRACKING */ - - -#if MALI_INTERNAL_TIMELINE_PROFILING_ENABLED -static ssize_t profiling_record_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos) -{ - char buf[64]; - int r; - - r = sprintf(buf, "%u\n", _mali_osk_profiling_is_recording() ? 1 : 0); - return simple_read_from_buffer(ubuf, cnt, ppos, buf, r); -} - -static ssize_t profiling_record_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) -{ - char buf[64]; - unsigned long val; - int ret; - - if (cnt >= sizeof(buf)) - { - return -EINVAL; - } - - if (copy_from_user(&buf, ubuf, cnt)) - { - return -EFAULT; - } - - buf[cnt] = 0; - - ret = strict_strtoul(buf, 10, &val); - if (ret < 0) - { - return ret; - } - - if (val != 0) - { - u32 limit = MALI_PROFILING_MAX_BUFFER_ENTRIES; /* This can be made configurable at a later stage if we need to */ - - /* check if we are already recording */ - if (MALI_TRUE == _mali_osk_profiling_is_recording()) - { - MALI_DEBUG_PRINT(3, ("Recording of profiling events already in progress\n")); - return -EFAULT; - } - - /* check if we need to clear out an old recording first */ - if (MALI_TRUE == _mali_osk_profiling_have_recording()) - { - if (_MALI_OSK_ERR_OK != _mali_osk_profiling_clear()) - { - MALI_DEBUG_PRINT(3, ("Failed to clear existing recording of profiling events\n")); - return -EFAULT; - } - } - - /* start recording profiling data */ - if (_MALI_OSK_ERR_OK != _mali_osk_profiling_start(&limit)) - { - MALI_DEBUG_PRINT(3, ("Failed to start recording of profiling events\n")); - return -EFAULT; - } - - MALI_DEBUG_PRINT(3, ("Profiling recording started (max %u events)\n", limit)); - } - else - { - /* stop recording profiling data */ - u32 count = 0; - if (_MALI_OSK_ERR_OK != _mali_osk_profiling_stop(&count)) - { - MALI_DEBUG_PRINT(2, ("Failed to stop recording of profiling events\n")); - return -EFAULT; - } - - MALI_DEBUG_PRINT(2, ("Profiling recording stopped (recorded %u events)\n", count)); - } - - *ppos += cnt; - return cnt; -} - -static const struct file_operations profiling_record_fops = { - .owner = THIS_MODULE, - .read = profiling_record_read, - .write = profiling_record_write, -}; - -static void *profiling_events_start(struct seq_file *s, loff_t *pos) -{ - loff_t *spos; - - /* check if we have data avaiable */ - if (MALI_TRUE != _mali_osk_profiling_have_recording()) - { - return NULL; - } - - spos = kmalloc(sizeof(loff_t), GFP_KERNEL); - if (NULL == spos) - { - return NULL; - } - - *spos = *pos; - return spos; -} - -static void *profiling_events_next(struct seq_file *s, void *v, loff_t *pos) -{ - loff_t *spos = v; - - /* check if we have data avaiable */ - if (MALI_TRUE != _mali_osk_profiling_have_recording()) - { - return NULL; - } - - /* check if the next entry actually is avaiable */ - if (_mali_osk_profiling_get_count() <= (u32)(*spos + 1)) - { - return NULL; - } - - *pos = ++*spos; - return spos; -} - -static void profiling_events_stop(struct seq_file *s, void *v) -{ - kfree(v); -} - -static int profiling_events_show(struct seq_file *seq_file, void *v) -{ - loff_t *spos = v; - u32 index; - u64 timestamp; - u32 event_id; - u32 data[5]; - - index = (u32)*spos; - - /* Retrieve all events */ - if (_MALI_OSK_ERR_OK == _mali_osk_profiling_get_event(index, ×tamp, &event_id, data)) - { - seq_printf(seq_file, "%llu %u %u %u %u %u %u\n", timestamp, event_id, data[0], data[1], data[2], data[3], data[4]); - return 0; - } - - return 0; -} - -static const struct seq_operations profiling_events_seq_ops = { - .start = profiling_events_start, - .next = profiling_events_next, - .stop = profiling_events_stop, - .show = profiling_events_show -}; - -static int profiling_events_open(struct inode *inode, struct file *file) -{ - return seq_open(file, &profiling_events_seq_ops); -} - -static const struct file_operations profiling_events_fops = { - .owner = THIS_MODULE, - .open = profiling_events_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, -}; -#endif - -static ssize_t memory_used_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos) -{ - char buf[64]; - size_t r; - u32 mem = _mali_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 memory_usage_fops = { - .owner = THIS_MODULE, - .read = memory_used_read, -}; - - -static ssize_t user_settings_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) -{ - unsigned long val; - int ret; - _mali_uk_user_setting_t setting; - char buf[32]; - - cnt = min(cnt, sizeof(buf) - 1); - if (copy_from_user(buf, ubuf, cnt)) - { - return -EFAULT; - } - buf[cnt] = '\0'; - - ret = strict_strtoul(buf, 10, &val); - if (0 != ret) - { - return ret; - } - - /* Update setting */ - setting = (_mali_uk_user_setting_t)(filp->private_data); - mali_set_user_setting(setting, val); - - *ppos += cnt; - return cnt; -} - -static ssize_t user_settings_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos) -{ - char buf[64]; - size_t r; - u32 value; - _mali_uk_user_setting_t setting; - - setting = (_mali_uk_user_setting_t)(filp->private_data); - value = mali_get_user_setting(setting); - - r = snprintf(buf, 64, "%u\n", value); - return simple_read_from_buffer(ubuf, cnt, ppos, buf, r); -} - -static const struct file_operations user_settings_fops = { - .owner = THIS_MODULE, - .open = open_copy_private_data, - .read = user_settings_read, - .write = user_settings_write, -}; - -static int mali_sysfs_user_settings_register(void) -{ - struct dentry *mali_user_settings_dir = debugfs_create_dir("userspace_settings", mali_debugfs_dir); - - if (mali_user_settings_dir != NULL) - { - int i; - for (i = 0; i < _MALI_UK_USER_SETTING_MAX; i++) - { - debugfs_create_file(_mali_uk_user_setting_descriptions[i], 0600, mali_user_settings_dir, (void*)i, &user_settings_fops); - } - } - - return 0; -} - -int mali_sysfs_register(struct mali_dev *device, dev_t dev, const char *mali_dev_name) -{ - int err = 0; - - device->mali_class = class_create(THIS_MODULE, mali_dev_name); - if (IS_ERR(device->mali_class)) - { - err = PTR_ERR(device->mali_class); - goto init_class_err; - } - mali_device = device_create(device->mali_class, NULL, dev, NULL, mali_dev_name); - if (IS_ERR(mali_device)) - { - err = PTR_ERR(mali_device); - goto init_mdev_err; - } - - mali_debugfs_dir = debugfs_create_dir(mali_dev_name, NULL); - if(ERR_PTR(-ENODEV) == mali_debugfs_dir) - { - /* Debugfs not supported. */ - mali_debugfs_dir = NULL; - } - else - { - if(NULL != mali_debugfs_dir) - { - /* Debugfs directory created successfully; create files now */ - struct dentry *mali_power_dir; - struct dentry *mali_gp_dir; - struct dentry *mali_pp_dir; - struct dentry *mali_l2_dir; -#if MALI_INTERNAL_TIMELINE_PROFILING_ENABLED - struct dentry *mali_profiling_dir; -#endif - - mali_power_dir = debugfs_create_dir("power", mali_debugfs_dir); - if (mali_power_dir != NULL) - { - debugfs_create_file("power_events", 0400, mali_power_dir, NULL, &power_events_fops); - } - - mali_gp_dir = debugfs_create_dir("gp", mali_debugfs_dir); - if (mali_gp_dir != NULL) - { - struct dentry *mali_gp_all_dir; - u32 ci; - struct mali_cluster *cluster; - - mali_gp_all_dir = debugfs_create_dir("all", mali_gp_dir); - if (mali_gp_all_dir != NULL) - { - debugfs_create_file("counter_src0", 0400, mali_gp_all_dir, NULL, &gp_all_counter_src0_fops); - debugfs_create_file("counter_src1", 0400, mali_gp_all_dir, NULL, &gp_all_counter_src1_fops); - } - - ci = 0; - cluster = mali_cluster_get_global_cluster(ci); - while (NULL != cluster) - { - u32 gi = 0; - struct mali_group *group = mali_cluster_get_group(cluster, gi); - while (NULL != group) - { - struct mali_gp_core *gp_core = mali_group_get_gp_core(group); - if (NULL != gp_core) - { - struct dentry *mali_gp_gpx_dir; - mali_gp_gpx_dir = debugfs_create_dir("gp0", mali_gp_dir); - if (NULL != mali_gp_gpx_dir) - { - debugfs_create_file("counter_src0", 0600, mali_gp_gpx_dir, gp_core, &gp_gpx_counter_src0_fops); - debugfs_create_file("counter_src1", 0600, mali_gp_gpx_dir, gp_core, &gp_gpx_counter_src1_fops); - } - break; /* no need to look for any other GP cores */ - } - - /* try next group */ - gi++; - group = mali_cluster_get_group(cluster, gi); - } - - /* try next cluster */ - ci++; - cluster = mali_cluster_get_global_cluster(ci); - } - } - - mali_pp_dir = debugfs_create_dir("pp", mali_debugfs_dir); - if (mali_pp_dir != NULL) - { - struct dentry *mali_pp_all_dir; - u32 ci; - struct mali_cluster *cluster; - - mali_pp_all_dir = debugfs_create_dir("all", mali_pp_dir); - if (mali_pp_all_dir != NULL) - { - debugfs_create_file("counter_src0", 0400, mali_pp_all_dir, NULL, &pp_all_counter_src0_fops); - debugfs_create_file("counter_src1", 0400, mali_pp_all_dir, NULL, &pp_all_counter_src1_fops); - } - - ci = 0; - cluster = mali_cluster_get_global_cluster(ci); - while (NULL != cluster) - { - u32 gi = 0; - struct mali_group *group = mali_cluster_get_group(cluster, gi); - while (NULL != group) - { - struct mali_pp_core *pp_core = mali_group_get_pp_core(group); - if (NULL != pp_core) - { - char buf[16]; - struct dentry *mali_pp_ppx_dir; - _mali_osk_snprintf(buf, sizeof(buf), "pp%u", mali_pp_core_get_id(pp_core)); - mali_pp_ppx_dir = debugfs_create_dir(buf, mali_pp_dir); - if (NULL != mali_pp_ppx_dir) - { - debugfs_create_file("counter_src0", 0600, mali_pp_ppx_dir, pp_core, &pp_ppx_counter_src0_fops); - debugfs_create_file("counter_src1", 0600, mali_pp_ppx_dir, pp_core, &pp_ppx_counter_src1_fops); - } - } - - /* try next group */ - gi++; - group = mali_cluster_get_group(cluster, gi); - } - - /* try next cluster */ - ci++; - cluster = mali_cluster_get_global_cluster(ci); - } - } - - mali_l2_dir = debugfs_create_dir("l2", mali_debugfs_dir); - if (mali_l2_dir != NULL) - { - struct dentry *mali_l2_all_dir; - u32 l2_id; - struct mali_l2_cache_core *l2_cache; - - mali_l2_all_dir = debugfs_create_dir("all", mali_l2_dir); - if (mali_l2_all_dir != NULL) - { - debugfs_create_file("counter_src0", 0400, mali_l2_all_dir, NULL, &l2_all_counter_src0_fops); - debugfs_create_file("counter_src1", 0400, mali_l2_all_dir, NULL, &l2_all_counter_src1_fops); - } - - l2_id = 0; - l2_cache = mali_l2_cache_core_get_glob_l2_core(l2_id); - while (NULL != l2_cache) - { - char buf[16]; - struct dentry *mali_l2_l2x_dir; - _mali_osk_snprintf(buf, sizeof(buf), "l2%u", l2_id); - mali_l2_l2x_dir = debugfs_create_dir(buf, mali_l2_dir); - if (NULL != mali_l2_l2x_dir) - { - debugfs_create_file("counter_src0", 0600, mali_l2_l2x_dir, l2_cache, &l2_l2x_counter_src0_fops); - debugfs_create_file("counter_src1", 0600, mali_l2_l2x_dir, l2_cache, &l2_l2x_counter_src1_fops); - } - - /* try next L2 */ - l2_id++; - l2_cache = mali_l2_cache_core_get_glob_l2_core(l2_id); - } - } - - debugfs_create_file("memory_usage", 0400, mali_debugfs_dir, NULL, &memory_usage_fops); - -#if MALI_INTERNAL_TIMELINE_PROFILING_ENABLED - mali_profiling_dir = debugfs_create_dir("profiling", mali_debugfs_dir); - if (mali_profiling_dir != NULL) - { - struct dentry *mali_profiling_proc_dir = debugfs_create_dir("proc", mali_profiling_dir); - if (mali_profiling_proc_dir != NULL) - { - struct dentry *mali_profiling_proc_default_dir = debugfs_create_dir("default", mali_profiling_proc_dir); - if (mali_profiling_proc_default_dir != NULL) - { - debugfs_create_file("enable", 0600, mali_profiling_proc_default_dir, (void*)_MALI_UK_USER_SETTING_SW_EVENTS_ENABLE, &user_settings_fops); - } - } - debugfs_create_file("record", 0600, mali_profiling_dir, NULL, &profiling_record_fops); - debugfs_create_file("events", 0400, mali_profiling_dir, NULL, &profiling_events_fops); - } -#endif - -#if MALI_STATE_TRACKING - debugfs_create_file("state_dump", 0400, mali_debugfs_dir, NULL, &mali_seq_internal_state_fops); -#endif - - if (mali_sysfs_user_settings_register()) - { - /* Failed to create the debugfs entries for the user settings DB. */ - MALI_DEBUG_PRINT(2, ("Failed to create user setting debugfs files. Ignoring...\n")); - } - } - } - - /* Success! */ - return 0; - - /* Error handling */ -init_mdev_err: - class_destroy(device->mali_class); -init_class_err: - - return err; -} - -int mali_sysfs_unregister(struct mali_dev *device, dev_t dev, const char *mali_dev_name) -{ - if(NULL != mali_debugfs_dir) - { - debugfs_remove_recursive(mali_debugfs_dir); - } - device_destroy(device->mali_class, dev); - class_destroy(device->mali_class); - - return 0; -} - -#else - -/* Dummy implementations for non-GPL */ - -int mali_sysfs_register(struct mali_dev *device, dev_t dev, const char *mali_dev_name) -{ - return 0; -} - -int mali_sysfs_unregister(struct mali_dev *device, dev_t dev, const char *mali_dev_name) -{ - return 0; -} - - -#endif diff --git a/drivers/media/video/samsung/mali/linux/mali_kernel_sysfs.h b/drivers/media/video/samsung/mali/linux/mali_kernel_sysfs.h deleted file mode 100644 index 24acca9..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_kernel_sysfs.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2011-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef __MALI_KERNEL_SYSFS_H__ -#define __MALI_KERNEL_SYSFS_H__ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include <linux/device.h> - -#define MALI_PROC_DIR "driver/mali" - -extern struct device *mali_device; -struct mali_dev; - -int mali_sysfs_register(struct mali_dev *mali_class, dev_t dev, const char *mali_dev_name); - -int mali_sysfs_unregister(struct mali_dev *mali_class, dev_t dev, const char *mali_dev_name); - - -#ifdef __cplusplus -} -#endif - -#endif /* __MALI_KERNEL_LINUX_H__ */ diff --git a/drivers/media/video/samsung/mali/linux/mali_linux_pm.h b/drivers/media/video/samsung/mali/linux/mali_linux_pm.h deleted file mode 100644 index 10f633e..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_linux_pm.h +++ /dev/null @@ -1,50 +0,0 @@ - -/* - * Copyright (C) 2010-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef __MALI_LINUX_PM_H__ -#define __MALI_LINUX_PM_H__ - -#ifdef CONFIG_PM -/* Number of power states supported for making power up and down */ -typedef enum -{ - _MALI_DEVICE_SUSPEND, /* Suspend */ - _MALI_DEVICE_RESUME, /* Resume */ - _MALI_DEVICE_MAX_POWER_STATES, /* Maximum power states */ -} _mali_device_power_states; - -/* Number of DVFS events */ -typedef enum -{ - _MALI_DVFS_PAUSE_EVENT = _MALI_DEVICE_MAX_POWER_STATES, /* DVFS Pause event */ - _MALI_DVFS_RESUME_EVENT, /* DVFS Resume event */ - _MALI_MAX_DEBUG_OPERATIONS, -} _mali_device_dvfs_events; - -extern _mali_device_power_states mali_device_state; -extern _mali_device_power_states mali_dvfs_device_state; -extern _mali_osk_lock_t *lock; -extern short is_wake_up_needed; -extern int timeout_fired; -extern struct platform_device mali_gpu_device; - -/* dvfs pm thread */ -extern struct task_struct *dvfs_pm_thread; - -/* Power management thread */ -extern struct task_struct *pm_thread; - -int mali_device_suspend(u32 event_id, struct task_struct **pwr_mgmt_thread); -int mali_device_resume(u32 event_id, struct task_struct **pwr_mgmt_thread); -int mali_get_ospmm_thread_state(void); - -#endif /* CONFIG_PM */ -#endif /* __MALI_LINUX_PM_H___ */ diff --git a/drivers/media/video/samsung/mali/linux/mali_linux_pm_testsuite.h b/drivers/media/video/samsung/mali/linux/mali_linux_pm_testsuite.h deleted file mode 100644 index 7d811bd..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_linux_pm_testsuite.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2010-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#ifndef __MALI_LINUX_PM_TESTSUITE_H__ -#define __MALI_LINUX_PM_TESTSUITE_H__ - -#if MALI_POWER_MGMT_TEST_SUITE && defined(CONFIG_PM) - -typedef enum -{ - _MALI_DEVICE_PMM_TIMEOUT_EVENT, - _MALI_DEVICE_PMM_JOB_SCHEDULING_EVENTS, - _MALI_DEVICE_PMM_REGISTERED_CORES, - _MALI_DEVICE_MAX_PMM_EVENTS - -} _mali_device_pmm_recording_events; - -extern unsigned int mali_timeout_event_recording_on; -extern unsigned int mali_job_scheduling_events_recording_on; -extern unsigned int pwr_mgmt_status_reg; -extern unsigned int is_mali_pmm_testsuite_enabled; -extern unsigned int is_mali_pmu_present; - -#endif /* MALI_POWER_MGMT_TEST_SUITE && defined(CONFIG_PM) */ - -#endif /* __MALI_LINUX_PM_TESTSUITE_H__ */ diff --git a/drivers/media/video/samsung/mali/linux/mali_linux_trace.h b/drivers/media/video/samsung/mali/linux/mali_linux_trace.h deleted file mode 100644 index 5329ba3..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_linux_trace.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#if !defined (MALI_LINUX_TRACE_H) || defined (TRACE_HEADER_MULTI_READ) -#define MALI_LINUX_TRACE_H - -#include <linux/types.h> - -#include <linux/stringify.h> -#include <linux/tracepoint.h> - -#undef TRACE_SYSTEM -#define TRACE_SYSTEM mali -#define TRACE_SYSTEM_STRING __stringfy(TRACE_SYSTEM) - -#define TRACE_INCLUDE_PATH . -#define TRACE_INCLUDE_FILE mali_linux_trace - -/** - * Define the tracepoint used to communicate the status of a GPU. Called - * when a GPU turns on or turns off. - * - * @param event_id The type of the event. This parameter is a bitfield - * encoding the type of the event. - * - * @param d0 First data parameter. - * @param d1 Second data parameter. - * @param d2 Third data parameter. - * @param d3 Fourth data parameter. - * @param d4 Fifth data parameter. - */ -TRACE_EVENT(mali_timeline_event, - - TP_PROTO(unsigned int event_id, unsigned int d0, unsigned int d1, - unsigned int d2, unsigned int d3, unsigned int d4), - - TP_ARGS(event_id, d0, d1, d2, d3, d4), - - TP_STRUCT__entry( - __field(unsigned int, event_id) - __field(unsigned int, d0) - __field(unsigned int, d1) - __field(unsigned int, d2) - __field(unsigned int, d3) - __field(unsigned int, d4) - ), - - TP_fast_assign( - __entry->event_id = event_id; - __entry->d0 = d0; - __entry->d1 = d1; - __entry->d2 = d2; - __entry->d3 = d3; - __entry->d4 = d4; - ), - - TP_printk("event=%d", __entry->event_id) -); - -/** - * Define a tracepoint used to regsiter the value of a hardware counter. - * Hardware counters belonging to the vertex or fragment processor are - * reported via this tracepoint each frame, whilst L2 cache hardware - * counters are reported continuously. - * - * @param counter_id The counter ID. - * @param value The value of the counter. - */ -TRACE_EVENT(mali_hw_counter, - - TP_PROTO(unsigned int counter_id, unsigned int value), - - TP_ARGS(counter_id, value), - - TP_STRUCT__entry( - __field(unsigned int, counter_id) - __field(unsigned int, value) - ), - - TP_fast_assign( - __entry->counter_id = counter_id; - ), - - TP_printk("event %d = %d", __entry->counter_id, __entry->value) -); - -/** - * Define a tracepoint used to send a bundle of software counters. - * - * @param counters The bundle of counters. - */ -TRACE_EVENT(mali_sw_counters, - - TP_PROTO(pid_t pid, pid_t tid, void * surface_id, unsigned int * counters), - - TP_ARGS(pid, tid, surface_id, counters), - - TP_STRUCT__entry( - __field(pid_t, pid) - __field(pid_t, tid) - __field(void *, surface_id) - __field(unsigned int *, counters) - ), - - TP_fast_assign( - __entry->pid = pid; - __entry->tid = tid; - __entry->surface_id = surface_id; - __entry->counters = counters; - ), - - TP_printk("counters were %s", __entry->counters == NULL? "NULL" : "not NULL") -); - -#endif /* MALI_LINUX_TRACE_H */ - -/* This part must exist outside the header guard. */ -#include <trace/define_trace.h> - diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_atomics.c b/drivers/media/video/samsung/mali/linux/mali_osk_atomics.c deleted file mode 100644 index 32f8e6b..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_atomics.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2010, 2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file mali_osk_atomics.c - * Implementation of the OS abstraction layer for the kernel device driver - */ - -#include "mali_osk.h" -#include <asm/atomic.h> -#include "mali_kernel_common.h" - -void _mali_osk_atomic_dec( _mali_osk_atomic_t *atom ) -{ - atomic_dec((atomic_t *)&atom->u.val); -} - -u32 _mali_osk_atomic_dec_return( _mali_osk_atomic_t *atom ) -{ - return atomic_dec_return((atomic_t *)&atom->u.val); -} - -void _mali_osk_atomic_inc( _mali_osk_atomic_t *atom ) -{ - atomic_inc((atomic_t *)&atom->u.val); -} - -u32 _mali_osk_atomic_inc_return( _mali_osk_atomic_t *atom ) -{ - return atomic_inc_return((atomic_t *)&atom->u.val); -} - -_mali_osk_errcode_t _mali_osk_atomic_init( _mali_osk_atomic_t *atom, u32 val ) -{ - MALI_CHECK_NON_NULL(atom, _MALI_OSK_ERR_INVALID_ARGS); - atomic_set((atomic_t *)&atom->u.val, val); - return _MALI_OSK_ERR_OK; -} - -u32 _mali_osk_atomic_read( _mali_osk_atomic_t *atom ) -{ - return atomic_read((atomic_t *)&atom->u.val); -} - -void _mali_osk_atomic_term( _mali_osk_atomic_t *atom ) -{ - MALI_IGNORE(atom); -} diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_irq.c b/drivers/media/video/samsung/mali/linux/mali_osk_irq.c deleted file mode 100644 index ddfe564..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_irq.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright (C) 2010-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file mali_osk_irq.c - * Implementation of the OS abstraction layer for the kernel device driver - */ - -#include <linux/slab.h> /* For memory allocation */ -#include <linux/workqueue.h> -#include <linux/version.h> - -#include "mali_osk.h" -#include "mali_kernel_common.h" -#include "mali_kernel_license.h" -#include "mali_kernel_linux.h" -#include "linux/interrupt.h" - -typedef struct _mali_osk_irq_t_struct -{ - u32 irqnum; - void *data; - _mali_osk_irq_uhandler_t uhandler; - _mali_osk_irq_bhandler_t bhandler; - struct work_struct work_queue_irq_handle; /* Workqueue for the bottom half of the IRQ-handling. This job is activated when this core gets an IRQ.*/ -} mali_osk_irq_object_t; - -#if MALI_LICENSE_IS_GPL -static struct workqueue_struct *pmm_wq = NULL; -struct workqueue_struct *mali_wq = NULL; -#endif - -typedef void (*workqueue_func_t)(void *); -typedef irqreturn_t (*irq_handler_func_t)(int, void *, struct pt_regs *); -static irqreturn_t irq_handler_upper_half (int port_name, void* dev_id ); /* , struct pt_regs *regs*/ - -#if defined(INIT_DELAYED_WORK) -static void irq_handler_bottom_half ( struct work_struct *work ); -#else -static void irq_handler_bottom_half ( void * input ); -#endif - -/** - * Linux kernel version has marked SA_SHIRQ as deprecated, IRQF_SHARED should be used. - * This is to handle older kernels which haven't done this swap. - */ -#ifndef IRQF_SHARED -#define IRQF_SHARED SA_SHIRQ -#endif /* IRQF_SHARED */ - -_mali_osk_irq_t *_mali_osk_irq_init( u32 irqnum, _mali_osk_irq_uhandler_t uhandler, _mali_osk_irq_bhandler_t bhandler, _mali_osk_irq_trigger_t trigger_func, _mali_osk_irq_ack_t ack_func, void *data, const char *description ) -{ - mali_osk_irq_object_t *irq_object; - - irq_object = kmalloc(sizeof(mali_osk_irq_object_t), GFP_KERNEL); - if (NULL == irq_object) return NULL; - -#if MALI_LICENSE_IS_GPL - if (NULL == mali_wq) - { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) - mali_wq = alloc_workqueue("mali", WQ_UNBOUND, 0); -#else - mali_wq = create_workqueue("mali"); -#endif - if(NULL == mali_wq) - { - MALI_PRINT_ERROR(("Unable to create Mali workqueue\n")); - kfree(irq_object); - return NULL; - } - } -#endif - - /* workqueue API changed in 2.6.20, support both versions: */ -#if defined(INIT_DELAYED_WORK) - /* New syntax: INIT_WORK( struct work_struct *work, void (*function)(struct work_struct *)) */ - INIT_WORK( &irq_object->work_queue_irq_handle, irq_handler_bottom_half); -#else - /* Old syntax: INIT_WORK( struct work_struct *work, void (*function)(void *), void *data) */ - INIT_WORK( &irq_object->work_queue_irq_handle, irq_handler_bottom_half, irq_object); -#endif /* defined(INIT_DELAYED_WORK) */ - - if (-1 == irqnum) - { - /* Probe for IRQ */ - if ( (NULL != trigger_func) && (NULL != ack_func) ) - { - unsigned long probe_count = 3; - _mali_osk_errcode_t err; - int irq; - - MALI_DEBUG_PRINT(2, ("Probing for irq\n")); - - do - { - unsigned long mask; - - mask = probe_irq_on(); - trigger_func(data); - - _mali_osk_time_ubusydelay(5); - - irq = probe_irq_off(mask); - err = ack_func(data); - } - while (irq < 0 && (err == _MALI_OSK_ERR_OK) && probe_count--); - - if (irq < 0 || (_MALI_OSK_ERR_OK != err)) irqnum = -1; - else irqnum = irq; - } - else irqnum = -1; /* no probe functions, fault */ - - if (-1 != irqnum) - { - /* found an irq */ - MALI_DEBUG_PRINT(2, ("Found irq %d\n", irqnum)); - } - else - { - MALI_DEBUG_PRINT(2, ("Probe for irq failed\n")); - } - } - - irq_object->irqnum = irqnum; - irq_object->uhandler = uhandler; - irq_object->bhandler = bhandler; - irq_object->data = data; - - /* Is this a real IRQ handler we need? */ - if (irqnum != _MALI_OSK_IRQ_NUMBER_FAKE && irqnum != _MALI_OSK_IRQ_NUMBER_PMM) - { - if (-1 == irqnum) - { - MALI_DEBUG_PRINT(2, ("No IRQ for core '%s' found during probe\n", description)); - kfree(irq_object); - return NULL; - } - - if (0 != request_irq(irqnum, irq_handler_upper_half, IRQF_SHARED, description, irq_object)) - { - MALI_DEBUG_PRINT(2, ("Unable to install IRQ handler for core '%s'\n", description)); - kfree(irq_object); - return NULL; - } - } - -#if MALI_LICENSE_IS_GPL - if ( _MALI_OSK_IRQ_NUMBER_PMM == irqnum ) - { - pmm_wq = create_singlethread_workqueue("mali-pmm-wq"); - } -#endif - - return irq_object; -} - -void _mali_osk_irq_schedulework( _mali_osk_irq_t *irq ) -{ - mali_osk_irq_object_t *irq_object = (mali_osk_irq_object_t *)irq; -#if MALI_LICENSE_IS_GPL - if ( irq_object->irqnum == _MALI_OSK_IRQ_NUMBER_PMM ) - { - queue_work( pmm_wq,&irq_object->work_queue_irq_handle ); - } - else - { - queue_work(mali_wq, &irq_object->work_queue_irq_handle); - } -#else - schedule_work(&irq_object->work_queue_irq_handle); -#endif -} - -void _mali_osk_flush_workqueue( _mali_osk_irq_t *irq ) -{ -#if MALI_LICENSE_IS_GPL - if (NULL != irq) - { - mali_osk_irq_object_t *irq_object = (mali_osk_irq_object_t *)irq; - if(irq_object->irqnum == _MALI_OSK_IRQ_NUMBER_PMM ) - { - flush_workqueue(pmm_wq); - } - else - { - flush_workqueue(mali_wq); - } - } - else - { - flush_workqueue(mali_wq); - } -#endif -} - -void _mali_osk_irq_term( _mali_osk_irq_t *irq ) -{ - mali_osk_irq_object_t *irq_object = (mali_osk_irq_object_t *)irq; - -#if MALI_LICENSE_IS_GPL - if(irq_object->irqnum == _MALI_OSK_IRQ_NUMBER_PMM ) - { - flush_workqueue(pmm_wq); - destroy_workqueue(pmm_wq); - } -#endif - free_irq(irq_object->irqnum, irq_object); - kfree(irq_object); - flush_scheduled_work(); -} - - -/** This function is called directly in interrupt context from the OS just after - * the CPU get the hw-irq from mali, or other devices on the same IRQ-channel. - * It is registered one of these function for each mali core. When an interrupt - * arrives this function will be called equal times as registered mali cores. - * That means that we only check one mali core in one function call, and the - * core we check for each turn is given by the \a dev_id variable. - * If we detect an pending interrupt on the given core, we mask the interrupt - * out by settging the core's IRQ_MASK register to zero. - * Then we schedule the mali_core_irq_handler_bottom_half to run as high priority - * work queue job. - */ -static irqreturn_t irq_handler_upper_half (int port_name, void* dev_id ) /* , struct pt_regs *regs*/ -{ - mali_osk_irq_object_t *irq_object = (mali_osk_irq_object_t *)dev_id; - - if (irq_object->uhandler(irq_object->data) == _MALI_OSK_ERR_OK) - { - return IRQ_HANDLED; - } - return IRQ_NONE; -} - -/* Is executed when an interrupt occur on one core */ -/* workqueue API changed in 2.6.20, support both versions: */ -#if defined(INIT_DELAYED_WORK) -static void irq_handler_bottom_half ( struct work_struct *work ) -#else -static void irq_handler_bottom_half ( void * input ) -#endif -{ - mali_osk_irq_object_t *irq_object; - -#if defined(INIT_DELAYED_WORK) - irq_object = _MALI_OSK_CONTAINER_OF(work, mali_osk_irq_object_t, work_queue_irq_handle); -#else - if ( NULL == input ) - { - MALI_PRINT_ERROR(("IRQ: Null pointer! Illegal!")); - return; /* Error */ - } - irq_object = (mali_osk_irq_object_t *) input; -#endif - - irq_object->bhandler(irq_object->data); -} - diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_locks.c b/drivers/media/video/samsung/mali/linux/mali_osk_locks.c deleted file mode 100644 index ee857d5..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_locks.c +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright (C) 2010-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file mali_osk_locks.c - * Implemenation of the OS abstraction layer for the kernel device driver - */ - -/* needed to detect kernel version specific code */ -#include <linux/version.h> - -#include <linux/spinlock.h> -#include <linux/rwsem.h> - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) -#include <linux/semaphore.h> -#else /* pre 2.6.26 the file was in the arch specific location */ -#include <asm/semaphore.h> -#endif - -#include <linux/slab.h> -#include "mali_osk.h" -#include "mali_kernel_common.h" - -/* These are all the locks we implement: */ -typedef enum -{ - _MALI_OSK_INTERNAL_LOCKTYPE_SPIN, /* Mutex, implicitly non-interruptable, use spin_lock/spin_unlock */ - _MALI_OSK_INTERNAL_LOCKTYPE_SPIN_IRQ, /* Mutex, IRQ version of spinlock, use spin_lock_irqsave/spin_unlock_irqrestore */ - _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX, /* Interruptable, use up()/down_interruptable() */ - _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT, /* Non-Interruptable, use up()/down() */ - _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT_RW, /* Non-interruptable, Reader/Writer, use {up,down}{read,write}() */ - - /* Linux supports, but we do not support: - * Non-Interruptable Reader/Writer spinlock mutexes - RW optimization will be switched off - */ - - /* Linux does not support: - * One-locks, of any sort - no optimization for this fact will be made. - */ - -} _mali_osk_internal_locktype; - -struct _mali_osk_lock_t_struct -{ - _mali_osk_internal_locktype type; - unsigned long flags; - union - { - spinlock_t spinlock; - struct semaphore sema; - struct rw_semaphore rw_sema; - } obj; - MALI_DEBUG_CODE( - /** original flags for debug checking */ - _mali_osk_lock_flags_t orig_flags; - - /* id of the thread currently holding this lock, 0 if no - * threads hold it. */ - u32 owner; - /* number of owners this lock currently has (can be > 1 if - * taken in R/O mode. */ - u32 nOwners; - /* what mode the lock was taken in */ - _mali_osk_lock_mode_t mode; - ); /* MALI_DEBUG_CODE */ -}; - -_mali_osk_lock_t *_mali_osk_lock_init( _mali_osk_lock_flags_t flags, u32 initial, u32 order ) -{ - _mali_osk_lock_t *lock = NULL; - - /* Validate parameters: */ - /* Flags acceptable */ - MALI_DEBUG_ASSERT( 0 == ( flags & ~(_MALI_OSK_LOCKFLAG_SPINLOCK - | _MALI_OSK_LOCKFLAG_SPINLOCK_IRQ - | _MALI_OSK_LOCKFLAG_NONINTERRUPTABLE - | _MALI_OSK_LOCKFLAG_READERWRITER - | _MALI_OSK_LOCKFLAG_ORDERED - | _MALI_OSK_LOCKFLAG_ONELOCK )) ); - /* Spinlocks are always non-interruptable */ - MALI_DEBUG_ASSERT( (((flags & _MALI_OSK_LOCKFLAG_SPINLOCK) || (flags & _MALI_OSK_LOCKFLAG_SPINLOCK_IRQ)) && (flags & _MALI_OSK_LOCKFLAG_NONINTERRUPTABLE)) - || !(flags & _MALI_OSK_LOCKFLAG_SPINLOCK)); - /* Parameter initial SBZ - for future expansion */ - MALI_DEBUG_ASSERT( 0 == initial ); - - lock = kmalloc(sizeof(_mali_osk_lock_t), GFP_KERNEL); - - if ( NULL == lock ) - { - return lock; - } - - /* Determine type of mutex: */ - /* defaults to interruptable mutex if no flags are specified */ - - if ( (flags & _MALI_OSK_LOCKFLAG_SPINLOCK) ) - { - /* Non-interruptable Spinlocks override all others */ - lock->type = _MALI_OSK_INTERNAL_LOCKTYPE_SPIN; - spin_lock_init( &lock->obj.spinlock ); - } - else if ( (flags & _MALI_OSK_LOCKFLAG_SPINLOCK_IRQ ) ) - { - lock->type = _MALI_OSK_INTERNAL_LOCKTYPE_SPIN_IRQ; - lock->flags = 0; - spin_lock_init( &lock->obj.spinlock ); - } - else if ( (flags & _MALI_OSK_LOCKFLAG_NONINTERRUPTABLE) - && (flags & _MALI_OSK_LOCKFLAG_READERWRITER) ) - { - lock->type = _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT_RW; - init_rwsem( &lock->obj.rw_sema ); - } - else - { - /* Usual mutex types */ - if ( (flags & _MALI_OSK_LOCKFLAG_NONINTERRUPTABLE) ) - { - lock->type = _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT; - } - else - { - lock->type = _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX; - } - - /* Initially unlocked */ - sema_init( &lock->obj.sema, 1 ); - } - -#ifdef DEBUG - /* Debug tracking of flags */ - lock->orig_flags = flags; - - /* Debug tracking of lock owner */ - lock->owner = 0; - lock->nOwners = 0; -#endif /* DEBUG */ - - return lock; -} - -#ifdef DEBUG -u32 _mali_osk_lock_get_owner( _mali_osk_lock_t *lock ) -{ - return lock->owner; -} - -u32 _mali_osk_lock_get_number_owners( _mali_osk_lock_t *lock ) -{ - return lock->nOwners; -} - -u32 _mali_osk_lock_get_mode( _mali_osk_lock_t *lock ) -{ - return lock->mode; -} -#endif /* DEBUG */ - -_mali_osk_errcode_t _mali_osk_lock_wait( _mali_osk_lock_t *lock, _mali_osk_lock_mode_t mode) -{ - _mali_osk_errcode_t err = _MALI_OSK_ERR_OK; - - /* Parameter validation */ - MALI_DEBUG_ASSERT_POINTER( lock ); - - MALI_DEBUG_ASSERT( _MALI_OSK_LOCKMODE_RW == mode - || _MALI_OSK_LOCKMODE_RO == mode ); - - /* Only allow RO locks when the initial object was a Reader/Writer lock - * Since information is lost on the internal locktype, we use the original - * information, which is only stored when built for DEBUG */ - MALI_DEBUG_ASSERT( _MALI_OSK_LOCKMODE_RW == mode - || (_MALI_OSK_LOCKMODE_RO == mode && (_MALI_OSK_LOCKFLAG_READERWRITER & lock->orig_flags)) ); - - switch ( lock->type ) - { - case _MALI_OSK_INTERNAL_LOCKTYPE_SPIN: - spin_lock(&lock->obj.spinlock); - break; - case _MALI_OSK_INTERNAL_LOCKTYPE_SPIN_IRQ: - { - unsigned long tmp_flags; - spin_lock_irqsave(&lock->obj.spinlock, tmp_flags); - lock->flags = tmp_flags; - } - break; - - case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX: - if ( down_interruptible(&lock->obj.sema) ) - { - MALI_PRINT_ERROR(("Can not lock mutex\n")); - err = _MALI_OSK_ERR_RESTARTSYSCALL; - } - break; - - case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT: - down(&lock->obj.sema); - break; - - case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT_RW: - if (mode == _MALI_OSK_LOCKMODE_RO) - { - down_read(&lock->obj.rw_sema); - } - else - { - down_write(&lock->obj.rw_sema); - } - break; - - default: - /* Reaching here indicates a programming error, so you will not get here - * on non-DEBUG builds */ - MALI_DEBUG_PRINT_ERROR( ("Invalid internal lock type: %.8X", lock->type ) ); - break; - } - -#ifdef DEBUG - /* This thread is now the owner of this lock */ - if (_MALI_OSK_ERR_OK == err) - { - if (mode == _MALI_OSK_LOCKMODE_RW) - { - /*MALI_DEBUG_ASSERT(0 == lock->owner);*/ - if (0 != lock->owner) - { - printk(KERN_ERR "%d: ERROR: Lock %p already has owner %d\n", _mali_osk_get_tid(), lock, lock->owner); - dump_stack(); - } - lock->owner = _mali_osk_get_tid(); - lock->mode = mode; - ++lock->nOwners; - } - else /* mode == _MALI_OSK_LOCKMODE_RO */ - { - lock->owner |= _mali_osk_get_tid(); - lock->mode = mode; - ++lock->nOwners; - } - } -#endif - - return err; -} - -void _mali_osk_lock_signal( _mali_osk_lock_t *lock, _mali_osk_lock_mode_t mode ) -{ - /* Parameter validation */ - MALI_DEBUG_ASSERT_POINTER( lock ); - - MALI_DEBUG_ASSERT( _MALI_OSK_LOCKMODE_RW == mode - || _MALI_OSK_LOCKMODE_RO == mode ); - - /* Only allow RO locks when the initial object was a Reader/Writer lock - * Since information is lost on the internal locktype, we use the original - * information, which is only stored when built for DEBUG */ - MALI_DEBUG_ASSERT( _MALI_OSK_LOCKMODE_RW == mode - || (_MALI_OSK_LOCKMODE_RO == mode && (_MALI_OSK_LOCKFLAG_READERWRITER & lock->orig_flags)) ); - -#ifdef DEBUG - /* make sure the thread releasing the lock actually was the owner */ - if (mode == _MALI_OSK_LOCKMODE_RW) - { - /*MALI_DEBUG_ASSERT(_mali_osk_get_tid() == lock->owner);*/ - if (_mali_osk_get_tid() != lock->owner) - { - printk(KERN_ERR "%d: ERROR: Lock %p owner was %d\n", _mali_osk_get_tid(), lock, lock->owner); - dump_stack(); - } - /* This lock now has no owner */ - lock->owner = 0; - --lock->nOwners; - } - else /* mode == _MALI_OSK_LOCKMODE_RO */ - { - if ((_mali_osk_get_tid() & lock->owner) != _mali_osk_get_tid()) - { - printk(KERN_ERR "%d: ERROR: Not an owner of %p lock.\n", _mali_osk_get_tid(), lock); - dump_stack(); - } - - /* if this is the last thread holding this lock in R/O mode, set owner - * back to 0 */ - if (0 == --lock->nOwners) - { - lock->owner = 0; - } - } -#endif /* DEBUG */ - - switch ( lock->type ) - { - case _MALI_OSK_INTERNAL_LOCKTYPE_SPIN: - spin_unlock(&lock->obj.spinlock); - break; - case _MALI_OSK_INTERNAL_LOCKTYPE_SPIN_IRQ: - spin_unlock_irqrestore(&lock->obj.spinlock, lock->flags); - break; - - case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX: - /* FALLTHROUGH */ - case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT: - up(&lock->obj.sema); - break; - - case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT_RW: - if (mode == _MALI_OSK_LOCKMODE_RO) - { - up_read(&lock->obj.rw_sema); - } - else - { - up_write(&lock->obj.rw_sema); - } - break; - - default: - /* Reaching here indicates a programming error, so you will not get here - * on non-DEBUG builds */ - MALI_DEBUG_PRINT_ERROR( ("Invalid internal lock type: %.8X", lock->type ) ); - break; - } -} - -void _mali_osk_lock_term( _mali_osk_lock_t *lock ) -{ - /* Parameter validation */ - MALI_DEBUG_ASSERT_POINTER( lock ); - - /* Linux requires no explicit termination of spinlocks, semaphores, or rw_semaphores */ - kfree(lock); -} diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_low_level_mem.c b/drivers/media/video/samsung/mali/linux/mali_osk_low_level_mem.c deleted file mode 100644 index 02558a0..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_low_level_mem.c +++ /dev/null @@ -1,660 +0,0 @@ -/* - * Copyright (C) 2010-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file mali_osk_low_level_mem.c - * Implementation of the OS abstraction layer for the kernel device driver - */ - -/* needed to detect kernel version specific code */ -#include <linux/version.h> - -#include <asm/io.h> -#include <linux/ioport.h> -#include <linux/slab.h> -#include <linux/mm.h> -#include <linux/dma-mapping.h> -#include <linux/spinlock.h> -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0) -#include <linux/shrinker.h> -#endif - -#include "mali_osk.h" -#include "mali_ukk.h" /* required to hook in _mali_ukk_mem_mmap handling */ -#include "mali_kernel_common.h" -#include "mali_kernel_linux.h" - -static void mali_kernel_memory_vma_open(struct vm_area_struct * vma); -static void mali_kernel_memory_vma_close(struct vm_area_struct * vma); - - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) -static int mali_kernel_memory_cpu_page_fault_handler(struct vm_area_struct *vma, struct vm_fault *vmf); -#else -static unsigned long mali_kernel_memory_cpu_page_fault_handler(struct vm_area_struct * vma, unsigned long address); -#endif - - -typedef struct mali_vma_usage_tracker -{ - int references; - u32 cookie; -} mali_vma_usage_tracker; - - -/* Linked list structure to hold details of all OS allocations in a particular - * mapping - */ -struct AllocationList -{ - struct AllocationList *next; - u32 offset; - u32 physaddr; -}; - -typedef struct AllocationList AllocationList; - -/* Private structure to store details of a mapping region returned - * from _mali_osk_mem_mapregion_init - */ -struct MappingInfo -{ - struct vm_area_struct *vma; - struct AllocationList *list; - struct AllocationList *tail; -}; - -typedef struct MappingInfo MappingInfo; - - -static u32 _kernel_page_allocate(void); -static void _kernel_page_release(u32 physical_address); -static AllocationList * _allocation_list_item_get(void); -static void _allocation_list_item_release(AllocationList * item); - - -/* Variable declarations */ -static DEFINE_SPINLOCK(allocation_list_spinlock); -static AllocationList * pre_allocated_memory = (AllocationList*) NULL ; -static int pre_allocated_memory_size_current = 0; -#ifdef MALI_OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB - static int pre_allocated_memory_size_max = MALI_OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB * 1024 * 1024; -#else - static int pre_allocated_memory_size_max = 16 * 1024 * 1024; /* 6 MiB */ -#endif - -static struct vm_operations_struct mali_kernel_vm_ops = -{ - .open = mali_kernel_memory_vma_open, - .close = mali_kernel_memory_vma_close, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) - .fault = mali_kernel_memory_cpu_page_fault_handler -#else - .nopfn = mali_kernel_memory_cpu_page_fault_handler -#endif -}; - -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0) - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) -static int mali_mem_shrink(int nr_to_scan, gfp_t gfp_mask) - #else -static int mali_mem_shrink(struct shrinker *shrinker, int nr_to_scan, gfp_t gfp_mask) - #endif -#else -static int mali_mem_shrink(struct shrinker *shrinker, struct shrink_control *sc) -#endif -{ - unsigned long flags; - AllocationList *item; -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0) - int nr = nr_to_scan; -#else - int nr = sc->nr_to_scan; -#endif - - if (0 == nr) - { - return pre_allocated_memory_size_current / PAGE_SIZE; - } - - if (0 == pre_allocated_memory_size_current) - { - /* No pages availble */ - return 0; - } - - if (0 == spin_trylock_irqsave(&allocation_list_spinlock, flags)) - { - /* Not able to lock. */ - return -1; - } - - while (pre_allocated_memory && nr > 0) - { - item = pre_allocated_memory; - pre_allocated_memory = item->next; - - _kernel_page_release(item->physaddr); - _mali_osk_free(item); - - pre_allocated_memory_size_current -= PAGE_SIZE; - --nr; - } - spin_unlock_irqrestore(&allocation_list_spinlock,flags); - - return pre_allocated_memory_size_current / PAGE_SIZE; -} - -struct shrinker mali_mem_shrinker = { - .shrink = mali_mem_shrink, - .seeks = DEFAULT_SEEKS, -}; - -void mali_osk_low_level_mem_init(void) -{ - pre_allocated_memory = (AllocationList*) NULL ; - - register_shrinker(&mali_mem_shrinker); -} - -void mali_osk_low_level_mem_term(void) -{ - unregister_shrinker(&mali_mem_shrinker); - - while ( NULL != pre_allocated_memory ) - { - AllocationList *item; - item = pre_allocated_memory; - pre_allocated_memory = item->next; - _kernel_page_release(item->physaddr); - _mali_osk_free( item ); - } - pre_allocated_memory_size_current = 0; -} - -static u32 _kernel_page_allocate(void) -{ - struct page *new_page; - u32 linux_phys_addr; - - new_page = alloc_page(GFP_HIGHUSER | __GFP_ZERO | __GFP_REPEAT | __GFP_NOWARN | __GFP_COLD); - - if ( NULL == new_page ) - { - return 0; - } - - /* Ensure page is flushed from CPU caches. */ - linux_phys_addr = dma_map_page(NULL, new_page, 0, PAGE_SIZE, DMA_BIDIRECTIONAL); - - return linux_phys_addr; -} - -static void _kernel_page_release(u32 physical_address) -{ - struct page *unmap_page; - - #if 1 - dma_unmap_page(NULL, physical_address, PAGE_SIZE, DMA_BIDIRECTIONAL); - #endif - - unmap_page = pfn_to_page( physical_address >> PAGE_SHIFT ); - MALI_DEBUG_ASSERT_POINTER( unmap_page ); - __free_page( unmap_page ); -} - -static AllocationList * _allocation_list_item_get(void) -{ - AllocationList *item = NULL; - unsigned long flags; - - spin_lock_irqsave(&allocation_list_spinlock,flags); - if ( pre_allocated_memory ) - { - item = pre_allocated_memory; - pre_allocated_memory = pre_allocated_memory->next; - pre_allocated_memory_size_current -= PAGE_SIZE; - - spin_unlock_irqrestore(&allocation_list_spinlock,flags); - return item; - } - spin_unlock_irqrestore(&allocation_list_spinlock,flags); - - item = _mali_osk_malloc( sizeof(AllocationList) ); - if ( NULL == item) - { - return NULL; - } - - item->physaddr = _kernel_page_allocate(); - if ( 0 == item->physaddr ) - { - /* Non-fatal error condition, out of memory. Upper levels will handle this. */ - _mali_osk_free( item ); - return NULL; - } - return item; -} - -static void _allocation_list_item_release(AllocationList * item) -{ - unsigned long flags; - spin_lock_irqsave(&allocation_list_spinlock,flags); - if ( pre_allocated_memory_size_current < pre_allocated_memory_size_max) - { - item->next = pre_allocated_memory; - pre_allocated_memory = item; - pre_allocated_memory_size_current += PAGE_SIZE; - spin_unlock_irqrestore(&allocation_list_spinlock,flags); - return; - } - spin_unlock_irqrestore(&allocation_list_spinlock,flags); - - _kernel_page_release(item->physaddr); - _mali_osk_free( item ); -} - - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) -static int mali_kernel_memory_cpu_page_fault_handler(struct vm_area_struct *vma, struct vm_fault *vmf) -#else -static unsigned long mali_kernel_memory_cpu_page_fault_handler(struct vm_area_struct * vma, unsigned long address) -#endif -{ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) - void __user * address; - address = vmf->virtual_address; -#endif - /* - * We always fail the call since all memory is pre-faulted when assigned to the process. - * Only the Mali cores can use page faults to extend buffers. - */ - - MALI_DEBUG_PRINT(1, ("Page-fault in Mali memory region caused by the CPU.\n")); - MALI_DEBUG_PRINT(1, ("Tried to access %p (process local virtual address) which is not currently mapped to any Mali memory.\n", (void*)address)); - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) - return VM_FAULT_SIGBUS; -#else - return NOPFN_SIGBUS; -#endif -} - -static void mali_kernel_memory_vma_open(struct vm_area_struct * vma) -{ - mali_vma_usage_tracker * vma_usage_tracker; - MALI_DEBUG_PRINT(4, ("Open called on vma %p\n", vma)); - - vma_usage_tracker = (mali_vma_usage_tracker*)vma->vm_private_data; - vma_usage_tracker->references++; - - return; -} - -static void mali_kernel_memory_vma_close(struct vm_area_struct * vma) -{ - _mali_uk_mem_munmap_s args = {0, }; - mali_memory_allocation * descriptor; - mali_vma_usage_tracker * vma_usage_tracker; - MALI_DEBUG_PRINT(3, ("Close called on vma %p\n", vma)); - - vma_usage_tracker = (mali_vma_usage_tracker*)vma->vm_private_data; - - BUG_ON(!vma_usage_tracker); - BUG_ON(0 == vma_usage_tracker->references); - - vma_usage_tracker->references--; - - if (0 != vma_usage_tracker->references) - { - MALI_DEBUG_PRINT(3, ("Ignoring this close, %d references still exists\n", vma_usage_tracker->references)); - return; - } - - /** @note args->context unused, initialized to 0. - * Instead, we use the memory_session from the cookie */ - - descriptor = (mali_memory_allocation *)vma_usage_tracker->cookie; - - args.cookie = (u32)descriptor; - args.mapping = descriptor->mapping; - args.size = descriptor->size; - - _mali_ukk_mem_munmap( &args ); - - /* vma_usage_tracker is free()d by _mali_osk_mem_mapregion_term(). - * In the case of the memory engine, it is called as the release function that has been registered with the engine*/ -} - - -void _mali_osk_mem_barrier( void ) -{ - mb(); -} - -void _mali_osk_write_mem_barrier( void ) -{ - wmb(); -} - -mali_io_address _mali_osk_mem_mapioregion( u32 phys, u32 size, const char *description ) -{ - return (mali_io_address)ioremap_nocache(phys, size); -} - -void _mali_osk_mem_unmapioregion( u32 phys, u32 size, mali_io_address virt ) -{ - iounmap((void*)virt); -} - -mali_io_address _mali_osk_mem_allocioregion( u32 *phys, u32 size ) -{ - void * virt; - MALI_DEBUG_ASSERT_POINTER( phys ); - MALI_DEBUG_ASSERT( 0 == (size & ~_MALI_OSK_CPU_PAGE_MASK) ); - MALI_DEBUG_ASSERT( 0 != size ); - - /* dma_alloc_* uses a limited region of address space. On most arch/marchs - * 2 to 14 MiB is available. This should be enough for the page tables, which - * currently is the only user of this function. */ - virt = dma_alloc_coherent(NULL, size, phys, GFP_KERNEL | GFP_DMA ); - - MALI_DEBUG_PRINT(3, ("Page table virt: 0x%x = dma_alloc_coherent(size:%d, phys:0x%x, )\n", virt, size, phys)); - - if ( NULL == virt ) - { - MALI_DEBUG_PRINT(5, ("allocioregion: Failed to allocate Pagetable memory, size=0x%.8X\n", size )); - return 0; - } - - MALI_DEBUG_ASSERT( 0 == (*phys & ~_MALI_OSK_CPU_PAGE_MASK) ); - - return (mali_io_address)virt; -} - -void _mali_osk_mem_freeioregion( u32 phys, u32 size, mali_io_address virt ) -{ - MALI_DEBUG_ASSERT_POINTER( (void*)virt ); - MALI_DEBUG_ASSERT( 0 != size ); - MALI_DEBUG_ASSERT( 0 == (phys & ( (1 << PAGE_SHIFT) - 1 )) ); - - dma_free_coherent(NULL, size, virt, phys); -} - -_mali_osk_errcode_t inline _mali_osk_mem_reqregion( u32 phys, u32 size, const char *description ) -{ - return ((NULL == request_mem_region(phys, size, description)) ? _MALI_OSK_ERR_NOMEM : _MALI_OSK_ERR_OK); -} - -void inline _mali_osk_mem_unreqregion( u32 phys, u32 size ) -{ - release_mem_region(phys, size); -} - -void inline _mali_osk_mem_iowrite32_relaxed( volatile mali_io_address addr, u32 offset, u32 val ) -{ - __raw_writel(cpu_to_le32(val),((u8*)addr) + offset); -} - -u32 inline _mali_osk_mem_ioread32( volatile mali_io_address addr, u32 offset ) -{ - return ioread32(((u8*)addr) + offset); -} - -void inline _mali_osk_mem_iowrite32( volatile mali_io_address addr, u32 offset, u32 val ) -{ - iowrite32(val, ((u8*)addr) + offset); -} - -void _mali_osk_cache_flushall( void ) -{ - /** @note Cached memory is not currently supported in this implementation */ -} - -void _mali_osk_cache_ensure_uncached_range_flushed( void *uncached_mapping, u32 offset, u32 size ) -{ - _mali_osk_write_mem_barrier(); -} - -_mali_osk_errcode_t _mali_osk_mem_mapregion_init( mali_memory_allocation * descriptor ) -{ - struct vm_area_struct *vma; - mali_vma_usage_tracker * vma_usage_tracker; - MappingInfo *mappingInfo; - - if (NULL == descriptor) return _MALI_OSK_ERR_FAULT; - - MALI_DEBUG_ASSERT( 0 != (descriptor->flags & MALI_MEMORY_ALLOCATION_FLAG_MAP_INTO_USERSPACE) ); - - vma = (struct vm_area_struct*)descriptor->process_addr_mapping_info; - - if (NULL == vma ) return _MALI_OSK_ERR_FAULT; - - /* Re-write the process_addr_mapping_info */ - mappingInfo = _mali_osk_calloc( 1, sizeof(MappingInfo) ); - - if ( NULL == mappingInfo ) return _MALI_OSK_ERR_FAULT; - - vma_usage_tracker = _mali_osk_calloc( 1, sizeof(mali_vma_usage_tracker) ); - - if (NULL == vma_usage_tracker) - { - MALI_DEBUG_PRINT(2, ("Failed to allocate memory to track memory usage\n")); - _mali_osk_free( mappingInfo ); - return _MALI_OSK_ERR_FAULT; - } - - mappingInfo->vma = vma; - descriptor->process_addr_mapping_info = mappingInfo; - - /* Do the va range allocation - in this case, it was done earlier, so we copy in that information */ - descriptor->mapping = (void __user*)vma->vm_start; - /* list member is already NULL */ - - /* - set some bits which indicate that: - The memory is IO memory, meaning that no paging is to be performed and the memory should not be included in crash dumps - The memory is reserved, meaning that it's present and can never be paged out (see also previous entry) - */ - vma->vm_flags |= VM_IO; - vma->vm_flags |= VM_RESERVED; - vma->vm_flags |= VM_DONTCOPY; - - vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); - vma->vm_ops = &mali_kernel_vm_ops; /* Operations used on any memory system */ - - vma_usage_tracker->references = 1; /* set initial reference count to be 1 as vma_open won't be called for the first mmap call */ - vma_usage_tracker->cookie = (u32)descriptor; /* cookie for munmap */ - - vma->vm_private_data = vma_usage_tracker; - - return _MALI_OSK_ERR_OK; -} - -void _mali_osk_mem_mapregion_term( mali_memory_allocation * descriptor ) -{ - struct vm_area_struct* vma; - mali_vma_usage_tracker * vma_usage_tracker; - MappingInfo *mappingInfo; - - if (NULL == descriptor) return; - - MALI_DEBUG_ASSERT( 0 != (descriptor->flags & MALI_MEMORY_ALLOCATION_FLAG_MAP_INTO_USERSPACE) ); - - mappingInfo = (MappingInfo *)descriptor->process_addr_mapping_info; - - MALI_DEBUG_ASSERT_POINTER( mappingInfo ); - - /* Linux does the right thing as part of munmap to remove the mapping - * All that remains is that we remove the vma_usage_tracker setup in init() */ - vma = mappingInfo->vma; - - MALI_DEBUG_ASSERT_POINTER( vma ); - - /* ASSERT that there are no allocations on the list. Unmap should've been - * called on all OS allocations. */ - MALI_DEBUG_ASSERT( NULL == mappingInfo->list ); - - vma_usage_tracker = vma->vm_private_data; - - /* We only get called if mem_mapregion_init succeeded */ - _mali_osk_free(vma_usage_tracker); - - _mali_osk_free( mappingInfo ); - return; -} - -_mali_osk_errcode_t _mali_osk_mem_mapregion_map( mali_memory_allocation * descriptor, u32 offset, u32 *phys_addr, u32 size ) -{ - struct vm_area_struct *vma; - MappingInfo *mappingInfo; - - if (NULL == descriptor) return _MALI_OSK_ERR_FAULT; - - MALI_DEBUG_ASSERT_POINTER( phys_addr ); - - MALI_DEBUG_ASSERT( 0 != (descriptor->flags & MALI_MEMORY_ALLOCATION_FLAG_MAP_INTO_USERSPACE) ); - - MALI_DEBUG_ASSERT( 0 == (size & ~_MALI_OSK_CPU_PAGE_MASK) ); - - MALI_DEBUG_ASSERT( 0 == (offset & ~_MALI_OSK_CPU_PAGE_MASK)); - - if (NULL == descriptor->mapping) return _MALI_OSK_ERR_INVALID_ARGS; - - if (size > (descriptor->size - offset)) - { - MALI_DEBUG_PRINT(1,("_mali_osk_mem_mapregion_map: virtual memory area not large enough to map physical 0x%x size %x into area 0x%x at offset 0x%xr\n", - *phys_addr, size, descriptor->mapping, offset)); - return _MALI_OSK_ERR_FAULT; - } - - mappingInfo = (MappingInfo *)descriptor->process_addr_mapping_info; - - MALI_DEBUG_ASSERT_POINTER( mappingInfo ); - - vma = mappingInfo->vma; - - if (NULL == vma ) return _MALI_OSK_ERR_FAULT; - - MALI_DEBUG_PRINT(7, ("Process map: mapping 0x%08X to process address 0x%08lX length 0x%08X\n", *phys_addr, (long unsigned int)(descriptor->mapping + offset), size)); - - if ( MALI_MEMORY_ALLOCATION_OS_ALLOCATED_PHYSADDR_MAGIC == *phys_addr ) - { - _mali_osk_errcode_t ret; - AllocationList *alloc_item; - u32 linux_phys_frame_num; - - alloc_item = _allocation_list_item_get(); - if (NULL == alloc_item) - { - MALI_DEBUG_PRINT(1, ("Failed to allocate list item\n")); - return _MALI_OSK_ERR_NOMEM; - } - - linux_phys_frame_num = alloc_item->physaddr >> PAGE_SHIFT; - - ret = ( remap_pfn_range( vma, ((u32)descriptor->mapping) + offset, linux_phys_frame_num, size, vma->vm_page_prot) ) ? _MALI_OSK_ERR_FAULT : _MALI_OSK_ERR_OK; - - if ( ret != _MALI_OSK_ERR_OK) - { - MALI_PRINT_ERROR(("%s %d could not remap_pfn_range()\n", __FUNCTION__, __LINE__)); - _allocation_list_item_release(alloc_item); - return ret; - } - - /* Put our alloc_item into the list of allocations on success */ - if (NULL == mappingInfo->list) - { - mappingInfo->list = alloc_item; - } - else - { - mappingInfo->tail->next = alloc_item; - } - - mappingInfo->tail = alloc_item; - alloc_item->next = NULL; - alloc_item->offset = offset; - - /* Write out new physical address on success */ - *phys_addr = alloc_item->physaddr; - - return ret; - } - - /* Otherwise, Use the supplied physical address */ - - /* ASSERT that supplied phys_addr is page aligned */ - MALI_DEBUG_ASSERT( 0 == ((*phys_addr) & ~_MALI_OSK_CPU_PAGE_MASK) ); - - return ( remap_pfn_range( vma, ((u32)descriptor->mapping) + offset, *phys_addr >> PAGE_SHIFT, size, vma->vm_page_prot) ) ? _MALI_OSK_ERR_FAULT : _MALI_OSK_ERR_OK; - -} - -void _mali_osk_mem_mapregion_unmap( mali_memory_allocation * descriptor, u32 offset, u32 size, _mali_osk_mem_mapregion_flags_t flags ) -{ - MappingInfo *mappingInfo; - - if (NULL == descriptor) return; - - MALI_DEBUG_ASSERT( 0 != (descriptor->flags & MALI_MEMORY_ALLOCATION_FLAG_MAP_INTO_USERSPACE) ); - - MALI_DEBUG_ASSERT( 0 == (size & ~_MALI_OSK_CPU_PAGE_MASK) ); - - MALI_DEBUG_ASSERT( 0 == (offset & ~_MALI_OSK_CPU_PAGE_MASK) ); - - if (NULL == descriptor->mapping) return; - - if (size > (descriptor->size - offset)) - { - MALI_DEBUG_PRINT(1,("_mali_osk_mem_mapregion_unmap: virtual memory area not large enough to unmap size %x from area 0x%x at offset 0x%x\n", - size, descriptor->mapping, offset)); - return; - } - mappingInfo = (MappingInfo *)descriptor->process_addr_mapping_info; - - MALI_DEBUG_ASSERT_POINTER( mappingInfo ); - - if ( 0 != (flags & _MALI_OSK_MEM_MAPREGION_FLAG_OS_ALLOCATED_PHYSADDR) ) - { - /* This physical RAM was allocated in _mali_osk_mem_mapregion_map and - * so needs to be unmapped - */ - while (size) - { - /* First find the allocation in the list of allocations */ - AllocationList *alloc = mappingInfo->list; - AllocationList **prev = &(mappingInfo->list); - - while (NULL != alloc && alloc->offset != offset) - { - prev = &(alloc->next); - alloc = alloc->next; - } - if (alloc == NULL) { - MALI_DEBUG_PRINT(1, ("Unmapping memory that isn't mapped\n")); - size -= _MALI_OSK_CPU_PAGE_SIZE; - offset += _MALI_OSK_CPU_PAGE_SIZE; - continue; - } - - *prev = alloc->next; - _allocation_list_item_release(alloc); - - /* Move onto the next allocation */ - size -= _MALI_OSK_CPU_PAGE_SIZE; - offset += _MALI_OSK_CPU_PAGE_SIZE; - } - } - - /* Linux does the right thing as part of munmap to remove the mapping */ - - return; -} diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_mali.c b/drivers/media/video/samsung/mali/linux/mali_osk_mali.c deleted file mode 100644 index 06cb215..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_mali.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2010-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file mali_osk_mali.c - * Implementation of the OS abstraction layer which is specific for the Mali kernel device driver - */ -#include <linux/kernel.h> -#include <asm/uaccess.h> -#include <mach/irqs.h> - -#include "mali_kernel_common.h" /* MALI_xxx macros */ -#include "mali_osk.h" /* kernel side OS functions */ -#include "mali_uk_types.h" -#include "arch/config.h" /* contains the configuration of the arch we are compiling for */ - -_mali_osk_errcode_t _mali_osk_resources_init( _mali_osk_resource_t **arch_config, u32 *num_resources ) -{ - *num_resources = sizeof(arch_configuration) / sizeof(arch_configuration[0]); - *arch_config = arch_configuration; - return _MALI_OSK_ERR_OK; -} - -void _mali_osk_resources_term( _mali_osk_resource_t **arch_config, u32 num_resources ) -{ - /* Nothing to do */ -} diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_math.c b/drivers/media/video/samsung/mali/linux/mali_osk_math.c deleted file mode 100644 index bb25e7d..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_math.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2010, 2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file mali_osk_math.c - * Implementation of the OS abstraction layer for the kernel device driver - */ - -#include "mali_osk.h" -#include <linux/bitops.h> - -u32 inline _mali_osk_clz( u32 input ) -{ - return 32-fls(input); -} diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_memory.c b/drivers/media/video/samsung/mali/linux/mali_osk_memory.c deleted file mode 100644 index 5354e85..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_memory.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2010-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file mali_osk_memory.c - * Implementation of the OS abstraction layer for the kernel device driver - */ - -#include "mali_osk.h" -#include <linux/slab.h> -#include <linux/vmalloc.h> - -void inline *_mali_osk_calloc( u32 n, u32 size ) -{ - return kcalloc(n, size, GFP_KERNEL); -} - -void inline *_mali_osk_malloc( u32 size ) -{ - return kmalloc(size, GFP_KERNEL); -} - -void inline _mali_osk_free( void *ptr ) -{ - kfree(ptr); -} - -void inline *_mali_osk_valloc( u32 size ) -{ - return vmalloc(size); -} - -void inline _mali_osk_vfree( void *ptr ) -{ - vfree(ptr); -} - -void inline *_mali_osk_memcpy( void *dst, const void *src, u32 len ) -{ - return memcpy(dst, src, len); -} - -void inline *_mali_osk_memset( void *s, u32 c, u32 n ) -{ - return memset(s, c, n); -} - -mali_bool _mali_osk_mem_check_allocated( u32 max_allocated ) -{ - /* No need to prevent an out-of-memory dialogue appearing on Linux, - * so we always return MALI_TRUE. - */ - return MALI_TRUE; -} diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_misc.c b/drivers/media/video/samsung/mali/linux/mali_osk_misc.c deleted file mode 100644 index ad486db..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_misc.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2010-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file mali_osk_misc.c - * Implementation of the OS abstraction layer for the kernel device driver - */ -#include <linux/kernel.h> -#include <asm/uaccess.h> -#include <asm/cacheflush.h> -#include <linux/sched.h> -#include <linux/module.h> -#include "mali_osk.h" - -void _mali_osk_dbgmsg( const char *fmt, ... ) -{ - va_list args; - va_start(args, fmt); - vprintk(fmt, args); - va_end(args); -} - -u32 _mali_osk_snprintf( char *buf, u32 size, const char *fmt, ... ) -{ - int res; - va_list args; - va_start(args, fmt); - - res = vscnprintf(buf, (size_t)size, fmt, args); - - va_end(args); - return res; -} - -void _mali_osk_abort(void) -{ - /* make a simple fault by dereferencing a NULL pointer */ - dump_stack(); - *(int *)0 = 0; -} - -void _mali_osk_break(void) -{ - _mali_osk_abort(); -} - -u32 _mali_osk_get_pid(void) -{ - /* Thread group ID is the process ID on Linux */ - return (u32)current->tgid; -} - -u32 _mali_osk_get_tid(void) -{ - /* pid is actually identifying the thread on Linux */ - return (u32)current->pid; -} diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_notification.c b/drivers/media/video/samsung/mali/linux/mali_osk_notification.c deleted file mode 100644 index c14c0d5..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_notification.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (C) 2010-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file mali_osk_notification.c - * Implementation of the OS abstraction layer for the kernel device driver - */ - -#include "mali_osk.h" -#include "mali_kernel_common.h" - -/* needed to detect kernel version specific code */ -#include <linux/version.h> - -#include <linux/sched.h> -#include <linux/slab.h> -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) -#include <linux/semaphore.h> -#else /* pre 2.6.26 the file was in the arch specific location */ -#include <asm/semaphore.h> -#endif - -/** - * Declaration of the notification queue object type - * Contains a linked list of notification pending delivery to user space. - * It also contains a wait queue of exclusive waiters blocked in the ioctl - * When a new notification is posted a single thread is resumed. - */ -struct _mali_osk_notification_queue_t_struct -{ - struct semaphore mutex; /**< Mutex protecting the list */ - wait_queue_head_t receive_queue; /**< Threads waiting for new entries to the queue */ - struct list_head head; /**< List of notifications waiting to be picked up */ -}; - -typedef struct _mali_osk_notification_wrapper_t_struct -{ - struct list_head list; /**< Internal linked list variable */ - _mali_osk_notification_t data; /**< Notification data */ -} _mali_osk_notification_wrapper_t; - -_mali_osk_notification_queue_t *_mali_osk_notification_queue_init( void ) -{ - _mali_osk_notification_queue_t * result; - - result = (_mali_osk_notification_queue_t *)kmalloc(sizeof(_mali_osk_notification_queue_t), GFP_KERNEL); - if (NULL == result) return NULL; - - sema_init(&result->mutex, 1); - init_waitqueue_head(&result->receive_queue); - INIT_LIST_HEAD(&result->head); - - return result; -} - -_mali_osk_notification_t *_mali_osk_notification_create( u32 type, u32 size ) -{ - /* OPT Recycling of notification objects */ - _mali_osk_notification_wrapper_t *notification; - - notification = (_mali_osk_notification_wrapper_t *)kmalloc( sizeof(_mali_osk_notification_wrapper_t) + size, - GFP_KERNEL | __GFP_HIGH | __GFP_REPEAT); - if (NULL == notification) - { - MALI_DEBUG_PRINT(1, ("Failed to create a notification object\n")); - return NULL; - } - - /* Init the list */ - INIT_LIST_HEAD(¬ification->list); - - if (0 != size) - { - notification->data.result_buffer = ((u8*)notification) + sizeof(_mali_osk_notification_wrapper_t); - } - else - { - notification->data.result_buffer = NULL; - } - - /* set up the non-allocating fields */ - notification->data.notification_type = type; - notification->data.result_buffer_size = size; - - /* all ok */ - return &(notification->data); -} - -void _mali_osk_notification_delete( _mali_osk_notification_t *object ) -{ - _mali_osk_notification_wrapper_t *notification; - MALI_DEBUG_ASSERT_POINTER( object ); - - notification = container_of( object, _mali_osk_notification_wrapper_t, data ); - - /* Free the container */ - kfree(notification); -} - -void _mali_osk_notification_queue_term( _mali_osk_notification_queue_t *queue ) -{ - MALI_DEBUG_ASSERT_POINTER( queue ); - - /* not much to do, just free the memory */ - kfree(queue); -} - -void _mali_osk_notification_queue_send( _mali_osk_notification_queue_t *queue, _mali_osk_notification_t *object ) -{ - _mali_osk_notification_wrapper_t *notification; - MALI_DEBUG_ASSERT_POINTER( queue ); - MALI_DEBUG_ASSERT_POINTER( object ); - - notification = container_of( object, _mali_osk_notification_wrapper_t, data ); - - /* lock queue access */ - down(&queue->mutex); - /* add to list */ - list_add_tail(¬ification->list, &queue->head); - /* unlock the queue */ - up(&queue->mutex); - - /* and wake up one possible exclusive waiter */ - wake_up(&queue->receive_queue); -} - -static int _mali_notification_queue_is_empty( _mali_osk_notification_queue_t *queue ) -{ - int ret; - - down(&queue->mutex); - ret = list_empty(&queue->head); - up(&queue->mutex); - return ret; -} - -#if MALI_STATE_TRACKING -mali_bool _mali_osk_notification_queue_is_empty( _mali_osk_notification_queue_t *queue ) -{ - return _mali_notification_queue_is_empty(queue) ? MALI_TRUE : MALI_FALSE; -} -#endif - -_mali_osk_errcode_t _mali_osk_notification_queue_dequeue( _mali_osk_notification_queue_t *queue, _mali_osk_notification_t **result ) -{ - _mali_osk_errcode_t ret = _MALI_OSK_ERR_ITEM_NOT_FOUND; - _mali_osk_notification_wrapper_t *wrapper_object; - - down(&queue->mutex); - - if (!list_empty(&queue->head)) - { - wrapper_object = list_entry(queue->head.next, _mali_osk_notification_wrapper_t, list); - *result = &(wrapper_object->data); - list_del_init(&wrapper_object->list); - ret = _MALI_OSK_ERR_OK; - } - - up(&queue->mutex); - - return ret; -} - -_mali_osk_errcode_t _mali_osk_notification_queue_receive( _mali_osk_notification_queue_t *queue, _mali_osk_notification_t **result ) -{ - /* check input */ - MALI_DEBUG_ASSERT_POINTER( queue ); - MALI_DEBUG_ASSERT_POINTER( result ); - - /* default result */ - *result = NULL; - - while (_MALI_OSK_ERR_OK != _mali_osk_notification_queue_dequeue(queue, result)) - { - if (wait_event_interruptible(queue->receive_queue, !_mali_notification_queue_is_empty(queue))) - { - return _MALI_OSK_ERR_RESTARTSYSCALL; - } - } - - return _MALI_OSK_ERR_OK; /* all ok */ -} diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_pm.c b/drivers/media/video/samsung/mali/linux/mali_osk_pm.c deleted file mode 100644 index 491a603..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_pm.c +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright (C) 2010-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file mali_osk_pm.c - * Implementation of the callback functions from common power management - */ - -#include <linux/sched.h> - -#ifdef CONFIG_PM_RUNTIME -#include <linux/pm_runtime.h> -#endif /* CONFIG_PM_RUNTIME */ -#include <linux/platform_device.h> -#include "mali_platform.h" -#include "mali_osk.h" -#include "mali_uk_types.h" -#include "mali_kernel_common.h" -#include "mali_kernel_license.h" -#include "mali_linux_pm.h" -#include "mali_kernel_license.h" - -#if ! MALI_LICENSE_IS_GPL -#undef CONFIG_PM_RUNTIME -#endif - -extern struct platform_device mali_gpu_device; - -#ifdef CONFIG_PM_RUNTIME -static mali_bool have_runtime_reference = MALI_FALSE; -#endif - -void _mali_osk_pm_dev_enable(void) -{ -#ifdef CONFIG_PM_RUNTIME - pm_runtime_enable(&(mali_gpu_device.dev)); -#endif -} - -/* NB: Function is not thread safe */ -_mali_osk_errcode_t _mali_osk_pm_dev_idle(void) -{ -#ifdef CONFIG_PM_RUNTIME - if (MALI_TRUE == have_runtime_reference) - { - int err; - err = pm_runtime_put_sync(&(mali_gpu_device.dev)); - if (0 > err) - { - MALI_PRINT_ERROR(("OSK PM: pm_runtime_put_sync() returned error code %d\n", err)); - return _MALI_OSK_ERR_FAULT; - } - have_runtime_reference = MALI_FALSE; - } -#endif - return _MALI_OSK_ERR_OK; -} - -/* NB: Function is not thread safe */ -_mali_osk_errcode_t _mali_osk_pm_dev_activate(void) -{ -#ifdef CONFIG_PM_RUNTIME - if (MALI_TRUE != have_runtime_reference) - { - int err; - err = pm_runtime_get_sync(&(mali_gpu_device.dev)); - if (0 > err) - { - MALI_PRINT_ERROR(("OSK PM: pm_runtime_get_sync() returned error code %d\n", err)); - return _MALI_OSK_ERR_FAULT; - } - have_runtime_reference = MALI_TRUE; - } -#endif - return _MALI_OSK_ERR_OK; -} diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_profiling_gator.c b/drivers/media/video/samsung/mali/linux/mali_osk_profiling_gator.c deleted file mode 100644 index 95bee53..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_profiling_gator.c +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (C) 2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include <linux/module.h> - -#include "mali_kernel_common.h" -#include "mali_osk.h" -#include "mali_ukk.h" -#include "mali_uk_types.h" -#include "mali_osk_profiling.h" -#include "mali_linux_trace.h" -#include "mali_gp.h" -#include "mali_pp.h" -#include "mali_l2_cache.h" -#include "mali_user_settings_db.h" - -_mali_osk_errcode_t _mali_osk_profiling_init(mali_bool auto_start) -{ - if (MALI_TRUE == auto_start) - { - mali_set_user_setting(_MALI_UK_USER_SETTING_SW_EVENTS_ENABLE, MALI_TRUE); - } - - return _MALI_OSK_ERR_OK; -} - -void _mali_osk_profiling_term(void) -{ - /* Nothing to do */ -} - -_mali_osk_errcode_t _mali_osk_profiling_start(u32 * limit) -{ - /* Nothing to do */ - return _MALI_OSK_ERR_OK; -} - -_mali_osk_errcode_t _mali_osk_profiling_stop(u32 *count) -{ - /* Nothing to do */ - return _MALI_OSK_ERR_OK; -} - -u32 _mali_osk_profiling_get_count(void) -{ - return 0; -} - -_mali_osk_errcode_t _mali_osk_profiling_get_event(u32 index, u64* timestamp, u32* event_id, u32 data[5]) -{ - /* Nothing to do */ - return _MALI_OSK_ERR_OK; -} - -_mali_osk_errcode_t _mali_osk_profiling_clear(void) -{ - /* Nothing to do */ - return _MALI_OSK_ERR_OK; -} - -mali_bool _mali_osk_profiling_is_recording(void) -{ - return MALI_FALSE; -} - -mali_bool _mali_osk_profiling_have_recording(void) -{ - return MALI_FALSE; -} - -void _mali_osk_profiling_report_sw_counters(u32 *counters) -{ - trace_mali_sw_counters(_mali_osk_get_pid(), _mali_osk_get_tid(), NULL, counters); -} - - -_mali_osk_errcode_t _mali_ukk_profiling_start(_mali_uk_profiling_start_s *args) -{ - return _mali_osk_profiling_start(&args->limit); -} - -_mali_osk_errcode_t _mali_ukk_profiling_add_event(_mali_uk_profiling_add_event_s *args) -{ - /* Always add process and thread identificator in the first two data elements for events from user space */ - _mali_osk_profiling_add_event(args->event_id, _mali_osk_get_pid(), _mali_osk_get_tid(), args->data[2], args->data[3], args->data[4]); - - return _MALI_OSK_ERR_OK; -} - -_mali_osk_errcode_t _mali_ukk_profiling_stop(_mali_uk_profiling_stop_s *args) -{ - return _mali_osk_profiling_stop(&args->count); -} - -_mali_osk_errcode_t _mali_ukk_profiling_get_event(_mali_uk_profiling_get_event_s *args) -{ - return _mali_osk_profiling_get_event(args->index, &args->timestamp, &args->event_id, args->data); -} - -_mali_osk_errcode_t _mali_ukk_profiling_clear(_mali_uk_profiling_clear_s *args) -{ - return _mali_osk_profiling_clear(); -} - -_mali_osk_errcode_t _mali_ukk_sw_counters_report(_mali_uk_sw_counters_report_s *args) -{ - _mali_osk_profiling_report_sw_counters(args->counters); - return _MALI_OSK_ERR_OK; -} - -/** - * Called by gator.ko to set HW counters - * - * @param counter_id The counter ID. - * @param event_id Event ID that the counter should count (HW counter value from TRM). - * - * @return 1 on success, 0 on failure. - */ -int _mali_profiling_set_event(u32 counter_id, s32 event_id) -{ - - if (COUNTER_VP_C0 == counter_id) - { - struct mali_gp_core* gp_core = mali_gp_get_global_gp_core(); - if (NULL != gp_core) - { - if (MALI_TRUE == mali_gp_core_set_counter_src0(gp_core, event_id)) - { - return 1; - } - } - } - if (COUNTER_VP_C1 == counter_id) - { - struct mali_gp_core* gp_core = mali_gp_get_global_gp_core(); - if (NULL != gp_core) - { - if (MALI_TRUE == mali_gp_core_set_counter_src1(gp_core, event_id)) - { - return 1; - } - } - } - if (COUNTER_FP0_C0 <= counter_id && COUNTER_FP3_C1 >= counter_id) - { - u32 core_id = (counter_id - COUNTER_FP0_C0) >> 1; - struct mali_pp_core* pp_core = mali_pp_get_global_pp_core(core_id); - if (NULL != pp_core) - { - u32 counter_src = (counter_id - COUNTER_FP0_C0) & 1; - if (0 == counter_src) - { - if (MALI_TRUE == mali_pp_core_set_counter_src0(pp_core, event_id)) - { - return 1; - } - } - else - { - if (MALI_TRUE == mali_pp_core_set_counter_src1(pp_core, event_id)) - { - return 1; - } - } - } - } - if (COUNTER_L2_C0 <= counter_id && COUNTER_L2_C1 >= counter_id) - { - u32 core_id = (counter_id - COUNTER_L2_C0) >> 1; - struct mali_l2_cache_core* l2_cache_core = mali_l2_cache_core_get_glob_l2_core(core_id); - if (NULL != l2_cache_core) - { - u32 counter_src = (counter_id - COUNTER_L2_C0) & 1; - if (0 == counter_src) - { - if (MALI_TRUE == mali_l2_cache_core_set_counter_src0(l2_cache_core, event_id)) - { - return 1; - } - } - else - { - if (MALI_TRUE == mali_l2_cache_core_set_counter_src1(l2_cache_core, event_id)) - { - return 1; - } - } - } - } - - return 0; -} - -/** - * Called by gator.ko to retrieve the L2 cache counter values for the first L2 cache. - * The L2 cache counters are unique in that they are polled by gator, rather than being - * transmitted via the tracepoint mechanism. - * - * @param src0 First L2 cache counter ID. - * @param val0 First L2 cache counter value. - * @param src1 Second L2 cache counter ID. - * @param val1 Second L2 cache counter value. - */ -void _mali_profiling_get_counters(u32 *src0, u32 *val0, u32 *src1, u32 *val1) -{ - struct mali_l2_cache_core *l2_cache = mali_l2_cache_core_get_glob_l2_core(0); - if (NULL != l2_cache) - { - if (MALI_TRUE == mali_l2_cache_lock_power_state(l2_cache)) - { - /* It is now safe to access the L2 cache core in order to retrieve the counters */ - mali_l2_cache_core_get_counter_values(l2_cache, src0, val0, src1, val1); - } - mali_l2_cache_unlock_power_state(l2_cache); - } -} - -/* - * List of possible actions to be controlled by Streamline. - * The following numbers are used by gator to control the frame buffer dumping and s/w counter reporting. - * We cannot use the enums in mali_uk_types.h because they are unknown inside gator. - */ -#define FBDUMP_CONTROL_ENABLE (1) -#define FBDUMP_CONTROL_RATE (2) -#define SW_COUNTER_ENABLE (3) -#define FBDUMP_CONTROL_RESIZE_FACTOR (4) - -/** - * Called by gator to control the production of profiling information at runtime. - */ -void _mali_profiling_control(u32 action, u32 value) -{ - switch(action) - { - case FBDUMP_CONTROL_ENABLE: - mali_set_user_setting(_MALI_UK_USER_SETTING_COLORBUFFER_CAPTURE_ENABLED, (value == 0 ? MALI_FALSE : MALI_TRUE)); - break; - case FBDUMP_CONTROL_RATE: - mali_set_user_setting(_MALI_UK_USER_SETTING_BUFFER_CAPTURE_N_FRAMES, value); - break; - case SW_COUNTER_ENABLE: - mali_set_user_setting(_MALI_UK_USER_SETTING_SW_COUNTER_ENABLED, value); - break; - case FBDUMP_CONTROL_RESIZE_FACTOR: - mali_set_user_setting(_MALI_UK_USER_SETTING_BUFFER_CAPTURE_RESIZE_FACTOR, value); - break; - default: - break; /* Ignore unimplemented actions */ - } -} - -EXPORT_SYMBOL(_mali_profiling_set_event); -EXPORT_SYMBOL(_mali_profiling_get_counters); -EXPORT_SYMBOL(_mali_profiling_control); diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_profiling_internal.c b/drivers/media/video/samsung/mali/linux/mali_osk_profiling_internal.c deleted file mode 100644 index 2df935d..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_profiling_internal.c +++ /dev/null @@ -1,324 +0,0 @@ -/* - * Copyright (C) 2010-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "mali_kernel_common.h" -#include "mali_osk.h" -#include "mali_osk_mali.h" -#include "mali_ukk.h" -#include "mali_timestamp.h" -#include "mali_osk_profiling.h" -#include "mali_user_settings_db.h" - -typedef struct mali_profiling_entry -{ - u64 timestamp; - u32 event_id; - u32 data[5]; -} mali_profiling_entry; - - -typedef enum mali_profiling_state -{ - MALI_PROFILING_STATE_UNINITIALIZED, - MALI_PROFILING_STATE_IDLE, - MALI_PROFILING_STATE_RUNNING, - MALI_PROFILING_STATE_RETURN, -} mali_profiling_state; - -static _mali_osk_lock_t *lock = NULL; -static mali_profiling_state prof_state = MALI_PROFILING_STATE_UNINITIALIZED; -static mali_profiling_entry* profile_entries = NULL; -static u32 profile_entry_count = 0; -static _mali_osk_atomic_t profile_insert_index; -static _mali_osk_atomic_t profile_entries_written; - -_mali_osk_errcode_t _mali_osk_profiling_init(mali_bool auto_start) -{ - profile_entries = NULL; - profile_entry_count = 0; - _mali_osk_atomic_init(&profile_insert_index, 0); - _mali_osk_atomic_init(&profile_entries_written, 0); - - lock = _mali_osk_lock_init(_MALI_OSK_LOCKFLAG_ORDERED | _MALI_OSK_LOCKFLAG_SPINLOCK | _MALI_OSK_LOCKFLAG_NONINTERRUPTABLE, 0, _MALI_OSK_LOCK_ORDER_PROFILING); - if (NULL == lock) - { - return _MALI_OSK_ERR_FAULT; - } - - prof_state = MALI_PROFILING_STATE_IDLE; - - if (MALI_TRUE == auto_start) - { - u32 limit = MALI_PROFILING_MAX_BUFFER_ENTRIES; /* Use maximum buffer size */ - - mali_set_user_setting(_MALI_UK_USER_SETTING_SW_EVENTS_ENABLE, MALI_TRUE); - if (_MALI_OSK_ERR_OK != _mali_osk_profiling_start(&limit)) - { - return _MALI_OSK_ERR_FAULT; - } - } - - return _MALI_OSK_ERR_OK; -} - -void _mali_osk_profiling_term(void) -{ - prof_state = MALI_PROFILING_STATE_UNINITIALIZED; - - /* wait for all elements to be completely inserted into array */ - while (_mali_osk_atomic_read(&profile_insert_index) != _mali_osk_atomic_read(&profile_entries_written)) - { - /* do nothing */; - } - - if (NULL != profile_entries) - { - _mali_osk_vfree(profile_entries); - profile_entries = NULL; - } - - if (NULL != lock) - { - _mali_osk_lock_term(lock); - lock = NULL; - } -} - -inline _mali_osk_errcode_t _mali_osk_profiling_start(u32 * limit) -{ - _mali_osk_errcode_t ret; - - mali_profiling_entry *new_profile_entries = _mali_osk_valloc(*limit * sizeof(mali_profiling_entry)); - - if(NULL == new_profile_entries) - { - return _MALI_OSK_ERR_NOMEM; - } - - _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW); - - if (prof_state != MALI_PROFILING_STATE_IDLE) - { - _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); - _mali_osk_vfree(new_profile_entries); - return _MALI_OSK_ERR_INVALID_ARGS; /* invalid to call this function in this state */ - } - - if (*limit > MALI_PROFILING_MAX_BUFFER_ENTRIES) - { - *limit = MALI_PROFILING_MAX_BUFFER_ENTRIES; - } - - profile_entries = new_profile_entries; - profile_entry_count = *limit; - - ret = _mali_timestamp_reset(); - - if (ret == _MALI_OSK_ERR_OK) - { - prof_state = MALI_PROFILING_STATE_RUNNING; - } - else - { - _mali_osk_vfree(profile_entries); - profile_entries = NULL; - } - - _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); - return ret; -} - -inline void _mali_osk_profiling_add_event(u32 event_id, u32 data0, u32 data1, u32 data2, u32 data3, u32 data4) -{ - if (prof_state == MALI_PROFILING_STATE_RUNNING) - { - u32 cur_index = (_mali_osk_atomic_inc_return(&profile_insert_index) - 1) % profile_entry_count; - - profile_entries[cur_index].timestamp = _mali_timestamp_get(); - profile_entries[cur_index].event_id = event_id; - profile_entries[cur_index].data[0] = data0; - profile_entries[cur_index].data[1] = data1; - profile_entries[cur_index].data[2] = data2; - profile_entries[cur_index].data[3] = data3; - profile_entries[cur_index].data[4] = data4; - - /* If event is "leave API function", add current memory usage to the event - * as data point 4. This is used in timeline profiling to indicate how - * much memory was used when leaving a function. */ - if (event_id == (MALI_PROFILING_EVENT_TYPE_SINGLE|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_SINGLE_SW_LEAVE_API_FUNC)) - { - profile_entries[cur_index].data[4] = _mali_ukk_report_memory_usage(); - } - - _mali_osk_atomic_inc(&profile_entries_written); - } -} - -inline void _mali_osk_profiling_report_hw_counter(u32 counter_id, u32 value) -{ - /* Not implemented */ -} - -void _mali_osk_profiling_report_sw_counters(u32 *counters) -{ - /* Not implemented */ -} - -inline _mali_osk_errcode_t _mali_osk_profiling_stop(u32 * count) -{ - _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW); - - if (prof_state != MALI_PROFILING_STATE_RUNNING) - { - _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); - return _MALI_OSK_ERR_INVALID_ARGS; /* invalid to call this function in this state */ - } - - /* go into return state (user to retreive events), no more events will be added after this */ - prof_state = MALI_PROFILING_STATE_RETURN; - - _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); - - /* wait for all elements to be completely inserted into array */ - while (_mali_osk_atomic_read(&profile_insert_index) != _mali_osk_atomic_read(&profile_entries_written)) - { - /* do nothing */; - } - - *count = _mali_osk_atomic_read(&profile_insert_index); - if(*count>profile_entry_count) *count=profile_entry_count; - - return _MALI_OSK_ERR_OK; -} - -inline u32 _mali_osk_profiling_get_count(void) -{ - u32 retval = 0; - - _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW); - if (prof_state == MALI_PROFILING_STATE_RETURN) - { - retval = _mali_osk_atomic_read(&profile_entries_written); - if(retval>profile_entry_count) retval = profile_entry_count; - } - _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); - - return retval; -} - -inline _mali_osk_errcode_t _mali_osk_profiling_get_event(u32 index, u64* timestamp, u32* event_id, u32 data[5]) -{ - _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW); - - if(index<profile_entry_count) - { - u32 idx = index; - if(_mali_osk_atomic_read(&profile_insert_index)>=profile_entry_count) - { - idx = (index + _mali_osk_atomic_read(&profile_insert_index)) % profile_entry_count; - } - - if (prof_state != MALI_PROFILING_STATE_RETURN) - { - _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); - return _MALI_OSK_ERR_INVALID_ARGS; /* invalid to call this function in this state */ - } - - if (idx >= _mali_osk_atomic_read(&profile_entries_written)) - { - _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); - return _MALI_OSK_ERR_FAULT; - } - - *timestamp = profile_entries[idx].timestamp; - *event_id = profile_entries[idx].event_id; - data[0] = profile_entries[idx].data[0]; - data[1] = profile_entries[idx].data[1]; - data[2] = profile_entries[idx].data[2]; - data[3] = profile_entries[idx].data[3]; - data[4] = profile_entries[idx].data[4]; - } - else - { - _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); - return _MALI_OSK_ERR_FAULT; - } - - _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); - return _MALI_OSK_ERR_OK; -} - -inline _mali_osk_errcode_t _mali_osk_profiling_clear(void) -{ - _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW); - - if (prof_state != MALI_PROFILING_STATE_RETURN) - { - _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); - return _MALI_OSK_ERR_INVALID_ARGS; /* invalid to call this function in this state */ - } - - prof_state = MALI_PROFILING_STATE_IDLE; - profile_entry_count = 0; - _mali_osk_atomic_init(&profile_insert_index, 0); - _mali_osk_atomic_init(&profile_entries_written, 0); - if (NULL != profile_entries) - { - _mali_osk_vfree(profile_entries); - profile_entries = NULL; - } - - _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); - return _MALI_OSK_ERR_OK; -} - -mali_bool _mali_osk_profiling_is_recording(void) -{ - return prof_state == MALI_PROFILING_STATE_RUNNING ? MALI_TRUE : MALI_FALSE; -} - -mali_bool _mali_osk_profiling_have_recording(void) -{ - return prof_state == MALI_PROFILING_STATE_RETURN ? MALI_TRUE : MALI_FALSE; -} - -_mali_osk_errcode_t _mali_ukk_profiling_start(_mali_uk_profiling_start_s *args) -{ - return _mali_osk_profiling_start(&args->limit); -} - -_mali_osk_errcode_t _mali_ukk_profiling_add_event(_mali_uk_profiling_add_event_s *args) -{ - /* Always add process and thread identificator in the first two data elements for events from user space */ - _mali_osk_profiling_add_event(args->event_id, _mali_osk_get_pid(), _mali_osk_get_tid(), args->data[2], args->data[3], args->data[4]); - return _MALI_OSK_ERR_OK; -} - -_mali_osk_errcode_t _mali_ukk_profiling_stop(_mali_uk_profiling_stop_s *args) -{ - return _mali_osk_profiling_stop(&args->count); -} - -_mali_osk_errcode_t _mali_ukk_profiling_get_event(_mali_uk_profiling_get_event_s *args) -{ - return _mali_osk_profiling_get_event(args->index, &args->timestamp, &args->event_id, args->data); -} - -_mali_osk_errcode_t _mali_ukk_profiling_clear(_mali_uk_profiling_clear_s *args) -{ - return _mali_osk_profiling_clear(); -} - -_mali_osk_errcode_t _mali_ukk_sw_counters_report(_mali_uk_sw_counters_report_s *args) -{ - _mali_osk_profiling_report_sw_counters(args->counters); - return _MALI_OSK_ERR_OK; -} - diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_specific.h b/drivers/media/video/samsung/mali/linux/mali_osk_specific.h deleted file mode 100644 index 83ee906..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_specific.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2010, 2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file mali_osk_specific.h - * Defines per-OS Kernel level specifics, such as unusual workarounds for - * certain OSs. - */ - -#ifndef __MALI_OSK_SPECIFIC_H__ -#define __MALI_OSK_SPECIFIC_H__ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#define MALI_STATIC_INLINE static inline -#define MALI_NON_STATIC_INLINE inline - -#ifdef __cplusplus -} -#endif - -/** The list of events supported by the Mali DDK. */ -typedef enum -{ - /* Vertex processor activity */ - ACTIVITY_VP = 0, - - /* Fragment processor activity */ - ACTIVITY_FP0, - ACTIVITY_FP1, - ACTIVITY_FP2, - ACTIVITY_FP3, - - /* L2 cache counters */ - COUNTER_L2_C0, - COUNTER_L2_C1, - - /* Vertex processor counters */ - COUNTER_VP_C0, - COUNTER_VP_C1, - - /* Fragment processor counters */ - COUNTER_FP0_C0, - COUNTER_FP0_C1, - COUNTER_FP1_C0, - COUNTER_FP1_C1, - COUNTER_FP2_C0, - COUNTER_FP2_C1, - COUNTER_FP3_C0, - COUNTER_FP3_C1, - - /* - * If more hardware counters are added, the _mali_osk_hw_counter_table - * below should also be updated. - */ - - /* EGL software counters */ - COUNTER_EGL_BLIT_TIME, - - /* GLES software counters */ - COUNTER_GLES_DRAW_ELEMENTS_CALLS, - COUNTER_GLES_DRAW_ELEMENTS_NUM_INDICES, - COUNTER_GLES_DRAW_ELEMENTS_NUM_TRANSFORMED, - COUNTER_GLES_DRAW_ARRAYS_CALLS, - COUNTER_GLES_DRAW_ARRAYS_NUM_TRANSFORMED, - COUNTER_GLES_DRAW_POINTS, - COUNTER_GLES_DRAW_LINES, - COUNTER_GLES_DRAW_LINE_LOOP, - COUNTER_GLES_DRAW_LINE_STRIP, - COUNTER_GLES_DRAW_TRIANGLES, - COUNTER_GLES_DRAW_TRIANGLE_STRIP, - COUNTER_GLES_DRAW_TRIANGLE_FAN, - COUNTER_GLES_NON_VBO_DATA_COPY_TIME, - COUNTER_GLES_UNIFORM_BYTES_COPIED_TO_MALI, - COUNTER_GLES_UPLOAD_TEXTURE_TIME, - COUNTER_GLES_UPLOAD_VBO_TIME, - COUNTER_GLES_NUM_FLUSHES, - COUNTER_GLES_NUM_VSHADERS_GENERATED, - COUNTER_GLES_NUM_FSHADERS_GENERATED, - COUNTER_GLES_VSHADER_GEN_TIME, - COUNTER_GLES_FSHADER_GEN_TIME, - COUNTER_GLES_INPUT_TRIANGLES, - COUNTER_GLES_VXCACHE_HIT, - COUNTER_GLES_VXCACHE_MISS, - COUNTER_GLES_VXCACHE_COLLISION, - COUNTER_GLES_CULLED_TRIANGLES, - COUNTER_GLES_CULLED_LINES, - COUNTER_GLES_BACKFACE_TRIANGLES, - COUNTER_GLES_GBCLIP_TRIANGLES, - COUNTER_GLES_GBCLIP_LINES, - COUNTER_GLES_TRIANGLES_DRAWN, - COUNTER_GLES_DRAWCALL_TIME, - COUNTER_GLES_TRIANGLES_COUNT, - COUNTER_GLES_INDEPENDENT_TRIANGLES_COUNT, - COUNTER_GLES_STRIP_TRIANGLES_COUNT, - COUNTER_GLES_FAN_TRIANGLES_COUNT, - COUNTER_GLES_LINES_COUNT, - COUNTER_GLES_INDEPENDENT_LINES_COUNT, - COUNTER_GLES_STRIP_LINES_COUNT, - COUNTER_GLES_LOOP_LINES_COUNT, - - /* Framebuffer capture pseudo-counter */ - COUNTER_FILMSTRIP, - - NUMBER_OF_EVENTS -} _mali_osk_counter_id; - -#define FIRST_ACTIVITY_EVENT ACTIVITY_VP -#define LAST_ACTIVITY_EVENT ACTIVITY_FP3 - -#define FIRST_HW_COUNTER COUNTER_L2_C0 -#define LAST_HW_COUNTER COUNTER_FP3_C1 - -#define FIRST_SW_COUNTER COUNTER_EGL_BLIT_TIME -#define LAST_SW_COUNTER COUNTER_GLES_LOOP_LINES_COUNT - -#define FIRST_SPECIAL_COUNTER COUNTER_FILMSTRIP -#define LAST_SPECIAL_COUNTER COUNTER_FILMSTRIP - -#endif /* __MALI_OSK_SPECIFIC_H__ */ diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_time.c b/drivers/media/video/samsung/mali/linux/mali_osk_time.c deleted file mode 100644 index b399b87..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_time.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2010, 2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file mali_osk_time.c - * Implementation of the OS abstraction layer for the kernel device driver - */ - -#include "mali_osk.h" -#include <linux/jiffies.h> -#include <linux/time.h> -#include <asm/delay.h> - -int _mali_osk_time_after( u32 ticka, u32 tickb ) -{ - return time_after((unsigned long)ticka, (unsigned long)tickb); -} - -u32 _mali_osk_time_mstoticks( u32 ms ) -{ - return msecs_to_jiffies(ms); -} - -u32 _mali_osk_time_tickstoms( u32 ticks ) -{ - return jiffies_to_msecs(ticks); -} - -u32 _mali_osk_time_tickcount( void ) -{ - return jiffies; -} - -void _mali_osk_time_ubusydelay( u32 usecs ) -{ - udelay(usecs); -} - -u64 _mali_osk_time_get_ns( void ) -{ - struct timespec tsval; - getnstimeofday(&tsval); - return (u64)timespec_to_ns(&tsval); -} diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_timers.c b/drivers/media/video/samsung/mali/linux/mali_osk_timers.c deleted file mode 100644 index e5829a3..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_timers.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2010-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file mali_osk_timers.c - * Implementation of the OS abstraction layer for the kernel device driver - */ - -#include <linux/timer.h> -#include <linux/slab.h> -#include "mali_osk.h" -#include "mali_kernel_common.h" - -struct _mali_osk_timer_t_struct -{ - struct timer_list timer; -}; - -typedef void (*timer_timeout_function_t)(unsigned long); - -_mali_osk_timer_t *_mali_osk_timer_init(void) -{ - _mali_osk_timer_t *t = (_mali_osk_timer_t*)kmalloc(sizeof(_mali_osk_timer_t), GFP_KERNEL); - if (NULL != t) init_timer(&t->timer); - return t; -} - -void _mali_osk_timer_add( _mali_osk_timer_t *tim, u32 ticks_to_expire ) -{ - MALI_DEBUG_ASSERT_POINTER(tim); - tim->timer.expires = _mali_osk_time_tickcount() + ticks_to_expire; - add_timer(&(tim->timer)); -} - -void _mali_osk_timer_mod( _mali_osk_timer_t *tim, u32 expiry_tick) -{ - MALI_DEBUG_ASSERT_POINTER(tim); - mod_timer(&(tim->timer), expiry_tick); -} - -void _mali_osk_timer_del( _mali_osk_timer_t *tim ) -{ - MALI_DEBUG_ASSERT_POINTER(tim); - del_timer_sync(&(tim->timer)); -} - -void _mali_osk_timer_setcallback( _mali_osk_timer_t *tim, _mali_osk_timer_callback_t callback, void *data ) -{ - MALI_DEBUG_ASSERT_POINTER(tim); - tim->timer.data = (unsigned long)data; - tim->timer.function = (timer_timeout_function_t)callback; -} - -void _mali_osk_timer_term( _mali_osk_timer_t *tim ) -{ - MALI_DEBUG_ASSERT_POINTER(tim); - kfree(tim); -} diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_wait_queue.c b/drivers/media/video/samsung/mali/linux/mali_osk_wait_queue.c deleted file mode 100644 index ce0561d..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_wait_queue.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file mali_osk_wait_queue.c - * Implemenation of the OS abstraction layer for the kernel device driver - */ - -#include <linux/wait.h> -#include <linux/slab.h> -#include <linux/sched.h> - -#include "mali_osk.h" -#include "mali_kernel_common.h" - -struct _mali_osk_wait_queue_t_struct -{ - wait_queue_head_t wait_queue; -}; - -_mali_osk_wait_queue_t* _mali_osk_wait_queue_init( void ) -{ - _mali_osk_wait_queue_t* ret = NULL; - - ret = kmalloc(sizeof(_mali_osk_wait_queue_t), GFP_KERNEL); - - if (NULL == ret) - { - return ret; - } - - init_waitqueue_head(&ret->wait_queue); - MALI_DEBUG_ASSERT(!waitqueue_active(&ret->wait_queue)); - - return ret; -} - -void _mali_osk_wait_queue_wait_event( _mali_osk_wait_queue_t *queue, mali_bool (*condition)(void) ) -{ - MALI_DEBUG_ASSERT_POINTER( queue ); - MALI_DEBUG_PRINT(6, ("Adding to wait queue %p\n", queue)); - wait_event(queue->wait_queue, condition()); -} - -void _mali_osk_wait_queue_wake_up( _mali_osk_wait_queue_t *queue ) -{ - MALI_DEBUG_ASSERT_POINTER( queue ); - - /* if queue is empty, don't attempt to wake up its elements */ - if (!waitqueue_active(&queue->wait_queue)) return; - - MALI_DEBUG_PRINT(6, ("Waking up elements in wait queue %p ....\n", queue)); - - wake_up_all(&queue->wait_queue); - - MALI_DEBUG_PRINT(6, ("... elements in wait queue %p woken up\n", queue)); -} - -void _mali_osk_wait_queue_term( _mali_osk_wait_queue_t *queue ) -{ - /* Parameter validation */ - MALI_DEBUG_ASSERT_POINTER( queue ); - - /* Linux requires no explicit termination of wait queues */ - kfree(queue); -} diff --git a/drivers/media/video/samsung/mali/linux/mali_pmu_power_up_down.c b/drivers/media/video/samsung/mali/linux/mali_pmu_power_up_down.c deleted file mode 100644 index f3b0a2c..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_pmu_power_up_down.c +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright (C) 2010, 2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file mali_pmu_power_up_down.c - */ - -#include <linux/version.h> -#include <linux/sched.h> -#include <linux/module.h> -#include "mali_osk.h" -#include "mali_kernel_common.h" -#include "mali_pmu.h" -#include "linux/mali/mali_utgard.h" - -/* Mali PMU power up/down APIs */ - -int mali_pmu_powerup(void) -{ - struct mali_pmu_core *pmu = mali_pmu_get_global_pmu_core(); - - MALI_DEBUG_PRINT(5, ("Mali PMU: Power up\n")); - - if (NULL == pmu) - { - return -ENXIO; - } - - if (_MALI_OSK_ERR_OK != mali_pmu_powerup_all(pmu)) - { - return -EFAULT; - } - - return 0; -} - -EXPORT_SYMBOL(mali_pmu_powerup); - -int mali_pmu_powerdown(void) -{ - struct mali_pmu_core *pmu = mali_pmu_get_global_pmu_core(); - - MALI_DEBUG_PRINT(5, ("Mali PMU: Power down\n")); - - if (NULL == pmu) - { - return -ENXIO; - } - - if (_MALI_OSK_ERR_OK != mali_pmu_powerdown_all(pmu)) - { - return -EFAULT; - } - - return 0; -} - -EXPORT_SYMBOL(mali_pmu_powerdown); diff --git a/drivers/media/video/samsung/mali/linux/mali_profiling_events.h b/drivers/media/video/samsung/mali/linux/mali_profiling_events.h deleted file mode 100644 index 2639a40..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_profiling_events.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (C) 2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef __MALI_PROFILING_EVENTS_H__ -#define __MALI_PROFILING_EVENTS_H__ - -/* Simple wrapper in order to find the OS specific location of this file */ -#include <linux/mali/mali_utgard_profiling_events.h> - -#endif /* __MALI_PROFILING_EVENTS_H__ */ diff --git a/drivers/media/video/samsung/mali/linux/mali_uk_types.h b/drivers/media/video/samsung/mali/linux/mali_uk_types.h deleted file mode 100644 index 1a81246..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_uk_types.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (C) 2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef __MALI_UK_TYPES_H__ -#define __MALI_UK_TYPES_H__ - -/* Simple wrapper in order to find the OS specific location of this file */ -//#include <linux/mali/mali_utgard_uk_types.h> -#include "../include/linux/mali/mali_utgard_uk_types.h" - -#endif /* __MALI_UK_TYPES_H__ */ diff --git a/drivers/media/video/samsung/mali/linux/mali_ukk_core.c b/drivers/media/video/samsung/mali/linux/mali_ukk_core.c deleted file mode 100644 index 22262fe..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_ukk_core.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2010-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include <linux/fs.h> /* file system operations */ -#include <linux/slab.h> /* memort allocation functions */ -#include <asm/uaccess.h> /* user space access */ - -#include "mali_ukk.h" -#include "mali_osk.h" -#include "mali_kernel_common.h" -#include "mali_session.h" -#include "mali_ukk_wrappers.h" - -int get_api_version_wrapper(struct mali_session_data *session_data, _mali_uk_get_api_version_s __user *uargs) -{ - _mali_uk_get_api_version_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - - if (0 != get_user(kargs.version, &uargs->version)) return -EFAULT; - - kargs.ctx = session_data; - err = _mali_ukk_get_api_version(&kargs); - if (_MALI_OSK_ERR_OK != err) return map_errcode(err); - - if (0 != put_user(kargs.version, &uargs->version)) return -EFAULT; - if (0 != put_user(kargs.compatible, &uargs->compatible)) return -EFAULT; - - return 0; -} - -int wait_for_notification_wrapper(struct mali_session_data *session_data, _mali_uk_wait_for_notification_s __user *uargs) -{ - _mali_uk_wait_for_notification_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - - kargs.ctx = session_data; - err = _mali_ukk_wait_for_notification(&kargs); - if (_MALI_OSK_ERR_OK != err) return map_errcode(err); - - if(_MALI_NOTIFICATION_CORE_SHUTDOWN_IN_PROGRESS != kargs.type) - { - kargs.ctx = NULL; /* prevent kernel address to be returned to user space */ - if (0 != copy_to_user(uargs, &kargs, sizeof(_mali_uk_wait_for_notification_s))) return -EFAULT; - } - else - { - if (0 != put_user(kargs.type, &uargs->type)) return -EFAULT; - } - - return 0; -} - -int post_notification_wrapper(struct mali_session_data *session_data, _mali_uk_post_notification_s __user *uargs) -{ - _mali_uk_post_notification_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - - kargs.ctx = session_data; - - if (0 != get_user(kargs.type, &uargs->type)) - { - return -EFAULT; - } - - err = _mali_ukk_post_notification(&kargs); - if (_MALI_OSK_ERR_OK != err) - { - return map_errcode(err); - } - - return 0; -} - -int get_user_settings_wrapper(struct mali_session_data *session_data, _mali_uk_get_user_settings_s __user *uargs) -{ - _mali_uk_get_user_settings_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - - kargs.ctx = session_data; - err = _mali_ukk_get_user_settings(&kargs); - if (_MALI_OSK_ERR_OK != err) - { - return map_errcode(err); - } - - kargs.ctx = NULL; /* prevent kernel address to be returned to user space */ - if (0 != copy_to_user(uargs, &kargs, sizeof(_mali_uk_get_user_settings_s))) return -EFAULT; - - return 0; -} diff --git a/drivers/media/video/samsung/mali/linux/mali_ukk_gp.c b/drivers/media/video/samsung/mali/linux/mali_ukk_gp.c deleted file mode 100644 index 7070016..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_ukk_gp.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2010, 2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include <linux/fs.h> /* file system operations */ -#include <asm/uaccess.h> /* user space access */ - -#include "mali_ukk.h" -#include "mali_osk.h" -#include "mali_kernel_common.h" -#include "mali_session.h" -#include "mali_ukk_wrappers.h" - -int gp_start_job_wrapper(struct mali_session_data *session_data, _mali_uk_gp_start_job_s __user *uargs) -{ - _mali_uk_gp_start_job_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - MALI_CHECK_NON_NULL(session_data, -EINVAL); - - if (!access_ok(VERIFY_WRITE, uargs, sizeof(_mali_uk_gp_start_job_s))) - { - return -EFAULT; - } - - if (0 != copy_from_user(&kargs, uargs, sizeof(_mali_uk_gp_start_job_s))) return -EFAULT; - - kargs.ctx = session_data; - err = _mali_ukk_gp_start_job(&kargs); - if (_MALI_OSK_ERR_OK != err) return map_errcode(err); - - kargs.ctx = NULL; /* prevent kernel address to be returned to user space */ - - if (0 != copy_to_user(uargs, &kargs, sizeof(_mali_uk_gp_start_job_s))) - { - /* - * If this happens, then user space will not know that the job was actually started, - * and if we return a queued job, then user space will still think that one is still queued. - * This will typically lead to a deadlock in user space. - * This could however only happen if user space deliberately passes a user buffer which - * passes the access_ok(VERIFY_WRITE) check, but isn't fully writable at the time of copy_to_user(). - * The official Mali driver will never attempt to do that, and kernel space should not be affected. - * That is why we do not bother to do a complex rollback in this very very very rare case. - */ - return -EFAULT; - } - - return 0; -} - -int gp_get_core_version_wrapper(struct mali_session_data *session_data, _mali_uk_get_gp_core_version_s __user *uargs) -{ - _mali_uk_get_gp_core_version_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - MALI_CHECK_NON_NULL(session_data, -EINVAL); - - kargs.ctx = session_data; - err = _mali_ukk_get_gp_core_version(&kargs); - if (_MALI_OSK_ERR_OK != err) return map_errcode(err); - - /* no known transactions to roll-back */ - - if (0 != put_user(kargs.version, &uargs->version)) return -EFAULT; - - return 0; -} - -int gp_suspend_response_wrapper(struct mali_session_data *session_data, _mali_uk_gp_suspend_response_s __user *uargs) -{ - _mali_uk_gp_suspend_response_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - MALI_CHECK_NON_NULL(session_data, -EINVAL); - - if (0 != copy_from_user(&kargs, uargs, sizeof(_mali_uk_gp_suspend_response_s))) return -EFAULT; - - kargs.ctx = session_data; - err = _mali_ukk_gp_suspend_response(&kargs); - if (_MALI_OSK_ERR_OK != err) return map_errcode(err); - - if (0 != put_user(kargs.cookie, &uargs->cookie)) return -EFAULT; - - /* no known transactions to roll-back */ - return 0; -} - -int gp_get_number_of_cores_wrapper(struct mali_session_data *session_data, _mali_uk_get_gp_number_of_cores_s __user *uargs) -{ - _mali_uk_get_gp_number_of_cores_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - MALI_CHECK_NON_NULL(session_data, -EINVAL); - - kargs.ctx = session_data; - err = _mali_ukk_get_gp_number_of_cores(&kargs); - if (_MALI_OSK_ERR_OK != err) return map_errcode(err); - - /* no known transactions to roll-back */ - - if (0 != put_user(kargs.number_of_cores, &uargs->number_of_cores)) return -EFAULT; - - return 0; -} diff --git a/drivers/media/video/samsung/mali/linux/mali_ukk_mem.c b/drivers/media/video/samsung/mali/linux/mali_ukk_mem.c deleted file mode 100644 index 260f257..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_ukk_mem.c +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (C) 2010-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include <linux/fs.h> /* file system operations */ -#include <asm/uaccess.h> /* user space access */ - -#include "mali_ukk.h" -#include "mali_osk.h" -#include "mali_kernel_common.h" -#include "mali_session.h" -#include "mali_ukk_wrappers.h" - -int mem_init_wrapper(struct mali_session_data *session_data, _mali_uk_init_mem_s __user *uargs) -{ - _mali_uk_init_mem_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - - kargs.ctx = session_data; - err = _mali_ukk_init_mem(&kargs); - if (_MALI_OSK_ERR_OK != err) - { - return map_errcode(err); - } - - if (0 != put_user(kargs.mali_address_base, &uargs->mali_address_base)) goto mem_init_rollback; - if (0 != put_user(kargs.memory_size, &uargs->memory_size)) goto mem_init_rollback; - - return 0; - -mem_init_rollback: - { - _mali_uk_term_mem_s kargs; - kargs.ctx = session_data; - err = _mali_ukk_term_mem(&kargs); - if (_MALI_OSK_ERR_OK != err) - { - MALI_DEBUG_PRINT(4, ("reverting _mali_ukk_init_mem, as a result of failing put_user(), failed\n")); - } - } - return -EFAULT; -} - -int mem_term_wrapper(struct mali_session_data *session_data, _mali_uk_term_mem_s __user *uargs) -{ - _mali_uk_term_mem_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - - kargs.ctx = session_data; - err = _mali_ukk_term_mem(&kargs); - if (_MALI_OSK_ERR_OK != err) - { - return map_errcode(err); - } - - return 0; -} - -int mem_map_ext_wrapper(struct mali_session_data *session_data, _mali_uk_map_external_mem_s __user * argument) -{ - _mali_uk_map_external_mem_s uk_args; - _mali_osk_errcode_t err_code; - - /* validate input */ - /* the session_data pointer was validated by caller */ - MALI_CHECK_NON_NULL( argument, -EINVAL); - - /* get call arguments from user space. copy_from_user returns how many bytes which where NOT copied */ - if ( 0 != copy_from_user(&uk_args, (void __user *)argument, sizeof(_mali_uk_map_external_mem_s)) ) - { - return -EFAULT; - } - - uk_args.ctx = session_data; - err_code = _mali_ukk_map_external_mem( &uk_args ); - - if (0 != put_user(uk_args.cookie, &argument->cookie)) - { - if (_MALI_OSK_ERR_OK == err_code) - { - /* Rollback */ - _mali_uk_unmap_external_mem_s uk_args_unmap; - - uk_args_unmap.ctx = session_data; - uk_args_unmap.cookie = uk_args.cookie; - err_code = _mali_ukk_unmap_external_mem( &uk_args_unmap ); - if (_MALI_OSK_ERR_OK != err_code) - { - MALI_DEBUG_PRINT(4, ("reverting _mali_ukk_unmap_external_mem, as a result of failing put_user(), failed\n")); - } - } - return -EFAULT; - } - - /* Return the error that _mali_ukk_free_big_block produced */ - return map_errcode(err_code); -} - -int mem_unmap_ext_wrapper(struct mali_session_data *session_data, _mali_uk_unmap_external_mem_s __user * argument) -{ - _mali_uk_unmap_external_mem_s uk_args; - _mali_osk_errcode_t err_code; - - /* validate input */ - /* the session_data pointer was validated by caller */ - MALI_CHECK_NON_NULL( argument, -EINVAL); - - /* get call arguments from user space. copy_from_user returns how many bytes which where NOT copied */ - if ( 0 != copy_from_user(&uk_args, (void __user *)argument, sizeof(_mali_uk_unmap_external_mem_s)) ) - { - return -EFAULT; - } - - uk_args.ctx = session_data; - err_code = _mali_ukk_unmap_external_mem( &uk_args ); - - /* Return the error that _mali_ukk_free_big_block produced */ - return map_errcode(err_code); -} - -#if MALI_USE_UNIFIED_MEMORY_PROVIDER != 0 -int mem_release_ump_wrapper(struct mali_session_data *session_data, _mali_uk_release_ump_mem_s __user * argument) -{ - _mali_uk_release_ump_mem_s uk_args; - _mali_osk_errcode_t err_code; - - /* validate input */ - /* the session_data pointer was validated by caller */ - MALI_CHECK_NON_NULL( argument, -EINVAL); - - /* get call arguments from user space. copy_from_user returns how many bytes which where NOT copied */ - if ( 0 != copy_from_user(&uk_args, (void __user *)argument, sizeof(_mali_uk_release_ump_mem_s)) ) - { - return -EFAULT; - } - - uk_args.ctx = session_data; - err_code = _mali_ukk_release_ump_mem( &uk_args ); - - /* Return the error that _mali_ukk_free_big_block produced */ - return map_errcode(err_code); -} - -int mem_attach_ump_wrapper(struct mali_session_data *session_data, _mali_uk_attach_ump_mem_s __user * argument) -{ - _mali_uk_attach_ump_mem_s uk_args; - _mali_osk_errcode_t err_code; - - /* validate input */ - /* the session_data pointer was validated by caller */ - MALI_CHECK_NON_NULL( argument, -EINVAL); - - /* get call arguments from user space. copy_from_user returns how many bytes which where NOT copied */ - if ( 0 != copy_from_user(&uk_args, (void __user *)argument, sizeof(_mali_uk_attach_ump_mem_s)) ) - { - return -EFAULT; - } - - uk_args.ctx = session_data; - err_code = _mali_ukk_attach_ump_mem( &uk_args ); - - if (0 != put_user(uk_args.cookie, &argument->cookie)) - { - if (_MALI_OSK_ERR_OK == err_code) - { - /* Rollback */ - _mali_uk_release_ump_mem_s uk_args_unmap; - - uk_args_unmap.ctx = session_data; - uk_args_unmap.cookie = uk_args.cookie; - err_code = _mali_ukk_release_ump_mem( &uk_args_unmap ); - if (_MALI_OSK_ERR_OK != err_code) - { - MALI_DEBUG_PRINT(4, ("reverting _mali_ukk_attach_mem, as a result of failing put_user(), failed\n")); - } - } - return -EFAULT; - } - - /* Return the error that _mali_ukk_map_external_ump_mem produced */ - return map_errcode(err_code); -} -#endif /* MALI_USE_UNIFIED_MEMORY_PROVIDER */ - -int mem_query_mmu_page_table_dump_size_wrapper(struct mali_session_data *session_data, _mali_uk_query_mmu_page_table_dump_size_s __user * uargs) -{ - _mali_uk_query_mmu_page_table_dump_size_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - MALI_CHECK_NON_NULL(session_data, -EINVAL); - - kargs.ctx = session_data; - - err = _mali_ukk_query_mmu_page_table_dump_size(&kargs); - if (_MALI_OSK_ERR_OK != err) return map_errcode(err); - - if (0 != put_user(kargs.size, &uargs->size)) return -EFAULT; - - return 0; -} - -int mem_dump_mmu_page_table_wrapper(struct mali_session_data *session_data, _mali_uk_dump_mmu_page_table_s __user * uargs) -{ - _mali_uk_dump_mmu_page_table_s kargs; - _mali_osk_errcode_t err; - void *buffer; - int rc = -EFAULT; - - /* validate input */ - MALI_CHECK_NON_NULL(uargs, -EINVAL); - /* the session_data pointer was validated by caller */ - - kargs.buffer = NULL; - - /* get location of user buffer */ - if (0 != get_user(buffer, &uargs->buffer)) goto err_exit; - /* get size of mmu page table info buffer from user space */ - if ( 0 != get_user(kargs.size, &uargs->size) ) goto err_exit; - /* verify we can access the whole of the user buffer */ - if (!access_ok(VERIFY_WRITE, buffer, kargs.size)) goto err_exit; - - /* allocate temporary buffer (kernel side) to store mmu page table info */ - kargs.buffer = _mali_osk_valloc(kargs.size); - if (NULL == kargs.buffer) - { - rc = -ENOMEM; - goto err_exit; - } - - kargs.ctx = session_data; - err = _mali_ukk_dump_mmu_page_table(&kargs); - if (_MALI_OSK_ERR_OK != err) - { - rc = map_errcode(err); - goto err_exit; - } - - /* copy mmu page table info back to user space and update pointers */ - if (0 != copy_to_user(uargs->buffer, kargs.buffer, kargs.size) ) goto err_exit; - if (0 != put_user((kargs.register_writes - (u32 *)kargs.buffer) + (u32 *)uargs->buffer, &uargs->register_writes)) goto err_exit; - if (0 != put_user((kargs.page_table_dump - (u32 *)kargs.buffer) + (u32 *)uargs->buffer, &uargs->page_table_dump)) goto err_exit; - if (0 != put_user(kargs.register_writes_size, &uargs->register_writes_size)) goto err_exit; - if (0 != put_user(kargs.page_table_dump_size, &uargs->page_table_dump_size)) goto err_exit; - rc = 0; - -err_exit: - if (kargs.buffer) _mali_osk_vfree(kargs.buffer); - return rc; -} diff --git a/drivers/media/video/samsung/mali/linux/mali_ukk_pp.c b/drivers/media/video/samsung/mali/linux/mali_ukk_pp.c deleted file mode 100644 index c11c61b..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_ukk_pp.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2010, 2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include <linux/fs.h> /* file system operations */ -#include <asm/uaccess.h> /* user space access */ - -#include "mali_ukk.h" -#include "mali_osk.h" -#include "mali_kernel_common.h" -#include "mali_session.h" -#include "mali_ukk_wrappers.h" - -int pp_start_job_wrapper(struct mali_session_data *session_data, _mali_uk_pp_start_job_s __user *uargs) -{ - _mali_uk_pp_start_job_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - MALI_CHECK_NON_NULL(session_data, -EINVAL); - - if (!access_ok(VERIFY_WRITE, uargs, sizeof(_mali_uk_pp_start_job_s))) - { - return -EFAULT; - } - - if (0 != copy_from_user(&kargs, uargs, sizeof(_mali_uk_pp_start_job_s))) return -EFAULT; - - kargs.ctx = session_data; - err = _mali_ukk_pp_start_job(&kargs); - if (_MALI_OSK_ERR_OK != err) return map_errcode(err); - - return 0; -} - -int pp_get_number_of_cores_wrapper(struct mali_session_data *session_data, _mali_uk_get_pp_number_of_cores_s __user *uargs) -{ - _mali_uk_get_pp_number_of_cores_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - MALI_CHECK_NON_NULL(session_data, -EINVAL); - - kargs.ctx = session_data; - err = _mali_ukk_get_pp_number_of_cores(&kargs); - if (_MALI_OSK_ERR_OK != err) return map_errcode(err); - - if (0 != put_user(kargs.number_of_cores, &uargs->number_of_cores)) return -EFAULT; - - return 0; -} - -int pp_get_core_version_wrapper(struct mali_session_data *session_data, _mali_uk_get_pp_core_version_s __user *uargs) -{ - _mali_uk_get_pp_core_version_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - MALI_CHECK_NON_NULL(session_data, -EINVAL); - - kargs.ctx = session_data; - err = _mali_ukk_get_pp_core_version(&kargs); - if (_MALI_OSK_ERR_OK != err) return map_errcode(err); - - if (0 != put_user(kargs.version, &uargs->version)) return -EFAULT; - - return 0; -} - -int pp_disable_wb_wrapper(struct mali_session_data *session_data, _mali_uk_pp_disable_wb_s __user *uargs) -{ - _mali_uk_pp_disable_wb_s kargs; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - MALI_CHECK_NON_NULL(session_data, -EINVAL); - - if (0 != copy_from_user(&kargs, uargs, sizeof(_mali_uk_pp_disable_wb_s))) return -EFAULT; - - kargs.ctx = session_data; - _mali_ukk_pp_job_disable_wb(&kargs); - - return 0; -} diff --git a/drivers/media/video/samsung/mali/linux/mali_ukk_profiling.c b/drivers/media/video/samsung/mali/linux/mali_ukk_profiling.c deleted file mode 100644 index f4e31c9..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_ukk_profiling.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) 2010-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include <linux/fs.h> /* file system operations */ -#include <asm/uaccess.h> /* user space access */ -#include <linux/slab.h> - -#include "mali_ukk.h" -#include "mali_osk.h" -#include "mali_kernel_common.h" -#include "mali_session.h" -#include "mali_ukk_wrappers.h" - -int profiling_start_wrapper(struct mali_session_data *session_data, _mali_uk_profiling_start_s __user *uargs) -{ - _mali_uk_profiling_start_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - - if (0 != copy_from_user(&kargs, uargs, sizeof(_mali_uk_profiling_start_s))) - { - return -EFAULT; - } - - kargs.ctx = session_data; - err = _mali_ukk_profiling_start(&kargs); - if (_MALI_OSK_ERR_OK != err) - { - return map_errcode(err); - } - - if (0 != put_user(kargs.limit, &uargs->limit)) - { - return -EFAULT; - } - - return 0; -} - -int profiling_add_event_wrapper(struct mali_session_data *session_data, _mali_uk_profiling_add_event_s __user *uargs) -{ - _mali_uk_profiling_add_event_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - - if (0 != copy_from_user(&kargs, uargs, sizeof(_mali_uk_profiling_add_event_s))) - { - return -EFAULT; - } - - kargs.ctx = session_data; - err = _mali_ukk_profiling_add_event(&kargs); - if (_MALI_OSK_ERR_OK != err) - { - return map_errcode(err); - } - - return 0; -} - -int profiling_stop_wrapper(struct mali_session_data *session_data, _mali_uk_profiling_stop_s __user *uargs) -{ - _mali_uk_profiling_stop_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - - kargs.ctx = session_data; - err = _mali_ukk_profiling_stop(&kargs); - if (_MALI_OSK_ERR_OK != err) - { - return map_errcode(err); - } - - if (0 != put_user(kargs.count, &uargs->count)) - { - return -EFAULT; - } - - return 0; -} - -int profiling_get_event_wrapper(struct mali_session_data *session_data, _mali_uk_profiling_get_event_s __user *uargs) -{ - _mali_uk_profiling_get_event_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - - if (0 != get_user(kargs.index, &uargs->index)) - { - return -EFAULT; - } - - kargs.ctx = session_data; - - err = _mali_ukk_profiling_get_event(&kargs); - if (_MALI_OSK_ERR_OK != err) - { - return map_errcode(err); - } - - kargs.ctx = NULL; /* prevent kernel address to be returned to user space */ - if (0 != copy_to_user(uargs, &kargs, sizeof(_mali_uk_profiling_get_event_s))) - { - return -EFAULT; - } - - return 0; -} - -int profiling_clear_wrapper(struct mali_session_data *session_data, _mali_uk_profiling_clear_s __user *uargs) -{ - _mali_uk_profiling_clear_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - - kargs.ctx = session_data; - err = _mali_ukk_profiling_clear(&kargs); - if (_MALI_OSK_ERR_OK != err) - { - return map_errcode(err); - } - - return 0; -} - -int profiling_report_sw_counters_wrapper(struct mali_session_data *session_data, _mali_uk_sw_counters_report_s __user *uargs) -{ - _mali_uk_sw_counters_report_s kargs; - _mali_osk_errcode_t err; - u32 *counter_buffer; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - - if (0 != copy_from_user(&kargs, uargs, sizeof(_mali_uk_sw_counters_report_s))) - { - return -EFAULT; - } - - /* make sure that kargs.num_counters is [at least somewhat] sane */ - if (kargs.num_counters > 10000) { - MALI_DEBUG_PRINT(1, ("User space attempted to allocate too many counters.\n")); - return -EINVAL; - } - - counter_buffer = (u32*)kmalloc(sizeof(u32) * kargs.num_counters, GFP_KERNEL); - if (NULL == counter_buffer) - { - return -ENOMEM; - } - - if (0 != copy_from_user(counter_buffer, kargs.counters, sizeof(u32) * kargs.num_counters)) - { - kfree(counter_buffer); - return -EFAULT; - } - - kargs.ctx = session_data; - kargs.counters = counter_buffer; - - err = _mali_ukk_sw_counters_report(&kargs); - - kfree(counter_buffer); - - if (_MALI_OSK_ERR_OK != err) - { - return map_errcode(err); - } - - return 0; -} - - diff --git a/drivers/media/video/samsung/mali/linux/mali_ukk_vsync.c b/drivers/media/video/samsung/mali/linux/mali_ukk_vsync.c deleted file mode 100644 index f9b5a3e..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_ukk_vsync.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2011-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include <linux/fs.h> /* file system operations */ -#include <asm/uaccess.h> /* user space access */ - -#include "mali_ukk.h" -#include "mali_osk.h" -#include "mali_kernel_common.h" -#include "mali_session.h" -#include "mali_ukk_wrappers.h" - - -int vsync_event_report_wrapper(struct mali_session_data *session_data, _mali_uk_vsync_event_report_s __user *uargs) -{ - _mali_uk_vsync_event_report_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - - if (0 != copy_from_user(&kargs, uargs, sizeof(_mali_uk_vsync_event_report_s))) - { - return -EFAULT; - } - - kargs.ctx = session_data; - err = _mali_ukk_vsync_event_report(&kargs); - if (_MALI_OSK_ERR_OK != err) - { - return map_errcode(err); - } - - return 0; -} - diff --git a/drivers/media/video/samsung/mali/linux/mali_ukk_wrappers.h b/drivers/media/video/samsung/mali/linux/mali_ukk_wrappers.h deleted file mode 100644 index 65857fd..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_ukk_wrappers.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2010-2012 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. - * - * A copy of the licence is included with the program, and can also be obtained from Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * @file mali_ukk_wrappers.h - * Defines the wrapper functions for each user-kernel function - */ - -#ifndef __MALI_UKK_WRAPPERS_H__ -#define __MALI_UKK_WRAPPERS_H__ - -#include "mali_uk_types.h" -#include "mali_osk.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -int wait_for_notification_wrapper(struct mali_session_data *session_data, _mali_uk_wait_for_notification_s __user *uargs); -int get_api_version_wrapper(struct mali_session_data *session_data, _mali_uk_get_api_version_s __user *uargs); -int get_user_settings_wrapper(struct mali_session_data *session_data, _mali_uk_get_user_settings_s __user *uargs); -int post_notification_wrapper(struct mali_session_data *session_data, _mali_uk_post_notification_s __user *uargs); -int mem_init_wrapper(struct mali_session_data *session_data, _mali_uk_init_mem_s __user *uargs); -int mem_term_wrapper(struct mali_session_data *session_data, _mali_uk_term_mem_s __user *uargs); -int mem_map_ext_wrapper(struct mali_session_data *session_data, _mali_uk_map_external_mem_s __user * argument); -int mem_unmap_ext_wrapper(struct mali_session_data *session_data, _mali_uk_unmap_external_mem_s __user * argument); -int mem_query_mmu_page_table_dump_size_wrapper(struct mali_session_data *session_data, _mali_uk_query_mmu_page_table_dump_size_s __user * uargs); -int mem_dump_mmu_page_table_wrapper(struct mali_session_data *session_data, _mali_uk_dump_mmu_page_table_s __user * uargs); - -#if MALI_USE_UNIFIED_MEMORY_PROVIDER != 0 -int mem_attach_ump_wrapper(struct mali_session_data *session_data, _mali_uk_attach_ump_mem_s __user * argument); -int mem_release_ump_wrapper(struct mali_session_data *session_data, _mali_uk_release_ump_mem_s __user * argument); -#endif /* MALI_USE_UNIFIED_MEMORY_PROVIDER */ - -int pp_start_job_wrapper(struct mali_session_data *session_data, _mali_uk_pp_start_job_s __user *uargs); -int pp_get_number_of_cores_wrapper(struct mali_session_data *session_data, _mali_uk_get_pp_number_of_cores_s __user *uargs); -int pp_get_core_version_wrapper(struct mali_session_data *session_data, _mali_uk_get_pp_core_version_s __user *uargs); -int pp_disable_wb_wrapper(struct mali_session_data *session_data, _mali_uk_pp_disable_wb_s __user *uargs); -int gp_start_job_wrapper(struct mali_session_data *session_data, _mali_uk_gp_start_job_s __user *uargs); -int gp_get_number_of_cores_wrapper(struct mali_session_data *session_data, _mali_uk_get_gp_number_of_cores_s __user *uargs); -int gp_get_core_version_wrapper(struct mali_session_data *session_data, _mali_uk_get_gp_core_version_s __user *uargs); -int gp_suspend_response_wrapper(struct mali_session_data *session_data, _mali_uk_gp_suspend_response_s __user *uargs); - -int profiling_start_wrapper(struct mali_session_data *session_data, _mali_uk_profiling_start_s __user *uargs); -int profiling_add_event_wrapper(struct mali_session_data *session_data, _mali_uk_profiling_add_event_s __user *uargs); -int profiling_stop_wrapper(struct mali_session_data *session_data, _mali_uk_profiling_stop_s __user *uargs); -int profiling_get_event_wrapper(struct mali_session_data *session_data, _mali_uk_profiling_get_event_s __user *uargs); -int profiling_clear_wrapper(struct mali_session_data *session_data, _mali_uk_profiling_clear_s __user *uargs); -int profiling_report_sw_counters_wrapper(struct mali_session_data *session_data, _mali_uk_sw_counters_report_s __user *uargs); - -int vsync_event_report_wrapper(struct mali_session_data *session_data, _mali_uk_vsync_event_report_s __user *uargs); - - -int map_errcode( _mali_osk_errcode_t err ); - -#ifdef __cplusplus -} -#endif - -#endif /* __MALI_UKK_WRAPPERS_H__ */ |