From 3536d5c6bfd05e861b3b430d4de36fdf31afa5e1 Mon Sep 17 00:00:00 2001 From: codeworkx Date: Sat, 23 Feb 2013 01:33:12 +0000 Subject: mali: update to r3p1-01rel1 Change-Id: I38a5488af2f2a64e2851826cdbc475ef5727c965 --- drivers/media/video/samsung/mali/Kbuild_module | 288 +++++++++++++++ drivers/media/video/samsung/mali/Kconfig_module | 30 ++ drivers/media/video/samsung/mali/Makefile | 52 +-- drivers/media/video/samsung/mali/Makefile_module | 12 +- .../samsung/mali/arch-pb-virtex5-m300/config.h | 0 .../mali/arch-pb-virtex5-m400-1-pmu/config.h | 2 +- .../video/samsung/mali/arch-pegasus-m400/config.h | 0 .../samsung/mali/arch-ve-virtex6-m450-8/config.h | 6 + .../samsung/mali/common/mali_block_allocator.c | 0 .../samsung/mali/common/mali_block_allocator.h | 2 +- .../samsung/mali/common/mali_device_pause_resume.c | 0 .../samsung/mali/common/mali_device_pause_resume.h | 0 drivers/media/video/samsung/mali/common/mali_gp.c | 98 +++++- drivers/media/video/samsung/mali/common/mali_gp.h | 0 .../media/video/samsung/mali/common/mali_gp_job.c | 18 +- .../media/video/samsung/mali/common/mali_gp_job.h | 38 +- .../video/samsung/mali/common/mali_gp_scheduler.c | 27 +- .../video/samsung/mali/common/mali_gp_scheduler.h | 0 .../media/video/samsung/mali/common/mali_group.c | 2 +- .../media/video/samsung/mali/common/mali_group.h | 2 +- .../media/video/samsung/mali/common/mali_hw_core.c | 0 .../media/video/samsung/mali/common/mali_hw_core.h | 33 ++ .../video/samsung/mali/common/mali_kernel_common.h | 10 - .../video/samsung/mali/common/mali_kernel_core.c | 216 +----------- .../video/samsung/mali/common/mali_kernel_core.h | 1 - .../mali/common/mali_kernel_descriptor_mapping.c | 0 .../mali/common/mali_kernel_descriptor_mapping.h | 0 .../video/samsung/mali/common/mali_kernel_mem_os.c | 6 +- .../video/samsung/mali/common/mali_kernel_mem_os.h | 2 +- .../mali/common/mali_kernel_memory_engine.c | 3 +- .../mali/common/mali_kernel_memory_engine.h | 1 + .../samsung/mali/common/mali_kernel_utilization.c | 0 .../samsung/mali/common/mali_kernel_utilization.h | 0 .../video/samsung/mali/common/mali_l2_cache.c | 28 +- .../samsung/mali/common/mali_mem_validation.h | 0 .../media/video/samsung/mali/common/mali_memory.c | 118 +++---- .../media/video/samsung/mali/common/mali_memory.h | 2 + .../samsung/mali/common/mali_mmu_page_directory.c | 20 +- .../samsung/mali/common/mali_mmu_page_directory.h | 21 +- drivers/media/video/samsung/mali/common/mali_osk.h | 11 - .../video/samsung/mali/common/mali_osk_bitops.h | 2 +- .../video/samsung/mali/common/mali_osk_list.h | 2 +- .../video/samsung/mali/common/mali_osk_mali.h | 0 .../video/samsung/mali/common/mali_osk_profiling.h | 22 +- drivers/media/video/samsung/mali/common/mali_pm.c | 21 +- drivers/media/video/samsung/mali/common/mali_pm.h | 0 drivers/media/video/samsung/mali/common/mali_pp.c | 121 +++++-- drivers/media/video/samsung/mali/common/mali_pp.h | 0 .../media/video/samsung/mali/common/mali_pp_job.c | 56 +-- .../media/video/samsung/mali/common/mali_pp_job.h | 109 +++--- .../video/samsung/mali/common/mali_pp_scheduler.c | 332 +++++++++-------- .../video/samsung/mali/common/mali_pp_scheduler.h | 1 + .../video/samsung/mali/common/mali_scheduler.c | 1 + .../video/samsung/mali/common/mali_scheduler.h | 0 .../media/video/samsung/mali/common/mali_session.h | 2 +- drivers/media/video/samsung/mali/common/mali_ukk.h | 61 +--- .../samsung/mali/common/mali_user_settings_db.c | 2 +- .../samsung/mali/common/mali_user_settings_db.h | 0 .../mali/include/linux/mali/mali_utgard_ioctl.h | 14 +- .../linux/mali/mali_utgard_profiling_events.h | 74 ++-- .../mali/include/linux/mali/mali_utgard_uk_types.h | 158 ++++----- .../mali/linux/license/gpl/mali_kernel_license.h | 2 +- .../media/video/samsung/mali/linux/mali_dma_buf.c | 392 +++++++++++++++++++++ .../media/video/samsung/mali/linux/mali_dma_buf.h | 29 ++ .../video/samsung/mali/linux/mali_kernel_ioctl.h | 78 ---- .../video/samsung/mali/linux/mali_kernel_linux.c | 159 +++------ .../video/samsung/mali/linux/mali_kernel_linux.h | 0 .../video/samsung/mali/linux/mali_kernel_pm.c | 2 +- .../video/samsung/mali/linux/mali_kernel_pm.h | 0 .../video/samsung/mali/linux/mali_kernel_sysfs.c | 34 +- .../video/samsung/mali/linux/mali_kernel_sysfs.h | 7 +- .../media/video/samsung/mali/linux/mali_linux_pm.h | 0 .../samsung/mali/linux/mali_linux_pm_testsuite.h | 0 .../video/samsung/mali/linux/mali_linux_trace.h | 1 + .../video/samsung/mali/linux/mali_osk_atomics.c | 2 +- .../video/samsung/mali/linux/mali_osk_indir_mmap.c | 86 ----- .../video/samsung/mali/linux/mali_osk_indir_mmap.h | 48 --- .../video/samsung/mali/linux/mali_osk_locks.c | 33 +- .../samsung/mali/linux/mali_osk_low_level_mem.c | 88 ++++- .../media/video/samsung/mali/linux/mali_osk_mali.c | 1 - .../media/video/samsung/mali/linux/mali_osk_math.c | 2 +- .../video/samsung/mali/linux/mali_osk_memory.c | 2 +- .../media/video/samsung/mali/linux/mali_osk_misc.c | 0 .../samsung/mali/linux/mali_osk_notification.c | 43 +-- .../media/video/samsung/mali/linux/mali_osk_pm.c | 1 - .../video/samsung/mali/linux/mali_osk_profiling.c | 261 ++++++++++++++ .../samsung/mali/linux/mali_osk_profiling_gator.c | 262 -------------- .../mali/linux/mali_osk_profiling_internal.c | 308 ---------------- .../video/samsung/mali/linux/mali_osk_specific.h | 14 +- .../media/video/samsung/mali/linux/mali_osk_time.c | 2 +- .../video/samsung/mali/linux/mali_osk_timers.c | 0 .../samsung/mali/linux/mali_profiling_internal.c | 294 ++++++++++++++++ .../samsung/mali/linux/mali_profiling_internal.h | 36 ++ .../media/video/samsung/mali/linux/mali_uk_types.h | 4 +- .../media/video/samsung/mali/linux/mali_ukk_core.c | 58 --- .../media/video/samsung/mali/linux/mali_ukk_gp.c | 37 +- .../media/video/samsung/mali/linux/mali_ukk_mem.c | 0 .../media/video/samsung/mali/linux/mali_ukk_pp.c | 13 +- .../video/samsung/mali/linux/mali_ukk_profiling.c | 1 + .../video/samsung/mali/linux/mali_ukk_vsync.c | 0 .../video/samsung/mali/linux/mali_ukk_wrappers.h | 3 +- .../samsung/mali/platform/default/mali_platform.c | 2 +- .../video/samsung/mali/platform/mali_platform.h | 2 + .../mali/platform/orion-m400/mali_platform.c | 0 .../mali/platform/orion-m400/mali_platform_dvfs.c | 2 +- .../mali/platform/pegasus-m400/mali_platform.c | 1 + .../platform/pegasus-m400/mali_platform_dvfs.c | 23 +- drivers/media/video/samsung/mali/readme.txt | 28 -- .../media/video/samsung/mali/regs/mali_gp_regs.h | 2 - .../mali/timestamp-arm11-cc/mali_timestamp.c | 2 +- .../mali/timestamp-arm11-cc/mali_timestamp.h | 2 +- .../mali/timestamp-default/mali_timestamp.c | 2 +- .../mali/timestamp-default/mali_timestamp.h | 2 +- drivers/media/video/samsung/ump/Kconfig | 13 +- drivers/media/video/samsung/ump/Kconfig_module | 16 + drivers/media/video/samsung/ump/Makefile | 28 +- drivers/media/video/samsung/ump/Makefile.common | 6 +- drivers/media/video/samsung/ump/Makefile_module | 119 ------- .../video/samsung/ump/arch-orion-m400/config.h | 12 +- .../video/samsung/ump/arch-pb-virtex5/config.h | 2 +- .../video/samsung/ump/arch-pegasus-m400/config.h | 12 +- .../video/samsung/ump/common/ump_kernel_api.c | 23 +- .../video/samsung/ump/common/ump_kernel_common.c | 28 +- .../video/samsung/ump/common/ump_kernel_common.h | 4 +- .../ump/common/ump_kernel_descriptor_mapping.c | 33 +- .../ump/common/ump_kernel_descriptor_mapping.h | 4 +- .../samsung/ump/common/ump_kernel_memory_backend.h | 7 +- .../video/samsung/ump/common/ump_kernel_ref_drv.c | 68 +--- .../video/samsung/ump/common/ump_kernel_types.h | 4 +- drivers/media/video/samsung/ump/common/ump_osk.h | 6 +- drivers/media/video/samsung/ump/common/ump_ukk.h | 4 +- .../samsung/ump/include/ump_kernel_interface.h | 4 +- .../ump/include/ump_kernel_interface_ref_drv.h | 8 +- .../samsung/ump/include/ump_kernel_interface_vcm.h | 37 -- .../samsung/ump/include/ump_kernel_platform.h | 4 +- .../ump/linux/license/gpl/ump_kernel_license.h | 6 +- drivers/media/video/samsung/ump/linux/ump_ioctl.h | 5 +- .../video/samsung/ump/linux/ump_kernel_linux.c | 17 +- .../video/samsung/ump/linux/ump_kernel_linux.h | 6 +- .../linux/ump_kernel_memory_backend_dedicated.c | 6 +- .../linux/ump_kernel_memory_backend_dedicated.h | 7 +- .../ump/linux/ump_kernel_memory_backend_os.c | 9 +- .../ump/linux/ump_kernel_memory_backend_os.h | 7 +- .../ump/linux/ump_kernel_memory_backend_vcm.c | 290 --------------- .../ump/linux/ump_kernel_memory_backend_vcm.h | 22 -- .../video/samsung/ump/linux/ump_memory_backend.c | 13 +- .../video/samsung/ump/linux/ump_osk_atomics.c | 6 +- .../samsung/ump/linux/ump_osk_low_level_mem.c | 132 +------ .../media/video/samsung/ump/linux/ump_osk_misc.c | 6 +- .../video/samsung/ump/linux/ump_ukk_ref_wrappers.c | 6 +- .../video/samsung/ump/linux/ump_ukk_ref_wrappers.h | 6 +- .../video/samsung/ump/linux/ump_ukk_wrappers.c | 4 +- .../video/samsung/ump/linux/ump_ukk_wrappers.h | 8 +- 153 files changed, 2562 insertions(+), 2834 deletions(-) create mode 100644 drivers/media/video/samsung/mali/Kbuild_module create mode 100644 drivers/media/video/samsung/mali/Kconfig_module mode change 100755 => 100644 drivers/media/video/samsung/mali/Makefile_module mode change 100755 => 100644 drivers/media/video/samsung/mali/arch-pb-virtex5-m300/config.h mode change 100755 => 100644 drivers/media/video/samsung/mali/arch-pegasus-m400/config.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_block_allocator.c mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_block_allocator.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_device_pause_resume.c mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_device_pause_resume.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_gp.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_gp_scheduler.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_hw_core.c mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_hw_core.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_kernel_core.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_kernel_descriptor_mapping.c mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_kernel_descriptor_mapping.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_kernel_mem_os.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_kernel_memory_engine.c mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_kernel_memory_engine.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_kernel_utilization.c mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_kernel_utilization.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_mem_validation.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_osk_bitops.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_osk_list.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_osk_mali.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_pm.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_pp.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_pp_scheduler.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_scheduler.c mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_scheduler.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_session.h mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_user_settings_db.c mode change 100755 => 100644 drivers/media/video/samsung/mali/common/mali_user_settings_db.h mode change 100755 => 100644 drivers/media/video/samsung/mali/linux/license/gpl/mali_kernel_license.h create mode 100644 drivers/media/video/samsung/mali/linux/mali_dma_buf.c create mode 100644 drivers/media/video/samsung/mali/linux/mali_dma_buf.h delete mode 100755 drivers/media/video/samsung/mali/linux/mali_kernel_ioctl.h mode change 100755 => 100644 drivers/media/video/samsung/mali/linux/mali_kernel_linux.h mode change 100755 => 100644 drivers/media/video/samsung/mali/linux/mali_kernel_pm.h mode change 100755 => 100644 drivers/media/video/samsung/mali/linux/mali_kernel_sysfs.h mode change 100755 => 100644 drivers/media/video/samsung/mali/linux/mali_linux_pm.h mode change 100755 => 100644 drivers/media/video/samsung/mali/linux/mali_linux_pm_testsuite.h mode change 100755 => 100644 drivers/media/video/samsung/mali/linux/mali_osk_atomics.c delete mode 100755 drivers/media/video/samsung/mali/linux/mali_osk_indir_mmap.c delete mode 100755 drivers/media/video/samsung/mali/linux/mali_osk_indir_mmap.h mode change 100755 => 100644 drivers/media/video/samsung/mali/linux/mali_osk_math.c mode change 100755 => 100644 drivers/media/video/samsung/mali/linux/mali_osk_memory.c mode change 100755 => 100644 drivers/media/video/samsung/mali/linux/mali_osk_misc.c mode change 100755 => 100644 drivers/media/video/samsung/mali/linux/mali_osk_notification.c create mode 100644 drivers/media/video/samsung/mali/linux/mali_osk_profiling.c delete mode 100644 drivers/media/video/samsung/mali/linux/mali_osk_profiling_gator.c delete mode 100644 drivers/media/video/samsung/mali/linux/mali_osk_profiling_internal.c mode change 100755 => 100644 drivers/media/video/samsung/mali/linux/mali_osk_specific.h mode change 100755 => 100644 drivers/media/video/samsung/mali/linux/mali_osk_time.c mode change 100755 => 100644 drivers/media/video/samsung/mali/linux/mali_osk_timers.c create mode 100644 drivers/media/video/samsung/mali/linux/mali_profiling_internal.c create mode 100644 drivers/media/video/samsung/mali/linux/mali_profiling_internal.h mode change 100755 => 100644 drivers/media/video/samsung/mali/linux/mali_ukk_gp.c mode change 100755 => 100644 drivers/media/video/samsung/mali/linux/mali_ukk_mem.c mode change 100755 => 100644 drivers/media/video/samsung/mali/linux/mali_ukk_vsync.c mode change 100755 => 100644 drivers/media/video/samsung/mali/platform/default/mali_platform.c mode change 100755 => 100644 drivers/media/video/samsung/mali/platform/orion-m400/mali_platform.c mode change 100755 => 100644 drivers/media/video/samsung/mali/platform/orion-m400/mali_platform_dvfs.c delete mode 100755 drivers/media/video/samsung/mali/readme.txt mode change 100755 => 100644 drivers/media/video/samsung/mali/timestamp-arm11-cc/mali_timestamp.c mode change 100755 => 100644 drivers/media/video/samsung/mali/timestamp-arm11-cc/mali_timestamp.h mode change 100755 => 100644 drivers/media/video/samsung/mali/timestamp-default/mali_timestamp.c mode change 100755 => 100644 drivers/media/video/samsung/mali/timestamp-default/mali_timestamp.h create mode 100644 drivers/media/video/samsung/ump/Kconfig_module mode change 100755 => 100644 drivers/media/video/samsung/ump/Makefile.common delete mode 100755 drivers/media/video/samsung/ump/Makefile_module mode change 100755 => 100644 drivers/media/video/samsung/ump/arch-pb-virtex5/config.h mode change 100755 => 100644 drivers/media/video/samsung/ump/arch-pegasus-m400/config.h mode change 100755 => 100644 drivers/media/video/samsung/ump/common/ump_kernel_descriptor_mapping.c mode change 100755 => 100644 drivers/media/video/samsung/ump/common/ump_kernel_descriptor_mapping.h delete mode 100644 drivers/media/video/samsung/ump/include/ump_kernel_interface_vcm.h mode change 100755 => 100644 drivers/media/video/samsung/ump/linux/license/gpl/ump_kernel_license.h mode change 100755 => 100644 drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_dedicated.h mode change 100755 => 100644 drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_os.h delete mode 100644 drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_vcm.c delete mode 100644 drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_vcm.h mode change 100755 => 100644 drivers/media/video/samsung/ump/linux/ump_osk_atomics.c mode change 100755 => 100644 drivers/media/video/samsung/ump/linux/ump_osk_misc.c (limited to 'drivers/media') diff --git a/drivers/media/video/samsung/mali/Kbuild_module b/drivers/media/video/samsung/mali/Kbuild_module new file mode 100644 index 0000000..d861b72 --- /dev/null +++ b/drivers/media/video/samsung/mali/Kbuild_module @@ -0,0 +1,288 @@ +# +# Copyright (C) 2010-2011 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. +# + +# This file is called by the Linux build system. + +OSKOS=linux + +# set up defaults if not defined by the user +USING_UMP ?= 0 +USING_OS_MEMORY ?= 0 +USING_MALI_PMM_TESTSUITE ?= 0 +OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB ?= 6 +USING_PROFILING ?= 1 +USING_INTERNAL_PROFILING ?= 0 +DISABLE_PP0 ?= 0 +DISABLE_PP1 ?= 0 +DISABLE_PP2 ?= 0 +DISABLE_PP3 ?= 0 +TIMESTAMP ?= default +BUILD ?= debug +TARGET_PLATFORM ?= default +KERNEL_RUNTIME_PM_ENABLED ?= 0 +CONFIG ?= pb-virtex5-m200 +MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP ?= 0 +MALI_PP_SCHEDULER_KEEP_SUB_JOB_STARTS_ALIGNED ?= 0 +MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP_BETWEEN_APPS ?= 0 + +DEFINES := $(EXTRA_DEFINES) + +# Get path to driver source from Linux build system +DRIVER_DIR=$(src) + +# For customer releases the Linux Device Drivers will be provided as ARM proprietary and GPL releases: +# The ARM proprietary product will only include the license/proprietary directory +# The GPL product will only include the license/gpl directory + +ifeq ($(wildcard $(DRIVER_DIR)/linux/license/gpl/*),) +ccflags-y += -I$(DRIVER_DIR)/linux/license/proprietary +# Disable profiling for proprietary +override USING_PROFILING := 0 +$(warning "USING_PROFILING not supported, disabling.") +else +ccflags-y += -I$(DRIVER_DIR)/linux/license/gpl +endif + + +ifeq ($(USING_PROFILING),1) +ifeq ($(USING_INTERNAL_PROFILING),0) +ifndef CONFIG_TRACEPOINTS +# Should default to gator profiling, but we dont have the kernel feature required, so disable profiling +override USING_PROFILING = 0 +$(warning "CONFIG_TRACEPOINTS required for USING_PROFILING") +endif +endif +endif + +ifeq ($(USING_PROFILING),0) +# make sure user hasnt selected incompatible flags +override USING_INTERNAL_PROFILING = 0 +endif + +MALI_RELEASE_NAME=$(shell cat $(DRIVER_DIR)/.version 2> /dev/null) + +# Check if a Mali Core sub module should be enabled, true or false returned +submodule_enabled = $(shell gcc $(DEFINES) -E $1/arch/config.h | grep type | grep -c $(2)) + +OSKFILES = \ + $(OSKOS)/mali_osk_atomics.c \ + $(OSKOS)/mali_osk_irq.c \ + $(OSKOS)/mali_osk_locks.c \ + $(OSKOS)/mali_osk_wait_queue.c \ + $(OSKOS)/mali_osk_low_level_mem.c \ + $(OSKOS)/mali_osk_math.c \ + $(OSKOS)/mali_osk_memory.c \ + $(OSKOS)/mali_osk_misc.c \ + $(OSKOS)/mali_osk_mali.c \ + $(OSKOS)/mali_osk_notification.c \ + $(OSKOS)/mali_osk_time.c \ + $(OSKOS)/mali_osk_timers.c + +UKKFILES = \ + $(OSKOS)/mali_ukk_mem.c \ + $(OSKOS)/mali_ukk_gp.c \ + $(OSKOS)/mali_ukk_pp.c \ + $(OSKOS)/mali_ukk_core.c + +ifeq ($(USING_PROFILING),1) +UKKFILES += \ + $(OSKOS)/mali_ukk_profiling.c +endif + +ifeq ($(MALI_PLATFORM_FILE),) +MALI_PLATFORM_FILE = platform/default/mali_platform.c +endif + +# Get subversion revision number, fall back to only ${MALI_RELEASE_NAME} if no svn info is available +SVN_REV := $(shell (cd $(DRIVER_DIR); (svnversion | grep -E "^[0-9]+" && svnversion) || git svn info | grep '^Revision: '| sed -e 's/^Revision: //' ) 2>/dev/null ) +ifeq ($(SVN_REV),) +SVN_REV := $(MALI_RELEASE_NAME) +else +SVN_REV := $(MALI_RELEASE_NAME)-r$(SVN_REV) +endif + +# Validate selected config +ifneq ($(shell [ -d $(DRIVER_DIR)/arch-$(CONFIG) ] && [ -f $(DRIVER_DIR)/arch-$(CONFIG)/config.h ] && echo "OK"), OK) +$(warning Current directory is $(shell pwd)) +$(error No configuration found for config $(CONFIG). Check that arch-$(CONFIG)/config.h exists) +else +# Link arch to the selected arch-config directory +$(shell [ -L $(DRIVER_DIR)/arch ] && rm $(DRIVER_DIR)/arch) +$(shell ln -sf arch-$(CONFIG) $(DRIVER_DIR)/arch) +$(shell touch $(DRIVER_DIR)/arch/config.h) +endif + +# Set up our defines, which will be passed to gcc +DEFINES += -DUSING_OS_MEMORY=$(USING_OS_MEMORY) +DEFINES += -DUSING_MMU=1 +DEFINES += -DUSING_UMP=$(USING_UMP) +DEFINES += -D_MALI_OSK_SPECIFIC_INDIRECT_MMAP +DEFINES += -DMALI_INTERNAL_TIMELINE_PROFILING_ENABLED=$(USING_INTERNAL_PROFILING) +DEFINES += -DDISABLE_PP0=$(DISABLE_PP0) +DEFINES += -DDISABLE_PP1=$(DISABLE_PP1) +DEFINES += -DDISABLE_PP2=$(DISABLE_PP2) +DEFINES += -DDISABLE_PP3=$(DISABLE_PP3) +DEFINES += -DMALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP=$(MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP) +DEFINES += -DMALI_PP_SCHEDULER_KEEP_SUB_JOB_STARTS_ALIGNED=$(MALI_PP_SCHEDULER_KEEP_SUB_JOB_STARTS_ALIGNED) +DEFINES += -DMALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP_BETWEEN_APPS=$(MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP_BETWEEN_APPS) +DEFINES += -DMALI_TIMELINE_PROFILING_ENABLED=$(USING_PROFILING) +DEFINES += -DMALI_POWER_MGMT_TEST_SUITE=$(USING_MALI_PMM_TESTSUITE) +ifeq ($(shell test $(SUBLEVEL) -gt 32 -a $(PATCHLEVEL) = 6 -a $(VERSION) = 2 -o $(VERSION) -gt 2 && echo "OK"),OK) +# MALI_STATE_TRACKING is only supported on Linux kernels from version 2.6.32. +DEFINES += -DMALI_STATE_TRACKING=1 +else +DEFINES += -DMALI_STATE_TRACKING=0 +endif +DEFINES += -DMALI_OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB=$(OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB) + +MALI_PLATFORM_FILE = platform/$(TARGET_PLATFORM)/mali_platform.c + + +ifdef CONFIG_PM +ifdef CONFIG_PM_RUNTIME + KERNEL_RUNTIME_PM_ENABLED = 1 +endif +endif + +DEFINES += -DMALI_PMM_RUNTIME_JOB_CONTROL_ON=$(KERNEL_RUNTIME_PM_ENABLED) + +ifeq ($(BUILD), debug) +DEFINES += -DDEBUG +endif +DEFINES += -DSVN_REV=$(SVN_REV) +DEFINES += -DSVN_REV_STRING=\"$(SVN_REV)\" + +# Linux has its own mmap cleanup handlers (see mali_kernel_memory.c) +DEFINES += -DMALI_UKK_HAS_IMPLICIT_MMAP_CLEANUP + +ifeq ($(USING_UMP),1) + DEFINES += -DMALI_USE_UNIFIED_MEMORY_PROVIDER=1 + ccflags-y += -I$(DRIVER_DIR)/../../ump/include/ump +else + DEFINES += -DMALI_USE_UNIFIED_MEMORY_PROVIDER=0 +endif + +# Use our defines when compiling +ccflags-y += $(DEFINES) -I$(DRIVER_DIR) -I$(DRIVER_DIR)/include -I$(DRIVER_DIR)/common -I$(DRIVER_DIR)/linux -I$(DRIVER_DIR)/platform + +# Source files which always are included in a build +SRC = \ + common/mali_kernel_core.c \ + linux/mali_kernel_linux.c \ + common/mali_kernel_descriptor_mapping.c \ + common/mali_session.c \ + common/mali_device_pause_resume.c \ + common/mali_kernel_vsync.c \ + linux/mali_ukk_vsync.c \ + linux/mali_kernel_sysfs.c \ + common/mali_mmu.c \ + common/mali_mmu_page_directory.c \ + common/mali_memory.c \ + common/mali_kernel_memory_engine.c \ + common/mali_block_allocator.c \ + common/mali_kernel_mem_os.c \ + common/mali_mem_validation.c \ + common/mali_hw_core.c \ + common/mali_gp.c \ + common/mali_pp.c \ + common/mali_pp_job.c \ + common/mali_gp_job.c \ + common/mali_scheduler.c \ + common/mali_gp_scheduler.c \ + common/mali_pp_scheduler.c \ + common/mali_cluster.c \ + common/mali_group.c \ + common/mali_dlbu.c \ + common/mali_pm.c \ + common/mali_pmu.c \ + common/mali_user_settings_db.c \ + $(OSKOS)/mali_osk_pm.c \ + linux/mali_kernel_pm.c \ + linux/mali_pmu_power_up_down.c \ + $(MALI_PLATFORM_FILE) \ + $(OSKFILES) \ + $(UKKFILES) \ + __malidrv_build_info.c + +# Selecting files to compile by parsing the config file + +ifeq ($(USING_INTERNAL_PROFILING),1) +PROFILING_BACKEND_SOURCES = \ + linux/mali_osk_profiling_internal.c \ + timestamp-$(TIMESTAMP)/mali_timestamp.c +ccflags-y += -I$(DRIVER_DIR)/timestamp-$(TIMESTAMP) +else +ifeq ($(USING_PROFILING),1) +PROFILING_BACKEND_SOURCES = \ + linux/mali_osk_profiling_gator.c +endif +endif + +# Add the profiling sources +SRC += $(PROFILING_BACKEND_SOURCES) + +ifeq ($(USING_MALI_PMM_TESTSUITE),1) +ccflags-y += -I$(DRIVER_DIR)/platform/mali_pmu_testing +endif + +mali-$(CONFIG_MALI400_GPU_UTILIZATION) += common/mali_kernel_utilization.o +mali-$(CONFIG_DMA_SHARED_BUFFER) += linux/mali_dma_buf.o + +ifneq ($(call submodule_enabled, $(DRIVER_DIR), MALI400PP),0) + # Mali-400 PP in use + ccflags-y += -DUSING_MALI400 +endif + +ifneq ($(call submodule_enabled, $(DRIVER_DIR), MALI300PP),0) + # Mali-400 PP in use + ccflags-y += -DUSING_MALI400 +endif + +ifneq ($(call submodule_enabled, $(DRIVER_DIR), MALI200),0) + # Mali200 in use + ccflags-y += -DUSING_MALI200 +endif + +# Always build in support for Mali L2 cache +SRC += common/mali_l2_cache.c + +# Tell the Linux build system to enable building of our .c files +mali-y += $(SRC:.c=.o) +# Tell the Linux build system from which .o file to create the kernel module +obj-$(CONFIG_MALI400) := mali.o + + +VERSION_STRINGS := +VERSION_STRINGS += CONFIG=$(CONFIG) +VERSION_STRINGS += USING_OS_MEMORY=$(USING_OS_MEMORY) +VERSION_STRINGS += API_VERSION=$(shell cd $(DRIVER_DIR); grep "\#define _MALI_API_VERSION" $(FILES_PREFIX)include/linux/mali/mali_utgard_uk_types.h | cut -d' ' -f 3 ) +VERSION_STRINGS += REPO_URL=$(shell cd $(DRIVER_DIR); (svn info || git svn info || echo 'URL: $(MALI_RELEASE_NAME)') 2>/dev/null | grep '^URL: ' | cut -d: -f2- | cut -b2-) +VERSION_STRINGS += REVISION=$(SVN_REV) +VERSION_STRINGS += CHANGED_REVISION=$(shell cd $(DRIVER_DIR); (svn info || git svn info || echo 'Last Changed Rev: $(MALI_RELEASE_NAME)') 2>/dev/null | grep '^Last Changed Rev: ' | cut -d: -f2- | cut -b2-) +VERSION_STRINGS += CHANGE_DATE=$(shell cd $(DRIVER_DIR); (svn info || git svn info || echo 'Last Changed Date: $(MALI_RELEASE_NAME)') 2>/dev/null | grep '^Last Changed Date: ' | cut -d: -f2- | cut -b2-) +VERSION_STRINGS += BUILD_DATE=$(shell date) + +VERSION_STRINGS += BUILD=$(shell echo $(BUILD) | tr a-z A-Z) +VERSION_STRINGS += CPU=$(CPU) +VERSION_STRINGS += USING_UMP=$(USING_UMP) +VERSION_STRINGS += USING_MALI200=$(call submodule_enabled, $(DRIVER_DIR), MALI200) +VERSION_STRINGS += USING_MALI400=$(call submodule_enabled, $(DRIVER_DIR), MALI400) +VERSION_STRINGS += USING_MALI400_L2_CACHE=$(call submodule_enabled, $(DRIVER_DIR), MALI400L2) +VERSION_STRINGS += USING_GP2=$(call submodule_enabled, $(DRIVER_DIR), MALIGP2) +VERSION_STRINGS += KDIR=$(KDIR) +VERSION_STRINGS += MALI_PLATFORM_FILE=$(MALI_PLATFORM_FILE) +VERSION_STRINGS += OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB=$(OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB) +VERSION_STRINGS += USING_PROFILING=$(USING_PROFILING) +VERSION_STRINGS += USING_INTERNAL_PROFILING=$(USING_INTERNAL_PROFILING) +VERSION_STRINGS += USING_GPU_UTILIZATION=$(CONFIG_MALI400_GPU_UTILIZATION) + +# Create file with Mali driver configuration +$(DRIVER_DIR)/__malidrv_build_info.c: + @echo 'const char *__malidrv_build_info(void) { return "malidrv: $(VERSION_STRINGS)";}' > $(DRIVER_DIR)/__malidrv_build_info.c diff --git a/drivers/media/video/samsung/mali/Kconfig_module b/drivers/media/video/samsung/mali/Kconfig_module new file mode 100644 index 0000000..dabb36e --- /dev/null +++ b/drivers/media/video/samsung/mali/Kconfig_module @@ -0,0 +1,30 @@ +config MALI400 + tristate "Mali-300/400/450 support" + depends on ARM + select FB + ---help--- + This enables support for the Mali-300, Mali-400, and Mali-450 GPUs. + + To compile this driver as a module, choose M here: the module will be + called mali. + +config MALI400_DEBUG + bool "Enable debug in Mali driver" + depends on MALI400 + ---help--- + This enabled extra debug checks and messages in the Mali-300/400/450 + driver. + +config MALI400_PROFILING + bool "Enable Mali profiling" + depends on MALI400 && TRACEPOINTS + ---help--- + This enables gator profiling of Mali GPU events. + +config MALI400_GPU_UTILIZATION + bool "Enable Mali GPU utilization tracking" + depends on MALI400 + ---help--- + This enables gathering and processing of the utilization of Mali GPU. + This data can be used as a basis to change GPU operating frequency. + diff --git a/drivers/media/video/samsung/mali/Makefile b/drivers/media/video/samsung/mali/Makefile index aa4b255..524f910 100644 --- a/drivers/media/video/samsung/mali/Makefile +++ b/drivers/media/video/samsung/mali/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2010 ARM Limited. All rights reserved. +# 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. @@ -38,11 +38,10 @@ USING_OS_MEMORY=1 endif ifeq ($(CONFIG_PM),y) -USING_PMM=1 + USING_PMM = 1 +ifeq ($(CONFIG_PM_RUNTIME),y) + KERNEL_RUNTIME_PM_ENABLED = 1 endif - -ifeq ($(CONFIG_PM_RUNTIME),y) -USING_MALI_RUN_TIME_PM=1 endif ifeq ($(CONFIG_VIDEO_MALI400MP_DVFS),y) @@ -75,15 +74,17 @@ USING_INTERNAL_PROFILING ?= 0 USING_TRACEPOINTS ?= 0 USING_MALI_MAJOR_PREDEFINE = 1 USING_MALI_DVFS_ENABLED ?= 1 -TIMESTAMP ?= default -BUILD ?= release USING_MALI_PMM_EARLYSUSPEND ?= 0 #USING_KERNEL_WITH_DMA_ALLOC_PHYS_PAGE ?= 0 -CONFIG_MALI_MEM_SIZE ?= 512 +#CONFIG_MALI_MEM_SIZE ?= 512 DISABLE_PP0 ?= 0 DISABLE_PP1 ?= 0 DISABLE_PP2 ?= 0 DISABLE_PP3 ?= 0 +TIMESTAMP ?= default +BUILD ?= release +TARGET_PLATFORM ?= default +KERNEL_RUNTIME_PM_ENABLED ?= 0 MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP ?= 0 MALI_PP_SCHEDULER_KEEP_SUB_JOB_STARTS_ALIGNED ?= 0 MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP_BETWEEN_APPS ?= 0 @@ -93,14 +94,15 @@ ifeq ($(USING_PROFILING),1) ifeq ($(USING_INTERNAL_PROFILING),0) ifndef CONFIG_TRACEPOINTS # Should default to gator profiling, but we dont have the kernel feature required, so disable profiling -USING_PROFILING = 0 +override USING_PROFILING = 0 +$(warning "CONFIG_TRACEPOINTS required for USING_PROFILING") endif endif endif ifeq ($(USING_PROFILING),0) # make sure user hasnt selected incompatible flags -USING_INTERNAL_PROFILING = 0 +override USING_INTERNAL_PROFILING = 0 endif USING_MALI_SLP_GLOBAL_LOCK ?= 0 @@ -119,22 +121,20 @@ endif -include ../../../arm_internal.mak # Set up our defines, which will be passed to gcc +DEFINES += -DONLY_ZBT=$(ONLY_ZBT) DEFINES += -DUSING_ZBT=$(USING_ZBT) -DEFINES += -DUSING_OS_MEMORY=$(USING_OS_MEMORY) DEFINES += -DUSING_MMU=$(USING_MMU) +DEFINES += -DUSING_OS_MEMORY=$(USING_OS_MEMORY) DEFINES += -DUSING_DED=$(USING_DED) DEFINES += -DUSING_UMP=$(USING_UMP) -DEFINES += -DONLY_ZBT=$(ONLY_ZBT) DEFINES += -D_MALI_OSK_SPECIFIC_INDIRECT_MMAP DEFINES += -DUSING_MALI_PMU=$(USING_MALI_PMU) -DEFINES += -DMALI_PMM_RUNTIME_JOB_CONTROL_ON=$(USING_MALI_RUN_TIME_PM) +DEFINES += -DMALI_PMM_RUNTIME_JOB_CONTROL_ON=$(KERNEL_RUNTIME_PM_ENABLED) DEFINES += -DUSING_MALI_PMM=$(USING_PMM) DEFINES += -DMALI_GPU_UTILIZATION=$(USING_GPU_UTILIZATION) DEFINES += -DCONFIG_MALI_MEM_SIZE=$(CONFIG_MALI_MEM_SIZE) DEFINES += -D_MALI_OSK_SPECIFIC_INDIRECT_MMAP -DEFINES += -DMALI_TIMELINE_PROFILING_ENABLED=$(USING_PROFILING) DEFINES += -DMALI_INTERNAL_TIMELINE_PROFILING_ENABLED=$(USING_INTERNAL_PROFILING) -DEFINES += -DMALI_POWER_MGMT_TEST_SUITE=$(USING_MALI_PMM_TESTSUITE) DEFINES += -DMALI_MAJOR_PREDEFINE=$(USING_MALI_MAJOR_PREDEFINE) DEFINES += -DMALI_DVFS_ENABLED=$(USING_MALI_DVFS_ENABLED) DEFINES += -DUSING_MALI_PMM_EARLYSUSPEND=$(USING_MALI_PMM_EARLYSUSPEND) @@ -148,6 +148,9 @@ DEFINES += -DDISABLE_PP3=$(DISABLE_PP3) DEFINES += -DMALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP=$(MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP) DEFINES += -DMALI_PP_SCHEDULER_KEEP_SUB_JOB_STARTS_ALIGNED=$(MALI_PP_SCHEDULER_KEEP_SUB_JOB_STARTS_ALIGNED) DEFINES += -DMALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP_BETWEEN_APPS=$(MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP_BETWEEN_APPS) +DEFINES += -DMALI_TIMELINE_PROFILING_ENABLED=$(USING_PROFILING) +DEFINES += -DMALI_POWER_MGMT_TEST_SUITE=$(USING_MALI_PMM_TESTSUITE) +DEFINES += -DMALI_OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB=$(OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB) ifeq ($(BUILD),debug) DEFINES += -DDEBUG @@ -158,7 +161,7 @@ DEFINES += -DMALI_UKK_HAS_IMPLICIT_MMAP_CLEANUP # UMP ifeq ($(CONFIG_VIDEO_UMP),y) - DEFINES += -DMALI_USE_UNIFIED_MEMORY_PROVIDER=1 -DHAVE_UNLOCKED_IOCTL + DEFINES += -DMALI_USE_UNIFIED_MEMORY_PROVIDER=1 EXTRA_CFLAGS += -I$(MALI_INCLUDE_PREFIX)../ump/include else DEFINES += -DMALI_USE_UNIFIED_MEMORY_PROVIDER=0 @@ -172,15 +175,11 @@ obj-$(CONFIG_VIDEO_MALI400MP) += mali.o INCLUDES = \ -I$(MALI_INCLUDE_PREFIX)\ -I$(MALI_INCLUDE_PREFIX)include \ - -I$(MALI_INCLUDE_PREFIX)platform\ -I$(MALI_INCLUDE_PREFIX)common \ -I$(MALI_INCLUDE_PREFIX)linux \ + -I$(MALI_INCLUDE_PREFIX)platform\ -I$(MALI_INCLUDE_PREFIX)regs -ifeq ($(USING_PROFILING),1) -INCLUDES += \ - -I$(MALI_INCLUDE_PREFIX)include -endif EXTRA_CFLAGS += $(INCLUDES)\ $(DEFINES) @@ -192,6 +191,7 @@ EXTRA_CFLAGS += -I$(MALI_INCLUDE_PREFIX)common/pmm ifeq ($(CONFIG_VIDEO_UMP),y) OSKFILES=\ $(FILES_PREFIX)$(OSKOS)/mali_osk_irq.o \ + $(FILES_PREFIX)$(OSKOS)/mali_osk_wait_queue.o \ $(FILES_PREFIX)$(OSKOS)/mali_osk_low_level_mem.o \ $(FILES_PREFIX)$(OSKOS)/mali_osk_mali.o \ $(FILES_PREFIX)$(OSKOS)/mali_osk_notification.o \ @@ -202,6 +202,7 @@ OSKFILES=\ $(FILES_PREFIX)$(OSKOS)/mali_osk_atomics.o \ $(FILES_PREFIX)$(OSKOS)/mali_osk_irq.o \ $(FILES_PREFIX)$(OSKOS)/mali_osk_locks.o \ + $(FILES_PREFIX)$(OSKOS)/mali_osk_wait_queue.o \ $(FILES_PREFIX)$(OSKOS)/mali_osk_low_level_mem.o \ $(FILES_PREFIX)$(OSKOS)/mali_osk_math.o \ $(FILES_PREFIX)$(OSKOS)/mali_osk_memory.o \ @@ -223,8 +224,7 @@ UKKFILES=\ $(FILES_PREFIX)$(OSKOS)/mali_ukk_mem.o \ $(FILES_PREFIX)$(OSKOS)/mali_ukk_gp.o \ $(FILES_PREFIX)$(OSKOS)/mali_ukk_pp.o \ - $(FILES_PREFIX)$(OSKOS)/mali_ukk_core.o \ - $(FILES_PREFIX)$(OSKOS)/mali_ukk_vsync.o + $(FILES_PREFIX)$(OSKOS)/mali_ukk_core.o ifeq ($(USING_PROFILING),1) UKKFILES += \ @@ -234,7 +234,6 @@ endif mali-y := \ common/mali_kernel_core.o \ linux/mali_kernel_linux.o \ - $(OSKOS)/mali_osk_indir_mmap.o \ common/mali_kernel_descriptor_mapping.o \ common/mali_session.o \ common/mali_device_pause_resume.o \ @@ -264,7 +263,7 @@ mali-y := \ common/mali_user_settings_db.o \ $(OSKOS)/mali_osk_pm.o \ linux/mali_kernel_pm.o \ - $(OSKOS)/mali_osk_wait_queue.o \ + linux/mali_pmu_power_up_down.o \ $(MALI_PLATFORM_FILE) \ $(OSKFILES) \ $(UKKFILES) @@ -280,7 +279,7 @@ EXTRA_CFLAGS += -I$(MALI_INCLUDE_PREFIX)timestamp-$(TIMESTAMP) else ifeq ($(USING_PROFILING),1) PROFILING_BACKEND_SOURCES = \ - linux/mali_osk_profiling_gator.o + linux/mali_osk_profiling.o endif endif @@ -308,6 +307,7 @@ EXTRA_CFLAGS += -DUSING_MALI400 # Mali Level2 cache in use EXTRA_CFLAGS += -DUSING_MALI400_L2_CACHE mali-y += common/mali_l2_cache.o + # Mali SLP Global lock feature ifeq ($(USING_MALI_SLP_GLOBAL_LOCK),1) mali-y += \ diff --git a/drivers/media/video/samsung/mali/Makefile_module b/drivers/media/video/samsung/mali/Makefile_module old mode 100755 new mode 100644 index 4fb0226..361ce08 --- a/drivers/media/video/samsung/mali/Makefile_module +++ b/drivers/media/video/samsung/mali/Makefile_module @@ -21,6 +21,14 @@ ARCH ?= arm OSKOS=linux FILES_PREFIX= +check_cc2 = \ + $(shell if $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \ + then \ + echo "$(2)"; \ + else \ + echo "$(3)"; \ + fi ;) + # This conditional makefile exports the global definition ARM_INTERNAL_BUILD. Customer releases will not include arm_internal.mak -include ../../../arm_internal.mak @@ -49,8 +57,8 @@ endif KDIR-$(shell uname -m):=/lib/modules/$(shell uname -r)/build ifeq ($(ARCH), arm) - # when compiling for ARM we're cross compiling - export CROSS_COMPILE ?= arm-none-linux-gnueabi- +# when compiling for ARM we're cross compiling +export CROSS_COMPILE ?= $(call check_cc2, arm-linux-gnueabi-gcc, arm-linux-gnueabi-, arm-none-linux-gnueabi-) endif # look up KDIR based om CPU selection diff --git a/drivers/media/video/samsung/mali/arch-pb-virtex5-m300/config.h b/drivers/media/video/samsung/mali/arch-pb-virtex5-m300/config.h old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/arch-pb-virtex5-m400-1-pmu/config.h b/drivers/media/video/samsung/mali/arch-pb-virtex5-m400-1-pmu/config.h index d85c090..6d84ab1 100644 --- a/drivers/media/video/samsung/mali/arch-pb-virtex5-m400-1-pmu/config.h +++ b/drivers/media/video/samsung/mali/arch-pb-virtex5-m400-1-pmu/config.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 ARM Limited. All rights reserved. + * 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. diff --git a/drivers/media/video/samsung/mali/arch-pegasus-m400/config.h b/drivers/media/video/samsung/mali/arch-pegasus-m400/config.h old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/arch-ve-virtex6-m450-8/config.h b/drivers/media/video/samsung/mali/arch-ve-virtex6-m450-8/config.h index 9b38f35..eb5da50 100644 --- a/drivers/media/video/samsung/mali/arch-ve-virtex6-m450-8/config.h +++ b/drivers/media/video/samsung/mali/arch-ve-virtex6-m450-8/config.h @@ -17,6 +17,12 @@ static _mali_osk_resource_t arch_configuration [] = { + /* PMU */ + { + .type = PMU, + .base = MALI_BASE_ADDRESS + 0x02000, + .description = "MALI PMU" + }, /* GP cluster */ { .type = MALI400L2, diff --git a/drivers/media/video/samsung/mali/common/mali_block_allocator.c b/drivers/media/video/samsung/mali/common/mali_block_allocator.c old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/common/mali_block_allocator.h b/drivers/media/video/samsung/mali/common/mali_block_allocator.h old mode 100755 new mode 100644 index d3f0f9b..6c6f13e --- a/drivers/media/video/samsung/mali/common/mali_block_allocator.h +++ b/drivers/media/video/samsung/mali/common/mali_block_allocator.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 ARM Limited. All rights reserved. + * 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. diff --git a/drivers/media/video/samsung/mali/common/mali_device_pause_resume.c b/drivers/media/video/samsung/mali/common/mali_device_pause_resume.c old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/common/mali_device_pause_resume.h b/drivers/media/video/samsung/mali/common/mali_device_pause_resume.h old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/common/mali_gp.c b/drivers/media/video/samsung/mali/common/mali_gp.c index d03721c..2110471 100644 --- a/drivers/media/video/samsung/mali/common/mali_gp.c +++ b/drivers/media/video/samsung/mali/common/mali_gp.c @@ -298,6 +298,14 @@ void mali_gp_job_start(struct mali_gp_core *core, struct mali_gp_job *job) mali_hw_core_register_write_array_relaxed(&core->hw_core, MALIGP2_REG_ADDR_MGMT_VSCL_START_ADDR, frame_registers, MALIGP2_NUM_REGS_FRAME); +#if PROFILING_PRINT_L2_HITRATE_ON_GP_FINISH + { + /* Read hits and Read misses*/ + mali_l2_cache_core_set_counter_src0(mali_l2_cache_core_get_glob_l2_core(0), 20); + mali_l2_cache_core_set_counter_src1(mali_l2_cache_core_get_glob_l2_core(0), 21); + } +#endif + /* This selects which performance counters we are reading */ if (MALI_HW_CORE_NO_COUNTER != core->counter_src0_used || MALI_HW_CORE_NO_COUNTER != core->counter_src0_used) { @@ -353,8 +361,8 @@ void mali_gp_job_start(struct mali_gp_core *core, struct mali_gp_job *job) #if MALI_TIMELINE_PROFILING_ENABLED _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE | MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(0) | MALI_PROFILING_EVENT_REASON_SINGLE_HW_FLUSH, - job->frame_builder_id, job->flush_id, 0, 0, 0); - _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(0), job->pid, job->tid, 0, 0, 0); + mali_gp_job_get_frame_builder_id(job), mali_gp_job_get_flush_id(job), 0, 0, 0); + _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(0), mali_gp_job_get_pid(job), mali_gp_job_get_tid(job), 0, 0, 0); #endif core->running_job = job; @@ -472,9 +480,7 @@ static void mali_gp_bottom_half(void *data) u32 irq_errors; #if MALI_TIMELINE_PROFILING_ENABLED -#if 0 /* Bottom half TLP logging is currently not supported */ - _mali_osk_profiling_add_event( MALI_PROFILING_EVENT_TYPE_START| MALI_PROFILING_EVENT_CHANNEL_SOFTWARE , _mali_osk_get_pid(), _mali_osk_get_tid()+11000, 0, 0, 0); -#endif + _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP(0), 0, 0); #endif mali_group_lock(core->group); /* Group lock grabbed in core handlers, but released in common group handler */ @@ -483,6 +489,9 @@ static void mali_gp_bottom_half(void *data) { MALI_PRINT_ERROR(("Interrupt bottom half of %s when core is OFF.", core->hw_core.description)); mali_group_unlock(core->group); +#if MALI_TIMELINE_PROFILING_ENABLED + _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0); +#endif return; } @@ -497,6 +506,9 @@ static void mali_gp_bottom_half(void *data) mali_gp_post_process_job(core, MALI_FALSE); MALI_DEBUG_PRINT(4, ("Mali GP: Job completed, calling group handler\n")); mali_group_bottom_half(core->group, GROUP_EVENT_GP_JOB_COMPLETED); /* Will release group lock */ +#if MALI_TIMELINE_PROFILING_ENABLED + _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0); +#endif return; } } @@ -511,6 +523,9 @@ static void mali_gp_bottom_half(void *data) mali_gp_post_process_job(core, MALI_FALSE); MALI_PRINT_ERROR(("Mali GP: Unknown interrupt 0x%08X from core %s, aborting job\n", irq_readout, core->hw_core.description)); mali_group_bottom_half(core->group, GROUP_EVENT_GP_JOB_FAILED); /* Will release group lock */ +#if MALI_TIMELINE_PROFILING_ENABLED + _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0); +#endif return; } else if (MALI_TRUE == core->core_timed_out) /* SW timeout */ @@ -522,6 +537,9 @@ static void mali_gp_bottom_half(void *data) mali_group_bottom_half(core->group, GROUP_EVENT_GP_JOB_TIMED_OUT); } core->core_timed_out = MALI_FALSE; +#if MALI_TIMELINE_PROFILING_ENABLED + _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0); +#endif return; } else if (irq_readout & MALIGP2_REG_VAL_IRQ_PLBU_OUT_OF_MEM) @@ -538,25 +556,30 @@ static void mali_gp_bottom_half(void *data) mali_gp_post_process_job(core, MALI_TRUE); MALI_DEBUG_PRINT(3, ("Mali GP: PLBU needs more heap memory\n")); mali_group_bottom_half(core->group, GROUP_EVENT_GP_OOM); /* Will release group lock */ +#if MALI_TIMELINE_PROFILING_ENABLED + _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0); +#endif return; } else if (irq_readout & MALIGP2_REG_VAL_IRQ_HANG) { - /* Just ignore hang interrupts, the job timer will detect hanging jobs anyways */ - mali_hw_core_register_write(&core->hw_core, MALIGP2_REG_ADDR_MGMT_INT_CLEAR, MALIGP2_REG_VAL_IRQ_HANG); + /* we mask hang interrupts, so this should never happen... */ + MALI_DEBUG_ASSERT( 0 ); } - /* - * The only way to get here is if we got a HANG interrupt, which we ignore, or only one of two needed END_CMD_LST interrupts. - * Re-enable interrupts and let core continue to run. - */ - mali_hw_core_register_write(&core->hw_core, MALIGP2_REG_ADDR_MGMT_INT_MASK, MALIGP2_REG_VAL_IRQ_MASK_USED); + /* The only way to get here is if we only got one of two needed END_CMD_LST + * interrupts. Disable the interrupt that has been received and continue to + * run. */ + mali_hw_core_register_write(&core->hw_core, MALIGP2_REG_ADDR_MGMT_INT_MASK, + MALIGP2_REG_VAL_IRQ_MASK_USED & + ((irq_readout & MALIGP2_REG_VAL_IRQ_PLBU_END_CMD_LST) + ? ~MALIGP2_REG_VAL_IRQ_PLBU_END_CMD_LST + : ~MALIGP2_REG_VAL_IRQ_VS_END_CMD_LST + )); mali_group_unlock(core->group); #if MALI_TIMELINE_PROFILING_ENABLED -#if 0 /* Bottom half TLP logging is currently not supported */ - _mali_osk_profiling_add_event( MALI_PROFILING_EVENT_TYPE_STOP| MALI_PROFILING_EVENT_CHANNEL_SOFTWARE , _mali_osk_get_pid(), _mali_osk_get_tid()+11000, 0, 0, 0); -#endif + _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0); #endif } @@ -599,6 +622,51 @@ static void mali_gp_post_process_job(struct mali_gp_core *core, mali_bool suspen u32 event_id; #endif +#if PROFILING_PRINT_L2_HITRATE_ON_GP_FINISH + { + u32 src0, value0, src1, value1, sum, per_thousand, per_thousand_now, diff0, diff1; + static u32 print_nr=0; + static u32 prev0=0; + static u32 prev1=0; + if ( !(++print_nr&511) ) + { + mali_l2_cache_core_get_counter_values(mali_l2_cache_core_get_glob_l2_core(0), &src0, &value0, &src1, &value1); + MALI_DEBUG_ASSERT( src0==20 ); /* Read hits */ + MALI_DEBUG_ASSERT( src1==21 ); /* Read misses */ + + sum = value0+value1; + if ( sum > 1000000 ) + { + per_thousand = value0 / (sum/1000); + } + else + { + per_thousand = (value0*1000) / (sum); + } + diff0 = value0-prev0; + diff1 = value1-prev1; + + sum = diff0 + diff1 ; + if ( sum > 1000000 ) + { + per_thousand_now = diff0 / (sum/1000); + } + else + { + per_thousand_now = (diff0*1000) / (sum); + } + + prev0=value0; + prev1=value1; + if (per_thousand_now<=1000) + { + MALI_DEBUG_PRINT(2, ("Mali L2: Read hits/misses: %d/%d = %d thousand_parts total, since previous: %d\n", value0, value1, per_thousand, per_thousand_now)); + } + + } + } +#endif + if (MALI_HW_CORE_NO_COUNTER != core->counter_src0_used) { val0 = mali_hw_core_register_read(&core->hw_core, MALIGP2_REG_ADDR_MGMT_PERF_CNT_0_VALUE); diff --git a/drivers/media/video/samsung/mali/common/mali_gp.h b/drivers/media/video/samsung/mali/common/mali_gp.h old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/common/mali_gp_job.c b/drivers/media/video/samsung/mali/common/mali_gp_job.c index abe1d93..2e445d6 100644 --- a/drivers/media/video/samsung/mali/common/mali_gp_job.c +++ b/drivers/media/video/samsung/mali/common/mali_gp_job.c @@ -13,29 +13,27 @@ #include "mali_osk_list.h" #include "mali_uk_types.h" -struct mali_gp_job *mali_gp_job_create(struct mali_session_data *session, _mali_uk_gp_start_job_s *args, u32 id) +struct mali_gp_job *mali_gp_job_create(struct mali_session_data *session, _mali_uk_gp_start_job_s *uargs, u32 id) { struct mali_gp_job *job; job = _mali_osk_malloc(sizeof(struct mali_gp_job)); if (NULL != job) { + if (0 != copy_from_user(&job->uargs, uargs, sizeof(_mali_uk_gp_start_job_s))) + { + _mali_osk_free(job); + return NULL; + } + _mali_osk_list_init(&job->list); job->session = session; job->id = id; - job->user_id = args->user_job_ptr; - _mali_osk_memcpy(job->frame_registers, args->frame_registers, sizeof(job->frame_registers)); - job->heap_current_addr = args->frame_registers[4]; - job->perf_counter_flag = args->perf_counter_flag; - job->perf_counter_src0 = args->perf_counter_src0; - job->perf_counter_src1 = args->perf_counter_src1; + job->heap_current_addr = job->uargs.frame_registers[4]; job->perf_counter_value0 = 0; job->perf_counter_value1 = 0; - job->pid = _mali_osk_get_pid(); job->tid = _mali_osk_get_tid(); - job->frame_builder_id = args->frame_builder_id; - job->flush_id = args->flush_id; return job; } diff --git a/drivers/media/video/samsung/mali/common/mali_gp_job.h b/drivers/media/video/samsung/mali/common/mali_gp_job.h index 9c29f1c..7b45552 100644 --- a/drivers/media/video/samsung/mali/common/mali_gp_job.h +++ b/drivers/media/video/samsung/mali/common/mali_gp_job.h @@ -25,22 +25,16 @@ struct mali_gp_job { _mali_osk_list_t list; /**< Used to link jobs together in the scheduler queue */ struct mali_session_data *session; /**< Session which submitted this job */ + _mali_uk_gp_start_job_s uargs; /**< Arguments from user space */ u32 id; /**< identifier for this job in kernel space (sequential numbering) */ - u32 user_id; /**< identifier for the job in user space */ - u32 frame_registers[MALIGP2_NUM_REGS_FRAME]; /**< core specific registers associated with this job, see ARM DDI0415A */ u32 heap_current_addr; /**< Holds the current HEAP address when the job has completed */ - u32 perf_counter_flag; /**< bitmask indicating which performance counters to enable, see \ref _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE and related macro definitions */ - u32 perf_counter_src0; /**< source id for performance counter 0 (see ARM DDI0415A, Table 3-60) */ - u32 perf_counter_src1; /**< source id for performance counter 1 (see ARM DDI0415A, Table 3-60) */ u32 perf_counter_value0; /**< Value of performance counter 0 (to be returned to user space) */ u32 perf_counter_value1; /**< Value of performance counter 1 (to be returned to user space) */ u32 pid; /**< Process ID of submitting process */ u32 tid; /**< Thread ID of submitting thread */ - u32 frame_builder_id; /**< id of the originating frame builder */ - u32 flush_id; /**< flush id within the originating frame builder */ }; -struct mali_gp_job *mali_gp_job_create(struct mali_session_data *session, _mali_uk_gp_start_job_s *args, u32 id); +struct mali_gp_job *mali_gp_job_create(struct mali_session_data *session, _mali_uk_gp_start_job_s *uargs, u32 id); void mali_gp_job_delete(struct mali_gp_job *job); MALI_STATIC_INLINE u32 mali_gp_job_get_id(struct mali_gp_job *job) @@ -50,22 +44,32 @@ MALI_STATIC_INLINE u32 mali_gp_job_get_id(struct mali_gp_job *job) MALI_STATIC_INLINE u32 mali_gp_job_get_user_id(struct mali_gp_job *job) { - return job->user_id; + return job->uargs.user_job_ptr; } MALI_STATIC_INLINE u32 mali_gp_job_get_frame_builder_id(struct mali_gp_job *job) { - return job->frame_builder_id; + return job->uargs.frame_builder_id; } MALI_STATIC_INLINE u32 mali_gp_job_get_flush_id(struct mali_gp_job *job) { - return job->flush_id; + return job->uargs.flush_id; +} + +MALI_STATIC_INLINE u32 mali_gp_job_get_pid(struct mali_gp_job *job) +{ + return job->pid; +} + +MALI_STATIC_INLINE u32 mali_gp_job_get_tid(struct mali_gp_job *job) +{ + return job->tid; } MALI_STATIC_INLINE u32* mali_gp_job_get_frame_registers(struct mali_gp_job *job) { - return job->frame_registers; + return job->uargs.frame_registers; } MALI_STATIC_INLINE struct mali_session_data *mali_gp_job_get_session(struct mali_gp_job *job) @@ -75,12 +79,12 @@ MALI_STATIC_INLINE struct mali_session_data *mali_gp_job_get_session(struct mali MALI_STATIC_INLINE mali_bool mali_gp_job_has_vs_job(struct mali_gp_job *job) { - return (job->frame_registers[0] != job->frame_registers[1]) ? MALI_TRUE : MALI_FALSE; + return (job->uargs.frame_registers[0] != job->uargs.frame_registers[1]) ? MALI_TRUE : MALI_FALSE; } MALI_STATIC_INLINE mali_bool mali_gp_job_has_plbu_job(struct mali_gp_job *job) { - return (job->frame_registers[2] != job->frame_registers[3]) ? MALI_TRUE : MALI_FALSE; + return (job->uargs.frame_registers[2] != job->uargs.frame_registers[3]) ? MALI_TRUE : MALI_FALSE; } MALI_STATIC_INLINE u32 mali_gp_job_get_current_heap_addr(struct mali_gp_job *job) @@ -95,17 +99,17 @@ MALI_STATIC_INLINE void mali_gp_job_set_current_heap_addr(struct mali_gp_job *jo MALI_STATIC_INLINE u32 mali_gp_job_get_perf_counter_flag(struct mali_gp_job *job) { - return job->perf_counter_flag; + return job->uargs.perf_counter_flag; } MALI_STATIC_INLINE u32 mali_gp_job_get_perf_counter_src0(struct mali_gp_job *job) { - return job->perf_counter_src0; + return job->uargs.perf_counter_src0; } MALI_STATIC_INLINE u32 mali_gp_job_get_perf_counter_src1(struct mali_gp_job *job) { - return job->perf_counter_src1; + return job->uargs.perf_counter_src1; } MALI_STATIC_INLINE u32 mali_gp_job_get_perf_counter_value0(struct mali_gp_job *job) diff --git a/drivers/media/video/samsung/mali/common/mali_gp_scheduler.c b/drivers/media/video/samsung/mali/common/mali_gp_scheduler.c index 05f00fc..52fa15b 100644 --- a/drivers/media/video/samsung/mali/common/mali_gp_scheduler.c +++ b/drivers/media/video/samsung/mali/common/mali_gp_scheduler.c @@ -56,13 +56,12 @@ _mali_osk_errcode_t mali_gp_scheduler_initialize(void) _MALI_OSK_INIT_LIST_HEAD(&job_queue); gp_scheduler_lock = _mali_osk_lock_init(_MALI_OSK_LOCKFLAG_ORDERED | _MALI_OSK_LOCKFLAG_NONINTERRUPTABLE, 0, _MALI_OSK_LOCK_ORDER_SCHEDULER); - gp_scheduler_working_wait_queue = _mali_osk_wait_queue_init(); - if (NULL == gp_scheduler_lock) { return _MALI_OSK_ERR_NOMEM; } + gp_scheduler_working_wait_queue = _mali_osk_wait_queue_init(); if (NULL == gp_scheduler_working_wait_queue) { _mali_osk_lock_term(gp_scheduler_lock); @@ -275,30 +274,28 @@ void mali_gp_scheduler_resume(void) mali_gp_scheduler_unlock(); } -_mali_osk_errcode_t _mali_ukk_gp_start_job(_mali_uk_gp_start_job_s *args) +_mali_osk_errcode_t _mali_ukk_gp_start_job(void *ctx, _mali_uk_gp_start_job_s *uargs) { struct mali_session_data *session; struct mali_gp_job *job; - MALI_DEBUG_ASSERT_POINTER(args); + MALI_DEBUG_ASSERT_POINTER(uargs); + MALI_DEBUG_ASSERT_POINTER(ctx); - if (NULL == args->ctx) - { - return _MALI_OSK_ERR_INVALID_ARGS; - } + session = (struct mali_session_data*)ctx; - session = (struct mali_session_data*)args->ctx; - if (NULL == session) - { - return _MALI_OSK_ERR_FAULT; - } - - job = mali_gp_job_create(session, args, mali_scheduler_get_new_id()); + job = mali_gp_job_create(session, uargs, mali_scheduler_get_new_id()); if (NULL == job) { return _MALI_OSK_ERR_NOMEM; } +#if PROFILING_SKIP_PP_AND_GP_JOBS +#warning GP jobs will not be executed + mali_gp_scheduler_return_job_to_user(job, MALI_TRUE); + return _MALI_OSK_ERR_OK; +#endif + mali_gp_scheduler_lock(); _mali_osk_list_addtail(&job->list, &job_queue); diff --git a/drivers/media/video/samsung/mali/common/mali_gp_scheduler.h b/drivers/media/video/samsung/mali/common/mali_gp_scheduler.h old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/common/mali_group.c b/drivers/media/video/samsung/mali/common/mali_group.c index 9202bc1..94bf774 100644 --- a/drivers/media/video/samsung/mali/common/mali_group.c +++ b/drivers/media/video/samsung/mali/common/mali_group.c @@ -536,7 +536,7 @@ static enum mali_group_activate_pd_status mali_group_activate_page_directory(str activate_success = mali_mmu_activate_page_directory(group->mmu, mali_session_get_page_directory(session)); MALI_DEBUG_ASSERT(activate_success); - if ( MALI_FALSE== activate_success ) return MALI_FALSE; + if ( MALI_FALSE== activate_success ) return MALI_GROUP_ACTIVATE_PD_STATUS_FAILED; group->session = session; retval = MALI_GROUP_ACTIVATE_PD_STATUS_OK_SWITCHED_PD; } diff --git a/drivers/media/video/samsung/mali/common/mali_group.h b/drivers/media/video/samsung/mali/common/mali_group.h index 3533d13..1561d6b 100644 --- a/drivers/media/video/samsung/mali/common/mali_group.h +++ b/drivers/media/video/samsung/mali/common/mali_group.h @@ -102,7 +102,7 @@ _mali_osk_errcode_t mali_group_start_gp_job(struct mali_group *group, struct mal */ _mali_osk_errcode_t mali_group_start_pp_job(struct mali_group *group, struct mali_pp_job *job, u32 sub_job); -/** @brief Resume GP job that suspended waiting for more heap memory +/** @brief Resume GP job that suspended waiting for more heap memory */ void mali_group_resume_gp_with_new_heap(struct mali_group *group, u32 job_id, u32 start_addr, u32 end_addr); /** @brief Abort GP job diff --git a/drivers/media/video/samsung/mali/common/mali_hw_core.c b/drivers/media/video/samsung/mali/common/mali_hw_core.c old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/common/mali_hw_core.h b/drivers/media/video/samsung/mali/common/mali_hw_core.h old mode 100755 new mode 100644 index c797804..b62e843 --- a/drivers/media/video/samsung/mali/common/mali_hw_core.h +++ b/drivers/media/video/samsung/mali/common/mali_hw_core.h @@ -48,6 +48,20 @@ MALI_STATIC_INLINE void mali_hw_core_register_write_relaxed(struct mali_hw_core _mali_osk_mem_iowrite32_relaxed(core->mapped_registers, relative_address, new_val); } +/* Conditionally write a register. + * The register will only be written if the new value is different from the old_value. + * If the new value is different, the old value will also be updated */ +MALI_STATIC_INLINE void mali_hw_core_register_write_relaxed_conditional(struct mali_hw_core *core, u32 relative_address, u32 new_val, const u32 old_val) +{ + MALI_DEBUG_PRINT(6, ("register_write_relaxed for core %s, relative addr=0x%04X, val=0x%08X\n", + core->description, relative_address, new_val)); + if(old_val != new_val) + { + _mali_osk_mem_iowrite32_relaxed(core->mapped_registers, relative_address, new_val); + } +} + + MALI_STATIC_INLINE void mali_hw_core_register_write(struct mali_hw_core *core, u32 relative_address, u32 new_val) { MALI_DEBUG_PRINT(6, ("register_write for core %s, relative addr=0x%04X, val=0x%08X\n", @@ -68,4 +82,23 @@ MALI_STATIC_INLINE void mali_hw_core_register_write_array_relaxed(struct mali_hw } } +/* Conditionally write a set of registers. + * The register will only be written if the new value is different from the old_value. + * If the new value is different, the old value will also be updated */ +MALI_STATIC_INLINE void mali_hw_core_register_write_array_relaxed_conditional(struct mali_hw_core *core, u32 relative_address, u32 *write_array, u32 nr_of_regs, const u32* old_array) +{ + u32 i; + MALI_DEBUG_PRINT(6, ("register_write_array: for core %s, relative addr=0x%04X, nr of regs=%u\n", + core->description,relative_address, nr_of_regs)); + + /* Do not use burst writes against the registers */ + for (i = 0; i< nr_of_regs; i++) + { + if(old_array[i] != write_array[i]) + { + mali_hw_core_register_write_relaxed(core, relative_address + i*4, write_array[i]); + } + } +} + #endif /* __MALI_HW_CORE_H__ */ diff --git a/drivers/media/video/samsung/mali/common/mali_kernel_common.h b/drivers/media/video/samsung/mali/common/mali_kernel_common.h index b354f92..a33660b 100644 --- a/drivers/media/video/samsung/mali/common/mali_kernel_common.h +++ b/drivers/media/video/samsung/mali/common/mali_kernel_common.h @@ -18,16 +18,6 @@ #endif #endif -/* Macro for generating a kernel panic. - * Turned on off by compile-time Makefile settings - */ -#if defined(USING_KERNEL_PANIC) -#include - #define MALI_PANIC(fmt, args...) panic( fmt, ## args ); -#else - #define MALI_PANIC(fmt, args...) -#endif - /* The file include several useful macros for error checking, debugging and printing. * - MALI_PRINTF(...) Do not use this function: Will be included in Release builds. * - MALI_DEBUG_PRINT(nr, (X) ) Prints the second argument if nr<=MALI_DEBUG_LEVEL. diff --git a/drivers/media/video/samsung/mali/common/mali_kernel_core.c b/drivers/media/video/samsung/mali/common/mali_kernel_core.c index 0155dfc..f31c505 100644 --- a/drivers/media/video/samsung/mali/common/mali_kernel_core.c +++ b/drivers/media/video/samsung/mali/common/mali_kernel_core.c @@ -35,6 +35,10 @@ #if MALI_TIMELINE_PROFILING_ENABLED #include "mali_osk_profiling.h" #endif +#if MALI_INTERNAL_TIMELINE_PROFILING_ENABLED +#include "mali_profiling_internal.h" +#endif + /** Pointer to table of resource definitions available to the Mali driver. * _mali_osk_resources_init() sets up the pointer to this table. @@ -52,21 +56,12 @@ static u32 global_gpu_base_address = 0; static u32 global_gpu_major_version = 0; static u32 global_gpu_minor_version = 0; -static _mali_osk_errcode_t build_system_info(void); -static void cleanup_system_info(_mali_system_info *cleanup); - -/* system info variables */ -static _mali_osk_lock_t *system_info_lock = NULL; -static _mali_system_info *system_info = NULL; -static u32 system_info_size = 0; static u32 first_pp_offset = 0; -#define HANG_CHECK_MSECS_DEFAULT 500 /* 500 ms */ #define WATCHDOG_MSECS_DEFAULT 4000 /* 4 s */ /* timer related */ int mali_max_job_runtime = WATCHDOG_MSECS_DEFAULT; -int mali_hang_check_interval = HANG_CHECK_MSECS_DEFAULT; static _mali_osk_resource_t *mali_find_resource(_mali_osk_resource_type_t type, u32 offset) { @@ -606,9 +601,6 @@ _mali_osk_errcode_t mali_initialize_subsystems(void) _mali_osk_errcode_t err; mali_bool is_pmu_enabled; - MALI_CHECK_NON_NULL(system_info_lock = _mali_osk_lock_init( (_mali_osk_lock_flags_t)(_MALI_OSK_LOCKFLAG_SPINLOCK - | _MALI_OSK_LOCKFLAG_NONINTERRUPTABLE), 0, 0 ), _MALI_OSK_ERR_FAULT); - err = mali_session_initialize(); if (_MALI_OSK_ERR_OK != err) goto session_init_failed; @@ -621,10 +613,6 @@ _mali_osk_errcode_t mali_initialize_subsystems(void) } #endif - /* Build dummy system info. Will be removed in the future. */ - err = build_system_info(); - if (_MALI_OSK_ERR_OK != err) goto build_system_info_failed; - /* Get data from config.h */ err = _mali_osk_resources_init(&arch_configuration, &num_resources); if (_MALI_OSK_ERR_OK != err) goto osk_resources_init_failed; @@ -729,8 +717,6 @@ parse_memory_config_failed: memory_init_failed: _mali_osk_resources_term(&arch_configuration, num_resources); osk_resources_init_failed: - cleanup_system_info(system_info); -build_system_info_failed: #if MALI_TIMELINE_PROFILING_ENABLED _mali_osk_profiling_term(); #endif @@ -742,6 +728,7 @@ session_init_failed: void mali_terminate_subsystems(void) { struct mali_pmu_core *pmu; + MALI_DEBUG_PRINT(2, ("terminate_subsystems() called\n")); /* shut down subsystems in reverse order from startup */ @@ -777,18 +764,11 @@ void mali_terminate_subsystems(void) _mali_osk_resources_term(&arch_configuration, num_resources); - cleanup_system_info(system_info); - #if MALI_TIMELINE_PROFILING_ENABLED _mali_osk_profiling_term(); #endif mali_session_terminate(); - - if (NULL != system_info_lock) - { - _mali_osk_lock_term( system_info_lock ); - } } _mali_product_id_t mali_kernel_core_get_product_id(void) @@ -809,94 +789,6 @@ void mali_kernel_core_wakeup(void) } } -static void cleanup_system_info(_mali_system_info *cleanup) -{ - _mali_core_info * current_core; - _mali_mem_info * current_mem; - - /* delete all the core info structs */ - while (NULL != cleanup->core_info) - { - current_core = cleanup->core_info; - cleanup->core_info = cleanup->core_info->next; - _mali_osk_free(current_core); - } - - /* delete all the mem info struct */ - while (NULL != cleanup->mem_info) - { - current_mem = cleanup->mem_info; - cleanup->mem_info = cleanup->mem_info->next; - _mali_osk_free(current_mem); - } - - /* delete the system info struct itself */ - _mali_osk_free(cleanup); -} - -/* Build a dummy system info struct. User space still need this. */ -static _mali_osk_errcode_t build_system_info(void) -{ - _mali_system_info * new_info; - _mali_core_info * current_core; - _mali_mem_info * current_mem; - u32 new_size = 0; - - /* create a new system info struct */ - MALI_CHECK_NON_NULL(new_info = (_mali_system_info *)_mali_osk_malloc(sizeof(_mali_system_info)), _MALI_OSK_ERR_NOMEM); - - _mali_osk_memset(new_info, 0, sizeof(_mali_system_info)); - - /* fill in the info */ - new_info->has_mmu = 1; - new_info->drivermode = _MALI_DRIVER_MODE_NORMAL; - - new_info->core_info = NULL; /* Not used by user space */ - - new_info->mem_info = _mali_osk_calloc(1, sizeof(_mali_mem_info)); - if(NULL == new_info->mem_info) - { - _mali_osk_free(new_info); - return _MALI_OSK_ERR_NOMEM; - } - - new_info->mem_info->size = 1024 * 1024 * 1024; /* 1GiB */ - new_info->mem_info->flags = _MALI_CPU_WRITEABLE | _MALI_CPU_READABLE | _MALI_PP_READABLE | _MALI_PP_WRITEABLE |_MALI_GP_READABLE | _MALI_GP_WRITEABLE | _MALI_MMU_READABLE | _MALI_MMU_WRITEABLE; - new_info->mem_info->maximum_order_supported = 30; - new_info->mem_info->identifier = 0; - new_info->mem_info->next = NULL; - - /* building succeeded, calculate the size */ - - /* size needed of the system info struct itself */ - new_size = sizeof(_mali_system_info); - - /* size needed for the cores */ - for (current_core = new_info->core_info; NULL != current_core; current_core = current_core->next) - { - new_size += sizeof(_mali_core_info); - } - - /* size needed for the memory banks */ - for (current_mem = new_info->mem_info; NULL != current_mem; current_mem = current_mem->next) - { - new_size += sizeof(_mali_mem_info); - } - - /* lock system info access so a user wont't get a corrupted version */ - _mali_osk_lock_wait( system_info_lock, _MALI_OSK_LOCKMODE_RW ); - - /* set new info */ - system_info = new_info; - system_info_size = new_size; - - /* we're safe */ - _mali_osk_lock_signal( system_info_lock, _MALI_OSK_LOCKMODE_RW ); - - /* ok result */ - return _MALI_OSK_ERR_OK; -} - _mali_osk_errcode_t _mali_ukk_get_api_version( _mali_uk_get_api_version_s *args ) { MALI_DEBUG_ASSERT_POINTER(args); @@ -918,102 +810,6 @@ _mali_osk_errcode_t _mali_ukk_get_api_version( _mali_uk_get_api_version_s *args MALI_SUCCESS; } -_mali_osk_errcode_t _mali_ukk_get_system_info_size(_mali_uk_get_system_info_size_s *args) -{ - MALI_DEBUG_ASSERT_POINTER(args); - args->size = system_info_size; - MALI_SUCCESS; -} - -_mali_osk_errcode_t _mali_ukk_get_system_info( _mali_uk_get_system_info_s *args ) -{ - _mali_core_info * current_core; - _mali_mem_info * current_mem; - _mali_osk_errcode_t err = _MALI_OSK_ERR_FAULT; - void * current_write_pos, ** current_patch_pos; - u32 adjust_ptr_base; - - /* check input */ - MALI_DEBUG_ASSERT_POINTER(args); - MALI_CHECK_NON_NULL(args->ctx, _MALI_OSK_ERR_INVALID_ARGS); - MALI_CHECK_NON_NULL(args->system_info, _MALI_OSK_ERR_INVALID_ARGS); - - /* lock the system info */ - _mali_osk_lock_wait( system_info_lock, _MALI_OSK_LOCKMODE_RW ); - - /* first check size */ - if (args->size < system_info_size) goto exit_when_locked; - - /* we build a copy of system_info in the user space buffer specified by the user and - * patch up the pointers. The ukk_private members of _mali_uk_get_system_info_s may - * indicate a different base address for patching the pointers (normally the - * address of the provided system_info buffer would be used). This is helpful when - * the system_info buffer needs to get copied to user space and the pointers need - * to be in user space. - */ - if (0 == args->ukk_private) - { - adjust_ptr_base = (u32)args->system_info; - } - else - { - adjust_ptr_base = args->ukk_private; - } - - /* copy each struct into the buffer, and update its pointers */ - current_write_pos = (void *)args->system_info; - - /* first, the master struct */ - _mali_osk_memcpy(current_write_pos, system_info, sizeof(_mali_system_info)); - - /* advance write pointer */ - current_write_pos = (void *)((u32)current_write_pos + sizeof(_mali_system_info)); - - /* first we write the core info structs, patch starts at master's core_info pointer */ - current_patch_pos = (void **)((u32)args->system_info + offsetof(_mali_system_info, core_info)); - - for (current_core = system_info->core_info; NULL != current_core; current_core = current_core->next) - { - - /* patch the pointer pointing to this core */ - *current_patch_pos = (void*)(adjust_ptr_base + ((u32)current_write_pos - (u32)args->system_info)); - - /* copy the core info */ - _mali_osk_memcpy(current_write_pos, current_core, sizeof(_mali_core_info)); - - /* update patch pos */ - current_patch_pos = (void **)((u32)current_write_pos + offsetof(_mali_core_info, next)); - - /* advance write pos in memory */ - current_write_pos = (void *)((u32)current_write_pos + sizeof(_mali_core_info)); - } - /* patching of last patch pos is not needed, since we wrote NULL there in the first place */ - - /* then we write the mem info structs, patch starts at master's mem_info pointer */ - current_patch_pos = (void **)((u32)args->system_info + offsetof(_mali_system_info, mem_info)); - - for (current_mem = system_info->mem_info; NULL != current_mem; current_mem = current_mem->next) - { - /* patch the pointer pointing to this core */ - *current_patch_pos = (void*)(adjust_ptr_base + ((u32)current_write_pos - (u32)args->system_info)); - - /* copy the core info */ - _mali_osk_memcpy(current_write_pos, current_mem, sizeof(_mali_mem_info)); - - /* update patch pos */ - current_patch_pos = (void **)((u32)current_write_pos + offsetof(_mali_mem_info, next)); - - /* advance write pos in memory */ - current_write_pos = (void *)((u32)current_write_pos + sizeof(_mali_mem_info)); - } - /* patching of last patch pos is not needed, since we wrote NULL there in the first place */ - - err = _MALI_OSK_ERR_OK; -exit_when_locked: - _mali_osk_lock_signal( system_info_lock, _MALI_OSK_LOCKMODE_RW ); - MALI_ERROR(err); -} - _mali_osk_errcode_t _mali_ukk_wait_for_notification( _mali_uk_wait_for_notification_s *args ) { _mali_osk_errcode_t err; @@ -1117,7 +913,7 @@ _mali_osk_errcode_t _mali_ukk_open(void **context) if (0 != mali_dlbu_phys_addr) { - mali_mmu_pagedir_update(session_data->page_directory, MALI_DLB_VIRT_ADDR, mali_dlbu_phys_addr, _MALI_OSK_MALI_PAGE_SIZE); + mali_mmu_pagedir_update(session_data->page_directory, MALI_DLB_VIRT_ADDR, mali_dlbu_phys_addr, _MALI_OSK_MALI_PAGE_SIZE, MALI_CACHE_STANDARD); } if (_MALI_OSK_ERR_OK != mali_memory_session_begin(session_data)) diff --git a/drivers/media/video/samsung/mali/common/mali_kernel_core.h b/drivers/media/video/samsung/mali/common/mali_kernel_core.h old mode 100755 new mode 100644 index d424c48..0ac967e --- a/drivers/media/video/samsung/mali/common/mali_kernel_core.h +++ b/drivers/media/video/samsung/mali/common/mali_kernel_core.h @@ -13,7 +13,6 @@ #include "mali_osk.h" -extern int mali_hang_check_interval; extern int mali_max_job_runtime; typedef enum diff --git a/drivers/media/video/samsung/mali/common/mali_kernel_descriptor_mapping.c b/drivers/media/video/samsung/mali/common/mali_kernel_descriptor_mapping.c old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/common/mali_kernel_descriptor_mapping.h b/drivers/media/video/samsung/mali/common/mali_kernel_descriptor_mapping.h old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/common/mali_kernel_mem_os.c b/drivers/media/video/samsung/mali/common/mali_kernel_mem_os.c index 7462a6d..2830ff8 100644 --- a/drivers/media/video/samsung/mali/common/mali_kernel_mem_os.c +++ b/drivers/media/video/samsung/mali/common/mali_kernel_mem_os.c @@ -95,7 +95,7 @@ static u32 os_allocator_stat(mali_physical_memory_allocator * allocator) static void os_allocator_destroy(mali_physical_memory_allocator * allocator) { os_allocator * info; - MALI_DEBUG_ASSERT_POINTER(allocator); + MALI_DEBUG_ASSERT_POINTER(allocator); MALI_DEBUG_ASSERT_POINTER(allocator->ctx); info = (os_allocator*)allocator->ctx; _mali_osk_lock_term(info->mutex); @@ -132,7 +132,7 @@ static mali_physical_memory_allocation_result os_allocator_allocate(void* ctx, m allocation->num_pages = ((left + _MALI_OSK_CPU_PAGE_SIZE - 1) & ~(_MALI_OSK_CPU_PAGE_SIZE - 1)) >> _MALI_OSK_CPU_PAGE_ORDER; MALI_DEBUG_PRINT(6, ("Allocating page array of size %d bytes\n", allocation->num_pages * sizeof(struct page*))); - while (left > 0) + while (left > 0 && ((info->num_pages_allocated + pages_allocated) < info->num_pages_max) && _mali_osk_mem_check_allocated(os_mem_max_usage)) { err = mali_allocation_engine_map_physical(engine, descriptor, *offset, MALI_MEMORY_ALLOCATION_OS_ALLOCATED_PHYSADDR_MAGIC, info->cpu_usage_adjust, _MALI_OSK_CPU_PAGE_SIZE); if ( _MALI_OSK_ERR_OK != err) @@ -243,7 +243,7 @@ static void os_allocator_release(void * ctx, void * handle) static mali_physical_memory_allocation_result os_allocator_allocate_page_table_block(void * ctx, mali_page_table_block * block) { - int allocation_order = 11; /* _MALI_OSK_CPU_PAGE_SIZE << 11 */ + int allocation_order = 6; /* _MALI_OSK_CPU_PAGE_SIZE << 6 */ void *virt = NULL; u32 size = _MALI_OSK_CPU_PAGE_SIZE << allocation_order; os_allocator * info; diff --git a/drivers/media/video/samsung/mali/common/mali_kernel_mem_os.h b/drivers/media/video/samsung/mali/common/mali_kernel_mem_os.h old mode 100755 new mode 100644 index 0946169..59e6494 --- a/drivers/media/video/samsung/mali/common/mali_kernel_mem_os.h +++ b/drivers/media/video/samsung/mali/common/mali_kernel_mem_os.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 ARM Limited. All rights reserved. + * 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. diff --git a/drivers/media/video/samsung/mali/common/mali_kernel_memory_engine.c b/drivers/media/video/samsung/mali/common/mali_kernel_memory_engine.c old mode 100755 new mode 100644 index 1377560..d770e3e --- a/drivers/media/video/samsung/mali/common/mali_kernel_memory_engine.c +++ b/drivers/media/video/samsung/mali/common/mali_kernel_memory_engine.c @@ -252,6 +252,7 @@ _mali_osk_errcode_t mali_allocation_engine_map_physical(mali_allocation_engine m if ( _MALI_OSK_ERR_OK != err ) { + MALI_DEBUG_PRINT(2, ("Map failed: %s %d\n", __FUNCTION__, __LINE__)); MALI_ERROR( err ); } } @@ -271,7 +272,7 @@ _mali_osk_errcode_t mali_allocation_engine_map_physical(mali_allocation_engine m MALI_DEBUG_PRINT( 2, ("Process address manager succeeded, but Mali Address manager failed for phys=0x%08X size=0x%08X, offset=0x%08X. Will unmap.\n", phys, size, offset)); engine->process_address->unmap_physical(descriptor, offset, size, unmap_flags); } - + MALI_DEBUG_PRINT(2, ("Map mali failed: %s %d\n", __FUNCTION__, __LINE__)); MALI_ERROR( err ); } diff --git a/drivers/media/video/samsung/mali/common/mali_kernel_memory_engine.h b/drivers/media/video/samsung/mali/common/mali_kernel_memory_engine.h old mode 100755 new mode 100644 index cda74c3..3b41cee --- a/drivers/media/video/samsung/mali/common/mali_kernel_memory_engine.h +++ b/drivers/media/video/samsung/mali/common/mali_kernel_memory_engine.h @@ -59,6 +59,7 @@ typedef struct mali_memory_allocation u32 size; /**< Size of the allocation */ u32 permission; /**< Permission settings */ mali_memory_allocation_flag flags; + u32 cache_settings; /* type: mali_memory_cache_settings, found in Ump DD breaks if we include it...*/ _mali_osk_lock_t * lock; diff --git a/drivers/media/video/samsung/mali/common/mali_kernel_utilization.c b/drivers/media/video/samsung/mali/common/mali_kernel_utilization.c old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/common/mali_kernel_utilization.h b/drivers/media/video/samsung/mali/common/mali_kernel_utilization.h old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/common/mali_l2_cache.c b/drivers/media/video/samsung/mali/common/mali_l2_cache.c index aa5cc54..b7267f1 100644 --- a/drivers/media/video/samsung/mali/common/mali_l2_cache.c +++ b/drivers/media/video/samsung/mali/common/mali_l2_cache.c @@ -194,44 +194,60 @@ u32 mali_l2_cache_get_id(struct mali_l2_cache_core *cache) mali_bool mali_l2_cache_core_set_counter_src0(struct mali_l2_cache_core *cache, u32 counter) { u32 value = 0; /* disabled src */ + mali_bool core_is_on; MALI_DEBUG_ASSERT_POINTER(cache); - MALI_DEBUG_ASSERT(counter < (1 << 7)); /* the possible values are 0-127 */ + + core_is_on = mali_l2_cache_lock_power_state(cache); _mali_osk_lock_wait(cache->counter_lock, _MALI_OSK_LOCKMODE_RW); cache->counter_src0 = counter; - if (counter != MALI_HW_CORE_NO_COUNTER) + if (MALI_HW_CORE_NO_COUNTER != counter) { value = counter; } - mali_hw_core_register_write(&cache->hw_core, MALI400_L2_CACHE_REGISTER_PERFCNT_SRC0, value); + if (MALI_TRUE == core_is_on) + { + mali_hw_core_register_write(&cache->hw_core, MALI400_L2_CACHE_REGISTER_PERFCNT_SRC0, value); + } _mali_osk_lock_signal(cache->counter_lock, _MALI_OSK_LOCKMODE_RW); + + mali_l2_cache_unlock_power_state(cache); + return MALI_TRUE; } mali_bool mali_l2_cache_core_set_counter_src1(struct mali_l2_cache_core *cache, u32 counter) { u32 value = 0; /* disabled src */ + mali_bool core_is_on; MALI_DEBUG_ASSERT_POINTER(cache); - MALI_DEBUG_ASSERT(counter < (1 << 7)); /* the possible values are 0-127 */ + + core_is_on = mali_l2_cache_lock_power_state(cache); _mali_osk_lock_wait(cache->counter_lock, _MALI_OSK_LOCKMODE_RW); cache->counter_src1 = counter; - if (counter != MALI_HW_CORE_NO_COUNTER) + if (MALI_HW_CORE_NO_COUNTER != counter) { value = counter; } - mali_hw_core_register_write(&cache->hw_core, MALI400_L2_CACHE_REGISTER_PERFCNT_SRC1, value); + if (MALI_TRUE == core_is_on) + { + mali_hw_core_register_write(&cache->hw_core, MALI400_L2_CACHE_REGISTER_PERFCNT_SRC1, value); + } _mali_osk_lock_signal(cache->counter_lock, _MALI_OSK_LOCKMODE_RW); + + mali_l2_cache_unlock_power_state(cache); + return MALI_TRUE; } diff --git a/drivers/media/video/samsung/mali/common/mali_mem_validation.h b/drivers/media/video/samsung/mali/common/mali_mem_validation.h old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/common/mali_memory.c b/drivers/media/video/samsung/mali/common/mali_memory.c index 7a11d1a..75506ed 100644 --- a/drivers/media/video/samsung/mali/common/mali_memory.c +++ b/drivers/media/video/samsung/mali/common/mali_memory.c @@ -146,6 +146,11 @@ static mali_physical_memory_allocator * physical_memory_allocators = NULL; static dedicated_memory_info * mem_region_registrations = NULL; +mali_allocation_engine mali_mem_get_memory_engine(void) +{ + return memory_engine; +} + /* called during module init */ _mali_osk_errcode_t mali_memory_initialize(void) { @@ -239,6 +244,8 @@ static void descriptor_table_cleanup_callback(int descriptor_id, void* map_targe void mali_memory_session_end(struct mali_session_data *session_data) { + _mali_osk_errcode_t err = _MALI_OSK_ERR_BUSY; + MALI_DEBUG_PRINT(3, ("MMU session end\n")); if (NULL == session_data) @@ -247,76 +254,63 @@ void mali_memory_session_end(struct mali_session_data *session_data) return; } -#ifndef MALI_UKK_HAS_IMPLICIT_MMAP_CLEANUP -#if _MALI_OSK_SPECIFIC_INDIRECT_MMAP -#error Indirect MMAP specified, but UKK does not have implicit MMAP cleanup. Current implementation does not handle this. -#else + while (err == _MALI_OSK_ERR_BUSY) { - _mali_osk_errcode_t err; - err = _MALI_OSK_ERR_BUSY; - while (err == _MALI_OSK_ERR_BUSY) - { - /* Lock the session so we can modify the memory list */ - _mali_osk_lock_wait( session_data->memory_lock, _MALI_OSK_LOCKMODE_RW ); - err = _MALI_OSK_ERR_OK; + /* Lock the session so we can modify the memory list */ + _mali_osk_lock_wait( session_data->memory_lock, _MALI_OSK_LOCKMODE_RW ); + err = _MALI_OSK_ERR_OK; - /* Free all memory engine allocations */ - if (0 == _mali_osk_list_empty(&session_data->memory_head)) - { - mali_memory_allocation *descriptor; - mali_memory_allocation *temp; - _mali_uk_mem_munmap_s unmap_args; + /* Free all memory engine allocations */ + if (0 == _mali_osk_list_empty(&session_data->memory_head)) + { + mali_memory_allocation *descriptor; + mali_memory_allocation *temp; + _mali_uk_mem_munmap_s unmap_args; - MALI_DEBUG_PRINT(1, ("Memory found on session usage list during session termination\n")); + MALI_DEBUG_PRINT(1, ("Memory found on session usage list during session termination\n")); - unmap_args.ctx = session_data; + unmap_args.ctx = session_data; - /* use the 'safe' list iterator, since freeing removes the active block from the list we're iterating */ - _MALI_OSK_LIST_FOREACHENTRY(descriptor, temp, &session_data->memory_head, mali_memory_allocation, list) + /* use the 'safe' list iterator, since freeing removes the active block from the list we're iterating */ + _MALI_OSK_LIST_FOREACHENTRY(descriptor, temp, &session_data->memory_head, mali_memory_allocation, list) + { + MALI_DEBUG_PRINT(4, ("Freeing block with mali address 0x%x size %d mapped in user space at 0x%x\n", + descriptor->mali_address, descriptor->size, descriptor->size, descriptor->mapping) + ); + /* ASSERT that the descriptor's lock references the correct thing */ + MALI_DEBUG_ASSERT( descriptor->lock == session_data->memory_lock ); + /* Therefore, we have already locked the descriptor */ + + unmap_args.size = descriptor->size; + unmap_args.mapping = descriptor->mapping; + unmap_args.cookie = (u32)descriptor; + + /* + * This removes the descriptor from the list, and frees the descriptor + * + * Does not handle the _MALI_OSK_SPECIFIC_INDIRECT_MMAP case, since + * the only OS we are aware of that requires indirect MMAP also has + * implicit mmap cleanup. + */ + err = _mali_ukk_mem_munmap_internal( &unmap_args ); + + if (err == _MALI_OSK_ERR_BUSY) { - MALI_DEBUG_PRINT(4, ("Freeing block with mali address 0x%x size %d mapped in user space at 0x%x\n", - descriptor->mali_address, descriptor->size, descriptor->size, descriptor->mapping) - ); - /* ASSERT that the descriptor's lock references the correct thing */ - MALI_DEBUG_ASSERT( descriptor->lock == session_data->memory_lock ); - /* Therefore, we have already locked the descriptor */ - - unmap_args.size = descriptor->size; - unmap_args.mapping = descriptor->mapping; - unmap_args.cookie = (u32)descriptor; - + _mali_osk_lock_signal( session_data->memory_lock, _MALI_OSK_LOCKMODE_RW ); /* - * This removes the descriptor from the list, and frees the descriptor - * - * Does not handle the _MALI_OSK_SPECIFIC_INDIRECT_MMAP case, since - * the only OS we are aware of that requires indirect MMAP also has - * implicit mmap cleanup. - */ - err = _mali_ukk_mem_munmap_internal( &unmap_args ); - - if (err == _MALI_OSK_ERR_BUSY) - { - _mali_osk_lock_signal( session_data->memory_lock, _MALI_OSK_LOCKMODE_RW ); - /* - * Reason for this; - * We where unable to stall the MMU, probably because we are in page fault handling. - * Sleep for a while with the session lock released, then try again. - * Abnormal termination of programs with running Mali jobs is a normal reason for this. - */ - _mali_osk_time_ubusydelay(10); - break; /* Will jump back into: "while (err == _MALI_OSK_ERR_BUSY)" */ - } + * Reason for this; + * We where unable to stall the MMU, probably because we are in page fault handling. + * Sleep for a while with the session lock released, then try again. + * Abnormal termination of programs with running Mali jobs is a normal reason for this. + */ + _mali_osk_time_ubusydelay(10); + break; /* Will jump back into: "while (err == _MALI_OSK_ERR_BUSY)" */ } } } - /* Assert that we really did free everything */ - MALI_DEBUG_ASSERT( _mali_osk_list_empty(&session_data->memory_head) ); } -#endif /* _MALI_OSK_SPECIFIC_INDIRECT_MMAP */ -#else - /* Lock the session so we can modify the memory list */ - _mali_osk_lock_wait( session_data->memory_lock, _MALI_OSK_LOCKMODE_RW ); -#endif /* MALI_UKK_HAS_IMPLICIT_MMAP_CLEANUP */ + /* Assert that we really did free everything */ + MALI_DEBUG_ASSERT( _mali_osk_list_empty(&session_data->memory_head) ); if (NULL != session_data->descriptor_mapping) { @@ -601,7 +595,9 @@ _mali_osk_errcode_t _mali_ukk_attach_ump_mem( _mali_uk_attach_ump_mem_s *args ) descriptor->mali_address = args->mali_address; descriptor->mali_addr_mapping_info = (void*)session_data; descriptor->process_addr_mapping_info = NULL; /* do not map to process address space */ + descriptor->cache_settings = (u32) MALI_CACHE_STANDARD; descriptor->lock = session_data->memory_lock; + if (args->flags & _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE) { descriptor->flags = MALI_MEMORY_ALLOCATION_FLAG_MAP_GUARD_PAGE; @@ -812,6 +808,7 @@ _mali_osk_errcode_t _mali_ukk_map_external_mem( _mali_uk_map_external_mem_s *arg descriptor->mali_address = args->mali_address; descriptor->mali_addr_mapping_info = (void*)session_data; descriptor->process_addr_mapping_info = NULL; /* do not map to process address space */ + descriptor->cache_settings = (u32)MALI_CACHE_STANDARD; descriptor->lock = session_data->memory_lock; if (args->flags & _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE) { @@ -947,7 +944,7 @@ static _mali_osk_errcode_t mali_address_manager_map(mali_memory_allocation * des MALI_DEBUG_PRINT(7, ("Mali map: mapping 0x%08X to Mali address 0x%08X length 0x%08X\n", *phys_addr, mali_address, size)); - mali_mmu_pagedir_update(session_data->page_directory, mali_address, *phys_addr, size); + mali_mmu_pagedir_update(session_data->page_directory, mali_address, *phys_addr, size, descriptor->cache_settings); MALI_SUCCESS; } @@ -976,6 +973,7 @@ _mali_osk_errcode_t _mali_ukk_mem_mmap( _mali_uk_mem_mmap_s *args ) descriptor->process_addr_mapping_info = args->ukk_private; /* save to be used during physical manager callback */ descriptor->flags = MALI_MEMORY_ALLOCATION_FLAG_MAP_INTO_USERSPACE; + descriptor->cache_settings = (u32) args->cache_settings ; descriptor->lock = session_data->memory_lock; _mali_osk_list_init( &descriptor->list ); diff --git a/drivers/media/video/samsung/mali/common/mali_memory.h b/drivers/media/video/samsung/mali/common/mali_memory.h index 53a994c..78e2945 100644 --- a/drivers/media/video/samsung/mali/common/mali_memory.h +++ b/drivers/media/video/samsung/mali/common/mali_memory.h @@ -77,4 +77,6 @@ _mali_osk_errcode_t mali_memory_core_resource_os_memory(_mali_osk_resource_t * r */ _mali_osk_errcode_t mali_memory_core_resource_dedicated_memory(_mali_osk_resource_t * resource); +mali_allocation_engine mali_mem_get_memory_engine(void); + #endif /* __MALI_MEMORY_H__ */ diff --git a/drivers/media/video/samsung/mali/common/mali_mmu_page_directory.c b/drivers/media/video/samsung/mali/common/mali_mmu_page_directory.c index 43a4cf4..cc91ae9 100644 --- a/drivers/media/video/samsung/mali/common/mali_mmu_page_directory.c +++ b/drivers/media/video/samsung/mali/common/mali_mmu_page_directory.c @@ -297,9 +297,25 @@ void mali_mmu_pagedir_free(struct mali_page_directory *pagedir) } -void mali_mmu_pagedir_update(struct mali_page_directory *pagedir, u32 mali_address, u32 phys_address, u32 size) +void mali_mmu_pagedir_update(struct mali_page_directory *pagedir, u32 mali_address, u32 phys_address, u32 size, mali_memory_cache_settings cache_settings) { u32 end_address = mali_address + size; + u32 permission_bits; + + switch ( cache_settings ) + { + case MALI_CACHE_GP_READ_ALLOCATE: + MALI_DEBUG_PRINT(3, ("Map L2 GP_Read_allocate\n")); + permission_bits = MALI_MMU_FLAGS_FORCE_GP_READ_ALLOCATE; + break; + + case MALI_CACHE_STANDARD: + MALI_DEBUG_PRINT(3, ("Map L2 Standard\n")); + /*falltrough */ + default: + if ( MALI_CACHE_STANDARD != cache_settings) MALI_PRINT_ERROR(("Wrong cache settings\n")); + permission_bits = MALI_MMU_FLAGS_WRITE_PERMISSION | MALI_MMU_FLAGS_READ_PERMISSION | MALI_MMU_FLAGS_PRESENT; + } /* Map physical pages into MMU page tables */ for ( ; mali_address < end_address; mali_address += MALI_MMU_PAGE_SIZE, phys_address += MALI_MMU_PAGE_SIZE) @@ -307,7 +323,7 @@ void mali_mmu_pagedir_update(struct mali_page_directory *pagedir, u32 mali_addre MALI_DEBUG_ASSERT_POINTER(pagedir->page_entries_mapped[MALI_MMU_PDE_ENTRY(mali_address)]); _mali_osk_mem_iowrite32_relaxed(pagedir->page_entries_mapped[MALI_MMU_PDE_ENTRY(mali_address)], MALI_MMU_PTE_ENTRY(mali_address) * sizeof(u32), - phys_address | MALI_MMU_FLAGS_WRITE_PERMISSION | MALI_MMU_FLAGS_READ_PERMISSION | MALI_MMU_FLAGS_PRESENT); + phys_address | permission_bits); } _mali_osk_write_mem_barrier(); } diff --git a/drivers/media/video/samsung/mali/common/mali_mmu_page_directory.h b/drivers/media/video/samsung/mali/common/mali_mmu_page_directory.h index 8aababe..628833a 100644 --- a/drivers/media/video/samsung/mali/common/mali_mmu_page_directory.h +++ b/drivers/media/video/samsung/mali/common/mali_mmu_page_directory.h @@ -50,10 +50,27 @@ typedef enum mali_mmu_entry_flags MALI_MMU_FLAGS_PRESENT = 0x01, MALI_MMU_FLAGS_READ_PERMISSION = 0x02, MALI_MMU_FLAGS_WRITE_PERMISSION = 0x04, - MALI_MMU_FLAGS_MASK = 0x07 + MALI_MMU_FLAGS_OVERRIDE_CACHE = 0x8, + MALI_MMU_FLAGS_WRITE_CACHEABLE = 0x10, + MALI_MMU_FLAGS_WRITE_ALLOCATE = 0x20, + MALI_MMU_FLAGS_WRITE_BUFFERABLE = 0x40, + MALI_MMU_FLAGS_READ_CACHEABLE = 0x80, + MALI_MMU_FLAGS_READ_ALLOCATE = 0x100, + MALI_MMU_FLAGS_MASK = 0x1FF, } mali_mmu_entry_flags; +#define MALI_MMU_FLAGS_FORCE_GP_READ_ALLOCATE ( \ +MALI_MMU_FLAGS_PRESENT | \ + MALI_MMU_FLAGS_READ_PERMISSION | \ + MALI_MMU_FLAGS_WRITE_PERMISSION | \ + MALI_MMU_FLAGS_OVERRIDE_CACHE | \ + MALI_MMU_FLAGS_WRITE_CACHEABLE | \ + MALI_MMU_FLAGS_WRITE_BUFFERABLE | \ + MALI_MMU_FLAGS_READ_CACHEABLE | \ + MALI_MMU_FLAGS_READ_ALLOCATE ) + + struct mali_page_directory { u32 page_directory; /**< Physical address of the memory session's page directory */ @@ -68,7 +85,7 @@ _mali_osk_errcode_t mali_mmu_pagedir_map(struct mali_page_directory *pagedir, u3 _mali_osk_errcode_t mali_mmu_pagedir_unmap(struct mali_page_directory *pagedir, u32 mali_address, u32 size); /* Back virtual address space with actual pages. Assumes input is contiguous and 4k aligned. */ -void mali_mmu_pagedir_update(struct mali_page_directory *pagedir, u32 mali_address, u32 phys_address, u32 size); +void mali_mmu_pagedir_update(struct mali_page_directory *pagedir, u32 mali_address, u32 phys_address, u32 size, u32 cache_settings); u32 mali_page_directory_get_phys_address(struct mali_page_directory *pagedir, u32 index); diff --git a/drivers/media/video/samsung/mali/common/mali_osk.h b/drivers/media/video/samsung/mali/common/mali_osk.h index e32d15d..c478057 100644 --- a/drivers/media/video/samsung/mali/common/mali_osk.h +++ b/drivers/media/video/samsung/mali/common/mali_osk.h @@ -1422,17 +1422,6 @@ void _mali_osk_notification_queue_term( _mali_osk_notification_queue_t *queue ); */ void _mali_osk_notification_queue_send( _mali_osk_notification_queue_t *queue, _mali_osk_notification_t *object ); -#if MALI_STATE_TRACKING -/** @brief Receive a notification from a queue - * - * Check if a notification queue is empty. - * - * @param queue The queue to check. - * @return MALI_TRUE if queue is empty, otherwise MALI_FALSE. - */ -mali_bool _mali_osk_notification_queue_is_empty( _mali_osk_notification_queue_t *queue ); -#endif - /** @brief Receive a notification from a queue * * Receives a single notification from the given queue. diff --git a/drivers/media/video/samsung/mali/common/mali_osk_bitops.h b/drivers/media/video/samsung/mali/common/mali_osk_bitops.h old mode 100755 new mode 100644 index f262f7d..ada1488 --- a/drivers/media/video/samsung/mali/common/mali_osk_bitops.h +++ b/drivers/media/video/samsung/mali/common/mali_osk_bitops.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 ARM Limited. All rights reserved. + * 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. diff --git a/drivers/media/video/samsung/mali/common/mali_osk_list.h b/drivers/media/video/samsung/mali/common/mali_osk_list.h old mode 100755 new mode 100644 index a8d15f2..5987b0a --- a/drivers/media/video/samsung/mali/common/mali_osk_list.h +++ b/drivers/media/video/samsung/mali/common/mali_osk_list.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 ARM Limited. All rights reserved. + * 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. diff --git a/drivers/media/video/samsung/mali/common/mali_osk_mali.h b/drivers/media/video/samsung/mali/common/mali_osk_mali.h old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/common/mali_osk_profiling.h b/drivers/media/video/samsung/mali/common/mali_osk_profiling.h index fd9a8fb..bf1cf8c 100644 --- a/drivers/media/video/samsung/mali/common/mali_osk_profiling.h +++ b/drivers/media/video/samsung/mali/common/mali_osk_profiling.h @@ -11,12 +11,9 @@ #ifndef __MALI_OSK_PROFILING_H__ #define __MALI_OSK_PROFILING_H__ -#if MALI_TIMELINE_PROFILING_ENABLED +#if MALI_TIMELINE_PROFILING_ENABLED && defined (CONFIG_TRACEPOINTS) -#if defined (CONFIG_TRACEPOINTS) && !MALI_INTERNAL_TIMELINE_PROFILING_ENABLED #include "mali_linux_trace.h" -#endif /* CONFIG_TRACEPOINTS && !MALI_INTERNAL_TIMELINE_PROFILING_ENABLED */ - #include "mali_profiling_events.h" #define MALI_PROFILING_MAX_BUFFER_ENTRIES 1048576 @@ -59,13 +56,8 @@ _mali_osk_errcode_t _mali_osk_profiling_start(u32 * limit); * @param data4 Fifth data parameter, depending on event_id specified. * @return _MALI_OSK_ERR_OK on success, otherwise failure. */ -#if defined (CONFIG_TRACEPOINTS) && !MALI_INTERNAL_TIMELINE_PROFILING_ENABLED /* Call Linux tracepoint directly */ #define _mali_osk_profiling_add_event(event_id, data0, data1, data2, data3, data4) trace_mali_timeline_event((event_id), (data0), (data1), (data2), (data3), (data4)) -#else -/* Internal profiling is handled like a plain function call */ -void _mali_osk_profiling_add_event(u32 event_id, u32 data0, u32 data1, u32 data2, u32 data3, u32 data4); -#endif /** * Report a hardware counter event. @@ -74,13 +66,8 @@ void _mali_osk_profiling_add_event(u32 event_id, u32 data0, u32 data1, u32 data2 * @param value The value of the counter. */ -#if defined (CONFIG_TRACEPOINTS) && !MALI_INTERNAL_TIMELINE_PROFILING_ENABLED /* Call Linux tracepoint directly */ #define _mali_osk_profiling_report_hw_counter(counter_id, value) trace_mali_hw_counter(counter_id, value) -#else -/* Internal profiling is handled like a plain function call */ -void _mali_osk_profiling_report_hw_counter(u32 counter_id, u32 value); -#endif /** * Report SW counters @@ -140,7 +127,12 @@ mali_bool _mali_osk_profiling_have_recording(void); /** @} */ /* end group _mali_osk_profiling */ -#endif /* MALI_TIMELINE_PROFILING_ENABLED */ +#else + /* Dummy add_event, for when profiling is disabled. */ + +#define _mali_osk_profiling_add_event(event_id, data0, data1, data2, data3, data4) + +#endif /* MALI_TIMELINE_PROFILING_ENABLED && defined(CONFIG_TRACEPOINTS*/ #endif /* __MALI_OSK_PROFILING_H__ */ diff --git a/drivers/media/video/samsung/mali/common/mali_pm.c b/drivers/media/video/samsung/mali/common/mali_pm.c index 1ef3807..933e54e 100644 --- a/drivers/media/video/samsung/mali/common/mali_pm.c +++ b/drivers/media/video/samsung/mali/common/mali_pm.c @@ -150,16 +150,13 @@ inline void mali_pm_execute_state_change_unlock(void) static void mali_pm_powerup(void) { +#if !MALI_PMM_RUNTIME_JOB_CONTROL_ON MALI_DEBUG_PRINT(3, ("Mali PM: Setting GPU power mode to MALI_POWER_MODE_ON\n")); mali_platform_power_mode_change(MALI_POWER_MODE_ON); - -#if MALI_PMM_RUNTIME_JOB_CONTROL_ON - +#else /* Aquire our reference */ - MALI_DEBUG_PRINT(4, ("Mali PM: Getting device PM reference (=> requesting MALI_POWER_MODE_ON)\n")); _mali_osk_pm_dev_activate(); #endif - mali_group_power_on(); } @@ -169,10 +166,16 @@ static void mali_pm_powerdown(mali_power_mode power_mode) { mali_group_power_off(); } - mali_platform_power_mode_change(power_mode); -#if MALI_PMM_RUNTIME_JOB_CONTROL_ON +#if !MALI_PMM_RUNTIME_JOB_CONTROL_ON + mali_platform_power_mode_change(power_mode); +#else _mali_osk_pm_dev_idle(); + + if (MALI_POWER_MODE_DEEP_SLEEP == power_mode) + { + mali_platform_power_mode_change(power_mode); + } #endif } @@ -539,9 +542,11 @@ void mali_pm_os_resume(void) void mali_pm_runtime_suspend(void) { MALI_DEBUG_PRINT(2, ("Mali PM: OS runtime suspended\n")); + mali_platform_power_mode_change(MALI_POWER_MODE_LIGHT_SLEEP); } void mali_pm_runtime_resume(void) { - MALI_DEBUG_PRINT(3, ("Mali PM: OS runtime resumed\n")); + MALI_DEBUG_PRINT(2, ("Mali PM: OS runtime resumed\n")); + mali_platform_power_mode_change(MALI_POWER_MODE_ON); } diff --git a/drivers/media/video/samsung/mali/common/mali_pm.h b/drivers/media/video/samsung/mali/common/mali_pm.h old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/common/mali_pp.c b/drivers/media/video/samsung/mali/common/mali_pp.c index 5549f82..b525063 100644 --- a/drivers/media/video/samsung/mali/common/mali_pp.c +++ b/drivers/media/video/samsung/mali/common/mali_pp.c @@ -12,6 +12,7 @@ #include "mali_hw_core.h" #include "mali_group.h" #include "mali_osk.h" +#include "mali_pp_scheduler.h" #include "regs/mali_200_regs.h" #include "mali_kernel_common.h" #include "mali_kernel_core.h" @@ -194,6 +195,55 @@ _mali_osk_errcode_t mali_pp_stop_bus_wait(struct mali_pp_core *core) return _MALI_OSK_ERR_OK; } +/* Frame register reset values. + * Taken from the Mali400 TRM, 3.6. Pixel processor control register summary */ +static const u32 mali_frame_registers_reset_values[_MALI_PP_MAX_FRAME_REGISTERS] = +{ + 0x0, /* Renderer List Address Register */ + 0x0, /* Renderer State Word Base Address Register */ + 0x0, /* Renderer Vertex Base Register */ + 0x2, /* Feature Enable Register */ + 0x0, /* Z Clear Value Register */ + 0x0, /* Stencil Clear Value Register */ + 0x0, /* ABGR Clear Value 0 Register */ + 0x0, /* ABGR Clear Value 1 Register */ + 0x0, /* ABGR Clear Value 2 Register */ + 0x0, /* ABGR Clear Value 3 Register */ + 0x0, /* Bounding Box Left Right Register */ + 0x0, /* Bounding Box Bottom Register */ + 0x0, /* FS Stack Address Register */ + 0x0, /* FS Stack Size and Initial Value Register */ + 0x0, /* Reserved */ + 0x0, /* Reserved */ + 0x0, /* Origin Offset X Register */ + 0x0, /* Origin Offset Y Register */ + 0x75, /* Subpixel Specifier Register */ + 0x0, /* Tiebreak mode Register */ + 0x0, /* Polygon List Format Register */ + 0x0, /* Scaling Register */ + 0x0 /* Tilebuffer configuration Register */ +}; + +/* WBx register reset values */ +static const u32 mali_wb_registers_reset_values[_MALI_PP_MAX_WB_REGISTERS] = +{ + 0x0, /* WBx Source Select Register */ + 0x0, /* WBx Target Address Register */ + 0x0, /* WBx Target Pixel Format Register */ + 0x0, /* WBx Target AA Format Register */ + 0x0, /* WBx Target Layout */ + 0x0, /* WBx Target Scanline Length */ + 0x0, /* WBx Target Flags Register */ + 0x0, /* WBx MRT Enable Register */ + 0x0, /* WBx MRT Offset Register */ + 0x0, /* WBx Global Test Enable Register */ + 0x0, /* WBx Global Test Reference Value Register */ + 0x0 /* WBx Global Test Compare Function Register */ +}; + +/* Performance Counter 0 Enable Register reset value */ +static const u32 mali_perf_cnt_enable_reset_value = 0; + _mali_osk_errcode_t mali_pp_hard_reset(struct mali_pp_core *core) { /* Bus must be stopped before calling this function */ @@ -206,7 +256,7 @@ _mali_osk_errcode_t mali_pp_hard_reset(struct mali_pp_core *core) MALI_DEBUG_PRINT(2, ("Mali PP: Hard reset of core %s\n", core->hw_core.description)); MALI_ASSERT_GROUP_LOCKED(core->group); - mali_pp_post_process_job(core); /* @@@@ is there some cases where it is unsafe to post process the job here? */ + mali_pp_post_process_job(core); /* @@@@ is there some cases where it is unsafe to post process the job here? */ /* Set register to a bogus value. The register will be used to detect when reset is complete */ mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_WRITE_BOUNDARY_LOW, reset_invalid_value); @@ -247,10 +297,11 @@ _mali_osk_errcode_t mali_pp_reset(struct mali_pp_core *core) MALI_DEBUG_PRINT(4, ("Mali PP: Reset of core %s\n", core->hw_core.description)); MALI_ASSERT_GROUP_LOCKED(core->group); - mali_pp_post_process_job(core); /* @@@@ is there some cases where it is unsafe to post process the job here? */ + mali_pp_post_process_job(core); /* @@@@ is there some cases where it is unsafe to post process the job here? */ mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_INT_MASK, 0); /* disable the IRQs */ + #if defined(USING_MALI200) /* On Mali-200, stop the bus, then do a hard reset of the core */ @@ -319,7 +370,10 @@ void mali_pp_job_start(struct mali_pp_core *core, struct mali_pp_job *job, u32 s MALI_DEBUG_ASSERT_POINTER(core); MALI_ASSERT_GROUP_LOCKED(core->group); - mali_hw_core_register_write_array_relaxed(&core->hw_core, MALI200_REG_ADDR_FRAME, frame_registers, MALI200_NUM_REGS_FRAME); + mali_hw_core_register_write_array_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_FRAME, frame_registers, MALI200_NUM_REGS_FRAME, mali_frame_registers_reset_values); + + _mali_osk_mem_barrier(); + if (0 != sub_job) { /* @@ -328,22 +382,34 @@ void mali_pp_job_start(struct mali_pp_core *core, struct mali_pp_job *job, u32 s * but we need to patch these for all other sub jobs */ mali_hw_core_register_write_relaxed(&core->hw_core, MALI200_REG_ADDR_FRAME, mali_pp_job_get_addr_frame(job, sub_job)); - mali_hw_core_register_write_relaxed(&core->hw_core, MALI200_REG_ADDR_STACK, mali_pp_job_get_addr_stack(job, sub_job)); + mali_hw_core_register_write_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_STACK, mali_pp_job_get_addr_stack(job, sub_job), mali_frame_registers_reset_values[MALI200_REG_ADDR_STACK/4]); } if (wb0_registers[0]) /* M200_WB0_REG_SOURCE_SELECT register */ { - mali_hw_core_register_write_array_relaxed(&core->hw_core, MALI200_REG_ADDR_WB0, wb0_registers, MALI200_NUM_REGS_WBx); + mali_hw_core_register_write_array_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_WB0, wb0_registers, MALI200_NUM_REGS_WBx, mali_wb_registers_reset_values); + } + else + { + mali_hw_core_register_write_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_WB0, 0, mali_wb_registers_reset_values[0] ); } if (wb1_registers[0]) /* M200_WB1_REG_SOURCE_SELECT register */ { - mali_hw_core_register_write_array_relaxed(&core->hw_core, MALI200_REG_ADDR_WB1, wb1_registers, MALI200_NUM_REGS_WBx); + mali_hw_core_register_write_array_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_WB1, wb1_registers, MALI200_NUM_REGS_WBx, mali_wb_registers_reset_values); + } + else + { + mali_hw_core_register_write_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_WB1, 0, mali_wb_registers_reset_values[0] ); } if (wb2_registers[0]) /* M200_WB2_REG_SOURCE_SELECT register */ { - mali_hw_core_register_write_array_relaxed(&core->hw_core, MALI200_REG_ADDR_WB2, wb2_registers, MALI200_NUM_REGS_WBx); + mali_hw_core_register_write_array_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_WB2, wb2_registers, MALI200_NUM_REGS_WBx, mali_wb_registers_reset_values); + } + else + { + mali_hw_core_register_write_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_WB2, 0, mali_wb_registers_reset_values[0] ); } /* This selects which performance counters we are reading */ @@ -352,13 +418,14 @@ void mali_pp_job_start(struct mali_pp_core *core, struct mali_pp_job *job, u32 s /* global_config has enabled HW counters, this will override anything specified by user space */ if (MALI_HW_CORE_NO_COUNTER != core->counter_src0_used) { - mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_0_SRC, core->counter_src0_used); - mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_0_ENABLE, MALI200_REG_VAL_PERF_CNT_ENABLE); + mali_hw_core_register_write_relaxed(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_0_SRC, core->counter_src0_used); + mali_hw_core_register_write_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_0_ENABLE, MALI200_REG_VAL_PERF_CNT_ENABLE, mali_perf_cnt_enable_reset_value); + } if (MALI_HW_CORE_NO_COUNTER != core->counter_src1_used) { - mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_1_SRC, core->counter_src1_used); - mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_1_ENABLE, MALI200_REG_VAL_PERF_CNT_ENABLE); + mali_hw_core_register_write_relaxed(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_1_SRC, core->counter_src1_used); + mali_hw_core_register_write_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_1_ENABLE, MALI200_REG_VAL_PERF_CNT_ENABLE, mali_perf_cnt_enable_reset_value); } } else @@ -370,15 +437,15 @@ void mali_pp_job_start(struct mali_pp_core *core, struct mali_pp_job *job, u32 s if (perf_counter_flag & _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE) { core->counter_src0_used = mali_pp_job_get_perf_counter_src0(job); - mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_0_SRC, core->counter_src0_used); - mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_0_ENABLE, MALI200_REG_VAL_PERF_CNT_ENABLE); + mali_hw_core_register_write_relaxed(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_0_SRC, core->counter_src0_used); + mali_hw_core_register_write_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_0_ENABLE, MALI200_REG_VAL_PERF_CNT_ENABLE, mali_perf_cnt_enable_reset_value); } if (perf_counter_flag & _MALI_PERFORMANCE_COUNTER_FLAG_SRC1_ENABLE) { core->counter_src1_used = mali_pp_job_get_perf_counter_src1(job); - mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_1_SRC, core->counter_src1_used); - mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_1_ENABLE, MALI200_REG_VAL_PERF_CNT_ENABLE); + mali_hw_core_register_write_relaxed(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_1_SRC, core->counter_src1_used); + mali_hw_core_register_write_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_1_ENABLE, MALI200_REG_VAL_PERF_CNT_ENABLE, mali_perf_cnt_enable_reset_value); } } } @@ -399,8 +466,8 @@ void mali_pp_job_start(struct mali_pp_core *core, struct mali_pp_job *job, u32 s core->timeout_job_id = mali_pp_job_get_id(job); #if MALI_TIMELINE_PROFILING_ENABLED - _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE | MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_id) | MALI_PROFILING_EVENT_REASON_SINGLE_HW_FLUSH, job->frame_builder_id, job->flush_id, 0, 0, 0); - _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START|MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_id), job->pid, job->tid, 0, 0, 0); + _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE | MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_id) | MALI_PROFILING_EVENT_REASON_SINGLE_HW_FLUSH, mali_pp_job_get_frame_builder_id(job), mali_pp_job_get_flush_id(job), 0, 0, 0); + _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START|MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_id), mali_pp_job_get_pid(job), mali_pp_job_get_tid(job), 0, 0, 0); #endif core->running_job = job; @@ -498,9 +565,7 @@ static void mali_pp_bottom_half(void *data) u32 irq_errors; #if MALI_TIMELINE_PROFILING_ENABLED -#if 0 /* Bottom half TLP logging is currently not supported */ - _mali_osk_profiling_add_event( MALI_PROFILING_EVENT_TYPE_START| MALI_PROFILING_EVENT_CHANNEL_SOFTWARE , _mali_osk_get_pid(), _mali_osk_get_tid(), 0, 0, 0); -#endif + _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP(core->core_id), 0, 0); #endif mali_group_lock(core->group); /* Group lock grabbed in core handlers, but released in common group handler */ @@ -509,6 +574,9 @@ static void mali_pp_bottom_half(void *data) { MALI_PRINT_ERROR(("Interrupt bottom half of %s when core is OFF.", core->hw_core.description)); mali_group_unlock(core->group); +#if MALI_TIMELINE_PROFILING_ENABLED + _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0); +#endif return; } @@ -521,6 +589,9 @@ static void mali_pp_bottom_half(void *data) mali_pp_post_process_job(core); MALI_DEBUG_PRINT(3, ("Mali PP: Job completed, calling group handler\n")); mali_group_bottom_half(core->group, GROUP_EVENT_PP_JOB_COMPLETED); /* Will release group lock */ +#if MALI_TIMELINE_PROFILING_ENABLED + _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0); +#endif return; } @@ -535,6 +606,9 @@ static void mali_pp_bottom_half(void *data) MALI_PRINT_ERROR(("Mali PP: Unknown interrupt 0x%08X from core %s, aborting job\n", irq_readout, core->hw_core.description)); mali_group_bottom_half(core->group, GROUP_EVENT_PP_JOB_FAILED); /* Will release group lock */ +#if MALI_TIMELINE_PROFILING_ENABLED + _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0); +#endif return; } else if (MALI_TRUE == core->core_timed_out) /* SW timeout */ @@ -551,6 +625,9 @@ static void mali_pp_bottom_half(void *data) mali_group_unlock(core->group); } core->core_timed_out = MALI_FALSE; +#if MALI_TIMELINE_PROFILING_ENABLED + _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0); +#endif return; } else if (irq_readout & MALI200_REG_VAL_IRQ_HANG) @@ -567,9 +644,7 @@ static void mali_pp_bottom_half(void *data) mali_group_unlock(core->group); #if MALI_TIMELINE_PROFILING_ENABLED -#if 0 /* Bottom half TLP logging is currently not supported */ - _mali_osk_profiling_add_event( MALI_PROFILING_EVENT_TYPE_STOP| MALI_PROFILING_EVENT_CHANNEL_SOFTWARE , _mali_osk_get_pid(), _mali_osk_get_tid(), 0, 0, 0); -#endif + _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0); #endif } diff --git a/drivers/media/video/samsung/mali/common/mali_pp.h b/drivers/media/video/samsung/mali/common/mali_pp.h old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/common/mali_pp_job.c b/drivers/media/video/samsung/mali/common/mali_pp_job.c index 1efcfda..3c23637 100644 --- a/drivers/media/video/samsung/mali/common/mali_pp_job.c +++ b/drivers/media/video/samsung/mali/common/mali_pp_job.c @@ -14,62 +14,41 @@ #include "mali_kernel_common.h" #include "mali_uk_types.h" -struct mali_pp_job *mali_pp_job_create(struct mali_session_data *session, _mali_uk_pp_start_job_s *args, u32 id) +struct mali_pp_job *mali_pp_job_create(struct mali_session_data *session, _mali_uk_pp_start_job_s *uargs, u32 id) { struct mali_pp_job *job; - if (args->num_cores > _MALI_PP_MAX_SUB_JOBS) - { - MALI_PRINT_ERROR(("Mali PP job: Too many sub jobs specified in job object\n")); - return NULL; - } - job = _mali_osk_malloc(sizeof(struct mali_pp_job)); if (NULL != job) { u32 i; - _mali_osk_list_init(&job->list); - job->session = session; - job->id = id; - job->user_id = args->user_job_ptr; - _mali_osk_memcpy(job->frame_registers, args->frame_registers, sizeof(job->frame_registers)); - _mali_osk_memcpy(job->frame_registers_addr_frame, args->frame_registers_addr_frame, sizeof(job->frame_registers_addr_frame)); - _mali_osk_memcpy(job->frame_registers_addr_stack, args->frame_registers_addr_stack, sizeof(job->frame_registers_addr_stack)); - /* Only copy write back registers for the units that are enabled */ - job->wb0_registers[0] = 0; - job->wb1_registers[0] = 0; - job->wb2_registers[0] = 0; - if (args->wb0_registers[0]) /* M200_WB0_REG_SOURCE_SELECT register */ - { - _mali_osk_memcpy(job->wb0_registers, args->wb0_registers, sizeof(job->wb0_registers)); - } - if (args->wb1_registers[0]) /* M200_WB1_REG_SOURCE_SELECT register */ + if (0 != _mali_osk_copy_from_user(&job->uargs, uargs, sizeof(_mali_uk_pp_start_job_s))) { - _mali_osk_memcpy(job->wb1_registers, args->wb1_registers, sizeof(job->wb1_registers)); + _mali_osk_free(job); + return NULL; } - if (args->wb2_registers[0]) /* M200_WB2_REG_SOURCE_SELECT register */ + + if (job->uargs.num_cores > _MALI_PP_MAX_SUB_JOBS) { - _mali_osk_memcpy(job->wb2_registers, args->wb2_registers, sizeof(job->wb2_registers)); + MALI_PRINT_ERROR(("Mali PP job: Too many sub jobs specified in job object\n")); + _mali_osk_free(job); + return NULL; } - job->perf_counter_flag = args->perf_counter_flag; - job->perf_counter_src0 = args->perf_counter_src0; - job->perf_counter_src1 = args->perf_counter_src1; - for (i = 0; i < args->num_cores; i++) + _mali_osk_list_init(&job->list); + job->session = session; + job->id = id; + for (i = 0; i < job->uargs.num_cores; i++) { job->perf_counter_value0[i] = 0; job->perf_counter_value1[i] = 0; } - job->sub_job_count = args->num_cores; job->sub_jobs_started = 0; job->sub_jobs_completed = 0; job->sub_job_errors = 0; - job->pid = _mali_osk_get_pid(); job->tid = _mali_osk_get_tid(); - job->frame_builder_id = args->frame_builder_id; - job->flush_id = args->flush_id; return job; } @@ -81,12 +60,3 @@ void mali_pp_job_delete(struct mali_pp_job *job) { _mali_osk_free(job); } - -_mali_osk_errcode_t mali_pp_job_check(struct mali_pp_job *job) -{ - if ((0 == job->frame_registers[0]) || (0 == job->frame_registers[1])) - { - return _MALI_OSK_ERR_FAULT; - } - return _MALI_OSK_ERR_OK; -} diff --git a/drivers/media/video/samsung/mali/common/mali_pp_job.h b/drivers/media/video/samsung/mali/common/mali_pp_job.h index 7fe87f8..7e25504 100644 --- a/drivers/media/video/samsung/mali/common/mali_pp_job.h +++ b/drivers/media/video/samsung/mali/common/mali_pp_job.h @@ -27,37 +27,28 @@ struct mali_pp_job { _mali_osk_list_t list; /**< Used to link jobs together in the scheduler queue */ struct mali_session_data *session; /**< Session which submitted this job */ + _mali_uk_pp_start_job_s uargs; /**< Arguments from user space */ u32 id; /**< identifier for this job in kernel space (sequencial numbering) */ - u32 user_id; /**< identifier for the job in user space */ - u32 frame_registers[_MALI_PP_MAX_FRAME_REGISTERS]; /**< core specific registers associated with this job, see ARM DDI0415A */ - u32 frame_registers_addr_frame[_MALI_PP_MAX_SUB_JOBS - 1]; /**< ADDR_FRAME registers for sub job 1-7 */ - u32 frame_registers_addr_stack[_MALI_PP_MAX_SUB_JOBS - 1]; /**< ADDR_STACK registers for sub job 1-7 */ - u32 wb0_registers[_MALI_PP_MAX_WB_REGISTERS]; /**< Write back unit 0 registers */ - u32 wb1_registers[_MALI_PP_MAX_WB_REGISTERS]; /**< Write back unit 1 registers */ - u32 wb2_registers[_MALI_PP_MAX_WB_REGISTERS]; /**< Write back unit 2 registers */ - u32 perf_counter_flag; /**< bitmask indicating which performance counters to enable, see \ref _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE and related macro definitions */ - u32 perf_counter_src0; /**< Source id for performance counter 0 (see ARM DDI0415A, Table 3-60) */ - u32 perf_counter_src1; /**< Source id for performance counter 1 (see ARM DDI0415A, Table 3-60) */ u32 perf_counter_value0[_MALI_PP_MAX_SUB_JOBS]; /**< Value of performance counter 0 (to be returned to user space), one for each sub job */ - u32 perf_counter_value1[_MALI_PP_MAX_SUB_JOBS]; /**< Value of performance counter 1 (to be returned to user space), one for each sub job */ - u32 sub_job_count; /**< Total number of sub-jobs in this superjob */ + u32 perf_counter_value1[_MALI_PP_MAX_SUB_JOBS]; /**< Value of performance counter 1 (to be returned to user space), one for each sub job */ u32 sub_jobs_started; /**< Total number of sub-jobs started (always started in ascending order) */ u32 sub_jobs_completed; /**< Number of completed sub-jobs in this superjob */ u32 sub_job_errors; /**< Bitfield with errors (errors for each single sub-job is or'ed together) */ u32 pid; /**< Process ID of submitting process */ u32 tid; /**< Thread ID of submitting thread */ - u32 frame_builder_id; /**< id of the originating frame builder */ - u32 flush_id; /**< flush id within the originating frame builder */ }; -struct mali_pp_job *mali_pp_job_create(struct mali_session_data *session, _mali_uk_pp_start_job_s *args, u32 id); +struct mali_pp_job *mali_pp_job_create(struct mali_session_data *session, _mali_uk_pp_start_job_s *uargs, u32 id); void mali_pp_job_delete(struct mali_pp_job *job); -_mali_osk_errcode_t mali_pp_job_check(struct mali_pp_job *job); - -/****************************************************** - * simple utility functions for dealing with pp jobs: - *****************************************************/ +MALI_STATIC_INLINE _mali_osk_errcode_t mali_pp_job_check(struct mali_pp_job *job) +{ + if ((0 == job->uargs.frame_registers[0]) || (0 == job->uargs.frame_registers[1])) + { + return _MALI_OSK_ERR_FAULT; + } + return _MALI_OSK_ERR_OK; +} MALI_STATIC_INLINE u32 mali_pp_job_get_id(struct mali_pp_job *job) { @@ -66,33 +57,43 @@ MALI_STATIC_INLINE u32 mali_pp_job_get_id(struct mali_pp_job *job) MALI_STATIC_INLINE u32 mali_pp_job_get_user_id(struct mali_pp_job *job) { - return job->user_id; + return job->uargs.user_job_ptr; } MALI_STATIC_INLINE u32 mali_pp_job_get_frame_builder_id(struct mali_pp_job *job) { - return job->frame_builder_id; + return job->uargs.frame_builder_id; } MALI_STATIC_INLINE u32 mali_pp_job_get_flush_id(struct mali_pp_job *job) { - return job->flush_id; + return job->uargs.flush_id; +} + +MALI_STATIC_INLINE u32 mali_pp_job_get_pid(struct mali_pp_job *job) +{ + return job->pid; +} + +MALI_STATIC_INLINE u32 mali_pp_job_get_tid(struct mali_pp_job *job) +{ + return job->tid; } MALI_STATIC_INLINE u32* mali_pp_job_get_frame_registers(struct mali_pp_job *job) { - return job->frame_registers; + return job->uargs.frame_registers; } MALI_STATIC_INLINE u32 mali_pp_job_get_addr_frame(struct mali_pp_job *job, u32 sub_job) { if (sub_job == 0) { - return job->frame_registers[MALI200_REG_ADDR_FRAME / sizeof(u32)]; + return job->uargs.frame_registers[MALI200_REG_ADDR_FRAME / sizeof(u32)]; } else if (sub_job < _MALI_PP_MAX_SUB_JOBS) { - return job->frame_registers_addr_frame[sub_job - 1]; + return job->uargs.frame_registers_addr_frame[sub_job - 1]; } return 0; @@ -102,11 +103,11 @@ MALI_STATIC_INLINE u32 mali_pp_job_get_addr_stack(struct mali_pp_job *job, u32 s { if (sub_job == 0) { - return job->frame_registers[MALI200_REG_ADDR_STACK / sizeof(u32)]; + return job->uargs.frame_registers[MALI200_REG_ADDR_STACK / sizeof(u32)]; } else if (sub_job < _MALI_PP_MAX_SUB_JOBS) { - return job->frame_registers_addr_stack[sub_job - 1]; + return job->uargs.frame_registers_addr_stack[sub_job - 1]; } return 0; @@ -114,32 +115,32 @@ MALI_STATIC_INLINE u32 mali_pp_job_get_addr_stack(struct mali_pp_job *job, u32 s MALI_STATIC_INLINE u32* mali_pp_job_get_wb0_registers(struct mali_pp_job *job) { - return job->wb0_registers; + return job->uargs.wb0_registers; } MALI_STATIC_INLINE u32* mali_pp_job_get_wb1_registers(struct mali_pp_job *job) { - return job->wb1_registers; + return job->uargs.wb1_registers; } MALI_STATIC_INLINE u32* mali_pp_job_get_wb2_registers(struct mali_pp_job *job) { - return job->wb2_registers; + return job->uargs.wb2_registers; } MALI_STATIC_INLINE void mali_pp_job_disable_wb0(struct mali_pp_job *job) { - job->wb0_registers[MALI200_REG_ADDR_WB_SOURCE_SELECT] = 0; + job->uargs.wb0_registers[MALI200_REG_ADDR_WB_SOURCE_SELECT] = 0; } MALI_STATIC_INLINE void mali_pp_job_disable_wb1(struct mali_pp_job *job) { - job->wb1_registers[MALI200_REG_ADDR_WB_SOURCE_SELECT] = 0; + job->uargs.wb1_registers[MALI200_REG_ADDR_WB_SOURCE_SELECT] = 0; } MALI_STATIC_INLINE void mali_pp_job_disable_wb2(struct mali_pp_job *job) { - job->wb2_registers[MALI200_REG_ADDR_WB_SOURCE_SELECT] = 0; + job->uargs.wb2_registers[MALI200_REG_ADDR_WB_SOURCE_SELECT] = 0; } MALI_STATIC_INLINE struct mali_session_data *mali_pp_job_get_session(struct mali_pp_job *job) @@ -149,7 +150,7 @@ MALI_STATIC_INLINE struct mali_session_data *mali_pp_job_get_session(struct mali MALI_STATIC_INLINE mali_bool mali_pp_job_has_unstarted_sub_jobs(struct mali_pp_job *job) { - return (job->sub_jobs_started < job->sub_job_count) ? MALI_TRUE : MALI_FALSE; + return (job->sub_jobs_started < job->uargs.num_cores) ? MALI_TRUE : MALI_FALSE; } /* Function used when we are terminating a session with jobs. Return TRUE if it has a rendering job. @@ -157,7 +158,7 @@ MALI_STATIC_INLINE mali_bool mali_pp_job_has_unstarted_sub_jobs(struct mali_pp_j MALI_STATIC_INLINE mali_bool mali_pp_job_is_currently_rendering_and_if_so_abort_new_starts(struct mali_pp_job *job) { /* All can not be started, since then it would not be in the job queue */ - MALI_DEBUG_ASSERT( job->sub_jobs_started != job->sub_job_count ); + MALI_DEBUG_ASSERT( job->sub_jobs_started != job->uargs.num_cores ); /* If at least one job is started */ if ( (job->sub_jobs_started > 0) ) @@ -165,7 +166,7 @@ MALI_STATIC_INLINE mali_bool mali_pp_job_is_currently_rendering_and_if_so_abort_ /* If at least one job is currently being rendered, and thus assigned to a group and core */ if (job->sub_jobs_started > job->sub_jobs_completed ) { - u32 jobs_remaining = job->sub_job_count - job->sub_jobs_started; + u32 jobs_remaining = job->uargs.num_cores - job->sub_jobs_started; job->sub_jobs_started += jobs_remaining; job->sub_jobs_completed += jobs_remaining; job->sub_job_errors += jobs_remaining; @@ -179,7 +180,7 @@ MALI_STATIC_INLINE mali_bool mali_pp_job_is_currently_rendering_and_if_so_abort_ MALI_STATIC_INLINE mali_bool mali_pp_job_is_complete(struct mali_pp_job *job) { - return (job->sub_job_count == job->sub_jobs_completed) ? MALI_TRUE : MALI_FALSE; + return (job->uargs.num_cores == job->sub_jobs_completed) ? MALI_TRUE : MALI_FALSE; } MALI_STATIC_INLINE u32 mali_pp_job_get_first_unstarted_sub_job(struct mali_pp_job *job) @@ -189,7 +190,7 @@ MALI_STATIC_INLINE u32 mali_pp_job_get_first_unstarted_sub_job(struct mali_pp_jo MALI_STATIC_INLINE u32 mali_pp_job_get_sub_job_count(struct mali_pp_job *job) { - return job->sub_job_count; + return job->uargs.num_cores; } MALI_STATIC_INLINE void mali_pp_job_mark_sub_job_started(struct mali_pp_job *job, u32 sub_job) @@ -199,6 +200,15 @@ MALI_STATIC_INLINE void mali_pp_job_mark_sub_job_started(struct mali_pp_job *job job->sub_jobs_started++; } +MALI_STATIC_INLINE void mali_pp_job_mark_sub_job_not_stated(struct mali_pp_job *job, u32 sub_job) +{ + /* This is only safe on Mali-200. */ +#if !defined(USING_MALI200) + MALI_DEBUG_ASSERT(0); +#endif + job->sub_jobs_started--; +} + MALI_STATIC_INLINE void mali_pp_job_mark_sub_job_completed(struct mali_pp_job *job, mali_bool success) { job->sub_jobs_completed++; @@ -217,19 +227,34 @@ MALI_STATIC_INLINE mali_bool mali_pp_job_was_success(struct mali_pp_job *job) return MALI_FALSE; } +MALI_STATIC_INLINE mali_bool mali_pp_job_has_active_barrier(struct mali_pp_job *job) +{ + return job->uargs.flags & _MALI_PP_JOB_FLAG_BARRIER ? MALI_TRUE : MALI_FALSE; +} + +MALI_STATIC_INLINE void mali_pp_job_barrier_enforced(struct mali_pp_job *job) +{ + job->uargs.flags &= ~_MALI_PP_JOB_FLAG_BARRIER; +} + +MALI_STATIC_INLINE mali_bool mali_pp_job_use_no_notification(struct mali_pp_job *job) +{ + return job->uargs.flags & _MALI_PP_JOB_FLAG_NO_NOTIFICATION ? MALI_TRUE : MALI_FALSE; +} + MALI_STATIC_INLINE u32 mali_pp_job_get_perf_counter_flag(struct mali_pp_job *job) { - return job->perf_counter_flag; + return job->uargs.perf_counter_flag; } MALI_STATIC_INLINE u32 mali_pp_job_get_perf_counter_src0(struct mali_pp_job *job) { - return job->perf_counter_src0; + return job->uargs.perf_counter_src0; } MALI_STATIC_INLINE u32 mali_pp_job_get_perf_counter_src1(struct mali_pp_job *job) { - return job->perf_counter_src1; + return job->uargs.perf_counter_src1; } MALI_STATIC_INLINE u32 mali_pp_job_get_perf_counter_value0(struct mali_pp_job *job, u32 sub_job) diff --git a/drivers/media/video/samsung/mali/common/mali_pp_scheduler.c b/drivers/media/video/samsung/mali/common/mali_pp_scheduler.c index ce07a76..eedf661 100644 --- a/drivers/media/video/samsung/mali/common/mali_pp_scheduler.c +++ b/drivers/media/video/samsung/mali/common/mali_pp_scheduler.c @@ -17,6 +17,8 @@ #include "mali_pp_job.h" #include "mali_group.h" #include "mali_cluster.h" +#include "mali_osk_profiling.h" + /* Maximum of 8 PP cores (a group can only have maximum of 1 PP core) */ #define MALI_MAX_NUMBER_OF_PP_GROUPS 8 @@ -38,10 +40,15 @@ struct mali_pp_slot * so we don't need to take the group lock so often (and also avoid clutter with the working lock) */ enum mali_pp_slot_state state; + struct mali_session_data *session; + struct mali_pp_job *job; + u32 subjob; }; static u32 pp_version = 0; static _MALI_OSK_LIST_HEAD(job_queue); /* List of jobs with some unscheduled work */ +static u32 job_queue_depth; + static struct mali_pp_slot slots[MALI_MAX_NUMBER_OF_PP_GROUPS]; static u32 num_slots = 0; static u32 num_slots_idle = 0; @@ -60,7 +67,7 @@ _mali_osk_errcode_t mali_pp_scheduler_initialize(void) _MALI_OSK_INIT_LIST_HEAD(&job_queue); - pp_scheduler_lock = _mali_osk_lock_init(_MALI_OSK_LOCKFLAG_ORDERED |_MALI_OSK_LOCKFLAG_NONINTERRUPTABLE, 0, _MALI_OSK_LOCK_ORDER_SCHEDULER); + pp_scheduler_lock = _mali_osk_lock_init(_MALI_OSK_LOCKFLAG_ORDERED | _MALI_OSK_LOCKFLAG_SPINLOCK_IRQ |_MALI_OSK_LOCKFLAG_NONINTERRUPTABLE, 0, _MALI_OSK_LOCK_ORDER_SCHEDULER); if (NULL == pp_scheduler_lock) { return _MALI_OSK_ERR_NOMEM; @@ -91,6 +98,7 @@ _mali_osk_errcode_t mali_pp_scheduler_initialize(void) } slots[num_slots].group = group; slots[num_slots].state = MALI_PP_SLOT_STATE_IDLE; + slots[num_slots].session = NULL; num_slots++; num_slots_idle++; } @@ -138,151 +146,186 @@ MALI_STATIC_INLINE void mali_pp_scheduler_assert_locked(void) #define MALI_ASSERT_PP_SCHEDULER_LOCKED() #endif -static void mali_pp_scheduler_schedule(void) +static mali_bool mali_pp_scheduler_session_has_running_jobs(struct mali_session_data *session) { u32 i; - struct mali_pp_job *job; -#if MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP_BETWEEN_APPS - struct mali_session_data * session; -#endif MALI_ASSERT_PP_SCHEDULER_LOCKED(); - if (0 < pause_count || 0 == num_slots_idle || _mali_osk_list_empty(&job_queue)) + if (num_slots_idle == num_slots) { - MALI_DEBUG_PRINT(4, ("Mali PP scheduler: Nothing to schedule (paused=%u, idle slots=%u)\n", - pause_count, num_slots_idle)); - return; /* Nothing to do, so early out */ + return MALI_FALSE; } - -#if MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP - if ( num_slots_idle < num_slots ) - { - MALI_DEBUG_PRINT(4, ("Mali PP scheduler: Job not started, since only %d/%d cores are available\n", num_slots_idle,num_slots)); - return; - } -#endif - -#if MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP_BETWEEN_APPS - /* Finding initial session for the PP cores */ - job = _MALI_OSK_LIST_ENTRY(job_queue.next, struct mali_pp_job, list); - session = job->session; - if ( num_slots != num_slots_idle ) + for (i = 0; i < num_slots; i++) { - for (i = 0; (i < num_slots) ; i++) - { - if ( slots[i].state == MALI_PP_SLOT_STATE_IDLE ) + if (MALI_PP_SLOT_STATE_WORKING == slots[i].state) + { + if (slots[i].session == session) { - continue; + return MALI_TRUE; } - session = mali_group_get_session(slots[i].group); - break; } } -#endif - for (i = 0; (i < num_slots) && (0 < num_slots_idle); i++) + return MALI_FALSE; +} + +static mali_bool slots_available(void) +{ + return num_slots_idle > 0; +} + +static void mali_pp_scheduler_schedule(void) +{ + struct mali_pp_job *job; + + if (0 < pause_count || 0 == num_slots_idle || 0 == job_queue_depth) { - u32 sub_job; - - if (_mali_osk_list_empty(&job_queue)) /* move this check down to where we know we have started all sub jobs for this job??? */ - { - break; /* No more jobs to schedule, so early out */ - } + MALI_DEBUG_PRINT(4, ("Mali PP scheduler: Nothing to schedule (paused=%u, idle slots=%u)\n", + pause_count, num_slots_idle)); + return; /* Nothing to do, so early out */ + } - if (MALI_PP_SLOT_STATE_IDLE != slots[i].state) + while(slots_available() && 0 < job_queue_depth) + { + u32 i, slot_count; + struct mali_pp_slot *reserved_slots[num_slots]; + struct mali_session_data *session; + + mali_pp_scheduler_lock(); + /* Get job */ + if (_mali_osk_list_empty(&job_queue) || !slots_available()) { - continue; + mali_pp_scheduler_unlock(); + break; /* No more jobs to schedule, so early out */ } - job = _MALI_OSK_LIST_ENTRY(job_queue.next, struct mali_pp_job, list); MALI_DEBUG_ASSERT(mali_pp_job_has_unstarted_sub_jobs(job)); /* All jobs on the job_queue should have unstarted sub jobs */ - - #if MALI_PP_SCHEDULER_KEEP_SUB_JOB_STARTS_ALIGNED - if ( (0==job->sub_jobs_started) && (num_slots_idle < num_slots) && (job->sub_job_count > num_slots_idle)) - { - MALI_DEBUG_PRINT(4, ("Mali PP scheduler: Job with %d subjobs not started, since only %d/%d cores are available\n", job->sub_job_count, num_slots_idle,num_slots)); - return; - } - #endif - - #if MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP_BETWEEN_APPS - if ( job->session != session ) + session = mali_pp_job_get_session(job); + + if (MALI_TRUE == mali_pp_job_has_active_barrier(job)) { - MALI_DEBUG_PRINT(4, ("Mali PP scheduler: Job not started since existing job is from another application\n")); - return; + if (MALI_TRUE == mali_pp_scheduler_session_has_running_jobs(mali_pp_job_get_session(job))) + { + /* There is already a running job from this + * session, so we need to enforce the barrier */ + mali_pp_scheduler_unlock(); + return; + } + else + { + /* Barrier is now enforced, update job object + * so we don't delay execution of sub-jobs */ + mali_pp_job_barrier_enforced(job); + } } - #endif - - sub_job = mali_pp_job_get_first_unstarted_sub_job(job); - MALI_DEBUG_PRINT(4, ("Mali PP scheduler: Starting job %u (0x%08X) part %u/%u\n", mali_pp_job_get_id(job), job, sub_job + 1, mali_pp_job_get_sub_job_count(job))); - if (_MALI_OSK_ERR_OK == mali_group_start_pp_job(slots[i].group, job, sub_job)) + /* Reserve slots */ + for (i = 0, slot_count = 0; i < num_slots; i++) { - MALI_DEBUG_PRINT(4, ("Mali PP scheduler: Job %u (0x%08X) part %u/%u started\n", mali_pp_job_get_id(job), job, sub_job + 1, mali_pp_job_get_sub_job_count(job))); + struct mali_pp_slot *slot = &slots[i]; + + if (MALI_PP_SLOT_STATE_IDLE != slot->state) continue; - /* Mark this sub job as started */ - mali_pp_job_mark_sub_job_started(job, sub_job); + slot->state = MALI_PP_SLOT_STATE_WORKING; + slot->session = session; + slot->job = job; + slot->subjob = mali_pp_job_get_first_unstarted_sub_job(job); + mali_pp_job_mark_sub_job_started(job, slot->subjob); + --job_queue_depth; - /* Mark slot as busy */ - slots[i].state = MALI_PP_SLOT_STATE_WORKING; - num_slots_idle--; + --num_slots_idle; + reserved_slots[slot_count++] = slot; if (!mali_pp_job_has_unstarted_sub_jobs(job)) { - /* - * All sub jobs have now started for this job, remove this job from the job queue. - * The job will now only be referred to by the slots which are running it. - * The last slot to complete will make sure it is returned to user space. - */ _mali_osk_list_del(&job->list); -#if MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP - MALI_DEBUG_PRINT(6, ("Mali PP scheduler: Skip scheduling more jobs when MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP is set.\n")); - return; -#endif + break; } } - else + + MALI_DEBUG_ASSERT(0 < slot_count); + + mali_pp_scheduler_unlock(); + + /* Start (sub)job(s) on core(s) */ + for(i = 0; i < slot_count; i++) { - MALI_DEBUG_PRINT(3, ("Mali PP scheduler: Failed to start PP job\n")); - return; + struct mali_pp_slot *slot = reserved_slots[i]; + struct mali_pp_job *job; + u32 subjob; + + MALI_DEBUG_ASSERT_POINTER(slot); + MALI_DEBUG_ASSERT(MALI_PP_SLOT_STATE_WORKING == slot->state); + MALI_DEBUG_ASSERT_POINTER(slot->job); + + job = slot->job; + subjob = slot->subjob; + + if (_MALI_OSK_ERR_OK == mali_group_start_pp_job(slot->group, slot->job, slot->subjob)) + { + MALI_DEBUG_PRINT(4, ("Mali PP scheduler: Job %u (0x%08X) part %u/%u started\n", + mali_pp_job_get_id(job), job, subjob + 1, + mali_pp_job_get_sub_job_count(job))); + } + else + { + MALI_DEBUG_PRINT(3, ("Mali PP scheduler: Failed to start PP job\n")); + /* This can only happen on Mali-200 */ +#if !defined(USING_MALI200) + MALI_DEBUG_ASSERT(0); +#endif + mali_pp_scheduler_lock(); + /* Put job back on queue */ + mali_pp_job_mark_sub_job_not_stated(job, subjob); + _mali_osk_list_add(&job->list, &job_queue); + /* Set slot idle */ + slot->state = MALI_PP_SLOT_STATE_IDLE; + slot->session = NULL; + slot->job = NULL; + slot->subjob = 0; + mali_pp_scheduler_unlock(); + } } } } static void mali_pp_scheduler_return_job_to_user(struct mali_pp_job *job) { - _mali_osk_notification_t *notobj = _mali_osk_notification_create(_MALI_NOTIFICATION_PP_FINISHED, sizeof(_mali_uk_pp_job_finished_s)); - if (NULL != notobj) + if (MALI_FALSE == mali_pp_job_use_no_notification(job)) { - u32 i; - u32 sub_jobs = mali_pp_job_get_sub_job_count(job); - mali_bool success = mali_pp_job_was_success(job); - - _mali_uk_pp_job_finished_s *jobres = notobj->result_buffer; - _mali_osk_memset(jobres, 0, sizeof(_mali_uk_pp_job_finished_s)); /* @@@@ can be removed once we initialize all members in this struct */ - jobres->user_job_ptr = mali_pp_job_get_user_id(job); - if (MALI_TRUE == success) + _mali_osk_notification_t *notobj = _mali_osk_notification_create(_MALI_NOTIFICATION_PP_FINISHED, sizeof(_mali_uk_pp_job_finished_s)); + if (NULL != notobj) { - jobres->status = _MALI_UK_JOB_STATUS_END_SUCCESS; + u32 i; + u32 sub_jobs = mali_pp_job_get_sub_job_count(job); + mali_bool success = mali_pp_job_was_success(job); + + _mali_uk_pp_job_finished_s *jobres = notobj->result_buffer; + _mali_osk_memset(jobres, 0, sizeof(_mali_uk_pp_job_finished_s)); /* @@@@ can be removed once we initialize all members in this struct */ + jobres->user_job_ptr = mali_pp_job_get_user_id(job); + if (MALI_TRUE == success) + { + jobres->status = _MALI_UK_JOB_STATUS_END_SUCCESS; + } + else + { + jobres->status = _MALI_UK_JOB_STATUS_END_UNKNOWN_ERR; + } + + for (i = 0; i < sub_jobs; i++) + { + jobres->perf_counter0[i] = mali_pp_job_get_perf_counter_value0(job, i); + jobres->perf_counter1[i] = mali_pp_job_get_perf_counter_value1(job, i); + } + + mali_session_send_notification(mali_pp_job_get_session(job), notobj); } else { - jobres->status = _MALI_UK_JOB_STATUS_END_UNKNOWN_ERR; + MALI_PRINT_ERROR(("Mali PP scheduler: Unable to allocate notification object\n")); } - - for (i = 0; i < sub_jobs; i++) - { - jobres->perf_counter0[i] = mali_pp_job_get_perf_counter_value0(job, i); - jobres->perf_counter1[i] = mali_pp_job_get_perf_counter_value1(job, i); - } - - mali_session_send_notification(mali_pp_job_get_session(job), notobj); - } - else - { - MALI_PRINT_ERROR(("Mali PP scheduler: Unable to allocate notification object\n")); } mali_pp_job_delete(job); @@ -290,34 +333,42 @@ static void mali_pp_scheduler_return_job_to_user(struct mali_pp_job *job) void mali_pp_scheduler_do_schedule(void) { - mali_pp_scheduler_lock(); - mali_pp_scheduler_schedule(); - - mali_pp_scheduler_unlock(); } void mali_pp_scheduler_job_done(struct mali_group *group, struct mali_pp_job *job, u32 sub_job, mali_bool success) { u32 i; + struct mali_pp_slot *slot = NULL; mali_bool job_is_done; - MALI_DEBUG_PRINT(3, ("Mali PP scheduler: Job %u (0x%08X) part %u/%u completed (%s)\n", mali_pp_job_get_id(job), job, sub_job + 1, mali_pp_job_get_sub_job_count(job), success ? "success" : "failure")); + MALI_DEBUG_PRINT(3, ("Mali PP scheduler: Job %u (0x%08X) part %u/%u completed (%s)\n", + mali_pp_job_get_id(job), + job, sub_job + 1, + mali_pp_job_get_sub_job_count(job), + success ? "success" : "failure")); mali_pp_scheduler_lock(); + mali_pp_job_mark_sub_job_completed(job, success); + /* Find slot which was running this job */ for (i = 0; i < num_slots; i++) { - if (slots[i].group == group) - { - MALI_DEBUG_ASSERT(MALI_PP_SLOT_STATE_WORKING == slots[i].state); - slots[i].state = MALI_PP_SLOT_STATE_IDLE; - num_slots_idle++; - mali_pp_job_mark_sub_job_completed(job, success); - } + slot = &slots[i]; + if (slot->group == group) + break; } + MALI_DEBUG_ASSERT_POINTER(slot); + + slot->state = MALI_PP_SLOT_STATE_IDLE; + slot->session = NULL; + slot->job = NULL; + slot->subjob = 0; + + num_slots_idle++; + /* If paused, then this was the last job, so wake up sleeping workers */ if (pause_count > 0) { @@ -327,10 +378,6 @@ void mali_pp_scheduler_job_done(struct mali_group *group, struct mali_pp_job *jo */ _mali_osk_wait_queue_wake_up(pp_scheduler_working_wait_queue); } - else - { - mali_pp_scheduler_schedule(); - } job_is_done = mali_pp_job_is_complete(job); @@ -342,6 +389,8 @@ void mali_pp_scheduler_job_done(struct mali_group *group, struct mali_pp_job *jo MALI_DEBUG_PRINT(4, ("Mali PP scheduler: All parts completed for job %u (0x%08X)\n", mali_pp_job_get_id(job), job)); mali_pp_scheduler_return_job_to_user(job); } + + mali_pp_scheduler_schedule(); } void mali_pp_scheduler_suspend(void) @@ -350,11 +399,7 @@ void mali_pp_scheduler_suspend(void) pause_count++; /* Increment the pause_count so that no more jobs will be scheduled */ mali_pp_scheduler_unlock(); - /*mali_pp_scheduler_working_lock();*/ - /* We have now aquired the working lock, which means that we have successfully paused the scheduler */ - /*mali_pp_scheduler_working_unlock();*/ - - /* go to sleep. When woken up again (in mali_pp_scheduler_job_done), the + /* Go to sleep. When woken up again (in mali_pp_scheduler_job_done), the * mali_pp_scheduler_suspended() function will be called. This will return true * iff state is idle and pause_count > 0, so if the core is active this * will not do anything. @@ -373,17 +418,17 @@ void mali_pp_scheduler_resume(void) mali_pp_scheduler_unlock(); } -_mali_osk_errcode_t _mali_ukk_pp_start_job(_mali_uk_pp_start_job_s *args) +_mali_osk_errcode_t _mali_ukk_pp_start_job(void *ctx, _mali_uk_pp_start_job_s *uargs) { struct mali_session_data *session; struct mali_pp_job *job; - MALI_DEBUG_ASSERT_POINTER(args); - MALI_DEBUG_ASSERT_POINTER(args->ctx); + MALI_DEBUG_ASSERT_POINTER(uargs); + MALI_DEBUG_ASSERT_POINTER(ctx); - session = (struct mali_session_data*)args->ctx; + session = (struct mali_session_data*)ctx; - job = mali_pp_job_create(session, args, mali_scheduler_get_new_id()); + job = mali_pp_job_create(session, uargs, mali_scheduler_get_new_id()); if (NULL == job) { return _MALI_OSK_ERR_NOMEM; @@ -397,16 +442,24 @@ _mali_osk_errcode_t _mali_ukk_pp_start_job(_mali_uk_pp_start_job_s *args) return _MALI_OSK_ERR_OK; /* User is notified via a notification, so this call is ok */ } +#if PROFILING_SKIP_PP_JOBS || PROFILING_SKIP_PP_AND_GP_JOBS +#warning PP jobs will not be executed + mali_pp_scheduler_return_job_to_user(job); + return _MALI_OSK_ERR_OK; +#endif + mali_pp_scheduler_lock(); + job_queue_depth += mali_pp_job_get_sub_job_count(job); _mali_osk_list_addtail(&job->list, &job_queue); - MALI_DEBUG_PRINT(3, ("Mali PP scheduler: Job %u (0x%08X) with %u parts queued\n", mali_pp_job_get_id(job), job, mali_pp_job_get_sub_job_count(job))); - - mali_pp_scheduler_schedule(); + MALI_DEBUG_PRINT(3, ("Mali PP scheduler: Job %u (0x%08X) with %u parts queued\n", + mali_pp_job_get_id(job), job, mali_pp_job_get_sub_job_count(job))); mali_pp_scheduler_unlock(); + if (slots_available()) mali_pp_scheduler_schedule(); + return _MALI_OSK_ERR_OK; } @@ -437,9 +490,8 @@ void _mali_ukk_pp_job_disable_wb(_mali_uk_pp_disable_wb_s *args) session = (struct mali_session_data*)args->ctx; - mali_pp_scheduler_lock(); - /* Check queue for jobs that match */ + mali_pp_scheduler_lock(); _MALI_OSK_LIST_FOREACHENTRY(job, tmp, &job_queue, struct mali_pp_job, list) { if (mali_pp_job_get_session(job) == session && @@ -461,7 +513,6 @@ void _mali_ukk_pp_job_disable_wb(_mali_uk_pp_disable_wb_s *args) break; } } - mali_pp_scheduler_unlock(); } @@ -479,6 +530,7 @@ void mali_pp_scheduler_abort_session(struct mali_session_data *session) if (mali_pp_job_get_session(job) == session) { _mali_osk_list_del(&(job->list)); + job_queue_depth -= mali_pp_job_get_sub_job_count(job) - mali_pp_job_get_first_unstarted_sub_job(job); if ( mali_pp_job_is_currently_rendering_and_if_so_abort_new_starts(job) ) { @@ -499,14 +551,9 @@ void mali_pp_scheduler_abort_session(struct mali_session_data *session) { struct mali_group *group = slots[i].group; - MALI_DEBUG_PRINT(5, ("PP sched abort: Looking at group 0x%08x\n", group)); + MALI_DEBUG_PRINT(5, ("PP sched abort: Attempting abort for session 0x%08x on group 0x%08x\n", session, group)); - if (MALI_PP_SLOT_STATE_WORKING == slots[i].state) - { - MALI_DEBUG_PRINT(4, ("Mali PP scheduler: Aborting session 0x%08x from group 0x%08x\n", session, group)); - - mali_group_abort_session(group, session); - } + mali_group_abort_session(group, session); } } @@ -521,6 +568,11 @@ static mali_bool mali_pp_scheduler_is_suspended(void) return ret; } +int mali_pp_scheduler_get_queue_depth(void) +{ + return job_queue_depth; +} + #if MALI_STATE_TRACKING u32 mali_pp_scheduler_dump_state(char *buf, u32 size) { diff --git a/drivers/media/video/samsung/mali/common/mali_pp_scheduler.h b/drivers/media/video/samsung/mali/common/mali_pp_scheduler.h old mode 100755 new mode 100644 index 48eb3bd..59bf403 --- a/drivers/media/video/samsung/mali/common/mali_pp_scheduler.h +++ b/drivers/media/video/samsung/mali/common/mali_pp_scheduler.h @@ -33,6 +33,7 @@ void mali_pp_scheduler_resume(void); */ void mali_pp_scheduler_abort_session(struct mali_session_data *session); +int mali_pp_scheduler_get_queue_depth(void); u32 mali_pp_scheduler_dump_state(char *buf, u32 size); #endif /* __MALI_PP_SCHEDULER_H__ */ diff --git a/drivers/media/video/samsung/mali/common/mali_scheduler.c b/drivers/media/video/samsung/mali/common/mali_scheduler.c old mode 100755 new mode 100644 index 52159a0..f360209 --- a/drivers/media/video/samsung/mali/common/mali_scheduler.c +++ b/drivers/media/video/samsung/mali/common/mali_scheduler.c @@ -34,3 +34,4 @@ u32 mali_scheduler_get_new_id(void) u32 job_id = _mali_osk_atomic_inc_return(&mali_job_autonumber); return job_id; } + diff --git a/drivers/media/video/samsung/mali/common/mali_scheduler.h b/drivers/media/video/samsung/mali/common/mali_scheduler.h old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/common/mali_session.h b/drivers/media/video/samsung/mali/common/mali_session.h old mode 100755 new mode 100644 index b47c340..c8640b5 --- a/drivers/media/video/samsung/mali/common/mali_session.h +++ b/drivers/media/video/samsung/mali/common/mali_session.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010, 2012 ARM Limited. All rights reserved. + * 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. diff --git a/drivers/media/video/samsung/mali/common/mali_ukk.h b/drivers/media/video/samsung/mali/common/mali_ukk.h index 8ff2002..6d41b6e 100644 --- a/drivers/media/video/samsung/mali/common/mali_ukk.h +++ b/drivers/media/video/samsung/mali/common/mali_ukk.h @@ -17,7 +17,7 @@ #define __MALI_UKK_H__ #include "mali_osk.h" -#include "../linux/mali_uk_types.h" +#include "mali_uk_types.h" #ifdef __cplusplus extern "C" @@ -218,55 +218,6 @@ _mali_osk_errcode_t _mali_ukk_close( void **context ); * * @{ */ -/** @brief Returns the size of the buffer needed for a _mali_ukk_get_system_info call - * - * This function must be called before a call is made to - * _mali_ukk_get_system_info, so that memory of the correct size can be - * allocated, and a pointer to this memory written into the system_info member - * of _mali_uk_get_system_info_s. - * - * @param args see _mali_uk_get_system_info_size_s in "mali_utgard_uk_types.h" - * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure. - */ -_mali_osk_errcode_t _mali_ukk_get_system_info_size( _mali_uk_get_system_info_size_s *args ); - -/** @brief Returns information about the system (cores and memory banks) - * - * A buffer for this needs to be allocated by the caller. The size of the buffer required is returned by - * _mali_ukk_get_system_info_size(). The user is responsible for freeing the buffer. - * - * The _mali_system_info structure will be written to the start of this buffer, - * and the core_info and mem_info lists will be written to locations inside - * the buffer, and will be suitably aligned. - * - * Under OS implementations of the U/K interface we need to pack/unpack - * pointers across the user/kernel boundary. This has required that we malloc() - * an intermediate buffer inside the kernel-side U/K interface, and free it - * before returning to user-side. To avoid modifying common code, we do the - * following pseudo-code, which we shall call 'pointer switching': - * - * @code - * { - * Copy_From_User(kargs, args, ... ); - * void __user * local_ptr = kargs->system_info; - * kargs->system_info = _mali_osk_malloc( ... ); - * _mali_ukk_get_system_info( kargs ); - * Copy_To_User( local_ptr, kargs->system_info, ... ); - * _mali_osk_free( kargs->system_info ); - * } - * @endcode - * @note The user-side's args->system_info members was unmodified here. - * - * However, the current implementation requires an extra ukk_private word so that the common code can work out - * how to patch pointers to user-mode for an OS's U/K implementation, this should be set to the user-space - * destination address for pointer-patching to occur. When NULL, it is unused, an no pointer-patching occurs in the - * common code. - * - * @param args see _mali_uk_get_system_info_s in "mali_utgard_uk_types.h" - * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure. - */ -_mali_osk_errcode_t _mali_ukk_get_system_info( _mali_uk_get_system_info_s *args ); - /** @brief Waits for a job notification. * * Sleeps until notified or a timeout occurs. Returns information about the notification. @@ -498,10 +449,11 @@ _mali_osk_errcode_t _mali_ukk_va_to_mali_pa( _mali_uk_va_to_mali_pa_s * args ); * * Job completion can be awaited with _mali_ukk_wait_for_notification(). * - * @param args see _mali_uk_pp_start_job_s in "mali_utgard_uk_types.h" + * @oaram ctx user-kernel context (mali_session) + * @param uargs see _mali_uk_pp_start_job_s in "mali_utgard_uk_types.h". Use _mali_osk_copy_from_user to retrieve data! * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure. */ -_mali_osk_errcode_t _mali_ukk_pp_start_job( _mali_uk_pp_start_job_s *args ); +_mali_osk_errcode_t _mali_ukk_pp_start_job( void *ctx, _mali_uk_pp_start_job_s *uargs ); /** @brief Returns the number of Fragment Processors in the system * @@ -551,10 +503,11 @@ void _mali_ukk_pp_job_disable_wb(_mali_uk_pp_disable_wb_s *args); * * Job completion can be awaited with _mali_ukk_wait_for_notification(). * - * @param args see _mali_uk_gp_start_job_s in "mali_utgard_uk_types.h" + * @oaram ctx user-kernel context (mali_session) + * @param uargs see _mali_uk_gp_start_job_s in "mali_utgard_uk_types.h". Use _mali_osk_copy_from_user to retrieve data! * @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure. */ -_mali_osk_errcode_t _mali_ukk_gp_start_job( _mali_uk_gp_start_job_s *args ); +_mali_osk_errcode_t _mali_ukk_gp_start_job( void *ctx, _mali_uk_gp_start_job_s *uargs ); /** @brief Returns the number of Vertex Processors in the system. * diff --git a/drivers/media/video/samsung/mali/common/mali_user_settings_db.c b/drivers/media/video/samsung/mali/common/mali_user_settings_db.c old mode 100755 new mode 100644 index 681c2b0..d3f1e50 --- a/drivers/media/video/samsung/mali/common/mali_user_settings_db.c +++ b/drivers/media/video/samsung/mali/common/mali_user_settings_db.c @@ -82,7 +82,7 @@ _mali_osk_errcode_t _mali_ukk_get_user_settings(_mali_uk_get_user_settings_s *ar { MALI_DEBUG_ASSERT_POINTER(args); - _mali_osk_memcpy(args->settings, mali_user_settings, (sizeof(u32) * _MALI_UK_USER_SETTING_MAX)); + _mali_osk_memcpy(args->settings, mali_user_settings, sizeof(mali_user_settings)); return _MALI_OSK_ERR_OK; } diff --git a/drivers/media/video/samsung/mali/common/mali_user_settings_db.h b/drivers/media/video/samsung/mali/common/mali_user_settings_db.h old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/include/linux/mali/mali_utgard_ioctl.h b/drivers/media/video/samsung/mali/include/linux/mali/mali_utgard_ioctl.h index 31af4cf..7935448 100644 --- a/drivers/media/video/samsung/mali/include/linux/mali/mali_utgard_ioctl.h +++ b/drivers/media/video/samsung/mali/include/linux/mali/mali_utgard_ioctl.h @@ -39,31 +39,36 @@ extern "C" #define MALI_IOC_PROFILING_BASE (_MALI_UK_PROFILING_SUBSYSTEM + MALI_IOC_BASE) #define MALI_IOC_VSYNC_BASE (_MALI_UK_VSYNC_SUBSYSTEM + MALI_IOC_BASE) -#define MALI_IOC_GET_SYSTEM_INFO_SIZE _IOR (MALI_IOC_CORE_BASE, _MALI_UK_GET_SYSTEM_INFO_SIZE, _mali_uk_get_system_info_s *) -#define MALI_IOC_GET_SYSTEM_INFO _IOR (MALI_IOC_CORE_BASE, _MALI_UK_GET_SYSTEM_INFO, _mali_uk_get_system_info_s *) #define MALI_IOC_WAIT_FOR_NOTIFICATION _IOWR(MALI_IOC_CORE_BASE, _MALI_UK_WAIT_FOR_NOTIFICATION, _mali_uk_wait_for_notification_s *) #define MALI_IOC_GET_API_VERSION _IOWR(MALI_IOC_CORE_BASE, _MALI_UK_GET_API_VERSION, _mali_uk_get_api_version_s *) #define MALI_IOC_POST_NOTIFICATION _IOWR(MALI_IOC_CORE_BASE, _MALI_UK_POST_NOTIFICATION, _mali_uk_post_notification_s *) #define MALI_IOC_GET_USER_SETTING _IOWR(MALI_IOC_CORE_BASE, _MALI_UK_GET_USER_SETTING, _mali_uk_get_user_setting_s *) #define MALI_IOC_GET_USER_SETTINGS _IOWR(MALI_IOC_CORE_BASE, _MALI_UK_GET_USER_SETTINGS, _mali_uk_get_user_settings_s *) + #define MALI_IOC_MEM_GET_BIG_BLOCK _IOWR(MALI_IOC_MEMORY_BASE, _MALI_UK_GET_BIG_BLOCK, void *) #define MALI_IOC_MEM_FREE_BIG_BLOCK _IOW (MALI_IOC_MEMORY_BASE, _MALI_UK_FREE_BIG_BLOCK, void *) #define MALI_IOC_MEM_INIT _IOR (MALI_IOC_MEMORY_BASE, _MALI_UK_INIT_MEM, _mali_uk_init_mem_s *) #define MALI_IOC_MEM_TERM _IOW (MALI_IOC_MEMORY_BASE, _MALI_UK_TERM_MEM, _mali_uk_term_mem_s *) #define MALI_IOC_MEM_MAP_EXT _IOWR(MALI_IOC_MEMORY_BASE, _MALI_UK_MAP_EXT_MEM, _mali_uk_map_external_mem_s *) #define MALI_IOC_MEM_UNMAP_EXT _IOW (MALI_IOC_MEMORY_BASE, _MALI_UK_UNMAP_EXT_MEM, _mali_uk_unmap_external_mem_s *) -#define MALI_IOC_MEM_QUERY_MMU_PAGE_TABLE_DUMP_SIZE _IOR (MALI_IOC_MEMORY_BASE, _MALI_UK_QUERY_MMU_PAGE_TABLE_DUMP_SIZE, _mali_uk_query_mmu_page_table_dump_size_s *) -#define MALI_IOC_MEM_DUMP_MMU_PAGE_TABLE _IOWR(MALI_IOC_MEMORY_BASE, _MALI_UK_DUMP_MMU_PAGE_TABLE, _mali_uk_dump_mmu_page_table_s *) +#define MALI_IOC_MEM_ATTACH_DMA_BUF _IOWR(MALI_IOC_MEMORY_BASE, _MALI_UK_ATTACH_DMA_BUF, _mali_uk_attach_dma_buf_s *) +#define MALI_IOC_MEM_RELEASE_DMA_BUF _IOW(MALI_IOC_MEMORY_BASE, _MALI_UK_RELEASE_DMA_BUF, _mali_uk_release_dma_buf_s *) +#define MALI_IOC_MEM_DMA_BUF_GET_SIZE _IOR(MALI_IOC_MEMORY_BASE, _MALI_UK_DMA_BUF_GET_SIZE, _mali_uk_dma_buf_get_size_s *) #define MALI_IOC_MEM_ATTACH_UMP _IOWR(MALI_IOC_MEMORY_BASE, _MALI_UK_ATTACH_UMP_MEM, _mali_uk_attach_ump_mem_s *) #define MALI_IOC_MEM_RELEASE_UMP _IOW(MALI_IOC_MEMORY_BASE, _MALI_UK_RELEASE_UMP_MEM, _mali_uk_release_ump_mem_s *) +#define MALI_IOC_MEM_QUERY_MMU_PAGE_TABLE_DUMP_SIZE _IOR (MALI_IOC_MEMORY_BASE, _MALI_UK_QUERY_MMU_PAGE_TABLE_DUMP_SIZE, _mali_uk_query_mmu_page_table_dump_size_s *) +#define MALI_IOC_MEM_DUMP_MMU_PAGE_TABLE _IOWR(MALI_IOC_MEMORY_BASE, _MALI_UK_DUMP_MMU_PAGE_TABLE, _mali_uk_dump_mmu_page_table_s *) + #define MALI_IOC_PP_START_JOB _IOWR(MALI_IOC_PP_BASE, _MALI_UK_PP_START_JOB, _mali_uk_pp_start_job_s *) #define MALI_IOC_PP_NUMBER_OF_CORES_GET _IOR (MALI_IOC_PP_BASE, _MALI_UK_GET_PP_NUMBER_OF_CORES, _mali_uk_get_pp_number_of_cores_s *) #define MALI_IOC_PP_CORE_VERSION_GET _IOR (MALI_IOC_PP_BASE, _MALI_UK_GET_PP_CORE_VERSION, _mali_uk_get_pp_core_version_s * ) #define MALI_IOC_PP_DISABLE_WB _IOW (MALI_IOC_PP_BASE, _MALI_UK_PP_DISABLE_WB, _mali_uk_pp_disable_wb_s * ) + #define MALI_IOC_GP2_START_JOB _IOWR(MALI_IOC_GP_BASE, _MALI_UK_GP_START_JOB, _mali_uk_gp_start_job_s *) #define MALI_IOC_GP2_NUMBER_OF_CORES_GET _IOR (MALI_IOC_GP_BASE, _MALI_UK_GET_GP_NUMBER_OF_CORES, _mali_uk_get_gp_number_of_cores_s *) #define MALI_IOC_GP2_CORE_VERSION_GET _IOR (MALI_IOC_GP_BASE, _MALI_UK_GET_GP_CORE_VERSION, _mali_uk_get_gp_core_version_s *) #define MALI_IOC_GP2_SUSPEND_RESPONSE _IOW (MALI_IOC_GP_BASE, _MALI_UK_GP_SUSPEND_RESPONSE,_mali_uk_gp_suspend_response_s *) + #define MALI_IOC_PROFILING_START _IOWR(MALI_IOC_PROFILING_BASE, _MALI_UK_PROFILING_START, _mali_uk_profiling_start_s *) #define MALI_IOC_PROFILING_ADD_EVENT _IOWR(MALI_IOC_PROFILING_BASE, _MALI_UK_PROFILING_ADD_EVENT, _mali_uk_profiling_add_event_s*) #define MALI_IOC_PROFILING_STOP _IOWR(MALI_IOC_PROFILING_BASE, _MALI_UK_PROFILING_STOP, _mali_uk_profiling_stop_s *) @@ -71,6 +76,7 @@ extern "C" #define MALI_IOC_PROFILING_CLEAR _IOWR(MALI_IOC_PROFILING_BASE, _MALI_UK_PROFILING_CLEAR, _mali_uk_profiling_clear_s *) #define MALI_IOC_PROFILING_GET_CONFIG _IOWR(MALI_IOC_PROFILING_BASE, _MALI_UK_PROFILING_GET_CONFIG, _mali_uk_get_user_settings_s *) #define MALI_IOC_PROFILING_REPORT_SW_COUNTERS _IOW (MALI_IOC_PROFILING_BASE, _MALI_UK_PROFILING_REPORT_SW_COUNTERS, _mali_uk_sw_counters_report_s *) + #define MALI_IOC_VSYNC_EVENT_REPORT _IOW (MALI_IOC_VSYNC_BASE, _MALI_UK_VSYNC_EVENT_REPORT, _mali_uk_vsync_event_report_s *) #ifdef __cplusplus diff --git a/drivers/media/video/samsung/mali/include/linux/mali/mali_utgard_profiling_events.h b/drivers/media/video/samsung/mali/include/linux/mali/mali_utgard_profiling_events.h index 129526f..92ca058 100644 --- a/drivers/media/video/samsung/mali/include/linux/mali/mali_utgard_profiling_events.h +++ b/drivers/media/video/samsung/mali/include/linux/mali/mali_utgard_profiling_events.h @@ -59,16 +59,19 @@ typedef enum */ typedef enum { - MALI_PROFILING_EVENT_REASON_SINGLE_SW_NONE = 0, - MALI_PROFILING_EVENT_REASON_SINGLE_SW_EGL_NEW_FRAME = 1, - MALI_PROFILING_EVENT_REASON_SINGLE_SW_FLUSH = 2, - MALI_PROFILING_EVENT_REASON_SINGLE_SW_EGL_SWAP_BUFFERS = 3, - MALI_PROFILING_EVENT_REASON_SINGLE_SW_FB_EVENT = 4, - MALI_PROFILING_EVENT_REASON_SINGLE_SW_ENTER_API_FUNC = 10, - MALI_PROFILING_EVENT_REASON_SINGLE_SW_LEAVE_API_FUNC = 11, - MALI_PROFILING_EVENT_REASON_SINGLE_SW_UMP_TRY_LOCK = 53, - MALI_PROFILING_EVENT_REASON_SINGLE_SW_UMP_LOCK = 54, - MALI_PROFILING_EVENT_REASON_SINGLE_SW_UMP_UNLOCK = 55, + MALI_PROFILING_EVENT_REASON_SINGLE_SW_NONE = 0, + MALI_PROFILING_EVENT_REASON_SINGLE_SW_EGL_NEW_FRAME = 1, + MALI_PROFILING_EVENT_REASON_SINGLE_SW_FLUSH = 2, + MALI_PROFILING_EVENT_REASON_SINGLE_SW_EGL_SWAP_BUFFERS = 3, + MALI_PROFILING_EVENT_REASON_SINGLE_SW_FB_EVENT = 4, + MALI_PROFILING_EVENT_REASON_SINGLE_SW_GP_ENQUEUE = 5, + MALI_PROFILING_EVENT_REASON_SINGLE_SW_PP_ENQUEUE = 6, + MALI_PROFILING_EVENT_REASON_SINGLE_SW_ENTER_API_FUNC = 10, + MALI_PROFILING_EVENT_REASON_SINGLE_SW_LEAVE_API_FUNC = 11, + MALI_PROFILING_EVENT_REASON_SINGLE_SW_UMP_TRY_LOCK = 53, + MALI_PROFILING_EVENT_REASON_SINGLE_SW_UMP_LOCK = 54, + MALI_PROFILING_EVENT_REASON_SINGLE_SW_UMP_UNLOCK = 55, + MALI_PROFILING_EVENT_REASON_SINGLE_LOCK_CONTENDED = 56, } cinstr_profiling_event_reason_single_sw_t; /** @@ -78,6 +81,7 @@ typedef enum { MALI_PROFILING_EVENT_REASON_START_STOP_SW_NONE = 0, MALI_PROFILING_EVENT_REASON_START_STOP_MALI = 1, + MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF = 2, } cinstr_profiling_event_reason_start_stop_sw_t; /** @@ -85,18 +89,22 @@ typedef enum */ typedef enum { - MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_NONE = 0, - MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_PIPELINE_FULL = 1, - MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_VSYNC = 26, - MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_FB_IFRAME_WAIT = 27, - MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_FB_IFRAME_SYNC = 28, - MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_VG_WAIT_FILTER_CLEANUP = 29, - MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_VG_WAIT_TEXTURE = 30, - MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_GLES_WAIT_MIPLEVEL = 31, - MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_GLES_WAIT_READPIXELS = 32, - MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_EGL_WAIT_SWAP_IMMEDIATE= 33, - MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_ICS_QUEUE_BUFFER = 34, - MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_ICS_DEQUEUE_BUFFER = 35, + MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_NONE = 0, /* NOT used */ + MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_PIPELINE_FULL = 1, /* NOT used */ + MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_VSYNC = 26, /* used in some build configurations */ + MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_FB_IFRAME_WAIT = 27, /* USED */ + MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_FB_IFRAME_SYNC = 28, /* USED */ + MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_VG_WAIT_FILTER_CLEANUP = 29, /* used */ + MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_VG_WAIT_TEXTURE = 30, /* used */ + MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_GLES_WAIT_MIPLEVEL = 31, /* used */ + MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_GLES_WAIT_READPIXELS = 32, /* used */ + MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_EGL_WAIT_SWAP_IMMEDIATE= 33, /* NOT used */ + MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_ICS_QUEUE_BUFFER = 34, /* USED */ + MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_ICS_DEQUEUE_BUFFER = 35, /* USED */ + MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_UMP_LOCK = 36, /* Not currently used */ + MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_X11_GLOBAL_LOCK = 37, /* Not currently used */ + MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_X11_SWAP = 38, /* Not currently used */ + MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_MALI_EGL_IMAGE_SYNC_WAIT = 39, /* USED */ } cinstr_profiling_event_reason_suspend_resume_sw_t; /** @@ -118,4 +126,26 @@ typedef enum MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE = 1, } cinstr_profiling_event_reason_single_gpu_t; +/** + * These values are applicable for the 3rd data parameter when + * the type MALI_PROFILING_EVENT_TYPE_START is used from the software channel + * with the MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF reason. + */ +typedef enum +{ + MALI_PROFILING_EVENT_DATA_CORE_GP0 = 1, + MALI_PROFILING_EVENT_DATA_CORE_PP0 = 5, + MALI_PROFILING_EVENT_DATA_CORE_PP1 = 6, + MALI_PROFILING_EVENT_DATA_CORE_PP2 = 7, + MALI_PROFILING_EVENT_DATA_CORE_PP3 = 8, + MALI_PROFILING_EVENT_DATA_CORE_PP4 = 9, + MALI_PROFILING_EVENT_DATA_CORE_PP5 = 10, + MALI_PROFILING_EVENT_DATA_CORE_PP6 = 11, + MALI_PROFILING_EVENT_DATA_CORE_PP7 = 12, +} cinstr_profiling_event_data_core_t; + +#define MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP(num) (MALI_PROFILING_EVENT_DATA_CORE_GP0 + (num)) +#define MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP(num) (MALI_PROFILING_EVENT_DATA_CORE_PP0 + (num)) + + #endif /*_MALI_UTGARD_PROFILING_EVENTS_H_*/ diff --git a/drivers/media/video/samsung/mali/include/linux/mali/mali_utgard_uk_types.h b/drivers/media/video/samsung/mali/include/linux/mali/mali_utgard_uk_types.h index 512b1e2..b35a715 100644 --- a/drivers/media/video/samsung/mali/include/linux/mali/mali_utgard_uk_types.h +++ b/drivers/media/video/samsung/mali/include/linux/mali/mali_utgard_uk_types.h @@ -63,8 +63,6 @@ typedef enum _MALI_UK_OPEN = 0, /**< _mali_ukk_open() */ _MALI_UK_CLOSE, /**< _mali_ukk_close() */ - _MALI_UK_GET_SYSTEM_INFO_SIZE, /**< _mali_ukk_get_system_info_size() */ - _MALI_UK_GET_SYSTEM_INFO, /**< _mali_ukk_get_system_info() */ _MALI_UK_WAIT_FOR_NOTIFICATION, /**< _mali_ukk_wait_for_notification() */ _MALI_UK_GET_API_VERSION, /**< _mali_ukk_get_api_version() */ _MALI_UK_POST_NOTIFICATION, /**< _mali_ukk_post_notification() */ @@ -73,19 +71,22 @@ typedef enum /** Memory functions */ - _MALI_UK_INIT_MEM = 0, /**< _mali_ukk_init_mem() */ - _MALI_UK_TERM_MEM, /**< _mali_ukk_term_mem() */ - _MALI_UK_GET_BIG_BLOCK, /**< _mali_ukk_get_big_block() */ - _MALI_UK_FREE_BIG_BLOCK, /**< _mali_ukk_free_big_block() */ - _MALI_UK_MAP_MEM, /**< _mali_ukk_mem_mmap() */ - _MALI_UK_UNMAP_MEM, /**< _mali_ukk_mem_munmap() */ + _MALI_UK_INIT_MEM = 0, /**< _mali_ukk_init_mem() */ + _MALI_UK_TERM_MEM, /**< _mali_ukk_term_mem() */ + _MALI_UK_GET_BIG_BLOCK, /**< _mali_ukk_get_big_block() */ + _MALI_UK_FREE_BIG_BLOCK, /**< _mali_ukk_free_big_block() */ + _MALI_UK_MAP_MEM, /**< _mali_ukk_mem_mmap() */ + _MALI_UK_UNMAP_MEM, /**< _mali_ukk_mem_munmap() */ _MALI_UK_QUERY_MMU_PAGE_TABLE_DUMP_SIZE, /**< _mali_ukk_mem_get_mmu_page_table_dump_size() */ - _MALI_UK_DUMP_MMU_PAGE_TABLE, /**< _mali_ukk_mem_dump_mmu_page_table() */ - _MALI_UK_ATTACH_UMP_MEM, /**< _mali_ukk_attach_ump_mem() */ - _MALI_UK_RELEASE_UMP_MEM, /**< _mali_ukk_release_ump_mem() */ - _MALI_UK_MAP_EXT_MEM, /**< _mali_uku_map_external_mem() */ - _MALI_UK_UNMAP_EXT_MEM, /**< _mali_uku_unmap_external_mem() */ - _MALI_UK_VA_TO_MALI_PA, /**< _mali_uku_va_to_mali_pa() */ + _MALI_UK_DUMP_MMU_PAGE_TABLE, /**< _mali_ukk_mem_dump_mmu_page_table() */ + _MALI_UK_ATTACH_DMA_BUF, /**< _mali_ukk_attach_dma_buf() */ + _MALI_UK_RELEASE_DMA_BUF, /**< _mali_ukk_release_dma_buf() */ + _MALI_UK_DMA_BUF_GET_SIZE, /**< _mali_ukk_dma_buf_get_size() */ + _MALI_UK_ATTACH_UMP_MEM, /**< _mali_ukk_attach_ump_mem() */ + _MALI_UK_RELEASE_UMP_MEM, /**< _mali_ukk_release_ump_mem() */ + _MALI_UK_MAP_EXT_MEM, /**< _mali_uku_map_external_mem() */ + _MALI_UK_UNMAP_EXT_MEM, /**< _mali_uku_unmap_external_mem() */ + _MALI_UK_VA_TO_MALI_PA, /**< _mali_uku_va_to_mali_pa() */ /** Common functions for each core */ @@ -172,33 +173,6 @@ typedef enum _mali_core_type /* insert new core here, do NOT alter the existing values */ } _mali_core_type; -/** @brief Information about each Mali Core - * - * Information is stored in a linked list, which is stored entirely in the - * buffer pointed to by the system_info member of the - * _mali_uk_get_system_info_s arguments provided to _mali_ukk_get_system_info() - * - * Both Fragment Processor (PP) and Vertex Processor (GP) cores are represented - * by this struct. - * - * The type is reported by the type field, _mali_core_info::_mali_core_type. - * - * Each core is given a unique Sequence number identifying it, the core_nr - * member. - * - * Flags are taken directly from the resource's flags, and are currently unused. - * - * Multiple mali_core_info structs are linked in a single linked list using the next field - */ -typedef struct _mali_core_info -{ - _mali_core_type type; /**< Type of core */ - _mali_core_version version; /**< Core Version, as reported by the Core's Version Register */ - u32 reg_address; /**< Address of Registers */ - u32 core_nr; /**< Sequence number */ - u32 flags; /**< Flags. Currently Unused. */ - struct _mali_core_info * next; /**< Next core in Linked List */ -} _mali_core_info; /** @brief Capabilities of Memory Banks * @@ -221,10 +195,18 @@ typedef enum _mali_bus_usage _MALI_GP_WRITEABLE = (1<<3), /** Writeable by the Vertex Processor */ _MALI_CPU_READABLE = (1<<4), /** Readable by the CPU */ _MALI_CPU_WRITEABLE = (1<<5), /** Writeable by the CPU */ + _MALI_GP_L2_ALLOC = (1<<6), /** GP allocate mali L2 cache lines*/ _MALI_MMU_READABLE = _MALI_PP_READABLE | _MALI_GP_READABLE, /** Readable by the MMU (including all cores behind it) */ _MALI_MMU_WRITEABLE = _MALI_PP_WRITEABLE | _MALI_GP_WRITEABLE, /** Writeable by the MMU (including all cores behind it) */ } _mali_bus_usage; +typedef enum mali_memory_cache_settings +{ + MALI_CACHE_STANDARD = 0, + MALI_CACHE_GP_READ_ALLOCATE = 1, +} mali_memory_cache_settings ; + + /** @brief Information about the Mali Memory system * * Information is stored in a linked list, which is stored entirely in the @@ -235,11 +217,6 @@ typedef enum _mali_bus_usage * Each allocation can only come from one bank, and will not cross multiple * banks. * - * Each bank is uniquely identified by its identifier member. On Mali-nonMMU - * systems, to allocate from this bank, the value of identifier must be passed - * as the type_id member of the _mali_uk_get_big_block_s arguments to - * _mali_ukk_get_big_block. - * * On Mali-MMU systems, there is only one bank, which describes the maximum * possible address range that could be allocated (which may be much less than * the available physical memory) @@ -260,54 +237,11 @@ typedef struct _mali_mem_info u32 size; /**< Size of the memory bank in bytes */ _mali_bus_usage flags; /**< Capabilitiy flags of the memory */ u32 maximum_order_supported; /**< log2 supported size */ - u32 identifier; /**< Unique identifier, to be used in allocate calls */ + u32 identifier; /* mali_memory_cache_settings cache_settings; */ struct _mali_mem_info * next; /**< Next List Link */ } _mali_mem_info; -/** @brief Info about the whole Mali system. - * - * This Contains a linked list of the cores and memory banks available. Each - * list pointer will remain inside the system_info buffer supplied in the - * _mali_uk_get_system_info_s arguments to a _mali_ukk_get_system_info call. - * - * The has_mmu member must be inspected to ensure the correct group of - * Memory function calls is obtained - that is, those for either Mali-MMU - * or Mali-nonMMU. @see _mali_uk_memory - */ -typedef struct _mali_system_info -{ - _mali_core_info * core_info; /**< List of _mali_core_info structures */ - _mali_mem_info * mem_info; /**< List of _mali_mem_info structures */ - u32 has_mmu; /**< Non-zero if Mali-MMU present. Zero otherwise. */ - _mali_driver_mode drivermode; /**< Reserved. Must always be _MALI_DRIVER_MODE_NORMAL */ -} _mali_system_info; - -/** @brief Arguments to _mali_ukk_get_system_info() - * - * A buffer of the size returned by _mali_ukk_get_system_info_size() must be - * allocated, and the pointer to this buffer must be written into the - * system_info member. The buffer must be suitably aligned for storage of - * the _mali_system_info structure - for example, one returned by - * _mali_osk_malloc(), which will be suitably aligned for any structure. - * - * The ukk_private member must be set to zero by the user-side. Under an OS - * implementation, the U/K interface must write in the user-side base address - * into the ukk_private member, so that the common code in - * _mali_ukk_get_system_info() can determine how to adjust the pointers such - * that they are sensible from user space. Leaving ukk_private as NULL implies - * that no pointer adjustment is necessary - which will be the case on a - * bare-metal/RTOS system. - * - * @see _mali_system_info - */ -typedef struct -{ - void *ctx; /**< [in,out] user-kernel context (trashed on output) */ - u32 size; /**< [in] size of buffer provided to store system information data */ - _mali_system_info * system_info; /**< [in,out] pointer to buffer to store system information data. No initialisation of buffer required on input. */ - u32 ukk_private; /**< [in] Kernel-side private word inserted by certain U/K interface implementations. Caller must set to Zero. */ -} _mali_uk_get_system_info_s; -/** @} */ /* end group _mali_uk_getsysteminfo */ + /** @} */ /* end group _mali_uk_core */ @@ -483,6 +417,10 @@ typedef struct #define _MALI_PP_MAX_WB_REGISTERS ((0x02C/4)+1) +/** Flag for _mali_uk_pp_start_job_s */ +#define _MALI_PP_JOB_FLAG_NO_NOTIFICATION (1<<0) +#define _MALI_PP_JOB_FLAG_BARRIER (1<<1) + /** @defgroup _mali_uk_ppstartjob_s Fragment Processor Start Job * @{ */ @@ -544,6 +482,7 @@ typedef struct u32 perf_counter_src1; /**< [in] source id for performance counter 1 (see ARM DDI0415A, Table 3-60) */ u32 frame_builder_id; /**< [in] id of the originating frame builder */ u32 flush_id; /**< [in] flush id within the originating frame builder */ + u32 flags; /**< [in] See _MALI_PP_JOB_FLAG_* for a list of avaiable flags */ } _mali_uk_pp_start_job_s; /** @} */ /* end group _mali_uk_ppstartjob_s */ @@ -761,7 +700,7 @@ typedef struct * The 16bit integer is stored twice in a 32bit integer * For example, for version 1 the value would be 0x00010001 */ -#define _MALI_API_VERSION 14 +#define _MALI_API_VERSION 17 #define _MALI_UK_API_VERSION _MAKE_VERSION_ID(_MALI_API_VERSION) /** @@ -838,7 +777,9 @@ typedef struct void *ctx; /**< [in,out] user-kernel context (trashed on output) */ } _mali_uk_term_mem_s; -/** @note Mali-MMU only */ +/** Flag for _mali_uk_map_external_mem_s, _mali_uk_attach_ump_mem_s and _mali_uk_attach_dma_buf_s */ +#define _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE (1<<0) + typedef struct { void *ctx; /**< [in,out] user-kernel context (trashed on output) */ @@ -850,16 +791,37 @@ typedef struct u32 cookie; /**< [out] identifier for mapped memory object in kernel space */ } _mali_uk_map_external_mem_s; -/** Flag for _mali_uk_map_external_mem_s and _mali_uk_attach_ump_mem_s */ -#define _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE (1<<0) - -/** @note Mali-MMU only */ typedef struct { void *ctx; /**< [in,out] user-kernel context (trashed on output) */ u32 cookie; /**< [out] identifier for mapped memory object in kernel space */ } _mali_uk_unmap_external_mem_s; +/** @note This is identical to _mali_uk_map_external_mem_s above, however phys_addr is replaced by memory descriptor */ +typedef struct +{ + void *ctx; /**< [in,out] user-kernel context (trashed on output) */ + u32 mem_fd; /**< [in] Memory descriptor */ + u32 size; /**< [in] size */ + u32 mali_address; /**< [in] mali address to map the physical memory to */ + u32 rights; /**< [in] rights necessary for accessing memory */ + u32 flags; /**< [in] flags, see \ref _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE */ + u32 cookie; /**< [out] identifier for mapped memory object in kernel space */ +} _mali_uk_attach_dma_buf_s; + +typedef struct +{ + void *ctx; /**< [in,out] user-kernel context (trashed on output) */ + u32 mem_fd; /**< [in] Memory descriptor */ + u32 size; /**< [out] size */ +} _mali_uk_dma_buf_get_size_s; + +typedef struct +{ + void *ctx; /**< [in,out] user-kernel context (trashed on output) */ + u32 cookie; /**< [in] identifier for mapped memory object in kernel space */ +} _mali_uk_release_dma_buf_s; + /** @note This is identical to _mali_uk_map_external_mem_s above, however phys_addr is replaced by secure_id */ typedef struct { @@ -872,7 +834,6 @@ typedef struct u32 cookie; /**< [out] identifier for mapped memory object in kernel space */ } _mali_uk_attach_ump_mem_s; -/** @note Mali-MMU only; will be supported in future version */ typedef struct { void *ctx; /**< [in,out] user-kernel context (trashed on output) */ @@ -1060,6 +1021,7 @@ typedef struct u32 cookie; /**< [out] Returns a cookie for use in munmap calls */ void *uku_private; /**< [in] User-side Private word used by U/K interface */ void *ukk_private; /**< [in] Kernel-side Private word used by U/K interface */ + mali_memory_cache_settings cache_settings; /**< [in] Option to set special cache flags, tuning L2 efficency */ } _mali_uk_mem_mmap_s; /** @brief Arguments to _mali_ukk_mem_munmap() 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 old mode 100755 new mode 100644 index e9e5e55..52bb5e0 --- 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 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 ARM Limited. All rights reserved. + * 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. diff --git a/drivers/media/video/samsung/mali/linux/mali_dma_buf.c b/drivers/media/video/samsung/mali/linux/mali_dma_buf.c new file mode 100644 index 0000000..4dd711f --- /dev/null +++ b/drivers/media/video/samsung/mali/linux/mali_dma_buf.c @@ -0,0 +1,392 @@ +/* + * 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 /* file system operations */ +#include /* user space access */ +#include +#include +#include + +#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 new file mode 100644 index 0000000..ee9a0ed --- /dev/null +++ b/drivers/media/video/samsung/mali/linux/mali_dma_buf.h @@ -0,0 +1,29 @@ +/* + * 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_ioctl.h b/drivers/media/video/samsung/mali/linux/mali_kernel_ioctl.h deleted file mode 100755 index 6fc59a7..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_kernel_ioctl.h +++ /dev/null @@ -1,78 +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_IOCTL_H__ -#define __MALI_KERNEL_IOCTL_H__ - -#include -#include -#include /* file system operations */ - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** - * @file mali_kernel_ioctl.h - * Interface to the Linux device driver. - * This file describes the interface needed to use the Linux device driver. - * Its interface is designed to used by the HAL implementation through a thin arch layer. - */ - -/** - * ioctl commands - */ - -#define MALI_IOC_BASE 0x82 -#define MALI_IOC_CORE_BASE (_MALI_UK_CORE_SUBSYSTEM + MALI_IOC_BASE) -#define MALI_IOC_MEMORY_BASE (_MALI_UK_MEMORY_SUBSYSTEM + MALI_IOC_BASE) -#define MALI_IOC_PP_BASE (_MALI_UK_PP_SUBSYSTEM + MALI_IOC_BASE) -#define MALI_IOC_GP_BASE (_MALI_UK_GP_SUBSYSTEM + MALI_IOC_BASE) -#define MALI_IOC_PROFILING_BASE (_MALI_UK_PROFILING_SUBSYSTEM + MALI_IOC_BASE) -#define MALI_IOC_VSYNC_BASE (_MALI_UK_VSYNC_SUBSYSTEM + MALI_IOC_BASE) - -#define MALI_IOC_GET_SYSTEM_INFO_SIZE _IOR (MALI_IOC_CORE_BASE, _MALI_UK_GET_SYSTEM_INFO_SIZE, _mali_uk_get_system_info_s *) -#define MALI_IOC_GET_SYSTEM_INFO _IOR (MALI_IOC_CORE_BASE, _MALI_UK_GET_SYSTEM_INFO, _mali_uk_get_system_info_s *) -#define MALI_IOC_WAIT_FOR_NOTIFICATION _IOWR(MALI_IOC_CORE_BASE, _MALI_UK_WAIT_FOR_NOTIFICATION, _mali_uk_wait_for_notification_s *) -#define MALI_IOC_GET_API_VERSION _IOWR(MALI_IOC_CORE_BASE, _MALI_UK_GET_API_VERSION, _mali_uk_get_api_version_s *) -#define MALI_IOC_POST_NOTIFICATION _IOWR(MALI_IOC_CORE_BASE, _MALI_UK_POST_NOTIFICATION, _mali_uk_post_notification_s *) -#define MALI_IOC_GET_USER_SETTING _IOWR(MALI_IOC_CORE_BASE, _MALI_UK_GET_USER_SETTING, _mali_uk_get_user_setting_s *) -#define MALI_IOC_GET_USER_SETTINGS _IOWR(MALI_IOC_CORE_BASE, _MALI_UK_GET_USER_SETTINGS, _mali_uk_get_user_settings_s *) -#define MALI_IOC_MEM_GET_BIG_BLOCK _IOWR(MALI_IOC_MEMORY_BASE, _MALI_UK_GET_BIG_BLOCK, void *) -#define MALI_IOC_MEM_FREE_BIG_BLOCK _IOW (MALI_IOC_MEMORY_BASE, _MALI_UK_FREE_BIG_BLOCK, void *) -#define MALI_IOC_MEM_INIT _IOR (MALI_IOC_MEMORY_BASE, _MALI_UK_INIT_MEM, _mali_uk_init_mem_s *) -#define MALI_IOC_MEM_TERM _IOW (MALI_IOC_MEMORY_BASE, _MALI_UK_TERM_MEM, _mali_uk_term_mem_s *) -#define MALI_IOC_MEM_MAP_EXT _IOWR(MALI_IOC_MEMORY_BASE, _MALI_UK_MAP_EXT_MEM, _mali_uk_map_external_mem_s *) -#define MALI_IOC_MEM_UNMAP_EXT _IOW (MALI_IOC_MEMORY_BASE, _MALI_UK_UNMAP_EXT_MEM, _mali_uk_unmap_external_mem_s *) -#define MALI_IOC_MEM_QUERY_MMU_PAGE_TABLE_DUMP_SIZE _IOR (MALI_IOC_MEMORY_BASE, _MALI_UK_QUERY_MMU_PAGE_TABLE_DUMP_SIZE, _mali_uk_query_mmu_page_table_dump_size_s *) -#define MALI_IOC_MEM_DUMP_MMU_PAGE_TABLE _IOWR(MALI_IOC_MEMORY_BASE, _MALI_UK_DUMP_MMU_PAGE_TABLE, _mali_uk_dump_mmu_page_table_s *) -#define MALI_IOC_MEM_ATTACH_UMP _IOWR(MALI_IOC_MEMORY_BASE, _MALI_UK_ATTACH_UMP_MEM, _mali_uk_attach_ump_mem_s *) -#define MALI_IOC_MEM_RELEASE_UMP _IOW(MALI_IOC_MEMORY_BASE, _MALI_UK_RELEASE_UMP_MEM, _mali_uk_release_ump_mem_s *) -#define MALI_IOC_PP_START_JOB _IOWR(MALI_IOC_PP_BASE, _MALI_UK_PP_START_JOB, _mali_uk_pp_start_job_s *) -#define MALI_IOC_PP_NUMBER_OF_CORES_GET _IOR (MALI_IOC_PP_BASE, _MALI_UK_GET_PP_NUMBER_OF_CORES, _mali_uk_get_pp_number_of_cores_s *) -#define MALI_IOC_PP_CORE_VERSION_GET _IOR (MALI_IOC_PP_BASE, _MALI_UK_GET_PP_CORE_VERSION, _mali_uk_get_pp_core_version_s * ) -#define MALI_IOC_GP2_START_JOB _IOWR(MALI_IOC_GP_BASE, _MALI_UK_GP_START_JOB, _mali_uk_gp_start_job_s *) -#define MALI_IOC_GP2_NUMBER_OF_CORES_GET _IOR (MALI_IOC_GP_BASE, _MALI_UK_GET_GP_NUMBER_OF_CORES, _mali_uk_get_gp_number_of_cores_s *) -#define MALI_IOC_GP2_CORE_VERSION_GET _IOR (MALI_IOC_GP_BASE, _MALI_UK_GET_GP_CORE_VERSION, _mali_uk_get_gp_core_version_s *) -#define MALI_IOC_GP2_SUSPEND_RESPONSE _IOW (MALI_IOC_GP_BASE, _MALI_UK_GP_SUSPEND_RESPONSE,_mali_uk_gp_suspend_response_s *) -#define MALI_IOC_PROFILING_START _IOWR(MALI_IOC_PROFILING_BASE, _MALI_UK_PROFILING_START, _mali_uk_profiling_start_s *) -#define MALI_IOC_PROFILING_ADD_EVENT _IOWR(MALI_IOC_PROFILING_BASE, _MALI_UK_PROFILING_ADD_EVENT, _mali_uk_profiling_add_event_s*) -#define MALI_IOC_PROFILING_STOP _IOWR(MALI_IOC_PROFILING_BASE, _MALI_UK_PROFILING_STOP, _mali_uk_profiling_stop_s *) -#define MALI_IOC_PROFILING_GET_EVENT _IOWR(MALI_IOC_PROFILING_BASE, _MALI_UK_PROFILING_GET_EVENT, _mali_uk_profiling_get_event_s *) -#define MALI_IOC_PROFILING_CLEAR _IOWR(MALI_IOC_PROFILING_BASE, _MALI_UK_PROFILING_CLEAR, _mali_uk_profiling_clear_s *) -#define MALI_IOC_PROFILING_GET_CONFIG _IOWR(MALI_IOC_PROFILING_BASE, _MALI_UK_PROFILING_GET_CONFIG, _mali_uk_get_user_settings_s *) -#define MALI_IOC_VSYNC_EVENT_REPORT _IOW (MALI_IOC_VSYNC_BASE, _MALI_UK_VSYNC_EVENT_REPORT, _mali_uk_vsync_event_report_s *) - -#ifdef __cplusplus -} -#endif - -#endif /* __MALI_KERNEL_IOCTL_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 index 3de368e..8367515 100644 --- a/drivers/media/video/samsung/mali/linux/mali_kernel_linux.c +++ b/drivers/media/video/samsung/mali/linux/mali_kernel_linux.c @@ -15,7 +15,7 @@ #include /* kernel module definitions */ #include /* file system operations */ #include /* character device definitions */ -#include /* memory mananger definitions */ +#include /* memory manager definitions */ #include #include "mali_kernel_common.h" #include "mali_session.h" @@ -28,6 +28,10 @@ #include "mali_kernel_sysfs.h" #include "mali_platform.h" #include "mali_kernel_license.h" +#include "mali_dma_buf.h" +#if MALI_INTERNAL_TIMELINE_PROFILING_ENABLED +#include "mali_profiling_internal.h" +#endif /* Streamline support for the Mali driver */ #if defined(CONFIG_TRACEPOINTS) && MALI_TIMELINE_PROFILING_ENABLED @@ -50,17 +54,10 @@ module_param(mali_debug_level, int, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP | S_IR 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"); @@ -78,92 +75,6 @@ MODULE_PARM_DESC(mali_boot_profiling, "Start profiling as a part of Mali driver #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 */ @@ -218,6 +129,15 @@ int mali_driver_init(void) ret = map_errcode(mali_initialize_subsystems()); if (0 != ret) goto initialize_subsystems_failed; +#if MALI_INTERNAL_TIMELINE_PROFILING_ENABLED + ret = _mali_internal_profiling_init(mali_boot_profiling ? MALI_TRUE : MALI_FALSE); + if (0 != ret) + { + /* No biggie if we wheren't able to initialize the profiling */ + MALI_PRINT_ERROR(("Failed to initialize profiling, feature will be unavailable\n")); + } +#endif + ret = initialize_sysfs(); if (0 != ret) goto initialize_sysfs_failed; @@ -227,6 +147,9 @@ int mali_driver_init(void) /* Error handling */ initialize_sysfs_failed: +#if MALI_INTERNAL_TIMELINE_PROFILING_ENABLED + _mali_internal_profiling_term(); +#endif mali_terminate_subsystems(); initialize_subsystems_failed: mali_osk_low_level_mem_term(); @@ -246,6 +169,10 @@ void mali_driver_exit(void) /* No need to terminate sysfs, this will be done automatically along with device termination */ +#if MALI_INTERNAL_TIMELINE_PROFILING_ENABLED + _mali_internal_profiling_term(); +#endif + mali_terminate_subsystems(); mali_osk_low_level_mem_term(); @@ -342,7 +269,7 @@ static int mali_mmap(struct file * filp, struct vm_area_struct * vma) return -EFAULT; } - MALI_DEBUG_PRINT(3, ("MMap() handler: start=0x%08X, phys=0x%08X, size=0x%08X\n", (unsigned int)vma->vm_start, (unsigned int)(vma->vm_pgoff << PAGE_SHIFT), (unsigned int)(vma->vm_end - vma->vm_start)) ); + 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; @@ -350,6 +277,19 @@ static int mali_mmap(struct file * filp, struct vm_area_struct * vma) 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); @@ -437,14 +377,6 @@ static int mali_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, switch(cmd) { - case MALI_IOC_GET_SYSTEM_INFO_SIZE: - err = get_system_info_size_wrapper(session_data, (_mali_uk_get_system_info_size_s __user *)arg); - break; - - case MALI_IOC_GET_SYSTEM_INFO: - err = get_system_info_wrapper(session_data, (_mali_uk_get_system_info_s __user *)arg); - break; - case MALI_IOC_WAIT_FOR_NOTIFICATION: err = wait_for_notification_wrapper(session_data, (_mali_uk_wait_for_notification_s __user *)arg); break; @@ -490,6 +422,7 @@ static int mali_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 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 */ @@ -548,6 +481,26 @@ static int mali_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 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; diff --git a/drivers/media/video/samsung/mali/linux/mali_kernel_linux.h b/drivers/media/video/samsung/mali/linux/mali_kernel_linux.h old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/linux/mali_kernel_pm.c b/drivers/media/video/samsung/mali/linux/mali_kernel_pm.c index 1d861f5..4639d55 100644 --- a/drivers/media/video/samsung/mali/linux/mali_kernel_pm.c +++ b/drivers/media/video/samsung/mali/linux/mali_kernel_pm.c @@ -65,7 +65,6 @@ static const struct dev_pm_ops mali_dev_pm_ops = .suspend = mali_os_suspend, .resume = mali_os_resume, #endif - .freeze = mali_os_suspend, .poweroff = mali_os_suspend, .thaw = mali_os_resume, @@ -266,3 +265,4 @@ void _mali_dev_platform_unregister(void) 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 old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/linux/mali_kernel_sysfs.c b/drivers/media/video/samsung/mali/linux/mali_kernel_sysfs.c index 64853d7..77ebc9d 100644 --- a/drivers/media/video/samsung/mali/linux/mali_kernel_sysfs.c +++ b/drivers/media/video/samsung/mali/linux/mali_kernel_sysfs.c @@ -17,9 +17,7 @@ #include #include #include -#include #include -#include #include "mali_kernel_license.h" #include "mali_kernel_common.h" #include "mali_kernel_linux.h" @@ -46,9 +44,11 @@ #include "mali_kernel_core.h" #include "mali_user_settings_db.h" #include "mali_device_pause_resume.h" +#include "mali_profiling_internal.h" #define POWER_BUFFER_SIZE 3 +struct device *mali_device; static struct dentry *mali_debugfs_dir = NULL; typedef enum @@ -70,6 +70,7 @@ static const char* const mali_power_events[_MALI_MAX_EVENTS] = { 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; @@ -682,7 +683,7 @@ static const struct file_operations l2_all_counter_src1_fops = { 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]))) @@ -791,7 +792,7 @@ static ssize_t profiling_record_read(struct file *filp, char __user *ubuf, size_ char buf[64]; int r; - r = sprintf(buf, "%u\n", _mali_osk_profiling_is_recording() ? 1 : 0); + r = sprintf(buf, "%u\n", _mali_internal_profiling_is_recording() ? 1 : 0); return simple_read_from_buffer(ubuf, cnt, ppos, buf, r); } @@ -824,16 +825,16 @@ static ssize_t profiling_record_write(struct file *filp, const char __user *ubuf 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()) + if (MALI_TRUE == _mali_internal_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_TRUE == _mali_internal_profiling_have_recording()) { - if (_MALI_OSK_ERR_OK != _mali_osk_profiling_clear()) + if (_MALI_OSK_ERR_OK != _mali_internal_profiling_clear()) { MALI_DEBUG_PRINT(3, ("Failed to clear existing recording of profiling events\n")); return -EFAULT; @@ -841,7 +842,7 @@ static ssize_t profiling_record_write(struct file *filp, const char __user *ubuf } /* start recording profiling data */ - if (_MALI_OSK_ERR_OK != _mali_osk_profiling_start(&limit)) + if (_MALI_OSK_ERR_OK != _mali_internal_profiling_start(&limit)) { MALI_DEBUG_PRINT(3, ("Failed to start recording of profiling events\n")); return -EFAULT; @@ -853,7 +854,7 @@ static ssize_t profiling_record_write(struct file *filp, const char __user *ubuf { /* stop recording profiling data */ u32 count = 0; - if (_MALI_OSK_ERR_OK != _mali_osk_profiling_stop(&count)) + if (_MALI_OSK_ERR_OK != _mali_internal_profiling_stop(&count)) { MALI_DEBUG_PRINT(2, ("Failed to stop recording of profiling events\n")); return -EFAULT; @@ -877,7 +878,7 @@ 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()) + if (MALI_TRUE != _mali_internal_profiling_have_recording()) { return NULL; } @@ -897,13 +898,13 @@ 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()) + if (MALI_TRUE != _mali_internal_profiling_have_recording()) { return NULL; } /* check if the next entry actually is avaiable */ - if (_mali_osk_profiling_get_count() <= (u32)(*spos + 1)) + if (_mali_internal_profiling_get_count() <= (u32)(*spos + 1)) { return NULL; } @@ -928,7 +929,7 @@ static int profiling_events_show(struct seq_file *seq_file, void *v) index = (u32)*spos; /* Retrieve all events */ - if (_MALI_OSK_ERR_OK == _mali_osk_profiling_get_event(index, ×tamp, &event_id, data)) + if (_MALI_OSK_ERR_OK == _mali_internal_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; @@ -1042,7 +1043,6 @@ static int mali_sysfs_user_settings_register(void) int mali_sysfs_register(struct mali_dev *device, dev_t dev, const char *mali_dev_name) { int err = 0; - struct device * mdev; device->mali_class = class_create(THIS_MODULE, mali_dev_name); if (IS_ERR(device->mali_class)) @@ -1050,10 +1050,10 @@ int mali_sysfs_register(struct mali_dev *device, dev_t dev, const char *mali_dev err = PTR_ERR(device->mali_class); goto init_class_err; } - mdev = device_create(device->mali_class, NULL, dev, NULL, mali_dev_name); - if (IS_ERR(mdev)) + mali_device = device_create(device->mali_class, NULL, dev, NULL, mali_dev_name); + if (IS_ERR(mali_device)) { - err = PTR_ERR(mdev); + err = PTR_ERR(mali_device); goto init_mdev_err; } diff --git a/drivers/media/video/samsung/mali/linux/mali_kernel_sysfs.h b/drivers/media/video/samsung/mali/linux/mali_kernel_sysfs.h old mode 100755 new mode 100644 index d79a886..24acca9 --- a/drivers/media/video/samsung/mali/linux/mali_kernel_sysfs.h +++ b/drivers/media/video/samsung/mali/linux/mali_kernel_sysfs.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 ARM Limited. All rights reserved. + * 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. @@ -16,8 +16,13 @@ extern "C" { #endif +#include + #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); diff --git a/drivers/media/video/samsung/mali/linux/mali_linux_pm.h b/drivers/media/video/samsung/mali/linux/mali_linux_pm.h old mode 100755 new mode 100644 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 old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/linux/mali_linux_trace.h b/drivers/media/video/samsung/mali/linux/mali_linux_trace.h index 09afcb3..5329ba3 100644 --- a/drivers/media/video/samsung/mali/linux/mali_linux_trace.h +++ b/drivers/media/video/samsung/mali/linux/mali_linux_trace.h @@ -12,6 +12,7 @@ #define MALI_LINUX_TRACE_H #include + #include #include diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_atomics.c b/drivers/media/video/samsung/mali/linux/mali_osk_atomics.c old mode 100755 new mode 100644 index 05831c5..32f8e6b --- a/drivers/media/video/samsung/mali/linux/mali_osk_atomics.c +++ b/drivers/media/video/samsung/mali/linux/mali_osk_atomics.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 ARM Limited. All rights reserved. + * 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. diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_indir_mmap.c b/drivers/media/video/samsung/mali/linux/mali_osk_indir_mmap.c deleted file mode 100755 index 7297218..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_indir_mmap.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2010 ARM Limited. All rights reserved. - * - * This program is free software and is provided to you under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence. - * - * 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 -#include -#include -#include -#include -#include -#include -#include - -#include "mali_osk.h" -#include "mali_ukk.h" -#include "mali_kernel_common.h" - -/** - * @file mali_osk_specific.c - * Implementation of per-OS Kernel level specifics - */ - -_mali_osk_errcode_t _mali_osk_specific_indirect_mmap( _mali_uk_mem_mmap_s *args ) -{ - /* args->ctx ignored here; args->ukk_private required instead */ - /* we need to lock the mmap semaphore before calling the do_mmap function */ - down_write(¤t->mm->mmap_sem); - - args->mapping = (void __user *)do_mmap( - (struct file *)args->ukk_private, - 0, /* start mapping from any address after NULL */ - args->size, - PROT_READ | PROT_WRITE, - MAP_SHARED, - args->phys_addr - ); - - /* and unlock it after the call */ - up_write(¤t->mm->mmap_sem); - - /* No cookie required here */ - args->cookie = 0; - /* uku_private meaningless, so zero */ - args->uku_private = NULL; - - if ( (NULL == args->mapping) || IS_ERR((void *)args->mapping) ) - { - return _MALI_OSK_ERR_FAULT; - } - - /* Success */ - return _MALI_OSK_ERR_OK; -} - - -_mali_osk_errcode_t _mali_osk_specific_indirect_munmap( _mali_uk_mem_munmap_s *args ) -{ - /* args->ctx and args->cookie ignored here */ - - if ((NULL != current) && (NULL != current->mm)) - { - /* remove mapping of mali memory from the process' view */ - /* lock mmap semaphore before call */ - /* lock mmap_sem before calling do_munmap */ - down_write(¤t->mm->mmap_sem); - do_munmap( - current->mm, - (unsigned long)args->mapping, - args->size - ); - /* and unlock after call */ - up_write(¤t->mm->mmap_sem); - MALI_DEBUG_PRINT(5, ("unmapped\n")); - } - else - { - MALI_DEBUG_PRINT(2, ("Freeing of a big block while no user process attached, assuming crash cleanup in progress\n")); - } - - return _MALI_OSK_ERR_OK; /* always succeeds */ -} diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_indir_mmap.h b/drivers/media/video/samsung/mali/linux/mali_osk_indir_mmap.h deleted file mode 100755 index f87739b..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_indir_mmap.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2010-2011 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_INDIR_MMAP_H__ -#define __MALI_OSK_INDIR_MMAP_H__ - -#include "mali_uk_types.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** - * Linux specific means for calling _mali_ukk_mem_mmap/munmap - * - * The presence of _MALI_OSK_SPECIFIC_INDIRECT_MMAP indicates that - * _mali_osk_specific_indirect_mmap and _mali_osk_specific_indirect_munmap - * should be used instead of _mali_ukk_mem_mmap/_mali_ukk_mem_munmap. - * - * The arguments are the same as _mali_ukk_mem_mmap/_mali_ukk_mem_munmap. - * - * In ALL operating system other than Linux, it is expected that common code - * should be able to call _mali_ukk_mem_mmap/_mali_ukk_mem_munmap directly. - * Such systems should NOT define _MALI_OSK_SPECIFIC_INDIRECT_MMAP. - */ -_mali_osk_errcode_t _mali_osk_specific_indirect_mmap( _mali_uk_mem_mmap_s *args ); -_mali_osk_errcode_t _mali_osk_specific_indirect_munmap( _mali_uk_mem_munmap_s *args ); - - -#ifdef __cplusplus -} -#endif - -#endif /* __MALI_OSK_INDIR_MMAP_H__ */ diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_locks.c b/drivers/media/video/samsung/mali/linux/mali_osk_locks.c index 0297c77..d007d93 100644 --- a/drivers/media/video/samsung/mali/linux/mali_osk_locks.c +++ b/drivers/media/video/samsung/mali/linux/mali_osk_locks.c @@ -13,19 +13,12 @@ * Implemenation of the OS abstraction layer for the kernel device driver */ -/* needed to detect kernel version specific code */ -#include - #include #include - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) -#include -#else /* pre 2.6.26 the file was in the arch specific location */ -#include -#endif +#include #include + #include "mali_osk.h" #include "mali_kernel_common.h" @@ -34,9 +27,9 @@ 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}() */ + _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX, /* Interruptable, use mutex_unlock()/down_interruptable() */ + _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT, /* Non-Interruptable, use mutex_unlock()/down() */ + _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT_RW, /* Non-interruptable, Reader/Writer, use {mutex_unlock,down}{read,write}() */ /* Linux supports, but we do not support: * Non-Interruptable Reader/Writer spinlock mutexes - RW optimization will be switched off @@ -55,7 +48,7 @@ struct _mali_osk_lock_t_struct union { spinlock_t spinlock; - struct semaphore sema; + struct mutex mutex; struct rw_semaphore rw_sema; } obj; MALI_DEBUG_CODE( @@ -132,7 +125,7 @@ _mali_osk_lock_t *_mali_osk_lock_init( _mali_osk_lock_flags_t flags, u32 initial } /* Initially unlocked */ - sema_init( &lock->obj.sema, 1 ); + mutex_init(&lock->obj.mutex); } #ifdef DEBUG @@ -186,11 +179,15 @@ _mali_osk_errcode_t _mali_osk_lock_wait( _mali_osk_lock_t *lock, _mali_osk_lock_ spin_lock(&lock->obj.spinlock); break; case _MALI_OSK_INTERNAL_LOCKTYPE_SPIN_IRQ: - spin_lock_irqsave(&lock->obj.spinlock, lock->flags); + { + 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) ) + if (mutex_lock_interruptible(&lock->obj.mutex)) { MALI_PRINT_ERROR(("Can not lock mutex\n")); err = _MALI_OSK_ERR_RESTARTSYSCALL; @@ -198,7 +195,7 @@ _mali_osk_errcode_t _mali_osk_lock_wait( _mali_osk_lock_t *lock, _mali_osk_lock_ break; case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT: - down(&lock->obj.sema); + mutex_lock(&lock->obj.mutex); break; case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT_RW: @@ -304,7 +301,7 @@ void _mali_osk_lock_signal( _mali_osk_lock_t *lock, _mali_osk_lock_mode_t mode ) case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX: /* FALLTHROUGH */ case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT: - up(&lock->obj.sema); + mutex_unlock(&lock->obj.mutex); break; case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT_RW: 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 index 5767912..02558a0 100644 --- 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 @@ -21,6 +21,10 @@ #include #include #include +#include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0) +#include +#endif #include "mali_osk.h" #include "mali_ukk.h" /* required to hook in _mali_ukk_mem_mmap handling */ @@ -64,6 +68,7 @@ struct MappingInfo { struct vm_area_struct *vma; struct AllocationList *list; + struct AllocationList *tail; }; typedef struct MappingInfo MappingInfo; @@ -82,7 +87,7 @@ 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 = 6 * 1024 * 1024; /* 6 MiB */ + static int pre_allocated_memory_size_max = 16 * 1024 * 1024; /* 6 MiB */ #endif static struct vm_operations_struct mali_kernel_vm_ops = @@ -96,14 +101,73 @@ static struct vm_operations_struct mali_kernel_vm_ops = #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; @@ -500,16 +564,24 @@ _mali_osk_errcode_t _mali_osk_mem_mapregion_map( mali_memory_allocation * descri 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 */ - alloc_item->next = mappingInfo->list; - alloc_item->offset = offset; + if (NULL == mappingInfo->list) + { + mappingInfo->list = alloc_item; + } + else + { + mappingInfo->tail->next = alloc_item; + } - /*alloc_item->physaddr = linux_phys_addr;*/ - mappingInfo->list = 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; @@ -560,6 +632,7 @@ void _mali_osk_mem_mapregion_unmap( mali_memory_allocation * descriptor, u32 off /* 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); @@ -572,11 +645,8 @@ void _mali_osk_mem_mapregion_unmap( mali_memory_allocation * descriptor, u32 off continue; } - _kernel_page_release(alloc->physaddr); - - /* Remove the allocation from the list */ *prev = alloc->next; - _mali_osk_free( alloc ); + _allocation_list_item_release(alloc); /* Move onto the next allocation */ size -= _MALI_OSK_CPU_PAGE_SIZE; diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_mali.c b/drivers/media/video/samsung/mali/linux/mali_osk_mali.c index 3def446..8dc90fd 100644 --- a/drivers/media/video/samsung/mali/linux/mali_osk_mali.c +++ b/drivers/media/video/samsung/mali/linux/mali_osk_mali.c @@ -18,7 +18,6 @@ #include "mali_kernel_common.h" /* MALI_xxx macros */ #include "mali_osk.h" /* kernel side OS functions */ #include "mali_uk_types.h" -#include "mali_kernel_linux.h" #include #include "arch/config.h" /* contains the configuration of the arch we are compiling for */ diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_math.c b/drivers/media/video/samsung/mali/linux/mali_osk_math.c old mode 100755 new mode 100644 index 3e62e51..bb25e7d --- a/drivers/media/video/samsung/mali/linux/mali_osk_math.c +++ b/drivers/media/video/samsung/mali/linux/mali_osk_math.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 ARM Limited. All rights reserved. + * 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. diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_memory.c b/drivers/media/video/samsung/mali/linux/mali_osk_memory.c old mode 100755 new mode 100644 index 7bb470f..5354e85 --- a/drivers/media/video/samsung/mali/linux/mali_osk_memory.c +++ b/drivers/media/video/samsung/mali/linux/mali_osk_memory.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 ARM Limited. All rights reserved. + * 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. diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_misc.c b/drivers/media/video/samsung/mali/linux/mali_osk_misc.c old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_notification.c b/drivers/media/video/samsung/mali/linux/mali_osk_notification.c old mode 100755 new mode 100644 index c14c0d5..2cfb5ef --- a/drivers/media/video/samsung/mali/linux/mali_osk_notification.c +++ b/drivers/media/video/samsung/mali/linux/mali_osk_notification.c @@ -21,11 +21,7 @@ #include #include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) -#include -#else /* pre 2.6.26 the file was in the arch specific location */ -#include -#endif +#include /** * Declaration of the notification queue object type @@ -35,7 +31,7 @@ */ struct _mali_osk_notification_queue_t_struct { - struct semaphore mutex; /**< Mutex protecting the list */ + spinlock_t 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 */ }; @@ -53,7 +49,7 @@ _mali_osk_notification_queue_t *_mali_osk_notification_queue_init( void ) 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); + spin_lock_init(&result->mutex); init_waitqueue_head(&result->receive_queue); INIT_LIST_HEAD(&result->head); @@ -121,39 +117,22 @@ void _mali_osk_notification_queue_send( _mali_osk_notification_queue_t *queue, _ notification = container_of( object, _mali_osk_notification_wrapper_t, data ); /* lock queue access */ - down(&queue->mutex); + spin_lock(&queue->mutex); /* add to list */ list_add_tail(¬ification->list, &queue->head); /* unlock the queue */ - up(&queue->mutex); + spin_unlock(&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); + spin_lock(&queue->mutex); if (!list_empty(&queue->head)) { @@ -163,7 +142,7 @@ _mali_osk_errcode_t _mali_osk_notification_queue_dequeue( _mali_osk_notification ret = _MALI_OSK_ERR_OK; } - up(&queue->mutex); + spin_unlock(&queue->mutex); return ret; } @@ -177,12 +156,10 @@ _mali_osk_errcode_t _mali_osk_notification_queue_receive( _mali_osk_notification /* default result */ *result = NULL; - while (_MALI_OSK_ERR_OK != _mali_osk_notification_queue_dequeue(queue, result)) + if (wait_event_interruptible(queue->receive_queue, + _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_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 index 20fb7b4..491a603 100644 --- a/drivers/media/video/samsung/mali/linux/mali_osk_pm.c +++ b/drivers/media/video/samsung/mali/linux/mali_osk_pm.c @@ -48,7 +48,6 @@ void _mali_osk_pm_dev_enable(void) _mali_osk_errcode_t _mali_osk_pm_dev_idle(void) { #ifdef CONFIG_PM_RUNTIME - if (MALI_TRUE == have_runtime_reference) { int err; diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_profiling.c b/drivers/media/video/samsung/mali/linux/mali_osk_profiling.c new file mode 100644 index 0000000..95bee53 --- /dev/null +++ b/drivers/media/video/samsung/mali/linux/mali_osk_profiling.c @@ -0,0 +1,261 @@ +/* + * 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 + +#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_gator.c b/drivers/media/video/samsung/mali/linux/mali_osk_profiling_gator.c deleted file mode 100644 index 75c888d..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_profiling_gator.c +++ /dev/null @@ -1,262 +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 - -#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_id == COUNTER_VP_C0) - { - 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; - } - } - } - else if (counter_id == COUNTER_VP_C1) - { - 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; - } - } - } - else if (counter_id >= COUNTER_FP0_C0 && counter_id <= COUNTER_FP3_C1) - { - 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; - } - } - } - } - else if (counter_id >= COUNTER_L2_C0 && counter_id <= COUNTER_L2_C1) - { - 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); /* @@@@ TODO: Fix hardcoded limit of maximum 1 L2 cache */ - 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); - /* @@@@ TODO: add error checking, if needed; src == MALI_HW_CORE_NO_COUNTER if not able to get value */ - } - 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 9a423d2..0000000 --- a/drivers/media/video/samsung/mali/linux/mali_osk_profiling_internal.c +++ /dev/null @@ -1,308 +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) -{ - u32 cur_index = _mali_osk_atomic_inc_return(&profile_insert_index) - 1; - - if (prof_state != MALI_PROFILING_STATE_RUNNING || cur_index >= profile_entry_count) - { - /* - * Not in recording mode, or buffer is full - * Decrement index again, and early out - */ - _mali_osk_atomic_dec(&profile_insert_index); - return; - } - - 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; - - _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); - - 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); - } - _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 (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 (index >= _mali_osk_atomic_read(&profile_entries_written)) - { - _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); - return _MALI_OSK_ERR_FAULT; - } - - *timestamp = profile_entries[index].timestamp; - *event_id = profile_entries[index].event_id; - data[0] = profile_entries[index].data[0]; - data[1] = profile_entries[index].data[1]; - data[2] = profile_entries[index].data[2]; - data[3] = profile_entries[index].data[3]; - data[4] = profile_entries[index].data[4]; - - _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 old mode 100755 new mode 100644 index 83ee906..157368b --- a/drivers/media/video/samsung/mali/linux/mali_osk_specific.h +++ b/drivers/media/video/samsung/mali/linux/mali_osk_specific.h @@ -17,17 +17,15 @@ #ifndef __MALI_OSK_SPECIFIC_H__ #define __MALI_OSK_SPECIFIC_H__ -#ifdef __cplusplus -extern "C" -{ -#endif +#include #define MALI_STATIC_INLINE static inline #define MALI_NON_STATIC_INLINE inline -#ifdef __cplusplus +MALI_STATIC_INLINE u32 _mali_osk_copy_from_user(void *to, void *from, u32 n) +{ + return (u32)copy_from_user(to, from, (unsigned long)n); } -#endif /** The list of events supported by the Mali DDK. */ typedef enum @@ -39,7 +37,7 @@ typedef enum ACTIVITY_FP0, ACTIVITY_FP1, ACTIVITY_FP2, - ACTIVITY_FP3, + ACTIVITY_FP3, /* L2 cache counters */ COUNTER_L2_C0, @@ -59,7 +57,7 @@ typedef enum COUNTER_FP3_C0, COUNTER_FP3_C1, - /* + /* * If more hardware counters are added, the _mali_osk_hw_counter_table * below should also be updated. */ diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_time.c b/drivers/media/video/samsung/mali/linux/mali_osk_time.c old mode 100755 new mode 100644 index da9b865..b399b87 --- a/drivers/media/video/samsung/mali/linux/mali_osk_time.c +++ b/drivers/media/video/samsung/mali/linux/mali_osk_time.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 ARM Limited. All rights reserved. + * 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. diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_timers.c b/drivers/media/video/samsung/mali/linux/mali_osk_timers.c old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/linux/mali_profiling_internal.c b/drivers/media/video/samsung/mali/linux/mali_profiling_internal.c new file mode 100644 index 0000000..8202497 --- /dev/null +++ b/drivers/media/video/samsung/mali/linux/mali_profiling_internal.c @@ -0,0 +1,294 @@ +/* + * 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" +#include "mali_profiling_internal.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 _mali_osk_atomic_t profile_insert_index; +static u32 profile_mask = 0; +static inline void add_event(u32 event_id, u32 data0, u32 data1, u32 data2, u32 data3, u32 data4); + +void probe_mali_timeline_event(void *data, TP_PROTO(unsigned int event_id, unsigned int d0, unsigned int d1, unsigned + int d2, unsigned int d3, unsigned int d4)) +{ + add_event(event_id, d0, d1, d2, d3, d4); +} + +_mali_osk_errcode_t _mali_internal_profiling_init(mali_bool auto_start) +{ + profile_entries = NULL; + profile_mask = 0; + _mali_osk_atomic_init(&profile_insert_index, 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_internal_profiling_start(&limit)) + { + return _MALI_OSK_ERR_FAULT; + } + } + + return _MALI_OSK_ERR_OK; +} + +void _mali_internal_profiling_term(void) +{ + u32 count; + + /* Ensure profiling is stopped */ + _mali_internal_profiling_stop(&count); + + prof_state = MALI_PROFILING_STATE_UNINITIALIZED; + + if (NULL != profile_entries) + { + _mali_osk_vfree(profile_entries); + profile_entries = NULL; + } + + if (NULL != lock) + { + _mali_osk_lock_term(lock); + lock = NULL; + } +} + +_mali_osk_errcode_t _mali_internal_profiling_start(u32 * limit) +{ + _mali_osk_errcode_t ret; + + mali_profiling_entry *new_profile_entries; + + _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW); + + if (MALI_PROFILING_MAX_BUFFER_ENTRIES < *limit) + { + *limit = MALI_PROFILING_MAX_BUFFER_ENTRIES; + } + + profile_mask = 1; + while (profile_mask <= *limit) + { + profile_mask <<= 1; + } + profile_mask >>= 1; + + *limit = profile_mask; + + profile_mask--; /* turns the power of two into a mask of one less */ + + new_profile_entries = _mali_osk_valloc(*limit * sizeof(mali_profiling_entry)); + + if (NULL == new_profile_entries) + { + _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); + return _MALI_OSK_ERR_NOMEM; + } + + if (MALI_PROFILING_STATE_IDLE != prof_state) + { + _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 */ + } + + profile_entries = new_profile_entries; + + ret = _mali_timestamp_reset(); + + if (_MALI_OSK_ERR_OK == ret) + { + prof_state = MALI_PROFILING_STATE_RUNNING; + } + else + { + _mali_osk_vfree(profile_entries); + profile_entries = NULL; + } + + register_trace_mali_timeline_event(probe_mali_timeline_event, NULL); + + _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); + return ret; +} + +static inline void add_event(u32 event_id, u32 data0, u32 data1, u32 data2, u32 data3, u32 data4) +{ + u32 cur_index = (_mali_osk_atomic_inc_return(&profile_insert_index) - 1) & profile_mask; + + 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_errcode_t _mali_internal_profiling_stop(u32 * count) +{ + _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW); + + if (MALI_PROFILING_STATE_RUNNING != prof_state) + { + _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; + + unregister_trace_mali_timeline_event(probe_mali_timeline_event, NULL); + tracepoint_synchronize_unregister(); + + _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); + + *count = _mali_osk_atomic_read(&profile_insert_index); + if (*count > profile_mask) *count = profile_mask; + + return _MALI_OSK_ERR_OK; +} + +u32 _mali_internal_profiling_get_count(void) +{ + u32 retval = 0; + + _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW); + if (MALI_PROFILING_STATE_RETURN == prof_state) + { + retval = _mali_osk_atomic_read(&profile_insert_index); + if (retval > profile_mask) retval = profile_mask; + } + _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); + + return retval; +} + +_mali_osk_errcode_t _mali_internal_profiling_get_event(u32 index, u64* timestamp, u32* event_id, u32 data[5]) +{ + u32 raw_index = _mali_osk_atomic_read(&profile_insert_index); + + _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW); + + if (index < profile_mask) + { + if ((raw_index & ~profile_mask) != 0) + { + index += raw_index; + index &= profile_mask; + } + + 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(index >= raw_index) + { + _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); + return _MALI_OSK_ERR_FAULT; + } + + *timestamp = profile_entries[index].timestamp; + *event_id = profile_entries[index].event_id; + data[0] = profile_entries[index].data[0]; + data[1] = profile_entries[index].data[1]; + data[2] = profile_entries[index].data[2]; + data[3] = profile_entries[index].data[3]; + data[4] = profile_entries[index].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; +} + +_mali_osk_errcode_t _mali_internal_profiling_clear(void) +{ + _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW); + + if (MALI_PROFILING_STATE_RETURN != prof_state) + { + _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_mask = 0; + _mali_osk_atomic_init(&profile_insert_index, 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_internal_profiling_is_recording(void) +{ + return prof_state == MALI_PROFILING_STATE_RUNNING ? MALI_TRUE : MALI_FALSE; +} + +mali_bool _mali_internal_profiling_have_recording(void) +{ + return prof_state == MALI_PROFILING_STATE_RETURN ? MALI_TRUE : MALI_FALSE; +} diff --git a/drivers/media/video/samsung/mali/linux/mali_profiling_internal.h b/drivers/media/video/samsung/mali/linux/mali_profiling_internal.h new file mode 100644 index 0000000..092b9b0 --- /dev/null +++ b/drivers/media/video/samsung/mali/linux/mali_profiling_internal.h @@ -0,0 +1,36 @@ +/* + * 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_INTERNAL_H__ +#define __MALI_PROFILING_INTERNAL_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "mali_osk.h" + +int _mali_internal_profiling_init(mali_bool auto_start); +void _mali_internal_profiling_term(void); + +mali_bool _mali_internal_profiling_is_recording(void); +mali_bool _mali_internal_profiling_have_recording(void); +_mali_osk_errcode_t _mali_internal_profiling_clear(void); +_mali_osk_errcode_t _mali_internal_profiling_get_event(u32 index, u64* timestamp, u32* event_id, u32 data[5]); +u32 _mali_internal_profiling_get_count(void); +int _mali_internal_profiling_stop(u32 * count); +int _mali_internal_profiling_start(u32 * limit); + +#ifdef __cplusplus +} +#endif + +#endif /* __MALI_PROFILING_INTERNAL_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 index b535e6c..fbe902a 100644 --- a/drivers/media/video/samsung/mali/linux/mali_uk_types.h +++ b/drivers/media/video/samsung/mali/linux/mali_uk_types.h @@ -11,9 +11,7 @@ #ifndef __MALI_UK_TYPES_H__ #define __MALI_UK_TYPES_H__ -#include "regs/mali_200_regs.h" - /* Simple wrapper in order to find the OS specific location of this file */ -#include "../include/linux/mali/mali_utgard_uk_types.h" +#include #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 index 6eb2df3..22262fe 100644 --- a/drivers/media/video/samsung/mali/linux/mali_ukk_core.c +++ b/drivers/media/video/samsung/mali/linux/mali_ukk_core.c @@ -36,64 +36,6 @@ int get_api_version_wrapper(struct mali_session_data *session_data, _mali_uk_get return 0; } -int get_system_info_size_wrapper(struct mali_session_data *session_data, _mali_uk_get_system_info_size_s __user *uargs) -{ - _mali_uk_get_system_info_size_s kargs; - _mali_osk_errcode_t err; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - - kargs.ctx = session_data; - err = _mali_ukk_get_system_info_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 get_system_info_wrapper(struct mali_session_data *session_data, _mali_uk_get_system_info_s __user *uargs) -{ - _mali_uk_get_system_info_s kargs; - _mali_osk_errcode_t err; - _mali_system_info *system_info_user; - _mali_system_info *system_info_kernel; - - MALI_CHECK_NON_NULL(uargs, -EINVAL); - - if (0 != get_user(kargs.system_info, &uargs->system_info)) return -EFAULT; - if (0 != get_user(kargs.size, &uargs->size)) return -EFAULT; - - /* A temporary kernel buffer for the system_info datastructure is passed through the system_info - * member. The ukk_private member will point to the user space destination of this buffer so - * that _mali_ukk_get_system_info() can correct the pointers in the system_info correctly - * for user space. - */ - system_info_kernel = kmalloc(kargs.size, GFP_KERNEL); - if (NULL == system_info_kernel) return -EFAULT; - - system_info_user = kargs.system_info; - kargs.system_info = system_info_kernel; - kargs.ukk_private = (u32)system_info_user; - kargs.ctx = session_data; - - err = _mali_ukk_get_system_info(&kargs); - if (_MALI_OSK_ERR_OK != err) - { - kfree(system_info_kernel); - return map_errcode(err); - } - - if (0 != copy_to_user(system_info_user, system_info_kernel, kargs.size)) - { - kfree(system_info_kernel); - return -EFAULT; - } - - kfree(system_info_kernel); - 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; diff --git a/drivers/media/video/samsung/mali/linux/mali_ukk_gp.c b/drivers/media/video/samsung/mali/linux/mali_ukk_gp.c old mode 100755 new mode 100644 index 7070016..4ee4a81 --- a/drivers/media/video/samsung/mali/linux/mali_ukk_gp.c +++ b/drivers/media/video/samsung/mali/linux/mali_ukk_gp.c @@ -18,40 +18,15 @@ 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_osk_errcode_t err; - MALI_CHECK_NON_NULL(uargs, -EINVAL); - MALI_CHECK_NON_NULL(session_data, -EINVAL); + 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; - } + err = _mali_ukk_gp_start_job(session_data, uargs); + if (_MALI_OSK_ERR_OK != err) return map_errcode(err); - 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; + return 0; } int gp_get_core_version_wrapper(struct mali_session_data *session_data, _mali_uk_get_gp_core_version_s __user *uargs) diff --git a/drivers/media/video/samsung/mali/linux/mali_ukk_mem.c b/drivers/media/video/samsung/mali/linux/mali_ukk_mem.c old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/linux/mali_ukk_pp.c b/drivers/media/video/samsung/mali/linux/mali_ukk_pp.c index c11c61b..00a84f7 100644 --- a/drivers/media/video/samsung/mali/linux/mali_ukk_pp.c +++ b/drivers/media/video/samsung/mali/linux/mali_ukk_pp.c @@ -18,24 +18,15 @@ 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); + err = _mali_ukk_pp_start_job(session_data, uargs); if (_MALI_OSK_ERR_OK != err) return map_errcode(err); - return 0; + 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) diff --git a/drivers/media/video/samsung/mali/linux/mali_ukk_profiling.c b/drivers/media/video/samsung/mali/linux/mali_ukk_profiling.c index 7324d9d..f4e31c9 100644 --- a/drivers/media/video/samsung/mali/linux/mali_ukk_profiling.c +++ b/drivers/media/video/samsung/mali/linux/mali_ukk_profiling.c @@ -180,3 +180,4 @@ int profiling_report_sw_counters_wrapper(struct mali_session_data *session_data, 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 old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/linux/mali_ukk_wrappers.h b/drivers/media/video/samsung/mali/linux/mali_ukk_wrappers.h index b568ce7..65857fd 100644 --- a/drivers/media/video/samsung/mali/linux/mali_ukk_wrappers.h +++ b/drivers/media/video/samsung/mali/linux/mali_ukk_wrappers.h @@ -24,8 +24,6 @@ extern "C" { #endif -int get_system_info_size_wrapper(struct mali_session_data *session_data, _mali_uk_get_system_info_size_s __user *uargs); -int get_system_info_wrapper(struct mali_session_data *session_data, _mali_uk_get_system_info_s __user *uargs); 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); @@ -60,6 +58,7 @@ int profiling_report_sw_counters_wrapper(struct mali_session_data *session_data, 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 diff --git a/drivers/media/video/samsung/mali/platform/default/mali_platform.c b/drivers/media/video/samsung/mali/platform/default/mali_platform.c old mode 100755 new mode 100644 index 9e64ce7..d966f25 --- a/drivers/media/video/samsung/mali/platform/default/mali_platform.c +++ b/drivers/media/video/samsung/mali/platform/default/mali_platform.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 ARM Limited. All rights reserved. + * 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. diff --git a/drivers/media/video/samsung/mali/platform/mali_platform.h b/drivers/media/video/samsung/mali/platform/mali_platform.h index 6e55dee..786a50c 100644 --- a/drivers/media/video/samsung/mali/platform/mali_platform.h +++ b/drivers/media/video/samsung/mali/platform/mali_platform.h @@ -138,6 +138,8 @@ int mali_dvfs_bottom_lock_pop(void); #endif #endif +int mali_dvfs_get_vol(int step); + #if MALI_VOLTAGE_LOCK int mali_voltage_lock_push(int lock_vol); int mali_voltage_lock_pop(void); diff --git a/drivers/media/video/samsung/mali/platform/orion-m400/mali_platform.c b/drivers/media/video/samsung/mali/platform/orion-m400/mali_platform.c old mode 100755 new mode 100644 diff --git a/drivers/media/video/samsung/mali/platform/orion-m400/mali_platform_dvfs.c b/drivers/media/video/samsung/mali/platform/orion-m400/mali_platform_dvfs.c old mode 100755 new mode 100644 index f8d76dc..d1bc62f --- a/drivers/media/video/samsung/mali/platform/orion-m400/mali_platform_dvfs.c +++ b/drivers/media/video/samsung/mali/platform/orion-m400/mali_platform_dvfs.c @@ -1 +1 @@ -/* * 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_platform_dvfs.c * Platform specific Mali driver dvfs functions */ #include "mali_kernel_common.h" #include "mali_osk.h" #include "mali_platform.h" #include #include #include #include #include #ifdef CONFIG_CPU_FREQ #include #include #define EXYNOS4_ASV_ENABLED #endif #include "mali_device_pause_resume.h" #include #define MALI_DVFS_WATING 10 // msec static int bMaliDvfsRun=0; #if MALI_GPU_BOTTOM_LOCK static _mali_osk_atomic_t bottomlock_status; #endif typedef struct mali_dvfs_tableTag{ unsigned int clock; unsigned int freq; unsigned int vol; }mali_dvfs_table; typedef struct mali_dvfs_statusTag{ unsigned int currentStep; mali_dvfs_table * pCurrentDvfs; }mali_dvfs_currentstatus; typedef struct mali_dvfs_thresholdTag{ unsigned int downthreshold; unsigned int upthreshold; }mali_dvfs_threshold_table; typedef struct mali_dvfs_staycount{ unsigned int staycount; }mali_dvfs_staycount_table; mali_dvfs_staycount_table mali_dvfs_staycount[MALI_DVFS_STEPS]={ /*step 0*/{1}, /*step 1*/{1},}; /*dvfs threshold*/ mali_dvfs_threshold_table mali_dvfs_threshold[MALI_DVFS_STEPS]={ /*step 0*/{((int)((255*0)/100)), ((int)((255*85)/100))}, /*step 1*/{((int)((255*75)/100)), ((int)((255*100)/100))} }; /*dvfs status*/ mali_dvfs_currentstatus maliDvfsStatus; int mali_dvfs_control=0; /*dvfs table*/ mali_dvfs_table mali_dvfs[MALI_DVFS_STEPS]={ /*step 0*/{160 ,1000000 , 950000}, /*step 1*/{267 ,1000000 ,1000000} }; #ifdef EXYNOS4_ASV_ENABLED #define ASV_8_LEVEL 8 #define ASV_5_LEVEL 5 #define ASV_LEVEL_SUPPORT 0 static unsigned int asv_3d_volt_5_table[ASV_5_LEVEL][MALI_DVFS_STEPS] = { /* L3(160MHz), L2(266MHz) */ {1000000, 1100000}, /* S */ {1000000, 1100000}, /* A */ { 950000, 1000000}, /* B */ { 950000, 1000000}, /* C */ { 950000, 950000}, /* D */ }; static unsigned int asv_3d_volt_8_table[ASV_8_LEVEL][MALI_DVFS_STEPS] = { /* L3(160MHz), L2(266MHz)) */ {1000000, 1100000}, /* SS */ {1000000, 1100000}, /* A1 */ {1000000, 1100000}, /* A2 */ { 950000, 1000000}, /* B1 */ { 950000, 1000000}, /* B2 */ { 950000, 1000000}, /* C1 */ { 950000, 1000000}, /* C2 */ { 950000, 950000}, /* D1 */ }; #endif static u32 mali_dvfs_utilization = 255; static void mali_dvfs_work_handler(struct work_struct *w); static struct workqueue_struct *mali_dvfs_wq = 0; extern mali_io_address clk_register_map; #if MALI_GPU_BOTTOM_LOCK extern _mali_osk_lock_t *mali_dvfs_lock; #endif static DECLARE_WORK(mali_dvfs_work, mali_dvfs_work_handler); static unsigned int get_mali_dvfs_status(void) { return maliDvfsStatus.currentStep; } #if MALI_GPU_BOTTOM_LOCK #if MALI_PMM_RUNTIME_JOB_CONTROL_ON int get_mali_dvfs_control_status(void) { return mali_dvfs_control; } mali_bool set_mali_dvfs_current_step(unsigned int step) { _mali_osk_lock_wait(mali_dvfs_lock, _MALI_OSK_LOCKMODE_RW); maliDvfsStatus.currentStep = step; _mali_osk_lock_signal(mali_dvfs_lock, _MALI_OSK_LOCKMODE_RW); return MALI_TRUE; } #endif #endif static mali_bool set_mali_dvfs_status(u32 step,mali_bool boostup) { u32 validatedStep=step; #ifdef CONFIG_REGULATOR if (mali_regulator_get_usecount()==0) { MALI_DEBUG_PRINT(1, ("regulator use_count is 0 \n")); return MALI_FALSE; } #endif if (boostup) { #ifdef CONFIG_REGULATOR /*change the voltage*/ mali_regulator_set_voltage(mali_dvfs[step].vol, mali_dvfs[step].vol); #endif /*change the clock*/ mali_clk_set_rate(mali_dvfs[step].clock, mali_dvfs[step].freq); } else { /*change the clock*/ mali_clk_set_rate(mali_dvfs[step].clock, mali_dvfs[step].freq); #ifdef CONFIG_REGULATOR /*change the voltage*/ mali_regulator_set_voltage(mali_dvfs[step].vol, mali_dvfs[step].vol); #endif } maliDvfsStatus.currentStep = validatedStep; /*for future use*/ maliDvfsStatus.pCurrentDvfs = &mali_dvfs[validatedStep]; return MALI_TRUE; } static void mali_platform_wating(u32 msec) { /*sample wating change this in the future with proper check routine. */ unsigned int read_val; while(1) { read_val = _mali_osk_mem_ioread32(clk_register_map, 0x00); if ((read_val & 0x8000)==0x0000) break; _mali_osk_time_ubusydelay(100); // 1000 -> 100 : 20101218 } /* _mali_osk_time_ubusydelay(msec*1000);*/ } static mali_bool change_mali_dvfs_status(u32 step, mali_bool boostup ) { MALI_DEBUG_PRINT(1, ("> change_mali_dvfs_status: %d, %d \n",step, boostup)); if (!set_mali_dvfs_status(step, boostup)) { MALI_DEBUG_PRINT(1, ("error on set_mali_dvfs_status: %d, %d \n",step, boostup)); return MALI_FALSE; } /*wait until clock and voltage is stablized*/ mali_platform_wating(MALI_DVFS_WATING); /*msec*/ return MALI_TRUE; } static unsigned int decideNextStatus(unsigned int utilization) { unsigned int level=0; // 0:stay, 1:up if (!mali_dvfs_control) { #if MALI_GPU_BOTTOM_LOCK if (_mali_osk_atomic_read(&bottomlock_status) > 0) level = 1; /* or bigger */ else if (utilization > mali_dvfs_threshold[maliDvfsStatus.currentStep].upthreshold) #else if (utilization > mali_dvfs_threshold[maliDvfsStatus.currentStep].upthreshold) #endif level=1; else if (utilization < mali_dvfs_threshold[maliDvfsStatus.currentStep].downthreshold) level=0; else level = maliDvfsStatus.currentStep; } else { if ((mali_dvfs_control > 0) && (mali_dvfs_control < mali_dvfs[1].clock)) level=0; else level=1; } return level; } #ifdef EXYNOS4_ASV_ENABLED static mali_bool mali_dvfs_table_update(void) { unsigned int exynos_result_of_asv_group; unsigned int i; exynos_result_of_asv_group = exynos_result_of_asv & 0xf; MALI_PRINT(("exynos_result_of_asv_group = 0x%x\n", exynos_result_of_asv_group)); if (ASV_LEVEL_SUPPORT) { //asv level information will be added. for (i = 0; i < MALI_DVFS_STEPS; i++) { mali_dvfs[i].vol = asv_3d_volt_5_table[exynos_result_of_asv_group][i]; MALI_PRINT(("mali_dvfs[%d].vol = %d\n", i, mali_dvfs[i].vol)); } } else { for (i = 0; i < MALI_DVFS_STEPS; i++) { mali_dvfs[i].vol = asv_3d_volt_8_table[exynos_result_of_asv_group][i]; MALI_PRINT(("mali_dvfs[%d].vol = %d\n", i, mali_dvfs[i].vol)); } } return MALI_TRUE; } #endif static mali_bool mali_dvfs_status(u32 utilization) { unsigned int nextStatus = 0; unsigned int curStatus = 0; mali_bool boostup = MALI_FALSE; #ifdef EXYNOS4_ASV_ENABLED static mali_bool asv_applied = MALI_FALSE; #endif static int stay_count = 0; // to prevent frequent switch MALI_DEBUG_PRINT(1, ("> mali_dvfs_status: %d \n",utilization)); #ifdef EXYNOS4_ASV_ENABLED if (asv_applied == MALI_FALSE) { mali_dvfs_table_update(); change_mali_dvfs_status(0,0); asv_applied = MALI_TRUE; return MALI_TRUE; } #endif /*decide next step*/ curStatus = get_mali_dvfs_status(); nextStatus = decideNextStatus(utilization); MALI_DEBUG_PRINT(1, ("= curStatus %d, nextStatus %d, maliDvfsStatus.currentStep %d \n", curStatus, nextStatus, maliDvfsStatus.currentStep)); /*if next status is same with current status, don't change anything*/ if ((curStatus!=nextStatus && stay_count==0)) { /*check if boost up or not*/ if (nextStatus > maliDvfsStatus.currentStep) boostup = 1; /*change mali dvfs status*/ if (!change_mali_dvfs_status(nextStatus,boostup)) { MALI_DEBUG_PRINT(1, ("error on change_mali_dvfs_status \n")); return MALI_FALSE; } stay_count = mali_dvfs_staycount[maliDvfsStatus.currentStep].staycount; } else { if (stay_count>0) stay_count--; } return MALI_TRUE; } int mali_dvfs_is_running(void) { return bMaliDvfsRun; } void mali_dvfs_late_resume(void) { // set the init clock as low when resume set_mali_dvfs_status(0,0); } static void mali_dvfs_work_handler(struct work_struct *w) { bMaliDvfsRun=1; MALI_DEBUG_PRINT(3, ("=== mali_dvfs_work_handler\n")); if (!mali_dvfs_status(mali_dvfs_utilization)) MALI_DEBUG_PRINT(1,( "error on mali dvfs status in mali_dvfs_work_handler")); bMaliDvfsRun=0; } mali_bool init_mali_dvfs_status(int step) { /*default status add here with the right function to get initilization value. */ if (!mali_dvfs_wq) mali_dvfs_wq = create_singlethread_workqueue("mali_dvfs"); #if MALI_GPU_BOTTOM_LOCK _mali_osk_atomic_init(&bottomlock_status, 0); #endif /*add a error handling here*/ maliDvfsStatus.currentStep = step; return MALI_TRUE; } void deinit_mali_dvfs_status(void) { #if MALI_GPU_BOTTOM_LOCK _mali_osk_atomic_term(&bottomlock_status); #endif if (mali_dvfs_wq) destroy_workqueue(mali_dvfs_wq); mali_dvfs_wq = NULL; } mali_bool mali_dvfs_handler(u32 utilization) { mali_dvfs_utilization = utilization; queue_work_on(0, mali_dvfs_wq,&mali_dvfs_work); /*add error handle here*/ return MALI_TRUE; } void mali_default_step_set(int step, mali_bool boostup) { mali_clk_set_rate(mali_dvfs[step].clock, mali_dvfs[step].freq); if (maliDvfsStatus.currentStep == 1) set_mali_dvfs_status(step, boostup); } #if MALI_GPU_BOTTOM_LOCK int mali_dvfs_bottom_lock_push(void) { int prev_status = _mali_osk_atomic_read(&bottomlock_status); if (prev_status < 0) { MALI_PRINT(("gpu bottom lock status is not valid for push")); return -1; } if (prev_status == 0) { mali_regulator_set_voltage(mali_dvfs[1].vol, mali_dvfs[1].vol); mali_clk_set_rate(mali_dvfs[1].clock, mali_dvfs[1].freq); set_mali_dvfs_current_step(1); } return _mali_osk_atomic_inc_return(&bottomlock_status); } int mali_dvfs_bottom_lock_pop(void) { if (_mali_osk_atomic_read(&bottomlock_status) <= 0) { MALI_PRINT(("gpu bottom lock status is not valid for pop")); return -1; } return _mali_osk_atomic_dec_return(&bottomlock_status); } #endif \ No newline at end of file +/* * 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_platform_dvfs.c * Platform specific Mali driver dvfs functions */ #include "mali_kernel_common.h" #include "mali_osk.h" #include "mali_platform.h" #include #include #include #include #include #ifdef CONFIG_CPU_FREQ #include #include #define EXYNOS4_ASV_ENABLED #endif #include "mali_device_pause_resume.h" #include #define MALI_DVFS_WATING 10 // msec static int bMaliDvfsRun=0; #if MALI_GPU_BOTTOM_LOCK static _mali_osk_atomic_t bottomlock_status; #endif typedef struct mali_dvfs_tableTag{ unsigned int clock; unsigned int freq; unsigned int vol; }mali_dvfs_table; typedef struct mali_dvfs_statusTag{ unsigned int currentStep; mali_dvfs_table * pCurrentDvfs; }mali_dvfs_currentstatus; typedef struct mali_dvfs_thresholdTag{ unsigned int downthreshold; unsigned int upthreshold; }mali_dvfs_threshold_table; typedef struct mali_dvfs_staycount{ unsigned int staycount; }mali_dvfs_staycount_table; mali_dvfs_staycount_table mali_dvfs_staycount[MALI_DVFS_STEPS]={ /*step 0*/{1}, /*step 1*/{1},}; /*dvfs threshold*/ mali_dvfs_threshold_table mali_dvfs_threshold[MALI_DVFS_STEPS]={ /*step 0*/{((int)((255*0)/100)), ((int)((255*85)/100))}, /*step 1*/{((int)((255*75)/100)), ((int)((255*100)/100))} }; /*dvfs status*/ mali_dvfs_currentstatus maliDvfsStatus; int mali_dvfs_control=0; /*dvfs table*/ mali_dvfs_table mali_dvfs[MALI_DVFS_STEPS]={ /*step 0*/{160 ,1000000 , 950000}, /*step 1*/{267 ,1000000 ,1000000} }; #ifdef EXYNOS4_ASV_ENABLED #define ASV_8_LEVEL 8 #define ASV_5_LEVEL 5 #define ASV_LEVEL_SUPPORT 0 static unsigned int asv_3d_volt_5_table[ASV_5_LEVEL][MALI_DVFS_STEPS] = { /* L3(160MHz), L2(266MHz) */ {1000000, 1100000}, /* S */ {1000000, 1100000}, /* A */ { 950000, 1000000}, /* B */ { 950000, 1000000}, /* C */ { 950000, 950000}, /* D */ }; static unsigned int asv_3d_volt_8_table[ASV_8_LEVEL][MALI_DVFS_STEPS] = { /* L3(160MHz), L2(266MHz)) */ {1000000, 1100000}, /* SS */ {1000000, 1100000}, /* A1 */ {1000000, 1100000}, /* A2 */ { 950000, 1000000}, /* B1 */ { 950000, 1000000}, /* B2 */ { 950000, 1000000}, /* C1 */ { 950000, 1000000}, /* C2 */ { 950000, 950000}, /* D1 */ }; #endif static u32 mali_dvfs_utilization = 255; static void mali_dvfs_work_handler(struct work_struct *w); static struct workqueue_struct *mali_dvfs_wq = 0; extern mali_io_address clk_register_map; #if MALI_GPU_BOTTOM_LOCK extern _mali_osk_lock_t *mali_dvfs_lock; #endif static DECLARE_WORK(mali_dvfs_work, mali_dvfs_work_handler); static unsigned int get_mali_dvfs_status(void) { return maliDvfsStatus.currentStep; } #if MALI_GPU_BOTTOM_LOCK #if MALI_PMM_RUNTIME_JOB_CONTROL_ON int get_mali_dvfs_control_status(void) { return mali_dvfs_control; } mali_bool set_mali_dvfs_current_step(unsigned int step) { _mali_osk_lock_wait(mali_dvfs_lock, _MALI_OSK_LOCKMODE_RW); maliDvfsStatus.currentStep = step; _mali_osk_lock_signal(mali_dvfs_lock, _MALI_OSK_LOCKMODE_RW); return MALI_TRUE; } #endif #endif static mali_bool set_mali_dvfs_status(u32 step,mali_bool boostup) { u32 validatedStep=step; #ifdef CONFIG_REGULATOR if (mali_regulator_get_usecount()==0) { MALI_DEBUG_PRINT(1, ("regulator use_count is 0 \n")); return MALI_FALSE; } #endif if (boostup) { #ifdef CONFIG_REGULATOR /*change the voltage*/ mali_regulator_set_voltage(mali_dvfs[step].vol, mali_dvfs[step].vol); #endif /*change the clock*/ mali_clk_set_rate(mali_dvfs[step].clock, mali_dvfs[step].freq); } else { /*change the clock*/ mali_clk_set_rate(mali_dvfs[step].clock, mali_dvfs[step].freq); #ifdef CONFIG_REGULATOR /*change the voltage*/ mali_regulator_set_voltage(mali_dvfs[step].vol, mali_dvfs[step].vol); #endif } maliDvfsStatus.currentStep = validatedStep; /*for future use*/ maliDvfsStatus.pCurrentDvfs = &mali_dvfs[validatedStep]; return MALI_TRUE; } static void mali_platform_wating(u32 msec) { /*sample wating change this in the future with proper check routine. */ unsigned int read_val; while(1) { read_val = _mali_osk_mem_ioread32(clk_register_map, 0x00); if ((read_val & 0x8000)==0x0000) break; _mali_osk_time_ubusydelay(100); // 1000 -> 100 : 20101218 } /* _mali_osk_time_ubusydelay(msec*1000);*/ } static mali_bool change_mali_dvfs_status(u32 step, mali_bool boostup ) { MALI_DEBUG_PRINT(1, ("> change_mali_dvfs_status: %d, %d \n",step, boostup)); if (!set_mali_dvfs_status(step, boostup)) { MALI_DEBUG_PRINT(1, ("error on set_mali_dvfs_status: %d, %d \n",step, boostup)); return MALI_FALSE; } /*wait until clock and voltage is stablized*/ mali_platform_wating(MALI_DVFS_WATING); /*msec*/ return MALI_TRUE; } static unsigned int decideNextStatus(unsigned int utilization) { unsigned int level=0; // 0:stay, 1:up if (!mali_dvfs_control) { #if MALI_GPU_BOTTOM_LOCK if (_mali_osk_atomic_read(&bottomlock_status) > 0) level = 1; /* or bigger */ else if (utilization > mali_dvfs_threshold[maliDvfsStatus.currentStep].upthreshold) #else if (utilization > mali_dvfs_threshold[maliDvfsStatus.currentStep].upthreshold) #endif level=1; else if (utilization < mali_dvfs_threshold[maliDvfsStatus.currentStep].downthreshold) level=0; else level = maliDvfsStatus.currentStep; } else { if ((mali_dvfs_control > 0) && (mali_dvfs_control < mali_dvfs[1].clock)) level=0; else level=1; } return level; } #ifdef EXYNOS4_ASV_ENABLED static mali_bool mali_dvfs_table_update(void) { unsigned int exynos_result_of_asv_group; unsigned int i; exynos_result_of_asv_group = exynos_result_of_asv & 0xf; MALI_PRINT(("exynos_result_of_asv_group = 0x%x\n", exynos_result_of_asv_group)); if (ASV_LEVEL_SUPPORT) { //asv level information will be added. for (i = 0; i < MALI_DVFS_STEPS; i++) { mali_dvfs[i].vol = asv_3d_volt_5_table[exynos_result_of_asv_group][i]; MALI_PRINT(("mali_dvfs[%d].vol = %d\n", i, mali_dvfs[i].vol)); } } else { for (i = 0; i < MALI_DVFS_STEPS; i++) { mali_dvfs[i].vol = asv_3d_volt_8_table[exynos_result_of_asv_group][i]; MALI_PRINT(("mali_dvfs[%d].vol = %d\n", i, mali_dvfs[i].vol)); } } return MALI_TRUE; } #endif static mali_bool mali_dvfs_status(u32 utilization) { unsigned int nextStatus = 0; unsigned int curStatus = 0; mali_bool boostup = MALI_FALSE; #ifdef EXYNOS4_ASV_ENABLED static mali_bool asv_applied = MALI_FALSE; #endif static int stay_count = 0; // to prevent frequent switch MALI_DEBUG_PRINT(1, ("> mali_dvfs_status: %d \n",utilization)); #ifdef EXYNOS4_ASV_ENABLED if (asv_applied == MALI_FALSE) { mali_dvfs_table_update(); change_mali_dvfs_status(0,0); asv_applied = MALI_TRUE; return MALI_TRUE; } #endif /*decide next step*/ curStatus = get_mali_dvfs_status(); nextStatus = decideNextStatus(utilization); MALI_DEBUG_PRINT(1, ("= curStatus %d, nextStatus %d, maliDvfsStatus.currentStep %d \n", curStatus, nextStatus, maliDvfsStatus.currentStep)); /*if next status is same with current status, don't change anything*/ if ((curStatus!=nextStatus && stay_count==0)) { /*check if boost up or not*/ if (nextStatus > maliDvfsStatus.currentStep) boostup = 1; /*change mali dvfs status*/ if (!change_mali_dvfs_status(nextStatus,boostup)) { MALI_DEBUG_PRINT(1, ("error on change_mali_dvfs_status \n")); return MALI_FALSE; } stay_count = mali_dvfs_staycount[maliDvfsStatus.currentStep].staycount; } else { if (stay_count>0) stay_count--; } return MALI_TRUE; } int mali_dvfs_is_running(void) { return bMaliDvfsRun; } void mali_dvfs_late_resume(void) { // set the init clock as low when resume set_mali_dvfs_status(0,0); } static void mali_dvfs_work_handler(struct work_struct *w) { bMaliDvfsRun=1; MALI_DEBUG_PRINT(3, ("=== mali_dvfs_work_handler\n")); if (!mali_dvfs_status(mali_dvfs_utilization)) MALI_DEBUG_PRINT(1,( "error on mali dvfs status in mali_dvfs_work_handler")); bMaliDvfsRun=0; } mali_bool init_mali_dvfs_status(int step) { /*default status add here with the right function to get initilization value. */ if (!mali_dvfs_wq) mali_dvfs_wq = create_singlethread_workqueue("mali_dvfs"); #if MALI_GPU_BOTTOM_LOCK _mali_osk_atomic_init(&bottomlock_status, 0); #endif /*add a error handling here*/ maliDvfsStatus.currentStep = step; return MALI_TRUE; } void deinit_mali_dvfs_status(void) { #if MALI_GPU_BOTTOM_LOCK _mali_osk_atomic_term(&bottomlock_status); #endif if (mali_dvfs_wq) destroy_workqueue(mali_dvfs_wq); mali_dvfs_wq = NULL; } mali_bool mali_dvfs_handler(u32 utilization) { mali_dvfs_utilization = utilization; queue_work_on(0, mali_dvfs_wq,&mali_dvfs_work); /*add error handle here*/ return MALI_TRUE; } void mali_default_step_set(int step, mali_bool boostup) { mali_clk_set_rate(mali_dvfs[step].clock, mali_dvfs[step].freq); if (maliDvfsStatus.currentStep == 1) set_mali_dvfs_status(step, boostup); } #if MALI_GPU_BOTTOM_LOCK int mali_dvfs_bottom_lock_push(void) { int prev_status = _mali_osk_atomic_read(&bottomlock_status); if (prev_status < 0) { MALI_PRINT(("gpu bottom lock status is not valid for push")); return -1; } if (prev_status == 0) { mali_regulator_set_voltage(mali_dvfs[1].vol, mali_dvfs[1].vol); mali_clk_set_rate(mali_dvfs[1].clock, mali_dvfs[1].freq); set_mali_dvfs_current_step(1); } return _mali_osk_atomic_inc_return(&bottomlock_status); } int mali_dvfs_bottom_lock_pop(void) { if (_mali_osk_atomic_read(&bottomlock_status) <= 0) { MALI_PRINT(("gpu bottom lock status is not valid for pop")); return -1; } return _mali_osk_atomic_dec_return(&bottomlock_status); } #endif \ No newline at end of file diff --git a/drivers/media/video/samsung/mali/platform/pegasus-m400/mali_platform.c b/drivers/media/video/samsung/mali/platform/pegasus-m400/mali_platform.c index e8e5129..8fc26cd 100644 --- a/drivers/media/video/samsung/mali/platform/pegasus-m400/mali_platform.c +++ b/drivers/media/video/samsung/mali/platform/pegasus-m400/mali_platform.c @@ -526,6 +526,7 @@ static _mali_osk_errcode_t enable_mali_clocks(void) err = clk_enable(mali_clock); MALI_DEBUG_PRINT(3,("enable_mali_clocks mali_clock %p error %d \n", mali_clock, err)); + mali_runtime_resume.vol = mali_dvfs_get_vol(MALI_DVFS_DEFAULT_STEP); #if MALI_PMM_RUNTIME_JOB_CONTROL_ON #if MALI_DVFS_ENABLED // set clock rate diff --git a/drivers/media/video/samsung/mali/platform/pegasus-m400/mali_platform_dvfs.c b/drivers/media/video/samsung/mali/platform/pegasus-m400/mali_platform_dvfs.c index b38fc9b..e83addd 100644 --- a/drivers/media/video/samsung/mali/platform/pegasus-m400/mali_platform_dvfs.c +++ b/drivers/media/video/samsung/mali/platform/pegasus-m400/mali_platform_dvfs.c @@ -304,10 +304,7 @@ mali_bool set_mali_dvfs_current_step(unsigned int step) static mali_bool set_mali_dvfs_status(u32 step,mali_bool boostup) { u32 validatedStep=step; -#if CPUFREQ_LOCK_DURING_440 int err; -#endif - #ifdef CONFIG_REGULATOR if (mali_regulator_get_usecount() == 0) { @@ -333,12 +330,10 @@ static mali_bool set_mali_dvfs_status(u32 step,mali_bool boostup) } #ifdef EXYNOS4_ASV_ENABLED - if (samsung_rev() < EXYNOS4412_REV_2_0) { - if (mali_dvfs[step].clock == 160) - exynos4x12_set_abb_member(ABB_G3D, ABB_MODE_100V); - else - exynos4x12_set_abb_member(ABB_G3D, ABB_MODE_130V); - } + if (mali_dvfs[step].clock == 160) + exynos4x12_set_abb_member(ABB_G3D, ABB_MODE_100V); + else + exynos4x12_set_abb_member(ABB_G3D, ABB_MODE_130V); #endif @@ -743,9 +738,7 @@ mali_bool mali_dvfs_handler(u32 utilization) int change_dvfs_tableset(int change_clk, int change_step) { -#if CPUFREQ_LOCK_DURING_440 int err; -#endif if (change_clk < mali_dvfs_all[1].clock) { mali_dvfs[change_step].clock = mali_dvfs_all[0].clock; @@ -822,6 +815,14 @@ int mali_dvfs_bottom_lock_pop(void) return _mali_osk_atomic_dec_return(&bottomlock_status); } +int mali_dvfs_get_vol(int step) +{ + step = step % MAX_MALI_DVFS_STEPS; + MALI_DEBUG_ASSERT(step USING_UMP= BUILD= \ -TARGET_PLATFORM= CONFIG= make - -where - kdir_path: Path to your Linux Kernel directory - ump_option: 1 = Enable UMP support(*) - 0 = disable UMP support - build_option: debug = debug build of driver - release = release build of driver - target_platform: Name of the sub-folder in platform/ that contains the - required mali_platform.c file. - your_config: Name of the sub-folder to find the required config.h(**) file - ("arch-" will be prepended) - -(*) For newer Linux Kernels, the Module.symvers file for the UMP device driver - must be available. The UMP_SYMVERS_FILE variable in the Makefile should - point to this file. This file is generated when the UMP driver is built. - -(**) The config.h file contains the configuration parameters needed, like where the - Mali GPU is located, interrupts it uses, memory and so on. - -The result will be a mali.ko file, which can be loaded into the Linux kernel -by using the insmod command. diff --git a/drivers/media/video/samsung/mali/regs/mali_gp_regs.h b/drivers/media/video/samsung/mali/regs/mali_gp_regs.h index 21c83c0..dd259cf 100644 --- a/drivers/media/video/samsung/mali/regs/mali_gp_regs.h +++ b/drivers/media/video/samsung/mali/regs/mali_gp_regs.h @@ -145,7 +145,6 @@ typedef enum MALIGP2_REG_VAL_IRQ_VS_END_CMD_LST | \ MALIGP2_REG_VAL_IRQ_PLBU_END_CMD_LST | \ MALIGP2_REG_VAL_IRQ_PLBU_OUT_OF_MEM | \ - MALIGP2_REG_VAL_IRQ_HANG | \ MALIGP2_REG_VAL_IRQ_FORCE_HANG | \ MALIGP2_REG_VAL_IRQ_WRITE_BOUND_ERR | \ MALIGP2_REG_VAL_IRQ_SYNC_ERROR | \ @@ -156,7 +155,6 @@ typedef enum MALIGP2_REG_VAL_IRQ_VS_END_CMD_LST | \ MALIGP2_REG_VAL_IRQ_PLBU_END_CMD_LST | \ MALIGP2_REG_VAL_IRQ_PLBU_OUT_OF_MEM | \ - MALIGP2_REG_VAL_IRQ_HANG | \ MALIGP2_REG_VAL_IRQ_FORCE_HANG | \ MALIGP2_REG_VAL_IRQ_WRITE_BOUND_ERR | \ MALIGP2_REG_VAL_IRQ_SYNC_ERROR | \ diff --git a/drivers/media/video/samsung/mali/timestamp-arm11-cc/mali_timestamp.c b/drivers/media/video/samsung/mali/timestamp-arm11-cc/mali_timestamp.c old mode 100755 new mode 100644 index a6b1d76..2426853 --- a/drivers/media/video/samsung/mali/timestamp-arm11-cc/mali_timestamp.c +++ b/drivers/media/video/samsung/mali/timestamp-arm11-cc/mali_timestamp.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 ARM Limited. All rights reserved. + * 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. diff --git a/drivers/media/video/samsung/mali/timestamp-arm11-cc/mali_timestamp.h b/drivers/media/video/samsung/mali/timestamp-arm11-cc/mali_timestamp.h old mode 100755 new mode 100644 index 3279dae..0551726 --- a/drivers/media/video/samsung/mali/timestamp-arm11-cc/mali_timestamp.h +++ b/drivers/media/video/samsung/mali/timestamp-arm11-cc/mali_timestamp.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 ARM Limited. All rights reserved. + * 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. diff --git a/drivers/media/video/samsung/mali/timestamp-default/mali_timestamp.c b/drivers/media/video/samsung/mali/timestamp-default/mali_timestamp.c old mode 100755 new mode 100644 index a6b1d76..2426853 --- a/drivers/media/video/samsung/mali/timestamp-default/mali_timestamp.c +++ b/drivers/media/video/samsung/mali/timestamp-default/mali_timestamp.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 ARM Limited. All rights reserved. + * 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. diff --git a/drivers/media/video/samsung/mali/timestamp-default/mali_timestamp.h b/drivers/media/video/samsung/mali/timestamp-default/mali_timestamp.h old mode 100755 new mode 100644 index 94b842a..e6d3f2a --- a/drivers/media/video/samsung/mali/timestamp-default/mali_timestamp.h +++ b/drivers/media/video/samsung/mali/timestamp-default/mali_timestamp.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 ARM Limited. All rights reserved. + * 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. diff --git a/drivers/media/video/samsung/ump/Kconfig b/drivers/media/video/samsung/ump/Kconfig index 9d8e5e6..aaae26e 100644 --- a/drivers/media/video/samsung/ump/Kconfig +++ b/drivers/media/video/samsung/ump/Kconfig @@ -17,18 +17,10 @@ config UMP_VCM_ALLOC help Use VCM(virtual-contiguous-memory) to allocate physical memory. - -config UMP_R3P1_LSI - bool "Uses the R3P1 as a ump module" - depends on VIDEO_UMP - default n - ---help--- - This uses the r3p1 as a UMP kernel module - choice depends on VIDEO_UMP prompt "UMP MEMEMORY OPTION" -default UMP_OSMEM_ONLY +default UMP_OSMEM_ONLY config UMP_DED_ONLY bool "ump dedicated memory only" ---help--- @@ -45,7 +37,7 @@ config UMP_VCM_ONLY endchoice config UMP_MEM_SIZE int "UMP Memory Size" - depends on VIDEO_UMP + depends on VIDEO_UMP default "512" ---help--- This value is dedicated memory size of UMP (unit is MByte). @@ -56,3 +48,4 @@ config VIDEO_UMP_DEBUG default n help This enables UMP driver debug messages. + diff --git a/drivers/media/video/samsung/ump/Kconfig_module b/drivers/media/video/samsung/ump/Kconfig_module new file mode 100644 index 0000000..3ae316c --- /dev/null +++ b/drivers/media/video/samsung/ump/Kconfig_module @@ -0,0 +1,16 @@ +config UMP + tristate "UMP support" + depends on ARM + ---help--- + This enables support for the UMP memory allocation and sharing API. + + To compile this driver as a module, choose M here: the module will be + called ump. + +config UMP_DEBUG + bool "Enable extra debug in UMP" + depends on UMP + default y + ---help--- + This enabled extra debug checks and messages in UMP. + diff --git a/drivers/media/video/samsung/ump/Makefile b/drivers/media/video/samsung/ump/Makefile index 1ac28d7..0ba1253 100644 --- a/drivers/media/video/samsung/ump/Makefile +++ b/drivers/media/video/samsung/ump/Makefile @@ -1,9 +1,9 @@ # -# Copyright (C) 2010 ARM Limited. All rights reserved. -# +# 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. # @@ -18,12 +18,6 @@ UMP_MEM_SIZE= $(CONFIG_UMP_MEM_SIZE) USING_MEMORY=1 endif -ifeq ($(CONFIG_UMP_VCM_ONLY),y) -UMP_MEM_SIZE= $(CONFIG_UMP_MEM_SIZE) -USING_MEMORY=2 -endif - - # For UMP Debug ifeq ($(CONFIG_VIDEO_UMP_DEBUG),y) DEFINES += -DDEBUG @@ -36,7 +30,7 @@ DEFINES += -DUMP_MEM_SIZE=$(UMP_MEM_SIZE) DEFINES += -DMALI_STATE_TRACKING=1 UDD_FILE_PREFIX := drivers/media/video/samsung/ump/ -KBUILDROOT = +KBUILDROOT = # linux build system integration @@ -60,7 +54,7 @@ OSKFILES+=\ $(KBUILDROOT)../mali/linux/mali_osk_locks.o \ $(KBUILDROOT)../mali/linux/mali_osk_math.o \ $(KBUILDROOT)../mali/linux/mali_osk_memory.o \ - $(KBUILDROOT)../mali/linux/mali_osk_misc.o + $(KBUILDROOT)../mali/linux/mali_osk_misc.o ump-y := \ $(KBUILDROOT)linux/ump_kernel_linux.o \ @@ -78,15 +72,13 @@ ump-y := \ $(KBUILDROOT)common/ump_kernel_ref_drv.o\ $(OSKFILES) -ump-$(CONFIG_UMP_VCM_ALLOC) += \ - $(KBUILDROOT)linux/ump_kernel_memory_backend_vcm.o \ - EXTRA_CFLAGS += $(INCLUDES) \ - $(DEFINES) - - + $(DEFINES) + + # Get subversion revision number, fall back to 0000 if no svn info is available SVN_REV:=$(shell ((svnversion | grep -E "^[0-9]+" && echo -n 'Revision: ' && svnversion) || git svn info | sed -e 's/$$$$/M/' | grep '^Revision: ' || echo ${MALI_RELEASE_NAME}) 2>/dev/null | sed -e 's/^Revision: //') - + EXTRA_CFLAGS += -DSVN_REV=$(SVN_REV) EXTRA_CFLAGS += -DSVN_REV_STRING=\"$(SVN_REV)\" + diff --git a/drivers/media/video/samsung/ump/Makefile.common b/drivers/media/video/samsung/ump/Makefile.common old mode 100755 new mode 100644 index 35527a2..503a38d --- a/drivers/media/video/samsung/ump/Makefile.common +++ b/drivers/media/video/samsung/ump/Makefile.common @@ -1,9 +1,9 @@ # # 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. # @@ -14,7 +14,7 @@ SRC = $(UMP_FILE_PREFIX)common/ump_kernel_common.c \ $(UMP_FILE_PREFIX)common/ump_kernel_ref_drv.c # Get subversion revision number, fall back to 0000 if no svn info is available -SVN_REV:=$(shell ((svnversion | grep -qv exported && echo -n 'Revision: ' && svnversion) || git svn info | sed -e 's/$$$$/M/' | grep '^Revision: ' || echo ${MALI_RELEASE_NAME}) 2>/dev/null | sed -e 's/^Revision: //') +SVN_REV:=$(shell ((svnversion | grep -E "^[0-9]+" && echo -n 'Revision: ' && svnversion) || git svn info | sed -e 's/$$$$/M/' | grep '^Revision: ' || echo ${MALI_RELEASE_NAME}) 2>/dev/null | sed -e 's/^Revision: //') EXTRA_CFLAGS += -DSVN_REV=$(SVN_REV) EXTRA_CFLAGS += -DSVN_REV_STRING=\"$(SVN_REV)\" diff --git a/drivers/media/video/samsung/ump/Makefile_module b/drivers/media/video/samsung/ump/Makefile_module deleted file mode 100755 index f0c3829..0000000 --- a/drivers/media/video/samsung/ump/Makefile_module +++ /dev/null @@ -1,119 +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. -# - -UMP_FILE_PREFIX = -UDD_FILE_PREFIX = ../mali/ - -ifneq ($(KBUILD_EXTMOD),) -include $(KBUILD_EXTMOD)/Makefile.common -else -include ./Makefile.common -endif - -# For each arch check: CROSS_COMPILE , KDIR , CFLAGS += -DARCH - -ARCH ?= arm -BUILD ?= debug - -EXTRA_CFLAGS += -DDEBUG -DMALI_STATE_TRACKING=0 -ifeq ($(BUILD), debug) -EXTRA_CFLAGS += -DDEBUG -endif - -# linux build system integration - -ifneq ($(KERNELRELEASE),) -# Inside the kernel build system - -EXTRA_CFLAGS += -I$(KBUILD_EXTMOD) -I$(KBUILD_EXTMOD)/common -I$(KBUILD_EXTMOD)/linux -I$(KBUILD_EXTMOD)/../mali/common -I$(KBUILD_EXTMOD)/../mali/linux -I$(KBUILD_EXTMOD)/../../ump/include/ump - -# For customer releases the Linux Device Drivers will be provided as ARM proprietary and GPL releases: -# The ARM proprietary product will only include the license/proprietary directory -# The GPL product will only include the license/gpl directory - -ifeq ($(wildcard $(KBUILD_EXTMOD)/linux/license/gpl/*),) -EXTRA_CFLAGS += -I$(KBUILD_EXTMOD)/linux/license/proprietary -else -EXTRA_CFLAGS += -I$(KBUILD_EXTMOD)/linux/license/gpl -endif - -SRC += $(UMP_FILE_PREFIX)linux/ump_kernel_linux.c \ - $(UMP_FILE_PREFIX)linux/ump_kernel_memory_backend_os.c \ - $(UMP_FILE_PREFIX)linux/ump_kernel_memory_backend_dedicated.c \ - $(UMP_FILE_PREFIX)linux/ump_memory_backend.c \ - $(UMP_FILE_PREFIX)linux/ump_ukk_wrappers.c \ - $(UMP_FILE_PREFIX)linux/ump_ukk_ref_wrappers.c \ - $(UMP_FILE_PREFIX)linux/ump_osk_atomics.c \ - $(UMP_FILE_PREFIX)linux/ump_osk_low_level_mem.c \ - $(UMP_FILE_PREFIX)linux/ump_osk_misc.c \ - $(UDD_FILE_PREFIX)linux/mali_osk_atomics.c \ - $(UDD_FILE_PREFIX)linux/mali_osk_locks.c \ - $(UDD_FILE_PREFIX)linux/mali_osk_memory.c \ - $(UDD_FILE_PREFIX)linux/mali_osk_math.c \ - $(UDD_FILE_PREFIX)linux/mali_osk_misc.c - -# Selecting files to compile by parsing the config file - -MODULE:=ump.ko - -obj-m := $(MODULE:.ko=.o) -$(MODULE:.ko=-y) := $(SRC:.c=.o) - -else -# Outside the kernel build system - -# Check that required parameters are supplied. -ifeq ($(CONFIG),) -$(error "CONFIG must be specified.") -endif -ifeq ($(CPU)$(KDIR),) -$(error "KDIR or CPU must be specified.") -endif - -# Get any user defined KDIR- or maybe even a hardcoded KDIR --include KDIR_CONFIGURATION - -# Define host system directory -KDIR-$(shell uname -m):=/lib/modules/$(shell uname -r)/build - -ifeq ($(ARCH), arm) - # when compiling for ARM we're cross compiling - export CROSS_COMPILE ?= arm-none-linux-gnueabi- -endif - -# look up KDIR based om CPU selection -KDIR ?= $(KDIR-$(CPU)) - -ifeq ($(KDIR),) -$(error No KDIR found for platform $(CPU)) -endif - -# Validate selected config -ifneq ($(shell [ -d arch-$(CONFIG) ] && [ -f arch-$(CONFIG)/config.h ] && echo "OK"), OK) -$(warning Current directory is $(shell pwd)) -$(error No configuration found for config $(CONFIG). Check that arch-$(CONFIG)/config.h exists) -else -# Link arch to the selected arch-config directory -$(shell [ -L arch ] && rm arch) -$(shell ln -sf arch-$(CONFIG) arch) -$(shell touch arch/config.h) -endif - -all: - $(MAKE) ARCH=$(ARCH) -C $(KDIR) M=$(CURDIR) modules - -kernelrelease: - $(MAKE) ARCH=$(ARCH) -C $(KDIR) kernelrelease - -clean: - $(MAKE) ARCH=$(ARCH) -C $(KDIR) M=$(CURDIR) clean - $(MAKE) ARCH=$(ARCH) -C $(KDIR) M=$(CURDIR)/../mali clean - -endif diff --git a/drivers/media/video/samsung/ump/arch-orion-m400/config.h b/drivers/media/video/samsung/ump/arch-orion-m400/config.h index 688edc9..7afbca6 100644 --- a/drivers/media/video/samsung/ump/arch-orion-m400/config.h +++ b/drivers/media/video/samsung/ump/arch-orion-m400/config.h @@ -1,9 +1,9 @@ /* * 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. */ @@ -11,12 +11,12 @@ #ifndef __ARCH_CONFIG_UMP_H__ #define __ARCH_CONFIG_UMP_H__ -#define ARCH_UMP_BACKEND_DEFAULT USING_MEMORY +#define ARCH_UMP_BACKEND_DEFAULT USING_MEMORY #if (USING_MEMORY == 0) /* Dedicated Memory */ -#define ARCH_UMP_MEMORY_ADDRESS_DEFAULT 0x2C000000 +#define ARCH_UMP_MEMORY_ADDRESS_DEFAULT 0x2C000000 #else -#define ARCH_UMP_MEMORY_ADDRESS_DEFAULT 0 +#define ARCH_UMP_MEMORY_ADDRESS_DEFAULT 0 #endif -#define ARCH_UMP_MEMORY_SIZE_DEFAULT UMP_MEM_SIZE*1024*1024 +#define ARCH_UMP_MEMORY_SIZE_DEFAULT UMP_MEM_SIZE*1024*1024 #endif /* __ARCH_CONFIG_UMP_H__ */ diff --git a/drivers/media/video/samsung/ump/arch-pb-virtex5/config.h b/drivers/media/video/samsung/ump/arch-pb-virtex5/config.h old mode 100755 new mode 100644 index 38ae1ee..532fc94 --- a/drivers/media/video/samsung/ump/arch-pb-virtex5/config.h +++ b/drivers/media/video/samsung/ump/arch-pb-virtex5/config.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 ARM Limited. All rights reserved. + * 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. diff --git a/drivers/media/video/samsung/ump/arch-pegasus-m400/config.h b/drivers/media/video/samsung/ump/arch-pegasus-m400/config.h old mode 100755 new mode 100644 index 688edc9..7afbca6 --- a/drivers/media/video/samsung/ump/arch-pegasus-m400/config.h +++ b/drivers/media/video/samsung/ump/arch-pegasus-m400/config.h @@ -1,9 +1,9 @@ /* * 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. */ @@ -11,12 +11,12 @@ #ifndef __ARCH_CONFIG_UMP_H__ #define __ARCH_CONFIG_UMP_H__ -#define ARCH_UMP_BACKEND_DEFAULT USING_MEMORY +#define ARCH_UMP_BACKEND_DEFAULT USING_MEMORY #if (USING_MEMORY == 0) /* Dedicated Memory */ -#define ARCH_UMP_MEMORY_ADDRESS_DEFAULT 0x2C000000 +#define ARCH_UMP_MEMORY_ADDRESS_DEFAULT 0x2C000000 #else -#define ARCH_UMP_MEMORY_ADDRESS_DEFAULT 0 +#define ARCH_UMP_MEMORY_ADDRESS_DEFAULT 0 #endif -#define ARCH_UMP_MEMORY_SIZE_DEFAULT UMP_MEM_SIZE*1024*1024 +#define ARCH_UMP_MEMORY_SIZE_DEFAULT UMP_MEM_SIZE*1024*1024 #endif /* __ARCH_CONFIG_UMP_H__ */ diff --git a/drivers/media/video/samsung/ump/common/ump_kernel_api.c b/drivers/media/video/samsung/ump/common/ump_kernel_api.c index 83f0d30..6569b02 100644 --- a/drivers/media/video/samsung/ump/common/ump_kernel_api.c +++ b/drivers/media/video/samsung/ump/common/ump_kernel_api.c @@ -1,9 +1,9 @@ /* * 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. */ @@ -55,24 +55,7 @@ UMP_KERNEL_API_EXPORT ump_dd_handle ump_dd_handle_create_from_secure_id(ump_secu return (ump_dd_handle)mem; } -UMP_KERNEL_API_EXPORT ump_dd_handle ump_dd_handle_get(ump_secure_id secure_id) -{ - ump_dd_mem * mem; - - _mali_osk_lock_wait(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW); - - DBG_MSG(5, ("Getting handle from secure ID. ID: %u\n", secure_id)); - if (0 != ump_descriptor_mapping_get(device.secure_id_map, (int)secure_id, (void**)&mem)) - { - _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW); - DBG_MSG(1, ("Secure ID not found. ID: %u\n", secure_id)); - return UMP_DD_HANDLE_INVALID; - } - _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW); - - return (ump_dd_handle)mem; -} UMP_KERNEL_API_EXPORT unsigned long ump_dd_phys_block_count_get(ump_dd_handle memh) { @@ -277,7 +260,7 @@ _mali_osk_errcode_t _ump_ukk_release( _ump_uk_release_s *release_info ) } _mali_osk_lock_signal(session_data->lock, _MALI_OSK_LOCKMODE_RW); - DBG_MSG_IF(1, _MALI_OSK_ERR_OK != ret, ("UMP memory with ID %u does not belong to this session.\n", secure_id)); + DBG_MSG_IF(1, _MALI_OSK_ERR_OK != ret, ("UMP memory with ID %u does not belong to this session.\n", secure_id)); DBG_MSG(4, ("_ump_ukk_release() returning 0x%x\n", ret)); return ret; diff --git a/drivers/media/video/samsung/ump/common/ump_kernel_common.c b/drivers/media/video/samsung/ump/common/ump_kernel_common.c index 1fa7c8a..b1545e8 100644 --- a/drivers/media/video/samsung/ump/common/ump_kernel_common.c +++ b/drivers/media/video/samsung/ump/common/ump_kernel_common.c @@ -1,9 +1,9 @@ /* * 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. */ @@ -228,17 +228,12 @@ _mali_osk_errcode_t _ump_ukk_map_mem( _ump_uk_map_mem_s *args ) int map_id; session_data = (ump_session_data *)args->ctx; - if(NULL == session_data) + if( NULL == session_data ) { MSG_ERR(("Session data is NULL in _ump_ukk_map_mem()\n")); return _MALI_OSK_ERR_INVALID_ARGS; } - /* SEC kernel stability 2012-02-17 */ - if (NULL == session_data->cookies_map) - { - MSG_ERR(("session_data->cookies_map is NULL in _ump_ukk_map_mem()\n")); - return _MALI_OSK_ERR_INVALID_ARGS; - } + descriptor = (ump_memory_allocation*) _mali_osk_calloc( 1, sizeof(ump_memory_allocation)); if (NULL == descriptor) { @@ -288,12 +283,6 @@ _mali_osk_errcode_t _ump_ukk_map_mem( _ump_uk_map_mem_s *args ) args->is_cached = 1; DBG_MSG(3, ("Mapping UMP secure_id: %d as cached.\n", args->secure_id)); } - else if ( args->is_cached) - { - mem->is_cached = 1; - descriptor->is_cached = 1; - DBG_MSG(3, ("Warning mapping UMP secure_id: %d. As cached, while it was allocated uncached.\n", args->secure_id)); - } else { descriptor->is_cached = 0; @@ -366,17 +355,12 @@ void _ump_ukk_unmap_mem( _ump_uk_unmap_mem_s *args ) session_data = (ump_session_data *)args->ctx; - if (NULL == session_data) + if( NULL == session_data ) { MSG_ERR(("Session data is NULL in _ump_ukk_map_mem()\n")); return; } - /* SEC kernel stability 2012-02-17 */ - if (NULL == session_data->cookies_map) - { - MSG_ERR(("session_data->cookies_map is NULL in _ump_ukk_map_mem()\n")); - return; - } + if (0 != ump_descriptor_mapping_get( session_data->cookies_map, (int)args->cookie, (void**)&descriptor) ) { MSG_ERR(("_ump_ukk_map_mem: cookie 0x%X not found for this session\n", args->cookie )); diff --git a/drivers/media/video/samsung/ump/common/ump_kernel_common.h b/drivers/media/video/samsung/ump/common/ump_kernel_common.h index 03d213d..6e3a2e9 100644 --- a/drivers/media/video/samsung/ump/common/ump_kernel_common.h +++ b/drivers/media/video/samsung/ump/common/ump_kernel_common.h @@ -1,9 +1,9 @@ /* * 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. */ diff --git a/drivers/media/video/samsung/ump/common/ump_kernel_descriptor_mapping.c b/drivers/media/video/samsung/ump/common/ump_kernel_descriptor_mapping.c old mode 100755 new mode 100644 index cc7b8be..d6b59b7 --- a/drivers/media/video/samsung/ump/common/ump_kernel_descriptor_mapping.c +++ b/drivers/media/video/samsung/ump/common/ump_kernel_descriptor_mapping.c @@ -1,9 +1,9 @@ /* * 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. */ @@ -65,9 +65,9 @@ void ump_descriptor_mapping_destroy(ump_descriptor_mapping * map) int ump_descriptor_mapping_allocate_mapping(ump_descriptor_mapping * map, void * target) { - int descriptor = -1;/*-EFAULT;*/ - _mali_osk_lock_wait(map->lock, _MALI_OSK_LOCKMODE_RW); - descriptor = _mali_osk_find_first_zero_bit(map->table->usage, map->current_nr_mappings); + int descriptor = -1;/*-EFAULT;*/ + _mali_osk_lock_wait(map->lock, _MALI_OSK_LOCKMODE_RW); + descriptor = _mali_osk_find_first_zero_bit(map->table->usage, map->current_nr_mappings); if (descriptor == map->current_nr_mappings) { int nr_mappings_new; @@ -89,8 +89,8 @@ int ump_descriptor_mapping_allocate_mapping(ump_descriptor_mapping * map, void * goto unlock_and_exit; } - _mali_osk_memcpy(new_table->usage, old_table->usage, (sizeof(unsigned long)*map->current_nr_mappings) / BITS_PER_LONG); - _mali_osk_memcpy(new_table->mappings, old_table->mappings, map->current_nr_mappings * sizeof(void*)); + _mali_osk_memcpy(new_table->usage, old_table->usage, (sizeof(unsigned long)*map->current_nr_mappings) / BITS_PER_LONG); + _mali_osk_memcpy(new_table->mappings, old_table->mappings, map->current_nr_mappings * sizeof(void*)); map->table = new_table; map->current_nr_mappings = nr_mappings_new; descriptor_table_free(old_table); @@ -107,10 +107,10 @@ unlock_and_exit: int ump_descriptor_mapping_get(ump_descriptor_mapping * map, int descriptor, void** target) { - int result = -1;/*-EFAULT;*/ - DEBUG_ASSERT(map); - _mali_osk_lock_wait(map->lock, _MALI_OSK_LOCKMODE_RO); - if ( (descriptor >= 0) && (descriptor < map->current_nr_mappings) && _mali_osk_test_bit(descriptor, map->table->usage) ) + int result = -1;/*-EFAULT;*/ + DEBUG_ASSERT(map); + _mali_osk_lock_wait(map->lock, _MALI_OSK_LOCKMODE_RO); + if ( (descriptor >= 0) && (descriptor < map->current_nr_mappings) && _mali_osk_test_bit(descriptor, map->table->usage) ) { *target = map->table->mappings[descriptor]; result = 0; @@ -122,9 +122,9 @@ int ump_descriptor_mapping_get(ump_descriptor_mapping * map, int descriptor, voi int ump_descriptor_mapping_set(ump_descriptor_mapping * map, int descriptor, void * target) { - int result = -1;/*-EFAULT;*/ - _mali_osk_lock_wait(map->lock, _MALI_OSK_LOCKMODE_RO); - if ( (descriptor >= 0) && (descriptor < map->current_nr_mappings) && _mali_osk_test_bit(descriptor, map->table->usage) ) + int result = -1;/*-EFAULT;*/ + _mali_osk_lock_wait(map->lock, _MALI_OSK_LOCKMODE_RO); + if ( (descriptor >= 0) && (descriptor < map->current_nr_mappings) && _mali_osk_test_bit(descriptor, map->table->usage) ) { map->table->mappings[descriptor] = target; result = 0; @@ -135,8 +135,8 @@ int ump_descriptor_mapping_set(ump_descriptor_mapping * map, int descriptor, voi void ump_descriptor_mapping_free(ump_descriptor_mapping * map, int descriptor) { - _mali_osk_lock_wait(map->lock, _MALI_OSK_LOCKMODE_RW); - if ( (descriptor >= 0) && (descriptor < map->current_nr_mappings) && _mali_osk_test_bit(descriptor, map->table->usage) ) + _mali_osk_lock_wait(map->lock, _MALI_OSK_LOCKMODE_RW); + if ( (descriptor >= 0) && (descriptor < map->current_nr_mappings) && _mali_osk_test_bit(descriptor, map->table->usage) ) { map->table->mappings[descriptor] = NULL; _mali_osk_clear_nonatomic_bit(descriptor, map->table->usage); @@ -163,3 +163,4 @@ static void descriptor_table_free(ump_descriptor_table * table) { _mali_osk_free(table); } + diff --git a/drivers/media/video/samsung/ump/common/ump_kernel_descriptor_mapping.h b/drivers/media/video/samsung/ump/common/ump_kernel_descriptor_mapping.h old mode 100755 new mode 100644 index 881d3d8..05b3982 --- a/drivers/media/video/samsung/ump/common/ump_kernel_descriptor_mapping.h +++ b/drivers/media/video/samsung/ump/common/ump_kernel_descriptor_mapping.h @@ -1,9 +1,9 @@ /* * 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. */ diff --git a/drivers/media/video/samsung/ump/common/ump_kernel_memory_backend.h b/drivers/media/video/samsung/ump/common/ump_kernel_memory_backend.h index 73915ee..a91ae28 100644 --- a/drivers/media/video/samsung/ump/common/ump_kernel_memory_backend.h +++ b/drivers/media/video/samsung/ump/common/ump_kernel_memory_backend.h @@ -1,9 +1,9 @@ /* * 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. */ @@ -40,8 +40,6 @@ typedef struct ump_memory_backend u32 (*stat)(struct ump_memory_backend *backend); int (*pre_allocate_physical_check)(void *ctx, u32 size); u32 (*adjust_to_mali_phys)(void *ctx, u32 cpu_phys); - void *(*get)(ump_dd_mem *mem, void *args); - void (*set)(ump_dd_mem *mem, void *args); void * ctx; } ump_memory_backend; @@ -49,3 +47,4 @@ ump_memory_backend * ump_memory_backend_create ( void ); void ump_memory_backend_destroy( void ); #endif /*__UMP_KERNEL_MEMORY_BACKEND_H__ */ + diff --git a/drivers/media/video/samsung/ump/common/ump_kernel_ref_drv.c b/drivers/media/video/samsung/ump/common/ump_kernel_ref_drv.c index a5ccfeb..cd5825e 100644 --- a/drivers/media/video/samsung/ump/common/ump_kernel_ref_drv.c +++ b/drivers/media/video/samsung/ump/common/ump_kernel_ref_drv.c @@ -1,9 +1,9 @@ /* * 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. */ @@ -158,8 +158,6 @@ _mali_osk_errcode_t _ump_ukk_allocate( _ump_uk_allocate_s *user_interaction ) new_allocation->is_cached = 0; else new_allocation->is_cached = 1; - new_allocation->backend_info = (void*)user_interaction->constraints; - /* special case a size of 0, we should try to emulate what malloc does in this case, which is to return a valid pointer that must be freed, but can't be dereferences */ if (0 == user_interaction->size) { @@ -197,65 +195,3 @@ _mali_osk_errcode_t _ump_ukk_allocate( _ump_uk_allocate_s *user_interaction ) return _MALI_OSK_ERR_OK; } - - -UMP_KERNEL_API_EXPORT ump_dd_status_code ump_dd_meminfo_set(ump_dd_handle memh, void* args) -{ - ump_dd_mem * mem; - ump_secure_id secure_id; - - DEBUG_ASSERT_POINTER(memh); - - secure_id = ump_dd_secure_id_get(memh); - - _mali_osk_lock_wait(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW); - if (0 == ump_descriptor_mapping_get(device.secure_id_map, (int)secure_id, (void**)&mem)) - { - device.backend->set(mem, args); - } - else - { - _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW); - DBG_MSG(1, ("Failed to look up mapping in ump_meminfo_set(). ID: %u\n", (ump_secure_id)secure_id)); - return UMP_DD_INVALID; - } - - _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW); - - return UMP_DD_SUCCESS; -} - -UMP_KERNEL_API_EXPORT void *ump_dd_meminfo_get(ump_secure_id secure_id, void* args) -{ - ump_dd_mem * mem; - void *result; - - _mali_osk_lock_wait(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW); - if (0 == ump_descriptor_mapping_get(device.secure_id_map, (int)secure_id, (void**)&mem)) - { - result = device.backend->get(mem, args); - } - else - { - _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW); - DBG_MSG(1, ("Failed to look up mapping in ump_meminfo_get(). ID: %u\n", (ump_secure_id)secure_id)); - return UMP_DD_HANDLE_INVALID; - } - - _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW); - - return result; -} - -UMP_KERNEL_API_EXPORT ump_dd_handle ump_dd_handle_get_from_vaddr(unsigned long vaddr) -{ - ump_dd_mem * mem; - - DBG_MSG(5, ("Getting handle from Virtual address. vaddr: %u\n", vaddr)); - - _ump_osk_mem_mapregion_get(&mem, vaddr); - - DBG_MSG(1, ("Getting handle's Handle : 0x%8lx\n", mem)); - - return (ump_dd_handle)mem; -} diff --git a/drivers/media/video/samsung/ump/common/ump_kernel_types.h b/drivers/media/video/samsung/ump/common/ump_kernel_types.h index fdacd86..19a9755 100644 --- a/drivers/media/video/samsung/ump/common/ump_kernel_types.h +++ b/drivers/media/video/samsung/ump/common/ump_kernel_types.h @@ -1,9 +1,9 @@ /* * 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. */ diff --git a/drivers/media/video/samsung/ump/common/ump_osk.h b/drivers/media/video/samsung/ump/common/ump_osk.h index dabdc7f..cae0433 100644 --- a/drivers/media/video/samsung/ump/common/ump_osk.h +++ b/drivers/media/video/samsung/ump/common/ump_osk.h @@ -1,9 +1,9 @@ /* * 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. */ @@ -42,8 +42,6 @@ void _ump_osk_mem_mapregion_term( ump_memory_allocation * descriptor ); void _ump_osk_msync( ump_dd_mem * mem, void * virt, u32 offset, u32 size, ump_uk_msync_op op, ump_session_data * session_data ); -void _ump_osk_mem_mapregion_get( ump_dd_mem ** mem, unsigned long vaddr); - #ifdef __cplusplus } #endif diff --git a/drivers/media/video/samsung/ump/common/ump_ukk.h b/drivers/media/video/samsung/ump/common/ump_ukk.h index 4e6bb86..56e4be3 100644 --- a/drivers/media/video/samsung/ump/common/ump_ukk.h +++ b/drivers/media/video/samsung/ump/common/ump_ukk.h @@ -1,9 +1,9 @@ /* * 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. */ diff --git a/drivers/media/video/samsung/ump/include/ump_kernel_interface.h b/drivers/media/video/samsung/ump/include/ump_kernel_interface.h index f84d237..042c8b1 100644 --- a/drivers/media/video/samsung/ump/include/ump_kernel_interface.h +++ b/drivers/media/video/samsung/ump/include/ump_kernel_interface.h @@ -1,9 +1,9 @@ /* * 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. */ diff --git a/drivers/media/video/samsung/ump/include/ump_kernel_interface_ref_drv.h b/drivers/media/video/samsung/ump/include/ump_kernel_interface_ref_drv.h index 36c5c9d..c993746 100644 --- a/drivers/media/video/samsung/ump/include/ump_kernel_interface_ref_drv.h +++ b/drivers/media/video/samsung/ump/include/ump_kernel_interface_ref_drv.h @@ -1,9 +1,9 @@ /* * 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. */ @@ -23,10 +23,6 @@ extern "C" { /** Turn specified physical memory into UMP memory. */ UMP_KERNEL_API_EXPORT ump_dd_handle ump_dd_handle_create_from_phys_blocks(ump_dd_physical_block * blocks, unsigned long num_blocks); -UMP_KERNEL_API_EXPORT ump_dd_handle ump_dd_handle_get(ump_secure_id secure_id); -UMP_KERNEL_API_EXPORT ump_dd_status_code ump_dd_meminfo_set(ump_dd_handle memh, void* args); -UMP_KERNEL_API_EXPORT void *ump_dd_meminfo_get(ump_secure_id secure_id, void* args); -UMP_KERNEL_API_EXPORT ump_dd_handle ump_dd_handle_get_from_vaddr(unsigned long vaddr); #ifdef __cplusplus } diff --git a/drivers/media/video/samsung/ump/include/ump_kernel_interface_vcm.h b/drivers/media/video/samsung/ump/include/ump_kernel_interface_vcm.h deleted file mode 100644 index 5ff4155..0000000 --- a/drivers/media/video/samsung/ump/include/ump_kernel_interface_vcm.h +++ /dev/null @@ -1,37 +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 ump_kernel_interface_vcm.h - */ - -#ifndef __UMP_KERNEL_INTERFACE_VCM_H__ -#define __UMP_KERNEL_INTERFACE_VCM_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** Turn specified physical memory into UMP memory. */ -struct ump_vcm { - struct vcm *vcm; - struct vcm_res *vcm_res; - unsigned int dev_id; -}; - - -#ifdef __cplusplus -} -#endif - -#endif /* __UMP_KERNEL_INTERFACE_VCM_H__ */ diff --git a/drivers/media/video/samsung/ump/include/ump_kernel_platform.h b/drivers/media/video/samsung/ump/include/ump_kernel_platform.h index 339e967..4349605 100644 --- a/drivers/media/video/samsung/ump/include/ump_kernel_platform.h +++ b/drivers/media/video/samsung/ump/include/ump_kernel_platform.h @@ -1,9 +1,9 @@ /* * 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. */ diff --git a/drivers/media/video/samsung/ump/linux/license/gpl/ump_kernel_license.h b/drivers/media/video/samsung/ump/linux/license/gpl/ump_kernel_license.h old mode 100755 new mode 100644 index 50a021c..187e33b --- a/drivers/media/video/samsung/ump/linux/license/gpl/ump_kernel_license.h +++ b/drivers/media/video/samsung/ump/linux/license/gpl/ump_kernel_license.h @@ -1,9 +1,9 @@ /* - * Copyright (C) 2010-2012 ARM Limited. All rights reserved. - * + * 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. */ diff --git a/drivers/media/video/samsung/ump/linux/ump_ioctl.h b/drivers/media/video/samsung/ump/linux/ump_ioctl.h index 1d49b4d..83bb2a4 100644 --- a/drivers/media/video/samsung/ump/linux/ump_ioctl.h +++ b/drivers/media/video/samsung/ump/linux/ump_ioctl.h @@ -1,9 +1,9 @@ /* * 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. */ @@ -53,6 +53,7 @@ extern "C" #define UMP_IOC_LOCK _IOW(UMP_IOCTL_NR, _UMP_IOC_LOCK, _ump_uk_lock_s) #define UMP_IOC_UNLOCK _IOW(UMP_IOCTL_NR, _UMP_IOC_UNLOCK, _ump_uk_unlock_s) + #ifdef __cplusplus } #endif diff --git a/drivers/media/video/samsung/ump/linux/ump_kernel_linux.c b/drivers/media/video/samsung/ump/linux/ump_kernel_linux.c index 58cef54..158cc88 100644 --- a/drivers/media/video/samsung/ump/linux/ump_kernel_linux.c +++ b/drivers/media/video/samsung/ump/linux/ump_kernel_linux.c @@ -1,9 +1,9 @@ /* * 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. */ @@ -92,7 +92,7 @@ static int ump_file_ioctl(struct inode *inode, struct file *filp, unsigned int c #endif static int ump_file_mmap(struct file * filp, struct vm_area_struct * vma); -#if defined(CONFIG_VIDEO_MALI400MP) || defined(CONFIG_VIDEO_MALI400MP_R3P0) || defined(CONFIG_VIDEO_MALI400MP_R2P3) +#if defined(CONFIG_VIDEO_MALI400MP) extern int map_errcode( _mali_osk_errcode_t err ); #endif @@ -399,9 +399,8 @@ static int ump_file_ioctl(struct inode *inode, struct file *filp, unsigned int c return err; } -#ifndef CONFIG_VIDEO_MALI400MP_R2P3 + #ifndef CONFIG_VIDEO_MALI400MP -#ifndef CONFIG_VIDEO_MALI400MP_R3P0 int map_errcode( _mali_osk_errcode_t err ) { switch(err) @@ -418,8 +417,7 @@ int map_errcode( _mali_osk_errcode_t err ) } } #endif -#endif -#endif + /* * Handle from OS to map specified virtual memory to specified UMP memory. */ @@ -431,7 +429,7 @@ static int ump_file_mmap(struct file * filp, struct vm_area_struct * vma) /* Validate the session data */ session_data = (struct ump_session_data *)filp->private_data; - if (NULL == session_data || NULL == session_data->cookies_map->table->mappings) + if (NULL == session_data) { MSG_ERR(("mmap() called without any session data available\n")); return -EFAULT; @@ -476,9 +474,6 @@ EXPORT_SYMBOL(ump_dd_phys_blocks_get); EXPORT_SYMBOL(ump_dd_size_get); EXPORT_SYMBOL(ump_dd_reference_add); EXPORT_SYMBOL(ump_dd_reference_release); -EXPORT_SYMBOL(ump_dd_meminfo_get); -EXPORT_SYMBOL(ump_dd_meminfo_set); -EXPORT_SYMBOL(ump_dd_handle_get_from_vaddr); /* Export our own extended kernel space allocator */ EXPORT_SYMBOL(ump_dd_handle_create_from_phys_blocks); diff --git a/drivers/media/video/samsung/ump/linux/ump_kernel_linux.h b/drivers/media/video/samsung/ump/linux/ump_kernel_linux.h index ef68040..4985bb7 100644 --- a/drivers/media/video/samsung/ump/linux/ump_kernel_linux.h +++ b/drivers/media/video/samsung/ump/linux/ump_kernel_linux.h @@ -1,9 +1,9 @@ /* * 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. */ @@ -15,4 +15,4 @@ int ump_kernel_device_initialize(void); void ump_kernel_device_terminate(void); -#endif /* __UMP_KERNEL_LINUX_H__ */ +#endif /* __UMP_KERNEL_H__ */ diff --git a/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_dedicated.c b/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_dedicated.c index 82c16cc..463e609 100644 --- a/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_dedicated.c +++ b/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_dedicated.c @@ -1,9 +1,9 @@ /* * 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. */ @@ -108,8 +108,6 @@ ump_memory_backend * ump_block_allocator_create(u32 base_address, u32 size) backend->stat = block_allocator_stat; backend->pre_allocate_physical_check = NULL; backend->adjust_to_mali_phys = NULL; - backend->get = NULL; - backend->set = NULL; return backend; } diff --git a/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_dedicated.h b/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_dedicated.h old mode 100755 new mode 100644 index 4f7180e..ca8faae --- a/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_dedicated.h +++ b/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_dedicated.h @@ -1,9 +1,9 @@ /* - * Copyright (C) 2010-2012 ARM Limited. All rights reserved. - * + * 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. */ @@ -20,3 +20,4 @@ ump_memory_backend * ump_block_allocator_create(u32 base_address, u32 size); #endif /* __UMP_KERNEL_MEMORY_BACKEND_DEDICATED_H__ */ + diff --git a/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_os.c b/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_os.c index 2d81546..fc3afa8 100644 --- a/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_os.c +++ b/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_os.c @@ -1,9 +1,9 @@ /* * 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. */ @@ -77,8 +77,6 @@ ump_memory_backend * ump_os_memory_backend_create(const int max_allocation) backend->stat = os_stat; backend->pre_allocate_physical_check = NULL; backend->adjust_to_mali_phys = NULL; - backend->get = NULL; - backend->set = NULL; return backend; } @@ -136,7 +134,7 @@ static int os_allocate(void* ctx, ump_dd_mem * descriptor) return 0; /* failure */ } - while (left > 0) + while (left > 0 && ((info->num_pages_allocated + pages_allocated) < info->num_pages_max)) { struct page * new_page; @@ -149,7 +147,6 @@ static int os_allocate(void* ctx, ump_dd_mem * descriptor) } if (NULL == new_page) { - MSG_ERR(("UMP memory allocated: Out of Memory !!\n")); break; } diff --git a/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_os.h b/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_os.h old mode 100755 new mode 100644 index b638562d..6f7e610 --- a/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_os.h +++ b/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_os.h @@ -1,9 +1,9 @@ /* - * Copyright (C) 2010-2012 ARM Limited. All rights reserved. - * + * 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. */ @@ -20,3 +20,4 @@ ump_memory_backend * ump_os_memory_backend_create(const int max_allocation); #endif /* __UMP_KERNEL_MEMORY_BACKEND_OS_H__ */ + diff --git a/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_vcm.c b/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_vcm.c deleted file mode 100644 index 46797ea..0000000 --- a/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_vcm.c +++ /dev/null @@ -1,290 +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. - */ - -/* create by boojin.kim@samsung.com */ -/* needed to detect kernel version specific code */ -#include - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) -#include -#else /* pre 2.6.26 the file was in the arch specific location */ -#include -#endif - -#include -#include -#include -#include -#include -#include "ump_kernel_common.h" -#include "ump_kernel_memory_backend.h" -#include "ump_kernel_interface_ref_drv.h" -#include "ump_kernel_memory_backend_vcm.h" -#include "../common/ump_uk_types.h" -#include -#include -#include - -#define UMP_REF_DRV_UK_VCM_DEV_G2D 12 - -typedef struct ump_vcm { - struct vcm *vcm; - struct vcm_res *vcm_res; - unsigned int dev_id; -} ump_vcm; - -typedef struct vcm_allocator { - struct semaphore mutex; - u32 num_vcm_blocks; -} vcm_allocator; - -static void ump_vcm_free(void* ctx, ump_dd_mem * descriptor); -static int ump_vcm_allocate(void* ctx, ump_dd_mem * descriptor); -static void *vcm_res_get(ump_dd_mem *mem, void* args); -static void vcm_attr_set(ump_dd_mem *mem, void* args); -static int vcm_mem_allocator(vcm_allocator *info, ump_dd_mem *descriptor); -static void vcm_memory_backend_destroy(ump_memory_backend * backend); - - -/* - * Create VCM memory backend - */ -ump_memory_backend * ump_vcm_memory_backend_create(const int max_allocation) -{ - ump_memory_backend * backend; - vcm_allocator * info; - - info = kmalloc(sizeof(vcm_allocator), GFP_KERNEL); - if (NULL == info) - { - return NULL; - } - - info->num_vcm_blocks = 0; - - - sema_init(&info->mutex, 1); - - backend = kmalloc(sizeof(ump_memory_backend), GFP_KERNEL); - if (NULL == backend) - { - kfree(info); - return NULL; - } - - backend->ctx = info; - backend->allocate = ump_vcm_allocate; - backend->release = ump_vcm_free; - backend->shutdown = vcm_memory_backend_destroy; - backend->pre_allocate_physical_check = NULL; - backend->adjust_to_mali_phys = NULL; - - backend->get = vcm_res_get; - backend->set = vcm_attr_set; - - - return backend; -} - -/* - * Destroy specified VCM memory backend - */ -static void vcm_memory_backend_destroy(ump_memory_backend * backend) -{ - vcm_allocator * info = (vcm_allocator*)backend->ctx; -#if 0 - DBG_MSG_IF(1, 0 != info->num_pages_allocated, ("%d pages still in use during shutdown\n", info->num_pages_allocated)); -#endif - kfree(info); - kfree(backend); -} - -/* - * Allocate UMP memory - */ -static int ump_vcm_allocate(void *ctx, ump_dd_mem * descriptor) -{ - int ret; /* success */ - vcm_allocator *info; - struct ump_vcm *ump_vcm; - - BUG_ON(!descriptor); - BUG_ON(!ctx); - - info = (vcm_allocator*)ctx; - - ump_vcm = kmalloc(sizeof(struct ump_vcm), GFP_KERNEL); - if (NULL == ump_vcm) - { - return 0; - } - - ump_vcm->dev_id = (int)descriptor->backend_info & ~UMP_REF_DRV_UK_CONSTRAINT_USE_CACHE; - - if(ump_vcm->dev_id == UMP_REF_DRV_UK_CONSTRAINT_NONE) { /* None */ - ump_vcm->dev_id = UMP_REF_DRV_UK_VCM_DEV_G2D; /* this ID is G2D */ - } - else if(ump_vcm->dev_id == UMP_REF_DRV_UK_CONSTRAINT_PHYSICALLY_LINEAR) { /* Physical Linear */ - return 0; - } - else { /* Other VCM */ - ump_vcm->dev_id -= 2; - } - - DBG_MSG(5, ("Device ID for VCM : %d\n", ump_vcm->dev_id)); - ump_vcm->vcm = vcm_find_vcm(ump_vcm->dev_id); - - if (!ump_vcm->vcm) - { - return 0; - } - descriptor->backend_info = (void*)ump_vcm; - - if (down_interruptible(&info->mutex)) { - DBG_MSG(1, ("Failed to get mutex in ump_vcm_allocate\n")); - return 0; /* failure */ - } - - ret = vcm_mem_allocator(info, descriptor); - up(&info->mutex); - - return ret; /* success */ -} - -static int vcm_mem_allocator(vcm_allocator *info, ump_dd_mem *descriptor) -{ - unsigned long num_blocks; - int i; - struct vcm_phys *phys; - struct vcm_phys_part *part; - int size_total = 0; - struct ump_vcm *ump_vcm; - - ump_vcm = (struct ump_vcm*)descriptor->backend_info; - - ump_vcm->vcm_res = - vcm_make_binding(ump_vcm->vcm, descriptor->size_bytes, - ump_vcm->dev_id, 0); - - phys = ump_vcm->vcm_res->phys; - part = phys->parts; - num_blocks = phys->count; - - DBG_MSG(5, - ("Allocating page array. Size: %lu, VCM Reservation : 0x%x\n", - phys->count * sizeof(ump_dd_physical_block), - ump_vcm->vcm_res->start)); - - /* Now, make a copy of the block information supplied by the user */ - descriptor->block_array = - (ump_dd_physical_block *) vmalloc(sizeof(ump_dd_physical_block) * - num_blocks); - - if (NULL == descriptor->block_array) { - vfree(descriptor->block_array); - DBG_MSG(1, ("Could not allocate a mem handle for function.\n")); - return 0; /* failure */ - } - - for (i = 0; i < num_blocks; i++) { - descriptor->block_array[i].addr = part->start; - descriptor->block_array[i].size = part->size; - - dmac_unmap_area(phys_to_virt(part->start), part->size, DMA_FROM_DEVICE); - outer_inv_range(part->start, part->start + part->size); - - ++part; - size_total += descriptor->block_array[i].size; - DBG_MSG(6, - ("UMP memory created with VCM. addr 0x%x, size: 0x%x\n", - descriptor->block_array[i].addr, - descriptor->block_array[i].size)); - } - - descriptor->size_bytes = size_total; - descriptor->nr_blocks = num_blocks; - descriptor->ctx = NULL; - - info->num_vcm_blocks += num_blocks; - return 1; -} - -/* - * Free specified UMP memory - */ -static void ump_vcm_free(void *ctx, ump_dd_mem * descriptor) -{ - struct ump_vcm *ump_vcm; - vcm_allocator *info; - - BUG_ON(!descriptor); - BUG_ON(!ctx); - - ump_vcm = (struct ump_vcm*)descriptor->backend_info; - info = (vcm_allocator*)ctx; - - BUG_ON(descriptor->nr_blocks > info->num_vcm_blocks); - - if (down_interruptible(&info->mutex)) { - DBG_MSG(1, ("Failed to get mutex in ump_vcm_free\n")); - return; - } - - DBG_MSG(5, ("Releasing %lu VCM pages\n", descriptor->nr_blocks)); - - info->num_vcm_blocks -= descriptor->nr_blocks; - - up(&info->mutex); - - DBG_MSG(6, ("Freeing physical page by VCM\n")); - vcm_destroy_binding(ump_vcm->vcm_res); - ump_vcm->vcm = NULL; - ump_vcm->vcm_res = NULL; - - kfree(ump_vcm); - vfree(descriptor->block_array); -} - -static void *vcm_res_get(ump_dd_mem *mem, void *args) -{ - struct ump_vcm *ump_vcm; - enum vcm_dev_id vcm_id; - - ump_vcm = (struct ump_vcm*)mem->backend_info; - vcm_id = (enum vcm_dev_id)args; - - if (vcm_reservation_in_vcm - (vcm_find_vcm(vcm_id), ump_vcm->vcm_res) - == S5PVCM_RES_NOT_IN_VCM) - return NULL; - else - return ump_vcm->vcm_res; -} - -static void vcm_attr_set(ump_dd_mem *mem, void *args) -{ - struct ump_vcm *ump_vcm, *ump_vcmh; - - ump_vcm = (struct ump_vcm*)args; - - ump_vcmh = kmalloc(sizeof(struct ump_vcm), GFP_KERNEL); - if (NULL == ump_vcmh) - { - return; - } - - ump_vcmh->dev_id = ump_vcm->dev_id; - ump_vcmh->vcm = ump_vcm->vcm; - ump_vcmh->vcm_res = ump_vcm->vcm_res; - - mem->backend_info= (void*)ump_vcmh; - - return; -} diff --git a/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_vcm.h b/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_vcm.h deleted file mode 100644 index c1ead0d..0000000 --- a/drivers/media/video/samsung/ump/linux/ump_kernel_memory_backend_vcm.h +++ /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 ump_kernel_memory_backend_vcm.h - */ - -#ifndef __UMP_KERNEL_MEMORY_BACKEND_VCM_H__ -#define __UMP_KERNEL_MEMORY_BACKEND_VCM_H__ - -#include "ump_kernel_memory_backend.h" - -ump_memory_backend * ump_vcm_memory_backend_create(const int max_allocation); - -#endif /* __UMP_KERNEL_MEMORY_BACKEND_VCM_H__ */ diff --git a/drivers/media/video/samsung/ump/linux/ump_memory_backend.c b/drivers/media/video/samsung/ump/linux/ump_memory_backend.c index 821ac27..23357f4 100644 --- a/drivers/media/video/samsung/ump/linux/ump_memory_backend.c +++ b/drivers/media/video/samsung/ump/linux/ump_memory_backend.c @@ -1,9 +1,9 @@ /* - * Copyright (C) 2010-2012 ARM Limited. All rights reserved. - * + * 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. */ @@ -56,13 +56,6 @@ ump_memory_backend* ump_memory_backend_create ( void ) DBG_MSG(2, ("Using OS memory backend, allocation limit: %d\n", ump_memory_size)); backend = ump_os_memory_backend_create(ump_memory_size); } -#ifdef CONFIG_UMP_VCM_ALLOC - else if (2 == ump_backend) - { - DBG_MSG(2, ("Using VCM memory backend, allocation limit: %d\n", ump_memory_size)); - backend = ump_vcm_memory_backend_create(ump_memory_size); - } -#endif return backend; } diff --git a/drivers/media/video/samsung/ump/linux/ump_osk_atomics.c b/drivers/media/video/samsung/ump/linux/ump_osk_atomics.c old mode 100755 new mode 100644 index 77be0c9..b117d99 --- a/drivers/media/video/samsung/ump/linux/ump_osk_atomics.c +++ b/drivers/media/video/samsung/ump/linux/ump_osk_atomics.c @@ -1,9 +1,9 @@ /* - * Copyright (C) 2010-2012 ARM Limited. All rights reserved. - * + * 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. */ diff --git a/drivers/media/video/samsung/ump/linux/ump_osk_low_level_mem.c b/drivers/media/video/samsung/ump/linux/ump_osk_low_level_mem.c index b38c714..0073c4d 100644 --- a/drivers/media/video/samsung/ump/linux/ump_osk_low_level_mem.c +++ b/drivers/media/video/samsung/ump/linux/ump_osk_low_level_mem.c @@ -1,9 +1,9 @@ /* * 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. */ @@ -23,7 +23,6 @@ #include /* kernel module definitions */ #include #include -#include #include #include @@ -106,8 +105,6 @@ static void ump_vma_close(struct vm_area_struct * vma) DBG_MSG(4, ("VMA close, VMA reference count decremented. VMA: 0x%08lx, reference count: %d\n", (unsigned long)vma, new_val)); - vma_usage_tracker->descriptor->process_mapping_info = vma; - if (0 == new_val) { ump_memory_allocation * descriptor; @@ -213,95 +210,6 @@ _mali_osk_errcode_t _ump_osk_mem_mapregion_map( ump_memory_allocation * descript return retval; } -static u32 _ump_osk_virt_to_phys_start(ump_dd_mem * mem, u32 start, u32 address, int *index) -{ - int i; - u32 offset = address - start; - ump_dd_physical_block *block; - u32 sum = 0; - - for (i=0; inr_blocks; i++) { - block = &mem->block_array[i]; - sum += block->size; - if (sum > offset) { - *index = i; - DBG_MSG(3, ("_ump_osk_virt_to_phys : index : %d, virtual 0x%x, phys 0x%x\n", i, address, (u32)block->addr + offset - (sum -block->size))); - return (u32)block->addr + offset - (sum -block->size); - } - } - - return _MALI_OSK_ERR_FAULT; -} - -static u32 _ump_osk_virt_to_phys_end(ump_dd_mem * mem, u32 start, u32 address, int *index) -{ - int i; - u32 offset = address - start; - ump_dd_physical_block *block; - u32 sum = 0; - - for (i=0; inr_blocks; i++) { - block = &mem->block_array[i]; - sum += block->size; - if (sum >= offset) { - *index = i; - DBG_MSG(3, ("_ump_osk_virt_to_phys : index : %d, virtual 0x%x, phys 0x%x\n", i, address, (u32)block->addr + offset - (sum -block->size))); - return (u32)block->addr + offset - (sum -block->size); - } - } - - return _MALI_OSK_ERR_FAULT; -} - -static void _ump_osk_msync_with_virt(ump_dd_mem * mem, ump_uk_msync_op op, u32 start, u32 address, u32 size) -{ - int start_index, end_index; - u32 start_p, end_p; - - DBG_MSG(3, ("Cache flush with user virtual address. start : 0x%x, end : 0x%x, address 0x%x, size 0x%x\n", start, start+mem->size_bytes, address, size)); - - start_p = _ump_osk_virt_to_phys_start(mem, start, address, &start_index); - end_p = _ump_osk_virt_to_phys_end(mem, start, address+size, &end_index); - - if (start_index==end_index) { - if (op == _UMP_UK_MSYNC_CLEAN_AND_INVALIDATE) - outer_flush_range(start_p, end_p); - else - outer_clean_range(start_p, end_p); - } else { - ump_dd_physical_block *block; - int i; - - for (i=start_index; i<=end_index; i++) { - block = &mem->block_array[i]; - - if (i == start_index) { - if (op == _UMP_UK_MSYNC_CLEAN_AND_INVALIDATE) { - outer_flush_range(start_p, block->addr+block->size); - } else { - outer_clean_range(start_p, block->addr+block->size); - } - } - else if (i == end_index) { - if (op == _UMP_UK_MSYNC_CLEAN_AND_INVALIDATE) { - outer_flush_range(block->addr, end_p); - } else { - outer_clean_range(block->addr, end_p); - } - break; - } - else { - if (op == _UMP_UK_MSYNC_CLEAN_AND_INVALIDATE) { - outer_flush_range(block->addr, block->addr+block->size); - } else { - outer_clean_range(block->addr, block->addr+block->size); - } - } - } - } - return; -} - static void level1_cache_flush_all(void) { DBG_MSG(4, ("UMP[xx] Flushing complete L1 cache\n")); @@ -436,39 +344,3 @@ void _ump_osk_msync( ump_dd_mem * mem, void * virt, u32 offset, u32 size, ump_uk return; } - -void _ump_osk_mem_mapregion_get( ump_dd_mem ** mem, unsigned long vaddr) -{ - struct mm_struct *mm = current->mm; - struct vm_area_struct *vma; - ump_vma_usage_tracker * vma_usage_tracker; - ump_memory_allocation *descriptor; - ump_dd_handle handle; - - DBG_MSG(3, ("_ump_osk_mem_mapregion_get: vaddr 0x%08lx\n", vaddr)); - - down_read(&mm->mmap_sem); - vma = find_vma(mm, vaddr); - up_read(&mm->mmap_sem); - if(!vma) - { - DBG_MSG(3, ("Not found VMA\n")); - *mem = NULL; - return; - } - DBG_MSG(4, ("Get vma: 0x%08lx vma->vm_start: 0x%08lx\n", (unsigned long)vma, vma->vm_start)); - - vma_usage_tracker = (struct ump_vma_usage_tracker*)vma->vm_private_data; - if(vma_usage_tracker == NULL) - { - DBG_MSG(3, ("Not found vma_usage_tracker\n")); - *mem = NULL; - return; - } - - descriptor = (struct ump_memory_allocation*)vma_usage_tracker->descriptor; - handle = (ump_dd_handle)descriptor->handle; - - DBG_MSG(3, ("Get handle: 0x%08lx\n", handle)); - *mem = (ump_dd_mem*)handle; -} diff --git a/drivers/media/video/samsung/ump/linux/ump_osk_misc.c b/drivers/media/video/samsung/ump/linux/ump_osk_misc.c old mode 100755 new mode 100644 index 1f1118e..3be6fed --- a/drivers/media/video/samsung/ump/linux/ump_osk_misc.c +++ b/drivers/media/video/samsung/ump/linux/ump_osk_misc.c @@ -1,9 +1,9 @@ /* - * Copyright (C) 2010-2012 ARM Limited. All rights reserved. - * + * 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. */ diff --git a/drivers/media/video/samsung/ump/linux/ump_ukk_ref_wrappers.c b/drivers/media/video/samsung/ump/linux/ump_ukk_ref_wrappers.c index 405bdca..9692e5b 100644 --- a/drivers/media/video/samsung/ump/linux/ump_ukk_ref_wrappers.c +++ b/drivers/media/video/samsung/ump/linux/ump_ukk_ref_wrappers.c @@ -1,9 +1,9 @@ /* - * Copyright (C) 2010-2012 ARM Limited. All rights reserved. - * + * 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. */ diff --git a/drivers/media/video/samsung/ump/linux/ump_ukk_ref_wrappers.h b/drivers/media/video/samsung/ump/linux/ump_ukk_ref_wrappers.h index 8e3c0fc..416a584 100644 --- a/drivers/media/video/samsung/ump/linux/ump_ukk_ref_wrappers.h +++ b/drivers/media/video/samsung/ump/linux/ump_ukk_ref_wrappers.h @@ -1,9 +1,9 @@ /* - * Copyright (C) 2010-2012 ARM Limited. All rights reserved. - * + * 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. */ diff --git a/drivers/media/video/samsung/ump/linux/ump_ukk_wrappers.c b/drivers/media/video/samsung/ump/linux/ump_ukk_wrappers.c index e5c5903..780f311 100644 --- a/drivers/media/video/samsung/ump/linux/ump_ukk_wrappers.c +++ b/drivers/media/video/samsung/ump/linux/ump_ukk_wrappers.c @@ -1,9 +1,9 @@ /* * 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. */ diff --git a/drivers/media/video/samsung/ump/linux/ump_ukk_wrappers.h b/drivers/media/video/samsung/ump/linux/ump_ukk_wrappers.h index 99b790d..e87a903 100644 --- a/drivers/media/video/samsung/ump/linux/ump_ukk_wrappers.h +++ b/drivers/media/video/samsung/ump/linux/ump_ukk_wrappers.h @@ -1,9 +1,9 @@ /* - * Copyright (C) 2010-2012 ARM Limited. All rights reserved. - * + * 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. */ @@ -36,6 +36,8 @@ int ump_lock_wrapper(u32 __user * argument, struct ump_session_data * session_d int ump_unlock_wrapper(u32 __user * argument, struct ump_session_data * session_data); + + #ifdef __cplusplus } #endif -- cgit v1.1