MALI: utgard: upgrade DDK to r6p1-01rel0
authorchenzhen <chenzhen@rock-chips.com>
Thu, 10 Mar 2016 09:31:51 +0000 (17:31 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Wed, 5 Apr 2017 09:16:10 +0000 (17:16 +0800)
Change-Id: I88e8aba740ec223c1107def64eb004390b7fd940
Signed-off-by: chenzhen <chenzhen@rock-chips.com>
186 files changed:
drivers/gpu/arm/mali400/mali/Kbuild
drivers/gpu/arm/mali400/mali/Kconfig
drivers/gpu/arm/mali400/mali/Makefile
drivers/gpu/arm/mali400/mali/common/mali_broadcast.c
drivers/gpu/arm/mali400/mali/common/mali_broadcast.h
drivers/gpu/arm/mali400/mali/common/mali_control_timer.c
drivers/gpu/arm/mali400/mali/common/mali_control_timer.h
drivers/gpu/arm/mali400/mali/common/mali_dlbu.c
drivers/gpu/arm/mali400/mali/common/mali_dlbu.h
drivers/gpu/arm/mali400/mali/common/mali_dvfs_policy.c
drivers/gpu/arm/mali400/mali/common/mali_dvfs_policy.h
drivers/gpu/arm/mali400/mali/common/mali_executor.c
drivers/gpu/arm/mali400/mali/common/mali_gp.c
drivers/gpu/arm/mali400/mali/common/mali_gp.h
drivers/gpu/arm/mali400/mali/common/mali_gp_job.c
drivers/gpu/arm/mali400/mali/common/mali_gp_job.h
drivers/gpu/arm/mali400/mali/common/mali_group.c
drivers/gpu/arm/mali400/mali/common/mali_hw_core.c
drivers/gpu/arm/mali400/mali/common/mali_hw_core.h
drivers/gpu/arm/mali400/mali/common/mali_kernel_common.h
drivers/gpu/arm/mali400/mali/common/mali_kernel_core.c
drivers/gpu/arm/mali400/mali/common/mali_kernel_core.h
drivers/gpu/arm/mali400/mali/common/mali_kernel_utilization.c
drivers/gpu/arm/mali400/mali/common/mali_kernel_utilization.h
drivers/gpu/arm/mali400/mali/common/mali_kernel_vsync.c
drivers/gpu/arm/mali400/mali/common/mali_l2_cache.c
drivers/gpu/arm/mali400/mali/common/mali_l2_cache.h
drivers/gpu/arm/mali400/mali/common/mali_mem_validation.c
drivers/gpu/arm/mali400/mali/common/mali_mem_validation.h
drivers/gpu/arm/mali400/mali/common/mali_mmu.c
drivers/gpu/arm/mali400/mali/common/mali_mmu.h
drivers/gpu/arm/mali400/mali/common/mali_mmu_page_directory.c
drivers/gpu/arm/mali400/mali/common/mali_mmu_page_directory.h
drivers/gpu/arm/mali400/mali/common/mali_osk.h
drivers/gpu/arm/mali400/mali/common/mali_osk_bitops.h
drivers/gpu/arm/mali400/mali/common/mali_osk_list.h
drivers/gpu/arm/mali400/mali/common/mali_osk_mali.h
drivers/gpu/arm/mali400/mali/common/mali_osk_profiling.h
drivers/gpu/arm/mali400/mali/common/mali_osk_types.h
drivers/gpu/arm/mali400/mali/common/mali_pm.c
drivers/gpu/arm/mali400/mali/common/mali_pm.h
drivers/gpu/arm/mali400/mali/common/mali_pm_domain.c
drivers/gpu/arm/mali400/mali/common/mali_pm_domain.h
drivers/gpu/arm/mali400/mali/common/mali_pm_metrics.c [new file with mode: 0644]
drivers/gpu/arm/mali400/mali/common/mali_pm_metrics.h [new file with mode: 0644]
drivers/gpu/arm/mali400/mali/common/mali_pmu.c
drivers/gpu/arm/mali400/mali/common/mali_pmu.h
drivers/gpu/arm/mali400/mali/common/mali_pp.c
drivers/gpu/arm/mali400/mali/common/mali_pp.h
drivers/gpu/arm/mali400/mali/common/mali_pp_job.c
drivers/gpu/arm/mali400/mali/common/mali_pp_job.h
drivers/gpu/arm/mali400/mali/common/mali_scheduler.c
drivers/gpu/arm/mali400/mali/common/mali_scheduler.h
drivers/gpu/arm/mali400/mali/common/mali_scheduler_types.h
drivers/gpu/arm/mali400/mali/common/mali_session.c
drivers/gpu/arm/mali400/mali/common/mali_soft_job.c
drivers/gpu/arm/mali400/mali/common/mali_soft_job.h
drivers/gpu/arm/mali400/mali/common/mali_spinlock_reentrant.c
drivers/gpu/arm/mali400/mali/common/mali_spinlock_reentrant.h
drivers/gpu/arm/mali400/mali/common/mali_timeline.c
drivers/gpu/arm/mali400/mali/common/mali_timeline.h
drivers/gpu/arm/mali400/mali/common/mali_timeline_fence_wait.c
drivers/gpu/arm/mali400/mali/common/mali_timeline_fence_wait.h
drivers/gpu/arm/mali400/mali/common/mali_timeline_sync_fence.c
drivers/gpu/arm/mali400/mali/common/mali_timeline_sync_fence.h
drivers/gpu/arm/mali400/mali/common/mali_ukk.h
drivers/gpu/arm/mali400/mali/common/mali_user_settings_db.c
drivers/gpu/arm/mali400/mali/common/mali_user_settings_db.h
drivers/gpu/arm/mali400/mali/include/linux/mali/mali_utgard.h
drivers/gpu/arm/mali400/mali/include/linux/mali/mali_utgard_ioctl.h
drivers/gpu/arm/mali400/mali/include/linux/mali/mali_utgard_profiling_events.h
drivers/gpu/arm/mali400/mali/include/linux/mali/mali_utgard_profiling_gator_api.h
drivers/gpu/arm/mali400/mali/include/linux/mali/mali_utgard_uk_types.h
drivers/gpu/arm/mali400/mali/linux/license/gpl/mali_kernel_license.h
drivers/gpu/arm/mali400/mali/linux/mali_devfreq.c [new file with mode: 0644]
drivers/gpu/arm/mali400/mali/linux/mali_devfreq.h [new file with mode: 0644]
drivers/gpu/arm/mali400/mali/linux/mali_device_pause_resume.c
drivers/gpu/arm/mali400/mali/linux/mali_kernel_linux.c
drivers/gpu/arm/mali400/mali/linux/mali_kernel_sysfs.c
drivers/gpu/arm/mali400/mali/linux/mali_kernel_sysfs.h
drivers/gpu/arm/mali400/mali/linux/mali_linux_trace.h
drivers/gpu/arm/mali400/mali/linux/mali_memory.c
drivers/gpu/arm/mali400/mali/linux/mali_memory.h
drivers/gpu/arm/mali400/mali/linux/mali_memory_block_alloc.c
drivers/gpu/arm/mali400/mali/linux/mali_memory_block_alloc.h
drivers/gpu/arm/mali400/mali/linux/mali_memory_cow.c
drivers/gpu/arm/mali400/mali/linux/mali_memory_cow.h
drivers/gpu/arm/mali400/mali/linux/mali_memory_dma_buf.c
drivers/gpu/arm/mali400/mali/linux/mali_memory_dma_buf.h
drivers/gpu/arm/mali400/mali/linux/mali_memory_external.c
drivers/gpu/arm/mali400/mali/linux/mali_memory_external.h
drivers/gpu/arm/mali400/mali/linux/mali_memory_manager.c
drivers/gpu/arm/mali400/mali/linux/mali_memory_manager.h
drivers/gpu/arm/mali400/mali/linux/mali_memory_os_alloc.h
drivers/gpu/arm/mali400/mali/linux/mali_memory_secure.c [new file with mode: 0644]
drivers/gpu/arm/mali400/mali/linux/mali_memory_secure.h [new file with mode: 0644]
drivers/gpu/arm/mali400/mali/linux/mali_memory_swap_alloc.c
drivers/gpu/arm/mali400/mali/linux/mali_memory_swap_alloc.h
drivers/gpu/arm/mali400/mali/linux/mali_memory_types.h
drivers/gpu/arm/mali400/mali/linux/mali_memory_ump.c
drivers/gpu/arm/mali400/mali/linux/mali_memory_ump.h
drivers/gpu/arm/mali400/mali/linux/mali_memory_util.c
drivers/gpu/arm/mali400/mali/linux/mali_memory_util.h
drivers/gpu/arm/mali400/mali/linux/mali_memory_virtual.c
drivers/gpu/arm/mali400/mali/linux/mali_memory_virtual.h
drivers/gpu/arm/mali400/mali/linux/mali_osk_atomics.c
drivers/gpu/arm/mali400/mali/linux/mali_osk_bitmap.c
drivers/gpu/arm/mali400/mali/linux/mali_osk_irq.c
drivers/gpu/arm/mali400/mali/linux/mali_osk_locks.c
drivers/gpu/arm/mali400/mali/linux/mali_osk_locks.h
drivers/gpu/arm/mali400/mali/linux/mali_osk_low_level_mem.c
drivers/gpu/arm/mali400/mali/linux/mali_osk_mali.c
drivers/gpu/arm/mali400/mali/linux/mali_osk_math.c
drivers/gpu/arm/mali400/mali/linux/mali_osk_memory.c
drivers/gpu/arm/mali400/mali/linux/mali_osk_misc.c
drivers/gpu/arm/mali400/mali/linux/mali_osk_notification.c
drivers/gpu/arm/mali400/mali/linux/mali_osk_profiling.c
drivers/gpu/arm/mali400/mali/linux/mali_osk_specific.h
drivers/gpu/arm/mali400/mali/linux/mali_osk_time.c
drivers/gpu/arm/mali400/mali/linux/mali_osk_timers.c
drivers/gpu/arm/mali400/mali/linux/mali_osk_wait_queue.c
drivers/gpu/arm/mali400/mali/linux/mali_osk_wq.c
drivers/gpu/arm/mali400/mali/linux/mali_pmu_power_up_down.c
drivers/gpu/arm/mali400/mali/linux/mali_profiling_events.h
drivers/gpu/arm/mali400/mali/linux/mali_profiling_gator_api.h
drivers/gpu/arm/mali400/mali/linux/mali_profiling_internal.c
drivers/gpu/arm/mali400/mali/linux/mali_profiling_internal.h
drivers/gpu/arm/mali400/mali/linux/mali_sync.c
drivers/gpu/arm/mali400/mali/linux/mali_sync.h
drivers/gpu/arm/mali400/mali/linux/mali_uk_types.h
drivers/gpu/arm/mali400/mali/linux/mali_ukk_core.c
drivers/gpu/arm/mali400/mali/linux/mali_ukk_gp.c
drivers/gpu/arm/mali400/mali/linux/mali_ukk_mem.c
drivers/gpu/arm/mali400/mali/linux/mali_ukk_pp.c
drivers/gpu/arm/mali400/mali/linux/mali_ukk_profiling.c
drivers/gpu/arm/mali400/mali/linux/mali_ukk_soft_job.c
drivers/gpu/arm/mali400/mali/linux/mali_ukk_timeline.c
drivers/gpu/arm/mali400/mali/linux/mali_ukk_vsync.c
drivers/gpu/arm/mali400/mali/linux/mali_ukk_wrappers.h
drivers/gpu/arm/mali400/mali/platform/arm/arm.c
drivers/gpu/arm/mali400/mali/platform/arm/arm_core_scaling.c
drivers/gpu/arm/mali400/mali/platform/arm/arm_core_scaling.h
drivers/gpu/arm/mali400/mali/platform/arm/juno_opp.c [new file with mode: 0644]
drivers/gpu/arm/mali400/mali/regs/mali_200_regs.h
drivers/gpu/arm/mali400/mali/regs/mali_gp_regs.h
drivers/gpu/arm/mali400/mali/timestamp-arm11-cc/mali_timestamp.c
drivers/gpu/arm/mali400/mali/timestamp-arm11-cc/mali_timestamp.h
drivers/gpu/arm/mali400/mali/timestamp-default/mali_timestamp.c
drivers/gpu/arm/mali400/mali/timestamp-default/mali_timestamp.h
drivers/gpu/arm/mali400/ump/Kbuild
drivers/gpu/arm/mali400/ump/Makefile
drivers/gpu/arm/mali400/ump/Makefile.common
drivers/gpu/arm/mali400/ump/arch-default/config.h
drivers/gpu/arm/mali400/ump/arch-pb-virtex5/config.h
drivers/gpu/arm/mali400/ump/common/ump_kernel_api.c
drivers/gpu/arm/mali400/ump/common/ump_kernel_common.c
drivers/gpu/arm/mali400/ump/common/ump_kernel_common.h
drivers/gpu/arm/mali400/ump/common/ump_kernel_descriptor_mapping.c
drivers/gpu/arm/mali400/ump/common/ump_kernel_descriptor_mapping.h
drivers/gpu/arm/mali400/ump/common/ump_kernel_memory_backend.h
drivers/gpu/arm/mali400/ump/common/ump_kernel_ref_drv.c
drivers/gpu/arm/mali400/ump/common/ump_kernel_types.h
drivers/gpu/arm/mali400/ump/common/ump_osk.h
drivers/gpu/arm/mali400/ump/common/ump_uk_types.h
drivers/gpu/arm/mali400/ump/common/ump_ukk.h
drivers/gpu/arm/mali400/ump/linux/license/gpl/ump_kernel_license.h
drivers/gpu/arm/mali400/ump/linux/ump_ioctl.h
drivers/gpu/arm/mali400/ump/linux/ump_kernel_linux.c
drivers/gpu/arm/mali400/ump/linux/ump_kernel_linux.h
drivers/gpu/arm/mali400/ump/linux/ump_kernel_memory_backend_dedicated.c
drivers/gpu/arm/mali400/ump/linux/ump_kernel_memory_backend_dedicated.h
drivers/gpu/arm/mali400/ump/linux/ump_kernel_memory_backend_os.c
drivers/gpu/arm/mali400/ump/linux/ump_kernel_memory_backend_os.h
drivers/gpu/arm/mali400/ump/linux/ump_kernel_random_mapping.c
drivers/gpu/arm/mali400/ump/linux/ump_kernel_random_mapping.h
drivers/gpu/arm/mali400/ump/linux/ump_memory_backend.c
drivers/gpu/arm/mali400/ump/linux/ump_osk_atomics.c
drivers/gpu/arm/mali400/ump/linux/ump_osk_low_level_mem.c
drivers/gpu/arm/mali400/ump/linux/ump_osk_misc.c
drivers/gpu/arm/mali400/ump/linux/ump_ukk_ref_wrappers.c
drivers/gpu/arm/mali400/ump/linux/ump_ukk_ref_wrappers.h
drivers/gpu/arm/mali400/ump/linux/ump_ukk_wrappers.c
drivers/gpu/arm/mali400/ump/linux/ump_ukk_wrappers.h
drivers/gpu/arm/mali400/umplock/Makefile
drivers/gpu/arm/mali400/umplock/umplock_driver.c
drivers/gpu/arm/mali400/umplock/umplock_ioctl.h

index ae42b53c8ad9afeb133a0aac2dd3a7c22bd14e49..3b74bd15cda114ebfce64ca3d902f7291de3eeae 100755 (executable)
@@ -44,6 +44,15 @@ ifneq ($(MALI_PLATFORM),)
                platform/$(MALI_PLATFORM)/mali_dvfs.o
 endif
 
                platform/$(MALI_PLATFORM)/mali_dvfs.o
 endif
 
+ifeq ($(MALI_PLATFORM_FILES),)
+ifeq ($(CONFIG_ARCH_EXYNOS4),y)
+EXTRA_DEFINES += -DMALI_FAKE_PLATFORM_DEVICE=1
+export MALI_PLATFORM=exynos4
+export MALI_PLATFORM_FILES_BUILDIN = $(notdir $(wildcard $(src)/platform/$(MALI_PLATFORM)/*.c))
+export MALI_PLATFORM_FILES_ADD_PREFIX = $(addprefix platform/$(MALI_PLATFORM)/,$(MALI_PLATFORM_FILES_BUILDIN)) 
+endif
+endif
+
 mali-y += \
        linux/mali_osk_atomics.o \
        linux/mali_osk_irq.o \
 mali-y += \
        linux/mali_osk_atomics.o \
        linux/mali_osk_irq.o \
@@ -80,6 +89,10 @@ mali-y += \
        linux/mali_ukk_soft_job.o \
        linux/mali_ukk_timeline.o
 
        linux/mali_ukk_soft_job.o \
        linux/mali_ukk_timeline.o
 
+mali-$(CONFIG_MALI_DEVFREQ) += \
+       linux/mali_devfreq.o \
+       common/mali_pm_metrics.o
+
 # Source files which always are included in a build
 mali-y += \
        common/mali_kernel_core.o \
 # Source files which always are included in a build
 mali-y += \
        common/mali_kernel_core.o \
@@ -118,10 +131,18 @@ mali-y += \
        linux/mali_pmu_power_up_down.o \
        __malidrv_build_info.o
 
        linux/mali_pmu_power_up_down.o \
        __malidrv_build_info.o
 
+ifneq ($(wildcard $(src)/linux/mali_slp_global_lock.c),)
+       mali-y += linux/mali_slp_global_lock.o
+endif
+
 ifneq ($(MALI_PLATFORM_FILES),)
        mali-y += $(MALI_PLATFORM_FILES:.c=.o)
 endif
 
 ifneq ($(MALI_PLATFORM_FILES),)
        mali-y += $(MALI_PLATFORM_FILES:.c=.o)
 endif
 
+ifneq ($(MALI_PLATFORM_FILES_ADD_PREFIX),)
+       mali-y += $(MALI_PLATFORM_FILES_ADD_PREFIX:.c=.o)
+endif
+
 mali-$(CONFIG_MALI400_PROFILING) += linux/mali_ukk_profiling.o
 mali-$(CONFIG_MALI400_PROFILING) += linux/mali_osk_profiling.o
 
 mali-$(CONFIG_MALI400_PROFILING) += linux/mali_ukk_profiling.o
 mali-$(CONFIG_MALI400_PROFILING) += linux/mali_osk_profiling.o
 
@@ -129,6 +150,7 @@ mali-$(CONFIG_MALI400_INTERNAL_PROFILING) += linux/mali_profiling_internal.o tim
 ccflags-$(CONFIG_MALI400_INTERNAL_PROFILING) += -I$(src)/timestamp-$(TIMESTAMP)
 
 mali-$(CONFIG_DMA_SHARED_BUFFER) += linux/mali_memory_dma_buf.o
 ccflags-$(CONFIG_MALI400_INTERNAL_PROFILING) += -I$(src)/timestamp-$(TIMESTAMP)
 
 mali-$(CONFIG_DMA_SHARED_BUFFER) += linux/mali_memory_dma_buf.o
+mali-$(CONFIG_DMA_SHARED_BUFFER) += linux/mali_memory_secure.o
 mali-$(CONFIG_SYNC) += linux/mali_sync.o
 ccflags-$(CONFIG_SYNC) += -Idrivers/staging/android
 
 mali-$(CONFIG_SYNC) += linux/mali_sync.o
 ccflags-$(CONFIG_SYNC) += -Idrivers/staging/android
 
@@ -154,7 +176,12 @@ ifeq ($(MALI_UPPER_HALF_SCHEDULING),1)
        ccflags-y += -DMALI_UPPER_HALF_SCHEDULING
 endif
 
        ccflags-y += -DMALI_UPPER_HALF_SCHEDULING
 endif
 
+#build-in include path is different
+ifeq ($(MALI_PLATFORM_FILES),)
+ccflags-$(CONFIG_MALI400_UMP) += -I$(src)/../ump/include/
+else
 ccflags-$(CONFIG_MALI400_UMP) += -I$(src)/../../ump/include/ump
 ccflags-$(CONFIG_MALI400_UMP) += -I$(src)/../../ump/include/ump
+endif
 ccflags-$(CONFIG_MALI400_DEBUG) += -DDEBUG
 
 # Use our defines when compiling
 ccflags-$(CONFIG_MALI400_DEBUG) += -DDEBUG
 
 # Use our defines when compiling
index f199123e6989505d02944e8c0e67a7367e008bb6..7b4e9fb2cf90c695f6b178a49ccee9c40f45f99c 100755 (executable)
@@ -50,7 +50,7 @@ config MALI400_UMP
 
 config MALI_DVFS
        bool "Enable Mali dynamically frequency change"
 
 config MALI_DVFS
        bool "Enable Mali dynamically frequency change"
-       depends on MALI400
+       depends on MALI400 && !MALI_DEVFREQ
        default y
        ---help---
          This enables support for dynamic change frequency of Mali with the goal of lowering power consumption.
        default y
        ---help---
          This enables support for dynamic change frequency of Mali with the goal of lowering power consumption.
@@ -96,6 +96,17 @@ config MALI_DT
          device tree is enabled in kernel and corresponding hardware description is implemented
          properly in device DTS file.
 
          device tree is enabled in kernel and corresponding hardware description is implemented
          properly in device DTS file.
 
+config MALI_DEVFREQ
+       bool "Using devfreq to tuning frequency"
+       depends on MALI400 && PM_DEVFREQ
+       default n
+       ---help---
+       Support devfreq for Mali.
+
+       Using the devfreq framework and, by default, the simpleondemand
+       governor, the frequency of Mali will be dynamically selected from the
+       available OPPs.
+
 config MALI_QUIET
        bool "Make Mali driver very quiet"
        depends on MALI400 && !MALI400_DEBUG
 config MALI_QUIET
        bool "Make Mali driver very quiet"
        depends on MALI400 && !MALI400_DEBUG
index 44c7bb83981a009335f46749c77184a283435fed..7f3f8aa940c3f1d16664cd122ae41dcf07a02cbf 100755 (executable)
@@ -1,5 +1,5 @@
 #
 #
-# Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+# Copyright (C) 2010-2016 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.
 # 
 # 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.
@@ -17,6 +17,7 @@ MALI_DMA_BUF_MAP_ON_ATTACH ?= 1
 MALI_PMU_PARALLEL_POWER_UP ?= 0
 USING_DT ?= 0
 MALI_MEM_SWAP_TRACKING ?= 0
 MALI_PMU_PARALLEL_POWER_UP ?= 0
 USING_DT ?= 0
 MALI_MEM_SWAP_TRACKING ?= 0
+USING_DEVFREQ ?= 0
 
 # The Makefile sets up "arch" based on the CONFIG, creates the version info
 # string and the __malidrv_build_info.c file, and then call the Linux build
 
 # The Makefile sets up "arch" based on the CONFIG, creates the version info
 # string and the __malidrv_build_info.c file, and then call the Linux build
@@ -158,6 +159,15 @@ export EXTRA_DEFINES += -DCONFIG_MALI_DT
 endif
 endif
 
 endif
 endif
 
+ifeq ($(USING_DEVFREQ), 1)
+ifdef CONFIG_PM_DEVFREQ
+export CONFIG_MALI_DEVFREQ=y
+export EXTRA_DEFINES += -DCONFIG_MALI_DEVFREQ=1
+else
+$(warning "You want to support DEVFREQ but kernel didn't support DEVFREQ.")
+endif
+endif
+
 ifneq ($(BUILD),release)
 # Debug
 export CONFIG_MALI400_DEBUG=y
 ifneq ($(BUILD),release)
 # Debug
 export CONFIG_MALI400_DEBUG=y
index 136db61ace4a4fc36f6363b35d905b8eaf5e5a27..4c4b2bc9ee9644e71589e6ddd616bfb0694fe8e3 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2014, 2016 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.
  * 
  * 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.
index efce44142ee9fa1b4c1d356a2cab18ddbec023f7..e12e8a2b59029a4923a906060cf0d8ffd814312b 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2014, 2016 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.
  * 
  * 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.
index 2d1f579692ca1113d081f2af04ecb093201d3c57..ddbf108c0b6894446962b5d155634a09bf4c314a 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2012, 2014-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2012, 2014-2016 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.
  * 
  * 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.
index f829174de58ef1304a497abef2d6f03028fa7d9a..16e7d7b912fcf76c981d373209e5b0ef3bcadc83 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2012, 2014-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2012, 2014, 2016 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.
  * 
  * 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.
index efe1ab3ab5cc329eb9478afbb932fa9bbe7e8e0a..4f2a121fc0e6fb3eadac7bd66eb276c66ce2d2d7 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2014, 2016 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.
  * 
  * 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.
index 6b068884bd499f7630be729f062cde77f6fdccf9..c031f1150b83a0089a9650452c486df9f15da0f0 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2014, 2016 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.
  * 
  * 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.
index 12ba069ec13bdc8475676a6f9891b568a9b9f1a3..1094f9df9dbe05d01a4154e4c326ced6503124b2 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2012, 2014-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2012, 2014, 2016 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.
  * 
  * 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.
index 55e4b354c1a948821d8ff86fe035e95c0b84a99c..17704269b7aae9c6a550271c53b787fc10839451 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2012, 2014-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2012, 2014, 2016 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.
  * 
  * 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.
index d8281822b6a45c841826cb2bc5689e4c31804018..4664f258c8e218f572a5474c13bb71ae2707e0f5 100755 (executable)
@@ -21,6 +21,7 @@
 #include "mali_timeline.h"
 #include "mali_osk_profiling.h"
 #include "mali_session.h"
 #include "mali_timeline.h"
 #include "mali_osk_profiling.h"
 #include "mali_session.h"
+#include "mali_osk_mali.h"
 
 /*Add for voltage scan function*/
 extern u32 mali_group_error;
 
 /*Add for voltage scan function*/
 extern u32 mali_group_error;
@@ -1497,6 +1498,75 @@ static mali_bool mali_executor_tackle_gp_bound(void)
        return MALI_FALSE;
 }
 
        return MALI_FALSE;
 }
 
+static mali_bool mali_executor_schedule_is_early_out(mali_bool *gpu_secure_mode_is_needed)
+{
+       struct mali_pp_job *next_pp_job_to_start = NULL;
+       struct mali_group *group;
+       struct mali_group *tmp_group;
+       struct mali_pp_job *physical_pp_job_working = NULL;
+       struct mali_pp_job *virtual_pp_job_working = NULL;
+       mali_bool gpu_working_in_protected_mode = MALI_FALSE;
+       mali_bool gpu_working_in_non_protected_mode = MALI_FALSE;
+
+       MALI_DEBUG_ASSERT_LOCK_HELD(mali_scheduler_lock_obj);
+
+       *gpu_secure_mode_is_needed = MALI_FALSE;
+
+       /* Check if the gpu secure mode is supported, exit if not.*/
+       if (MALI_FALSE == _mali_osk_gpu_secure_mode_is_supported()) {
+               return MALI_FALSE;
+       }
+
+       /* Check if need to set gpu secure mode for the next pp job,
+        * get the next pp job that will be scheduled  if exist.
+        */
+       next_pp_job_to_start = mali_scheduler_job_pp_next();
+
+       /* Check current pp physical/virtual running job is protected job or not if exist.*/
+       _MALI_OSK_LIST_FOREACHENTRY(group, tmp_group, &group_list_working,
+                                   struct mali_group, executor_list) {
+               physical_pp_job_working = group->pp_running_job;
+               break;
+       }
+
+       if (EXEC_STATE_WORKING == virtual_group_state) {
+               virtual_pp_job_working = virtual_group->pp_running_job;
+       }
+
+       if (NULL != physical_pp_job_working) {
+               if (MALI_TRUE == mali_pp_job_is_protected_job(physical_pp_job_working)) {
+                       gpu_working_in_protected_mode = MALI_TRUE;
+               } else {
+                       gpu_working_in_non_protected_mode = MALI_TRUE;
+               }
+       } else if (NULL != virtual_pp_job_working) {
+               if (MALI_TRUE == mali_pp_job_is_protected_job(virtual_pp_job_working)) {
+                       gpu_working_in_protected_mode = MALI_TRUE;
+               } else {
+                       gpu_working_in_non_protected_mode = MALI_TRUE;
+               }
+       } else if (EXEC_STATE_WORKING == gp_group_state) {
+               gpu_working_in_non_protected_mode = MALI_TRUE;
+       }
+
+       /* If the next pp job is the protected pp job.*/
+       if ((NULL != next_pp_job_to_start) && MALI_TRUE == mali_pp_job_is_protected_job(next_pp_job_to_start)) {
+               /* if gp is working or any non-protected pp job is working now, unable to schedule protected pp job. */
+               if (MALI_TRUE == gpu_working_in_non_protected_mode)
+                       return MALI_TRUE;
+
+               *gpu_secure_mode_is_needed = MALI_TRUE;
+               return MALI_FALSE;
+
+       }
+
+       if (MALI_TRUE == gpu_working_in_protected_mode) {
+               /* Unable to schedule non-protected pp job/gp job if exist protected pp running jobs*/
+               return MALI_TRUE;
+       }
+
+       return MALI_FALSE;
+}
 /*
  * This is where jobs are actually started.
  */
 /*
  * This is where jobs are actually started.
  */
@@ -1507,6 +1577,7 @@ static void mali_executor_schedule(void)
        u32 num_physical_to_process = 0;
        mali_bool trigger_pm_update = MALI_FALSE;
        mali_bool deactivate_idle_group = MALI_TRUE;
        u32 num_physical_to_process = 0;
        mali_bool trigger_pm_update = MALI_FALSE;
        mali_bool deactivate_idle_group = MALI_TRUE;
+       mali_bool gpu_secure_mode_is_needed = MALI_FALSE;
 
        /* Physical groups + jobs to start in this function */
        struct mali_group *groups_to_start[MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS];
 
        /* Physical groups + jobs to start in this function */
        struct mali_group *groups_to_start[MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS];
@@ -1530,9 +1601,16 @@ static void mali_executor_schedule(void)
        /* Lock needed in order to safely handle the job queues */
        mali_scheduler_lock();
 
        /* Lock needed in order to safely handle the job queues */
        mali_scheduler_lock();
 
-       /* 1. Activate gp firstly if have gp job queued. */
-       if (EXEC_STATE_INACTIVE == gp_group_state &&
-           0 < mali_scheduler_job_gp_count()) {
+       /* 1. Check the schedule if need to early out. */
+       if (MALI_TRUE == mali_executor_schedule_is_early_out(&gpu_secure_mode_is_needed)) {
+               mali_scheduler_unlock();
+               return;
+       }
+
+       /* 2. Activate gp firstly if have gp job queued. */
+       if ((EXEC_STATE_INACTIVE == gp_group_state)
+           && (0 < mali_scheduler_job_gp_count())
+           && (gpu_secure_mode_is_needed == MALI_FALSE)) {
 
                enum mali_group_state state =
                        mali_group_activate(gp_group);
 
                enum mali_group_state state =
                        mali_group_activate(gp_group);
@@ -1544,9 +1622,9 @@ static void mali_executor_schedule(void)
                }
        }
 
                }
        }
 
-       /* 2. Prepare as many physical groups as needed/possible */
+       /* 3. Prepare as many physical groups as needed/possible */
 
 
-       num_physical_needed = mali_scheduler_job_physical_head_count();
+       num_physical_needed = mali_scheduler_job_physical_head_count(gpu_secure_mode_is_needed);
 
        /* On mali-450 platform, we don't need to enter in this block frequently. */
        if (0 < num_physical_needed) {
 
        /* On mali-450 platform, we don't need to enter in this block frequently. */
        if (0 < num_physical_needed) {
@@ -1563,7 +1641,7 @@ static void mali_executor_schedule(void)
 
                if (0 < num_physical_needed) {
 
 
                if (0 < num_physical_needed) {
 
-                       /* 2.1. Activate groups which are inactive */
+                       /* 3.1. Activate groups which are inactive */
 
                        struct mali_group *group;
                        struct mali_group *temp;
 
                        struct mali_group *group;
                        struct mali_group *temp;
@@ -1595,7 +1673,7 @@ static void mali_executor_schedule(void)
                if (mali_executor_virtual_group_is_usable()) {
 
                        /*
                if (mali_executor_virtual_group_is_usable()) {
 
                        /*
-                        * 2.2. And finally, steal and activate groups
+                        * 3.2. And finally, steal and activate groups
                         * from virtual group if we need even more
                         */
                        while (0 < num_physical_needed) {
                         * from virtual group if we need even more
                         */
                        while (0 < num_physical_needed) {
@@ -1638,7 +1716,7 @@ static void mali_executor_schedule(void)
                        }
                }
 
                        }
                }
 
-               /* 2.3. Assign physical jobs to groups */
+               /* 3.3. Assign physical jobs to groups */
 
                if (0 < num_physical_to_process) {
                        struct mali_group *group;
 
                if (0 < num_physical_to_process) {
                        struct mali_group *group;
@@ -1653,24 +1731,30 @@ static void mali_executor_schedule(void)
                                                  MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS);
 
                                MALI_DEBUG_ASSERT(0 <
                                                  MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS);
 
                                MALI_DEBUG_ASSERT(0 <
-                                                 mali_scheduler_job_physical_head_count());
+                                                 mali_scheduler_job_physical_head_count(gpu_secure_mode_is_needed));
 
 
-                               if (mali_executor_hint_is_enabled(
-                                           MALI_EXECUTOR_HINT_GP_BOUND)) {
-                                       if (MALI_TRUE == mali_executor_tackle_gp_bound()) {
-                                               /*
-                                               * We're gp bound,
-                                               * don't start this right now.
-                                               */
-                                               deactivate_idle_group = MALI_FALSE;
-                                               num_physical_to_process = 0;
-                                               break;
-                                       }
+                               /* If the next pp job is non-protected, check if gp bound now. */
+                               if ((MALI_FALSE == gpu_secure_mode_is_needed)
+                                   && (mali_executor_hint_is_enabled(MALI_EXECUTOR_HINT_GP_BOUND))
+                                   && (MALI_TRUE == mali_executor_tackle_gp_bound())) {
+                                       /*
+                                       * We're gp bound,
+                                       * don't start this right now.
+                                       */
+                                       deactivate_idle_group = MALI_FALSE;
+                                       num_physical_to_process = 0;
+                                       break;
                                }
 
                                job = mali_scheduler_job_pp_physical_get(
                                              &sub_job);
 
                                }
 
                                job = mali_scheduler_job_pp_physical_get(
                                              &sub_job);
 
+                               if (MALI_FALSE == gpu_secure_mode_is_needed) {
+                                       MALI_DEBUG_ASSERT(MALI_FALSE == mali_pp_job_is_protected_job(job));
+                               } else {
+                                       MALI_DEBUG_ASSERT(MALI_TRUE == mali_pp_job_is_protected_job(job));
+                               }
+
                                MALI_DEBUG_ASSERT_POINTER(job);
                                MALI_DEBUG_ASSERT(sub_job <= MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS);
 
                                MALI_DEBUG_ASSERT_POINTER(job);
                                MALI_DEBUG_ASSERT(sub_job <= MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS);
 
@@ -1697,8 +1781,7 @@ static void mali_executor_schedule(void)
                }
        }
 
                }
        }
 
-
-       /* 3. Deactivate idle pp group , must put deactive here before active vitual group
+       /* 4. Deactivate idle pp group , must put deactive here before active vitual group
         *    for cover case first only has physical job in normal queue but group inactive,
         *    so delay the job start go to active group, when group activated,
         *    call scheduler again, but now if we get high queue virtual job,
         *    for cover case first only has physical job in normal queue but group inactive,
         *    so delay the job start go to active group, when group activated,
         *    call scheduler again, but now if we get high queue virtual job,
@@ -1710,34 +1793,41 @@ static void mali_executor_schedule(void)
                trigger_pm_update = MALI_TRUE;
        }
 
                trigger_pm_update = MALI_TRUE;
        }
 
-       /* 4. Activate virtual group, if needed */
-
+       /* 5. Activate virtual group, if needed */
        if (EXEC_STATE_INACTIVE == virtual_group_state &&
        if (EXEC_STATE_INACTIVE == virtual_group_state &&
-           0 < mali_scheduler_job_next_is_virtual()) {
-               enum mali_group_state state =
-                       mali_group_activate(virtual_group);
-               if (MALI_GROUP_STATE_ACTIVE == state) {
-                       /* Set virtual group state to idle */
-                       virtual_group_state = EXEC_STATE_IDLE;
-               } else {
-                       trigger_pm_update = MALI_TRUE;
+           MALI_TRUE ==  mali_scheduler_job_next_is_virtual()) {
+               struct mali_pp_job *virtual_job = mali_scheduler_job_pp_virtual_peek();
+               if ((MALI_FALSE == gpu_secure_mode_is_needed && MALI_FALSE == mali_pp_job_is_protected_job(virtual_job))
+                   || (MALI_TRUE == gpu_secure_mode_is_needed && MALI_TRUE == mali_pp_job_is_protected_job(virtual_job))) {
+                       enum mali_group_state state =
+                               mali_group_activate(virtual_group);
+                       if (MALI_GROUP_STATE_ACTIVE == state) {
+                               /* Set virtual group state to idle */
+                               virtual_group_state = EXEC_STATE_IDLE;
+                       } else {
+                               trigger_pm_update = MALI_TRUE;
+                       }
                }
        }
 
                }
        }
 
-       /* 5. To power up group asap, we trigger pm update here. */
+       /* 6. To power up group asap, we trigger pm update here. */
 
        if (MALI_TRUE == trigger_pm_update) {
                trigger_pm_update = MALI_FALSE;
                mali_pm_update_async();
        }
 
 
        if (MALI_TRUE == trigger_pm_update) {
                trigger_pm_update = MALI_FALSE;
                mali_pm_update_async();
        }
 
-       /* 6. Assign jobs to idle virtual group (or deactivate if no job) */
+       /* 7. Assign jobs to idle virtual group (or deactivate if no job) */
 
        if (EXEC_STATE_IDLE == virtual_group_state) {
 
        if (EXEC_STATE_IDLE == virtual_group_state) {
-               if (0 < mali_scheduler_job_next_is_virtual()) {
-                       virtual_job_to_start =
-                               mali_scheduler_job_pp_virtual_get();
-                       virtual_group_state = EXEC_STATE_WORKING;
+               if (MALI_TRUE == mali_scheduler_job_next_is_virtual()) {
+                       struct mali_pp_job *virtual_job = mali_scheduler_job_pp_virtual_peek();
+                       if ((MALI_FALSE == gpu_secure_mode_is_needed && MALI_FALSE == mali_pp_job_is_protected_job(virtual_job))
+                           || (MALI_TRUE == gpu_secure_mode_is_needed && MALI_TRUE == mali_pp_job_is_protected_job(virtual_job))) {
+                               virtual_job_to_start =
+                                       mali_scheduler_job_pp_virtual_get();
+                               virtual_group_state = EXEC_STATE_WORKING;
+                       }
                } else if (!mali_timeline_has_virtual_pp_job()) {
                        virtual_group_state = EXEC_STATE_INACTIVE;
 
                } else if (!mali_timeline_has_virtual_pp_job()) {
                        virtual_group_state = EXEC_STATE_INACTIVE;
 
@@ -1747,9 +1837,9 @@ static void mali_executor_schedule(void)
                }
        }
 
                }
        }
 
-       /* 7. Assign job to idle GP group (or deactivate if no job) */
+       /* 8. Assign job to idle GP group (or deactivate if no job) */
 
 
-       if (EXEC_STATE_IDLE == gp_group_state) {
+       if (EXEC_STATE_IDLE == gp_group_state && MALI_FALSE == gpu_secure_mode_is_needed) {
                if (0 < mali_scheduler_job_gp_count()) {
                        gp_job_to_start = mali_scheduler_job_gp_get();
                        gp_group_state = EXEC_STATE_WORKING;
                if (0 < mali_scheduler_job_gp_count()) {
                        gp_job_to_start = mali_scheduler_job_gp_get();
                        gp_group_state = EXEC_STATE_WORKING;
@@ -1761,12 +1851,11 @@ static void mali_executor_schedule(void)
                }
        }
 
                }
        }
 
-       /* 8. We no longer need the schedule/queue lock */
+       /* 9. We no longer need the schedule/queue lock */
 
        mali_scheduler_unlock();
 
 
        mali_scheduler_unlock();
 
-       /* 9. start jobs */
-
+       /* 10. start jobs */
        if (NULL != virtual_job_to_start) {
                MALI_DEBUG_ASSERT(!mali_group_pp_is_active(virtual_group));
                mali_group_start_pp_job(virtual_group,
        if (NULL != virtual_job_to_start) {
                MALI_DEBUG_ASSERT(!mali_group_pp_is_active(virtual_group));
                mali_group_start_pp_job(virtual_group,
@@ -1788,7 +1877,7 @@ static void mali_executor_schedule(void)
                mali_group_start_gp_job(gp_group, gp_job_to_start);
        }
 
                mali_group_start_gp_job(gp_group, gp_job_to_start);
        }
 
-       /* 10. Trigger any pending PM updates */
+       /* 11. Trigger any pending PM updates */
        if (MALI_TRUE == trigger_pm_update) {
                mali_pm_update_async();
        }
        if (MALI_TRUE == trigger_pm_update) {
                mali_pm_update_async();
        }
index a690781837e98f991fc2509ceef2185b0f40d7e4..a918552162a80384e5ccdc86bc3a5a367a56bb87 100755 (executable)
@@ -12,6 +12,7 @@
 #include "mali_hw_core.h"
 #include "mali_group.h"
 #include "mali_osk.h"
 #include "mali_hw_core.h"
 #include "mali_group.h"
 #include "mali_osk.h"
+#include "mali_osk_mali.h"
 #include "regs/mali_gp_regs.h"
 #include "mali_kernel_common.h"
 #include "mali_kernel_core.h"
 #include "regs/mali_gp_regs.h"
 #include "mali_kernel_common.h"
 #include "mali_kernel_core.h"
@@ -199,6 +200,11 @@ void mali_gp_job_start(struct mali_gp_core *core, struct mali_gp_job *job)
        u32 counter_src0 = mali_gp_job_get_perf_counter_src0(job);
        u32 counter_src1 = mali_gp_job_get_perf_counter_src1(job);
 
        u32 counter_src0 = mali_gp_job_get_perf_counter_src0(job);
        u32 counter_src1 = mali_gp_job_get_perf_counter_src1(job);
 
+       /* Disable gpu secure mode. */
+       if (MALI_TRUE == _mali_osk_gpu_secure_mode_is_enabled()) {
+               _mali_osk_gpu_secure_mode_disable();
+       }
+
        MALI_DEBUG_ASSERT_POINTER(core);
 
        if (mali_gp_job_has_vs_job(job)) {
        MALI_DEBUG_ASSERT_POINTER(core);
 
        if (mali_gp_job_has_vs_job(job)) {
index 8d5f69c23229ce8445b4382aad3106c285ac0152..ecbe70e940c33f42521a992617304436a36f338e 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2011-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2014, 2016 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.
  * 
  * 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.
index 81b46437af13fc79742d5c32bd09428224d14e5e..18e9f775ddbeef732977146ee5d1e24a825cfc47 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2011-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2016 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.
  * 
  * 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.
@@ -120,33 +120,32 @@ struct mali_gp_job *mali_gp_job_create(struct mali_session_data *session, _mali_
                INIT_LIST_HEAD(&job->vary_todo);
                job->dmem = NULL;
 
                INIT_LIST_HEAD(&job->vary_todo);
                job->dmem = NULL;
 
-               if (job->uargs.varying_alloc_num > session->allocation_mgr.mali_allocation_num) {
+               if (job->uargs.deferred_mem_num > session->allocation_mgr.mali_allocation_num) {
                        MALI_PRINT_ERROR(("Mali GP job: The number of  varying buffer to defer bind  is invalid !\n"));
                        goto fail1;
                }
 
                /* add varying allocation list*/
                        MALI_PRINT_ERROR(("Mali GP job: The number of  varying buffer to defer bind  is invalid !\n"));
                        goto fail1;
                }
 
                /* add varying allocation list*/
-               if (job->uargs.varying_alloc_num > 0) {
+               if (job->uargs.deferred_mem_num > 0) {
                        /* copy varying list from user space*/
                        /* copy varying list from user space*/
-                       job->varying_list = _mali_osk_calloc(1, sizeof(u32) * job->uargs.varying_alloc_num);
+                       job->varying_list = _mali_osk_calloc(1, sizeof(u32) * job->uargs.deferred_mem_num);
                        if (!job->varying_list) {
                        if (!job->varying_list) {
-                               MALI_PRINT_ERROR(("Mali GP job: allocate varying_list failed varying_alloc_num = %d !\n", job->uargs.varying_alloc_num));
+                               MALI_PRINT_ERROR(("Mali GP job: allocate varying_list failed varying_alloc_num = %d !\n", job->uargs.deferred_mem_num));
                                goto fail1;
                        }
 
                        if (0 != _mali_osk_copy_from_user(&copy_of_uargs, uargs, sizeof(_mali_uk_gp_start_job_s))) {
                                goto fail1;
                        }
                                goto fail1;
                        }
 
                        if (0 != _mali_osk_copy_from_user(&copy_of_uargs, uargs, sizeof(_mali_uk_gp_start_job_s))) {
                                goto fail1;
                        }
+                       memory_list = (u32 __user *)(uintptr_t)copy_of_uargs.deferred_mem_list;
 
 
-                       memory_list = (u32 __user *)(uintptr_t)copy_of_uargs.varying_alloc_list;
-
-                       if (0 != _mali_osk_copy_from_user(job->varying_list, memory_list, sizeof(u32) * job->uargs.varying_alloc_num)) {
+                       if (0 != _mali_osk_copy_from_user(job->varying_list, memory_list, sizeof(u32) * job->uargs.deferred_mem_num)) {
                                MALI_PRINT_ERROR(("Mali GP job: Failed to copy varying list from user space!\n"));
                                goto fail;
                        }
 
                        if (unlikely(_mali_gp_add_varying_allocations(session, job, job->varying_list,
                                MALI_PRINT_ERROR(("Mali GP job: Failed to copy varying list from user space!\n"));
                                goto fail;
                        }
 
                        if (unlikely(_mali_gp_add_varying_allocations(session, job, job->varying_list,
-                                       job->uargs.varying_alloc_num))) {
+                                       job->uargs.deferred_mem_num))) {
                                MALI_PRINT_ERROR(("Mali GP job: _mali_gp_add_varying_allocations failed!\n"));
                                goto fail;
                        }
                                MALI_PRINT_ERROR(("Mali GP job: _mali_gp_add_varying_allocations failed!\n"));
                                goto fail;
                        }
index 5dd534155249feb9e3d7ed19ffd75fccb56a5b42..fbf8ee8fd605208d6c29a4882e7cbe52a29e0a31 100755 (executable)
@@ -73,7 +73,7 @@ struct mali_gp_job {
        u32 bind_flag;                                     /** < flag for deferbind*/
        u32 *varying_list;                                 /**< varying memory list need to to defer bind*/
        struct list_head vary_todo;                        /**< list of backend list need to do defer bind*/
        u32 bind_flag;                                     /** < flag for deferbind*/
        u32 *varying_list;                                 /**< varying memory list need to to defer bind*/
        struct list_head vary_todo;                        /**< list of backend list need to do defer bind*/
-       u32 required_varying_memsize;                      /** < size of varying memory to reallocate*/
+       u32 required_varying_memsize;                      /** < size of varying memory to reallocate*/
        u32 big_job;                                       /** < if the gp job have large varying output and may take long time*/
 };
 
        u32 big_job;                                       /** < if the gp job have large varying output and may take long time*/
 };
 
index aface075724679a3197e80a2e1aacbfc65eedff5..b9651a40e5b5dee8ab95b378dbffcc0ed2baa525 100755 (executable)
@@ -1468,19 +1468,19 @@ _mali_osk_errcode_t mali_group_upper_half_mmu(void *data)
                /* group complete and on job shedule on it, it already power off */
                if (NULL != group->gp_core) {
                        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
                /* group complete and on job shedule on it, it already power off */
                if (NULL != group->gp_core) {
                        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
-                                       MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                       MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
-                                       0, 0, /* No pid and tid for interrupt handler */
-                                       MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP_MMU(0),
-                                       0xFFFFFFFF, 0);
+                                                     MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+                                                     MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
+                                                     0, 0, /* No pid and tid for interrupt handler */
+                                                     MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP_MMU(0),
+                                                     0xFFFFFFFF, 0);
                } else {
                        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
                } else {
                        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
-                                       MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                       MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
-                                       0, 0, /* No pid and tid for interrupt handler */
-                                       MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP_MMU(
-                                               mali_pp_core_get_id(group->pp_core)),
-                                       0xFFFFFFFF, 0);
+                                                     MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+                                                     MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
+                                                     0, 0, /* No pid and tid for interrupt handler */
+                                                     MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP_MMU(
+                                                             mali_pp_core_get_id(group->pp_core)),
+                                                     0xFFFFFFFF, 0);
                }
 
                mali_executor_unlock();
                }
 
                mali_executor_unlock();
@@ -1597,11 +1597,11 @@ _mali_osk_errcode_t mali_group_upper_half_gp(void *data)
        if (!mali_group_is_working(group) && (!mali_group_power_is_on(group))) {
                /* group complete and on job shedule on it, it already power off */
                _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
        if (!mali_group_is_working(group) && (!mali_group_power_is_on(group))) {
                /* group complete and on job shedule on it, it already power off */
                _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
-                                     MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                     MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
-                                     0, 0, /* No pid and tid for interrupt handler */
-                                     MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP(0),
-                                     0xFFFFFFFF, 0);
+                                             MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+                                             MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
+                                             0, 0, /* No pid and tid for interrupt handler */
+                                             MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP(0),
+                                             0xFFFFFFFF, 0);
                mali_executor_unlock();
                return ret;
        }
                mali_executor_unlock();
                return ret;
        }
@@ -1687,12 +1687,12 @@ _mali_osk_errcode_t mali_group_upper_half_pp(void *data)
        if (!mali_group_is_working(group) && (!mali_group_power_is_on(group))) {
                /* group complete and on job shedule on it, it already power off */
                _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
        if (!mali_group_is_working(group) && (!mali_group_power_is_on(group))) {
                /* group complete and on job shedule on it, it already power off */
                _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
-                                     MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                     MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
-                                     0, 0, /* No pid and tid for interrupt handler */
-                                     MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP(
-                                             mali_pp_core_get_id(group->pp_core)),
-                                     0xFFFFFFFF, 0);
+                                             MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+                                             MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
+                                             0, 0, /* No pid and tid for interrupt handler */
+                                             MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP(
+                                                     mali_pp_core_get_id(group->pp_core)),
+                                             0xFFFFFFFF, 0);
                mali_executor_unlock();
                return ret;
        }
                mali_executor_unlock();
                return ret;
        }
index c90cf38d8516c8122c9ea7e65fa4686a5d74dc61..dd10cfe89aeb8fe52df5e16d3c828590082ce27b 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2011-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2014, 2016 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.
  * 
  * 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.
index ac2ffbedf308589f278da15a6d1f0bf7f4c29cfb..e4357253998be1dd36c7c168afd9e44e5639da76 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2011-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2016 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.
  * 
  * 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.
index 990cf3ac78e021d52d5b60d6d940fa4a7a3812e8..9bae26579866ceb107f42e668216ca66b1d6ce63 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2012-2014, 2016 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.
  * 
  * 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.
index 6dca53af2e4755005c7c49ab160f524be101d184..6a62c9298f35556a532ee19ae45e546638294009 100755 (executable)
@@ -756,6 +756,9 @@ _mali_osk_errcode_t mali_initialize_subsystems(void)
                return err;
        }
 
                return err;
        }
 
+       /*Try to init gpu secure mode */
+       _mali_osk_gpu_secure_mode_init();
+
 #if defined(CONFIG_MALI400_PROFILING)
        err = _mali_osk_profiling_init(mali_boot_profiling ? MALI_TRUE : MALI_FALSE);
        if (_MALI_OSK_ERR_OK != err) {
 #if defined(CONFIG_MALI400_PROFILING)
        err = _mali_osk_profiling_init(mali_boot_profiling ? MALI_TRUE : MALI_FALSE);
        if (_MALI_OSK_ERR_OK != err) {
@@ -939,6 +942,8 @@ void mali_terminate_subsystems(void)
        _mali_osk_profiling_term();
 #endif
 
        _mali_osk_profiling_term();
 #endif
 
+       _mali_osk_gpu_secure_mode_deinit();
+
        mali_memory_terminate();
 
        mali_session_terminate();
        mali_memory_terminate();
 
        mali_session_terminate();
index 8cdbc5af3205fdeac9d5fa266c30cc870a3ecf5c..cf6af3263f0b387daaebe0e6324c8034df53fbf2 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2016 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.
  * 
  * 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.
index 63b94174224963bc8ea85f96651a2fb188276ba0..ca7ebea4763b92404fe49fb7bae95e52f1b63b2b 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
index 3c20b1983762ae376356cfca59d0b4f28675e4b6..5206225ca2f11ba70fede83ab9e67c983b6f04da 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
index 2eed4c88cf5616d14015fbe3f6ed383c884fa896..3b2b108c747a8f03f806c1217add6984ef3a8a6f 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2011-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2014, 2016 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.
  * 
  * 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.
index 494ba789cd08c643523301e5812e35af85328732..4fbb51c870d7e00ba27e472694f07f6cc7990f90 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2016 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.
  * 
  * 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.
index 6dc8ec22d6deaee8c93a6d4b4a2042b8675ad433..de92ad63e9aa7fed6985aee4519484648a2ab35f 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
index 0ab35094004b3c4fc90aec2945c431d87f2fa1d3..dbc68bd4c21269dc7a698e9a8730bb66fa4efe07 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2011-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2014, 2016 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.
  * 
  * 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.
index 267720625d87ee1e243b5ac01ae16d617b4dc644..f7e6cb1009b3d097fed4afeef8b7faf94594e8a5 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2011-2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2013, 2016 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.
  * 
  * 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.
index b975c1468d6783c5ec310d2a61572755c42cc9a6..fba534058b7991c9311a44a8f4066eea4d7fa12b 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
index 101c968bd45d332d8df7509bfb14ae774a0fed36..398b2096c5d840691c4560ea0563d8e3bb8d5523 100755 (executable)
@@ -91,6 +91,7 @@ MALI_STATIC_INLINE enum mali_interrupt_result mali_mmu_get_interrupt_result(stru
        if (0 == rawstat_used) {
                return MALI_INTERRUPT_RESULT_NONE;
        }
        if (0 == rawstat_used) {
                return MALI_INTERRUPT_RESULT_NONE;
        }
+
        return MALI_INTERRUPT_RESULT_ERROR;
 }
 
        return MALI_INTERRUPT_RESULT_ERROR;
 }
 
index 126fd77ec9c993678bda3ecf82b8ba6e9da06356..74d8cc85bc8ef403a4b87cf92947c1b95a8f209e 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2011-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2016 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.
  * 
  * 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.
index 561fb60b9803eefb2e493653ae3b5bc5acc43559..4fc1058d73f6c0b9b52a6dc7373c0fe7de4c59db 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2011-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2014, 2016 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.
  * 
  * 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.
index 4c9e57cba18f26f1f3e914895ccfeeba7561a10c..5c20fc32993f0e29fc75d03d874ab7ba9a315fc9 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2016 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.
  * 
  * 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,6 +16,7 @@
 #ifndef __MALI_OSK_H__
 #define __MALI_OSK_H__
 
 #ifndef __MALI_OSK_H__
 #define __MALI_OSK_H__
 
+#include <linux/seq_file.h>
 #include "mali_osk_types.h"
 #include "mali_osk_specific.h"           /* include any per-os specifics */
 #include "mali_osk_locks.h"
 #include "mali_osk_types.h"
 #include "mali_osk_specific.h"           /* include any per-os specifics */
 #include "mali_osk_locks.h"
@@ -50,6 +51,8 @@ extern "C" {
 #define MALI_DEBUG_ASSERT_LOCK_HELD(l) do {} while(0)
 #endif
 
 #define MALI_DEBUG_ASSERT_LOCK_HELD(l) do {} while(0)
 #endif
 
+#define _mali_osk_ctxprintf     seq_printf
+
 /** @} */ /* end group _mali_osk_lock */
 
 /** @addtogroup _mali_osk_miscellaneous
 /** @} */ /* end group _mali_osk_lock */
 
 /** @addtogroup _mali_osk_miscellaneous
@@ -1237,17 +1240,6 @@ void _mali_osk_dbgmsg(const char *fmt, ...);
  */
 u32 _mali_osk_snprintf(char *buf, u32 size, const char *fmt, ...);
 
  */
 u32 _mali_osk_snprintf(char *buf, u32 size, const char *fmt, ...);
 
-/** @brief Print fmt into print_ctx.
- *
- * The interpretation of \a fmt is the same as the \c format parameter in
- * _mali_osu_vsnprintf().
- *
- * @param print_ctx a pointer to the result file buffer
- * @param fmt a _mali_osu_vsnprintf() style format string
- * @param ... a variable-number of parameters suitable for \a fmt
- */
-void _mali_osk_ctxprintf(_mali_osk_print_ctx *print_ctx, const char *fmt, ...);
-
 /** @brief Abnormal process abort.
  *
  * Terminates the caller-process if this function is called.
 /** @brief Abnormal process abort.
  *
  * Terminates the caller-process if this function is called.
index c1709f94c8837c566b5670ed48b892818eec4086..61e0a9110b3ffaf8e1472ba20efa768fb5108607 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2013-2014, 2016 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.
  * 
  * 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.
index 22d22446d7a0bedbd11fca59610352e5fa2e267c..a41f5ab3e77ba228cd3b7f084c5525e94beded62 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
index 230dbecc204042a9db1b375489e4f985124db5ab..0d6906ad204b29a527e84ed3d7c516ae494ecb65 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2016 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.
  * 
  * 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.
 extern "C" {
 #endif
 
 extern "C" {
 #endif
 
+#ifdef CONFIG_MALI_DEVFREQ
+struct mali_device {
+       struct device *dev;
+#ifdef CONFIG_HAVE_CLK
+       struct clk *clock;
+#endif
+#ifdef CONFIG_REGULATOR
+       struct regulator *regulator;
+#endif
+#ifdef CONFIG_PM_DEVFREQ
+       struct devfreq_dev_profile devfreq_profile;
+       struct devfreq *devfreq;
+       unsigned long current_freq;
+       unsigned long current_voltage;
+#ifdef CONFIG_DEVFREQ_THERMAL
+       struct thermal_cooling_device *devfreq_cooling;
+#endif
+#endif
+       struct mali_pm_metrics_data mali_metrics;
+};
+#endif
+
 /** @addtogroup _mali_osk_miscellaneous
  * @{ */
 
 /** @addtogroup _mali_osk_miscellaneous
  * @{ */
 
@@ -88,6 +110,38 @@ u32 _mali_osk_get_pmu_switch_delay(void);
  */
 mali_bool _mali_osk_shared_interrupts(void);
 
  */
 mali_bool _mali_osk_shared_interrupts(void);
 
+/** @brief Initialize the gpu secure mode.
+ * The gpu secure mode will initially be in a disabled state.
+ * @return _MALI_OSK_ERR_OK on success, otherwise failure.
+ */
+_mali_osk_errcode_t _mali_osk_gpu_secure_mode_init(void);
+
+/** @brief Deinitialize the gpu secure mode.
+ * @return _MALI_OSK_ERR_OK on success, otherwise failure.
+ */
+_mali_osk_errcode_t _mali_osk_gpu_secure_mode_deinit(void);
+
+/** @brief Enable the gpu secure mode.
+ * @return _MALI_OSK_ERR_OK on success, otherwise failure.
+ */
+_mali_osk_errcode_t _mali_osk_gpu_secure_mode_enable(void);
+
+/** @brief Disable the gpu secure mode.
+ * @return _MALI_OSK_ERR_OK on success, otherwise failure.
+ */
+_mali_osk_errcode_t _mali_osk_gpu_secure_mode_disable(void);
+
+/** @brief Check if the gpu secure mode has been enabled.
+ * @return MALI_TRUE if enabled, otherwise MALI_FALSE.
+ */
+mali_bool _mali_osk_gpu_secure_mode_is_enabled(void);
+
+/** @brief Check if the gpu secure mode is supported.
+ * @return MALI_TRUE if supported, otherwise MALI_FALSE.
+ */
+mali_bool _mali_osk_gpu_secure_mode_is_supported(void);
+
+
 /** @} */ /* end group _mali_osk_miscellaneous */
 
 #ifdef __cplusplus
 /** @} */ /* end group _mali_osk_miscellaneous */
 
 #ifdef __cplusplus
index 10f4dc552b03d468619ed509d0d14f7cf34c3346..eca6ad493c33b492b617aecd5b9735e76abd64a8 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2016 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.
  * 
  * 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.
index b65ad29e16c02fcc2576cd5a2e9e090691725a23..6e9a1336bf0be77fb7a26c9212422a03f78f3c5c 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2016 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.
  * 
  * 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.
index dbd94d31074155c84a283ab325217fef9494475c..1ef03a69a084a792a49af8522a610e73bae1b7db 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2011-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2016 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.
  * 
  * 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.
index d72c732e698d654e0ece4103308ae81a5c11a408..3c11977f00fa062353fdee583aced401efa50486 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2011-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2016 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.
  * 
  * 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.
index dbf985e6d37b0ac27d7c7648a21c7febefae8375..9db848865a80c7e241208987adbd05370939d19a 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2014, 2016 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.
  * 
  * 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.
index aceb3449359af6779138470665b954eb14e02669..2ac8c0d3068c3694f74ac9950be75951a01eecd5 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2014, 2016 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.
  * 
  * This program is free software and is provided to you under the terms of the GNU General Public License version 2
  * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
diff --git a/drivers/gpu/arm/mali400/mali/common/mali_pm_metrics.c b/drivers/gpu/arm/mali400/mali/common/mali_pm_metrics.c
new file mode 100644 (file)
index 0000000..981ec81
--- /dev/null
@@ -0,0 +1,255 @@
+/*
+ * Copyright (C) 2010-2014, 2016 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_pm_metrics.h"
+#include "mali_osk_locks.h"
+#include "mali_osk_mali.h"
+#include <linux/ktime.h>
+
+#define MALI_PM_TIME_SHIFT 0
+#define MALI_UTILIZATION_MAX_PERIOD 80000000/* ns = 100ms */
+
+_mali_osk_errcode_t mali_pm_metrics_init(struct mali_device *mdev)
+{
+       int i = 0;
+
+       MALI_DEBUG_ASSERT(mdev != NULL);
+
+       mdev->mali_metrics.time_period_start = ktime_get();
+       mdev->mali_metrics.time_period_start_gp = mdev->mali_metrics.time_period_start;
+       mdev->mali_metrics.time_period_start_pp = mdev->mali_metrics.time_period_start;
+
+       mdev->mali_metrics.time_busy = 0;
+       mdev->mali_metrics.time_idle = 0;
+       mdev->mali_metrics.prev_busy = 0;
+       mdev->mali_metrics.prev_idle = 0;
+       mdev->mali_metrics.num_running_gp_cores = 0;
+       mdev->mali_metrics.num_running_pp_cores = 0;
+       mdev->mali_metrics.time_busy_gp = 0;
+       mdev->mali_metrics.time_idle_gp = 0;
+
+       for (i = 0; i < MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS; i++) {
+               mdev->mali_metrics.time_busy_pp[i] = 0;
+               mdev->mali_metrics.time_idle_pp[i] = 0;
+       }
+       mdev->mali_metrics.gpu_active = MALI_FALSE;
+
+       mdev->mali_metrics.lock = _mali_osk_spinlock_irq_init(_MALI_OSK_LOCKFLAG_UNORDERED, _MALI_OSK_LOCK_ORDER_FIRST);
+       if (NULL == mdev->mali_metrics.lock) {
+               return _MALI_OSK_ERR_NOMEM;
+       }
+
+       return _MALI_OSK_ERR_OK;
+}
+
+void mali_pm_metrics_term(struct mali_device *mdev)
+{
+       _mali_osk_spinlock_irq_term(mdev->mali_metrics.lock);
+}
+
+/*caller needs to hold mdev->mali_metrics.lock before calling this function*/
+void mali_pm_record_job_status(struct mali_device *mdev)
+{
+       ktime_t now;
+       ktime_t diff;
+       u64 ns_time;
+
+       MALI_DEBUG_ASSERT(mdev != NULL);
+
+       now = ktime_get();
+       diff = ktime_sub(now, mdev->mali_metrics.time_period_start);
+
+       ns_time = (u64)(ktime_to_ns(diff) >> MALI_PM_TIME_SHIFT);
+       mdev->mali_metrics.time_busy += ns_time;
+       mdev->mali_metrics.time_period_start = now;
+}
+
+void mali_pm_record_gpu_idle(mali_bool is_gp)
+{
+       ktime_t now;
+       ktime_t diff;
+       u64 ns_time;
+       struct mali_device *mdev = dev_get_drvdata(&mali_platform_device->dev);
+
+       MALI_DEBUG_ASSERT(mdev != NULL);
+
+       _mali_osk_spinlock_irq_lock(mdev->mali_metrics.lock);
+       now = ktime_get();
+
+       if (MALI_TRUE == is_gp) {
+               --mdev->mali_metrics.num_running_gp_cores;
+               if (0 == mdev->mali_metrics.num_running_gp_cores) {
+                       diff = ktime_sub(now, mdev->mali_metrics.time_period_start_gp);
+                       ns_time = (u64)(ktime_to_ns(diff) >> MALI_PM_TIME_SHIFT);
+                       mdev->mali_metrics.time_busy_gp += ns_time;
+                       mdev->mali_metrics.time_period_start_gp = now;
+
+                       if (0 == mdev->mali_metrics.num_running_pp_cores) {
+                               MALI_DEBUG_ASSERT(mdev->mali_metrics.gpu_active == MALI_TRUE);
+                               diff = ktime_sub(now, mdev->mali_metrics.time_period_start);
+                               ns_time = (u64)(ktime_to_ns(diff) >> MALI_PM_TIME_SHIFT);
+                               mdev->mali_metrics.time_busy += ns_time;
+                               mdev->mali_metrics.time_period_start = now;
+                               mdev->mali_metrics.gpu_active = MALI_FALSE;
+                       }
+               }
+       } else {
+               --mdev->mali_metrics.num_running_pp_cores;
+               if (0 == mdev->mali_metrics.num_running_pp_cores) {
+                       diff = ktime_sub(now, mdev->mali_metrics.time_period_start_pp);
+                       ns_time = (u64)(ktime_to_ns(diff) >> MALI_PM_TIME_SHIFT);
+                       mdev->mali_metrics.time_busy_pp[0] += ns_time;
+                       mdev->mali_metrics.time_period_start_pp = now;
+
+                       if (0 == mdev->mali_metrics.num_running_gp_cores) {
+                               MALI_DEBUG_ASSERT(mdev->mali_metrics.gpu_active == MALI_TRUE);
+                               diff = ktime_sub(now, mdev->mali_metrics.time_period_start);
+                               ns_time = (u64)(ktime_to_ns(diff) >> MALI_PM_TIME_SHIFT);
+                               mdev->mali_metrics.time_busy += ns_time;
+                               mdev->mali_metrics.time_period_start = now;
+                               mdev->mali_metrics.gpu_active = MALI_FALSE;
+                       }
+               }
+       }
+
+       _mali_osk_spinlock_irq_unlock(mdev->mali_metrics.lock);
+}
+
+void mali_pm_record_gpu_active(mali_bool is_gp)
+{
+       ktime_t now;
+       ktime_t diff;
+       struct mali_device *mdev = dev_get_drvdata(&mali_platform_device->dev);
+
+       MALI_DEBUG_ASSERT(mdev != NULL);
+
+       _mali_osk_spinlock_irq_lock(mdev->mali_metrics.lock);
+       now = ktime_get();
+
+       if (MALI_TRUE == is_gp) {
+               mdev->mali_metrics.num_running_gp_cores++;
+               if (1 == mdev->mali_metrics.num_running_gp_cores) {
+                       diff = ktime_sub(now, mdev->mali_metrics.time_period_start_gp);
+                       mdev->mali_metrics.time_idle_gp += (u64)(ktime_to_ns(diff) >> MALI_PM_TIME_SHIFT);
+                       mdev->mali_metrics.time_period_start_gp = now;
+                       if (0 == mdev->mali_metrics.num_running_pp_cores) {
+                               MALI_DEBUG_ASSERT(mdev->mali_metrics.gpu_active == MALI_FALSE);
+                               diff = ktime_sub(now, mdev->mali_metrics.time_period_start);
+                               mdev->mali_metrics.time_idle += (u64)(ktime_to_ns(diff) >> MALI_PM_TIME_SHIFT);
+                               mdev->mali_metrics.time_period_start = now;
+                               mdev->mali_metrics.gpu_active = MALI_TRUE;
+                       }
+               } else {
+                       MALI_DEBUG_ASSERT(mdev->mali_metrics.gpu_active == MALI_TRUE);
+               }
+       } else {
+               mdev->mali_metrics.num_running_pp_cores++;
+               if (1 == mdev->mali_metrics.num_running_pp_cores) {
+                       diff = ktime_sub(now, mdev->mali_metrics.time_period_start_pp);
+                       mdev->mali_metrics.time_idle_pp[0] += (u64)(ktime_to_ns(diff) >> MALI_PM_TIME_SHIFT);
+                       mdev->mali_metrics.time_period_start_pp = now;
+                       if (0 == mdev->mali_metrics.num_running_gp_cores) {
+                               MALI_DEBUG_ASSERT(mdev->mali_metrics.gpu_active == MALI_FALSE);
+                               diff = ktime_sub(now, mdev->mali_metrics.time_period_start);
+                               mdev->mali_metrics.time_idle += (u64)(ktime_to_ns(diff) >> MALI_PM_TIME_SHIFT);
+                               mdev->mali_metrics.time_period_start = now;
+                               mdev->mali_metrics.gpu_active = MALI_TRUE;
+                       }
+               } else {
+                       MALI_DEBUG_ASSERT(mdev->mali_metrics.gpu_active == MALI_TRUE);
+               }
+       }
+
+       _mali_osk_spinlock_irq_unlock(mdev->mali_metrics.lock);
+}
+
+
+/*caller needs to hold mdev->mali_metrics.lock before calling this function*/
+static void mali_pm_get_dvfs_utilisation_calc(struct mali_device *mdev, ktime_t now)
+{
+       ktime_t diff;
+
+       MALI_DEBUG_ASSERT(mdev != NULL);
+
+       diff = ktime_sub(now, mdev->mali_metrics.time_period_start);
+
+       if (mdev->mali_metrics.gpu_active) {
+               mdev->mali_metrics.time_busy += (u64)(ktime_to_ns(diff) >> MALI_PM_TIME_SHIFT);
+       } else {
+               mdev->mali_metrics.time_idle += (u64)(ktime_to_ns(diff) >> MALI_PM_TIME_SHIFT);
+       }
+}
+
+/* Caller needs to hold mdev->mali_metrics.lock before calling this function. */
+static void mali_pm_reset_dvfs_utilisation_unlocked(struct mali_device *mdev, ktime_t now)
+{
+       /* Store previous value */
+       mdev->mali_metrics.prev_idle = mdev->mali_metrics.time_idle;
+       mdev->mali_metrics.prev_busy = mdev->mali_metrics.time_busy;
+
+       /* Reset current values */
+       mdev->mali_metrics.time_period_start = now;
+       mdev->mali_metrics.time_period_start_gp = now;
+       mdev->mali_metrics.time_period_start_pp = now;
+       mdev->mali_metrics.time_idle = 0;
+       mdev->mali_metrics.time_busy = 0;
+
+       mdev->mali_metrics.time_busy_gp = 0;
+       mdev->mali_metrics.time_idle_gp = 0;
+       mdev->mali_metrics.time_busy_pp[0] = 0;
+       mdev->mali_metrics.time_idle_pp[0] = 0;
+}
+
+void mali_pm_reset_dvfs_utilisation(struct mali_device *mdev)
+{
+       _mali_osk_spinlock_irq_lock(mdev->mali_metrics.lock);
+       mali_pm_reset_dvfs_utilisation_unlocked(mdev, ktime_get());
+       _mali_osk_spinlock_irq_unlock(mdev->mali_metrics.lock);
+}
+
+void mali_pm_get_dvfs_utilisation(struct mali_device *mdev,
+                                 unsigned long *total_out, unsigned long *busy_out)
+{
+       ktime_t now = ktime_get();
+       u64 busy = 0;
+       u64 total = 0;
+
+       _mali_osk_spinlock_irq_lock(mdev->mali_metrics.lock);
+
+       mali_pm_get_dvfs_utilisation_calc(mdev, now);
+
+       busy = mdev->mali_metrics.time_busy;
+       total = busy + mdev->mali_metrics.time_idle;
+
+       /* Reset stats if older than MALI_UTILIZATION_MAX_PERIOD (default
+        * 100ms) */
+       if (total >= MALI_UTILIZATION_MAX_PERIOD) {
+               mali_pm_reset_dvfs_utilisation_unlocked(mdev, now);
+       } else if (total < (MALI_UTILIZATION_MAX_PERIOD / 2)) {
+               total += mdev->mali_metrics.prev_idle +
+                        mdev->mali_metrics.prev_busy;
+               busy += mdev->mali_metrics.prev_busy;
+       }
+
+       *total_out = (unsigned long)total;
+       *busy_out = (unsigned long)busy;
+       _mali_osk_spinlock_irq_unlock(mdev->mali_metrics.lock);
+}
+
+void mali_pm_metrics_spin_lock(void)
+{
+       struct mali_device *mdev = dev_get_drvdata(&mali_platform_device->dev);
+       _mali_osk_spinlock_irq_lock(mdev->mali_metrics.lock);
+}
+
+void mali_pm_metrics_spin_unlock(void)
+{
+       struct mali_device *mdev = dev_get_drvdata(&mali_platform_device->dev);
+       _mali_osk_spinlock_irq_unlock(mdev->mali_metrics.lock);
+}
diff --git a/drivers/gpu/arm/mali400/mali/common/mali_pm_metrics.h b/drivers/gpu/arm/mali400/mali/common/mali_pm_metrics.h
new file mode 100644 (file)
index 0000000..256f448
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2010-2014, 2016 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_PM_METRICS_H__
+#define __MALI_PM_METRICS_H__
+
+#ifdef CONFIG_MALI_DEVFREQ
+#include "mali_osk_locks.h"
+#include "mali_group.h"
+
+struct mali_device;
+
+/**
+ * Metrics data collected for use by the power management framework.
+ */
+struct mali_pm_metrics_data {
+       ktime_t time_period_start;
+       u64 time_busy;
+       u64 time_idle;
+       u64 prev_busy;
+       u64 prev_idle;
+       u32 num_running_gp_cores;
+       u32 num_running_pp_cores;
+       ktime_t time_period_start_gp;
+       u64 time_busy_gp;
+       u64 time_idle_gp;
+       ktime_t time_period_start_pp;
+       u64 time_busy_pp[MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS];
+       u64 time_idle_pp[MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS];
+       mali_bool gpu_active;
+       _mali_osk_spinlock_irq_t *lock;
+};
+
+/**
+ * Initialize/start the Mali GPU pm_metrics metrics reporting.
+ *
+ * @return _MALI_OSK_ERR_OK on success, otherwise failure.
+ */
+_mali_osk_errcode_t mali_pm_metrics_init(struct mali_device *mdev);
+
+/**
+ * Terminate the Mali GPU pm_metrics metrics reporting
+ */
+void mali_pm_metrics_term(struct mali_device *mdev);
+
+/**
+ * Should be called when a job is about to execute a GPU job
+ */
+void mali_pm_record_gpu_active(mali_bool is_gp);
+
+/**
+ * Should be called when a job is finished
+ */
+void mali_pm_record_gpu_idle(mali_bool is_gp);
+
+void mali_pm_reset_dvfs_utilisation(struct mali_device *mdev);
+
+void mali_pm_get_dvfs_utilisation(struct mali_device *mdev, unsigned long *total_out, unsigned long *busy_out);
+
+void mali_pm_metrics_spin_lock(void);
+
+void mali_pm_metrics_spin_unlock(void);
+#else
+void mali_pm_record_gpu_idle(mali_bool is_gp) {}
+void mali_pm_record_gpu_active(mali_bool is_gp) {}
+#endif
+#endif /* __MALI_PM_METRICS_H__ */
index 2a3008a6dd83ec973f1c3218b806126f163e5265..bf0d4135159948b5febb0997128d56a628aecb32 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2016 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.
  * 
  * 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.
index 5ca78795f5350371028047c0a2b13c9b22adb77c..36ff58ea2d9f2b672ee7ea5b1a017fe19a1385dc 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
index 68bfd50bf9ae029e7503f5bdabf83a7ece904af5..fb890a7d3ee9fa03c55f090509da98545894b2a9 100755 (executable)
@@ -15,6 +15,8 @@
 #include "regs/mali_200_regs.h"
 #include "mali_kernel_common.h"
 #include "mali_kernel_core.h"
 #include "regs/mali_200_regs.h"
 #include "mali_kernel_common.h"
 #include "mali_kernel_core.h"
+#include "mali_osk_mali.h"
+
 #if defined(CONFIG_MALI400_PROFILING)
 #include "mali_osk_profiling.h"
 #endif
 #if defined(CONFIG_MALI400_PROFILING)
 #include "mali_osk_profiling.h"
 #endif
@@ -296,6 +298,13 @@ void mali_pp_job_start(struct mali_pp_core *core, struct mali_pp_job *job, u32 s
 
        MALI_DEBUG_ASSERT_POINTER(core);
 
 
        MALI_DEBUG_ASSERT_POINTER(core);
 
+       /* Change gpu secure mode if needed. */
+       if (MALI_TRUE == mali_pp_job_is_protected_job(job) && MALI_FALSE == _mali_osk_gpu_secure_mode_is_enabled()) {
+               _mali_osk_gpu_secure_mode_enable();
+       } else if (MALI_FALSE == mali_pp_job_is_protected_job(job) && MALI_TRUE == _mali_osk_gpu_secure_mode_is_enabled()) {
+               _mali_osk_gpu_secure_mode_disable();
+       }
+
        /* Write frame registers */
 
        /*
        /* Write frame registers */
 
        /*
index 45712a30e831c5e042f20a5c1dbde31237aea3e4..76f5bd0bedf6327080d2dd6cb70b69fdc72c9060 100755 (executable)
@@ -93,6 +93,7 @@ MALI_STATIC_INLINE enum mali_interrupt_result mali_pp_get_interrupt_result(struc
        } else if (MALI200_REG_VAL_IRQ_END_OF_FRAME == rawstat_used) {
                return MALI_INTERRUPT_RESULT_SUCCESS;
        }
        } else if (MALI200_REG_VAL_IRQ_END_OF_FRAME == rawstat_used) {
                return MALI_INTERRUPT_RESULT_SUCCESS;
        }
+
        return MALI_INTERRUPT_RESULT_ERROR;
 }
 
        return MALI_INTERRUPT_RESULT_ERROR;
 }
 
index 5528360841af7f62772bbf5abe9ce59e0bbf63d6..27349c9ca8d3de1997e26a15b41d0bc59ddf9050 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2011-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2016 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.
  * 
  * 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.
index 7b9d2efa3019cd4a0f1bfa3fed0962382c025d35..d033fa331415131efffaf90557eb8eba64516d46 100755 (executable)
@@ -495,6 +495,13 @@ MALI_STATIC_INLINE mali_bool mali_pp_job_is_window_surface(
               ? MALI_TRUE : MALI_FALSE;
 }
 
               ? MALI_TRUE : MALI_FALSE;
 }
 
+MALI_STATIC_INLINE mali_bool mali_pp_job_is_protected_job(struct mali_pp_job *job)
+{
+       MALI_DEBUG_ASSERT_POINTER(job);
+       return (job->uargs.flags & _MALI_PP_JOB_FLAG_PROTECTED)
+              ? MALI_TRUE : MALI_FALSE;
+}
+
 MALI_STATIC_INLINE u32 mali_pp_job_get_perf_counter_flag(struct mali_pp_job *job)
 {
        MALI_DEBUG_ASSERT_POINTER(job);
 MALI_STATIC_INLINE u32 mali_pp_job_get_perf_counter_flag(struct mali_pp_job *job)
 {
        MALI_DEBUG_ASSERT_POINTER(job);
index 5547159db94cdddce39dad0eefa80da591d8a423..a4136ce1130e9a45b2ed7e9c31ee9739d861c2eb 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2016 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.
  * 
  * 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.
@@ -20,7 +20,7 @@
 #include "mali_group.h"
 #include <linux/wait.h>
 #include <linux/sched.h>
 #include "mali_group.h"
 #include <linux/wait.h>
 #include <linux/sched.h>
-
+#include "mali_pm_metrics.h"
 
 #if defined(CONFIG_DMA_SHARED_BUFFER)
 #include "mali_memory_dma_buf.h"
 
 #if defined(CONFIG_DMA_SHARED_BUFFER)
 #include "mali_memory_dma_buf.h"
@@ -191,7 +191,7 @@ void mali_scheduler_terminate(void)
        _mali_osk_atomic_term(&mali_job_id_autonumber);
 }
 
        _mali_osk_atomic_term(&mali_job_id_autonumber);
 }
 
-u32 mali_scheduler_job_physical_head_count(void)
+u32 mali_scheduler_job_physical_head_count(mali_bool gpu_mode_is_secure)
 {
        /*
         * Count how many physical sub jobs are present from the head of queue
 {
        /*
         * Count how many physical sub jobs are present from the head of queue
@@ -216,16 +216,23 @@ u32 mali_scheduler_job_physical_head_count(void)
                         * Remember; virtual jobs can't be queued and started
                         * at the same time, so this must be a physical job
                         */
                         * Remember; virtual jobs can't be queued and started
                         * at the same time, so this must be a physical job
                         */
-                       count += mali_pp_job_unstarted_sub_job_count(job);
-                       if (MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS <= count) {
-                               return MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS;
+                       if ((MALI_FALSE  == gpu_mode_is_secure && MALI_FALSE == mali_pp_job_is_protected_job(job))
+                           || (MALI_TRUE  == gpu_mode_is_secure && MALI_TRUE == mali_pp_job_is_protected_job(job))) {
+
+                               count += mali_pp_job_unstarted_sub_job_count(job);
+                               if (MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS <= count) {
+                                       return MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS;
+                               }
                        }
                }
        }
 
        _MALI_OSK_LIST_FOREACHENTRY(job, temp, &job_queue_pp.high_pri,
                                    struct mali_pp_job, list) {
                        }
                }
        }
 
        _MALI_OSK_LIST_FOREACHENTRY(job, temp, &job_queue_pp.high_pri,
                                    struct mali_pp_job, list) {
-               if (MALI_FALSE == mali_pp_job_is_virtual(job)) {
+               if ((MALI_FALSE == mali_pp_job_is_virtual(job))
+                   && ((MALI_FALSE  == gpu_mode_is_secure && MALI_FALSE == mali_pp_job_is_protected_job(job))
+                       || (MALI_TRUE  == gpu_mode_is_secure && MALI_TRUE == mali_pp_job_is_protected_job(job)))) {
+
                        count += mali_pp_job_unstarted_sub_job_count(job);
                        if (MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS <= count) {
                                return MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS;
                        count += mali_pp_job_unstarted_sub_job_count(job);
                        if (MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS <= count) {
                                return MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS;
@@ -238,24 +245,57 @@ u32 mali_scheduler_job_physical_head_count(void)
 
        _MALI_OSK_LIST_FOREACHENTRY(job, temp, &job_queue_pp.normal_pri,
                                    struct mali_pp_job, list) {
 
        _MALI_OSK_LIST_FOREACHENTRY(job, temp, &job_queue_pp.normal_pri,
                                    struct mali_pp_job, list) {
-               if (MALI_FALSE == mali_pp_job_is_virtual(job)) {
-                       /* any partially started is already counted */
-                       if (MALI_FALSE == mali_pp_job_has_started_sub_jobs(job)) {
-                               count += mali_pp_job_unstarted_sub_job_count(job);
-                               if (MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS <=
-                                   count) {
-                                       return MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS;
-                               }
+               if ((MALI_FALSE == mali_pp_job_is_virtual(job))
+                   && (MALI_FALSE == mali_pp_job_has_started_sub_jobs(job))
+                   && ((MALI_FALSE  == gpu_mode_is_secure && MALI_FALSE == mali_pp_job_is_protected_job(job))
+                       || (MALI_TRUE  == gpu_mode_is_secure && MALI_TRUE == mali_pp_job_is_protected_job(job)))) {
+
+                       count += mali_pp_job_unstarted_sub_job_count(job);
+                       if (MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS <= count) {
+                               return MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS;
                        }
                } else {
                        /* Came across a virtual job, so stop counting */
                        return count;
                }
        }
                        }
                } else {
                        /* Came across a virtual job, so stop counting */
                        return count;
                }
        }
-
        return count;
 }
 
        return count;
 }
 
+struct mali_pp_job *mali_scheduler_job_pp_next(void)
+{
+       struct mali_pp_job *job;
+       struct mali_pp_job *temp;
+
+       MALI_DEBUG_ASSERT_LOCK_HELD(mali_scheduler_lock_obj);
+
+       /* Check for partially started normal pri jobs */
+       if (!_mali_osk_list_empty(&job_queue_pp.normal_pri)) {
+               MALI_DEBUG_ASSERT(0 < job_queue_pp.depth);
+
+               job = _MALI_OSK_LIST_ENTRY(job_queue_pp.normal_pri.next,
+                                          struct mali_pp_job, list);
+
+               MALI_DEBUG_ASSERT_POINTER(job);
+
+               if (MALI_TRUE == mali_pp_job_has_started_sub_jobs(job)) {
+                       return job;
+               }
+       }
+
+       _MALI_OSK_LIST_FOREACHENTRY(job, temp, &job_queue_pp.high_pri,
+                                   struct mali_pp_job, list) {
+               return job;
+       }
+
+       _MALI_OSK_LIST_FOREACHENTRY(job, temp, &job_queue_pp.normal_pri,
+                                   struct mali_pp_job, list) {
+               return job;
+       }
+
+       return NULL;
+}
+
 mali_bool mali_scheduler_job_next_is_virtual(void)
 {
        struct mali_pp_job *job;
 mali_bool mali_scheduler_job_next_is_virtual(void)
 {
        struct mali_pp_job *job;
@@ -534,6 +574,7 @@ void mali_scheduler_complete_gp_job(struct mali_gp_job *job,
                if (mali_utilization_enabled()) {
                        mali_utilization_gp_end();
                }
                if (mali_utilization_enabled()) {
                        mali_utilization_gp_end();
                }
+               mali_pm_record_gpu_idle(MALI_TRUE);
        }
 
        mali_gp_job_delete(job);
        }
 
        mali_gp_job_delete(job);
@@ -561,6 +602,7 @@ void mali_scheduler_complete_pp_job(struct mali_pp_job *job,
                if (mali_utilization_enabled()) {
                        mali_utilization_pp_end();
                }
                if (mali_utilization_enabled()) {
                        mali_utilization_pp_end();
                }
+               mali_pm_record_gpu_idle(MALI_FALSE);
        }
 
        /* With ZRAM feature enabled, all pp jobs will be force to use deferred delete. */
        }
 
        /* With ZRAM feature enabled, all pp jobs will be force to use deferred delete. */
@@ -987,6 +1029,8 @@ static mali_bool mali_scheduler_queue_gp_job(struct mali_gp_job *job)
                mali_utilization_gp_start();
        }
 
                mali_utilization_gp_start();
        }
 
+       mali_pm_record_gpu_active(MALI_TRUE);
+
        /* Add profiling events for job enqueued */
        _mali_osk_profiling_add_event(
                MALI_PROFILING_EVENT_TYPE_SINGLE |
        /* Add profiling events for job enqueued */
        _mali_osk_profiling_add_event(
                MALI_PROFILING_EVENT_TYPE_SINGLE |
@@ -1062,8 +1106,9 @@ static mali_bool mali_scheduler_queue_pp_job(struct mali_pp_job *job)
                mali_utilization_pp_start();
        }
 
                mali_utilization_pp_start();
        }
 
-       /* Add profiling events for job enqueued */
+       mali_pm_record_gpu_active(MALI_FALSE);
 
 
+       /* Add profiling events for job enqueued */
        _mali_osk_profiling_add_event(
                MALI_PROFILING_EVENT_TYPE_SINGLE |
                MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
        _mali_osk_profiling_add_event(
                MALI_PROFILING_EVENT_TYPE_SINGLE |
                MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
index f24cf42b8a794d818923fecdb0671f9fc6dd14b7..0ab91776654ff534823018c00c121278287c0a29 100755 (executable)
@@ -60,9 +60,10 @@ MALI_STATIC_INLINE u32 mali_scheduler_job_gp_big_job_count(void)
        return job_queue_gp.big_job_num;
 }
 
        return job_queue_gp.big_job_num;
 }
 
-u32 mali_scheduler_job_physical_head_count(void);
+u32 mali_scheduler_job_physical_head_count(mali_bool gpu_mode_is_secure);
 
 mali_bool mali_scheduler_job_next_is_virtual(void);
 
 mali_bool mali_scheduler_job_next_is_virtual(void);
+struct mali_pp_job *mali_scheduler_job_pp_next(void);
 
 struct mali_gp_job *mali_scheduler_job_gp_get(void);
 struct mali_pp_job *mali_scheduler_job_pp_physical_peek(void);
 
 struct mali_gp_job *mali_scheduler_job_gp_get(void);
 struct mali_pp_job *mali_scheduler_job_pp_physical_peek(void);
index f862961d146e7ea04be6567cce783ded6c64b28c..0819c590b4d2fd6350fe73a00e8184aaa032fef2 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2014, 2016 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.
  * 
  * 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.
index e0a2805b13d3a22d7e00ab94ef2b189ff76973ab..1b409619a6398f1bc953c229ea51e144363704a9 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2016 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.
  * 
  * 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.
@@ -116,20 +116,20 @@ void mali_session_memory_tracking(_mali_osk_print_ctx *print_ctx)
                _mali_osk_ctxprintf(print_ctx, "  %-25s  %-10u  %-10u  %-15u  %-15u  %-10u  %-10u  %-10u\n",
                                    session->comm, session->pid,
                                    (atomic_read(&session->mali_mem_allocated_pages)) * _MALI_OSK_MALI_PAGE_SIZE,
                _mali_osk_ctxprintf(print_ctx, "  %-25s  %-10u  %-10u  %-15u  %-15u  %-10u  %-10u  %-10u\n",
                                    session->comm, session->pid,
                                    (atomic_read(&session->mali_mem_allocated_pages)) * _MALI_OSK_MALI_PAGE_SIZE,
-                                   session->max_mali_mem_allocated_size,
-                                   (atomic_read(&session->mali_mem_array[MALI_MEM_EXTERNAL])) * _MALI_OSK_MALI_PAGE_SIZE,
-                                   (atomic_read(&session->mali_mem_array[MALI_MEM_UMP])) * _MALI_OSK_MALI_PAGE_SIZE,
-                                   (atomic_read(&session->mali_mem_array[MALI_MEM_DMA_BUF])) * _MALI_OSK_MALI_PAGE_SIZE,
-                                   (atomic_read(&session->mali_mem_array[MALI_MEM_SWAP])) * _MALI_OSK_MALI_PAGE_SIZE
+                                   (unsigned int)session->max_mali_mem_allocated_size,
+                                   (unsigned int)((atomic_read(&session->mali_mem_array[MALI_MEM_EXTERNAL])) * _MALI_OSK_MALI_PAGE_SIZE),
+                                   (unsigned int)((atomic_read(&session->mali_mem_array[MALI_MEM_UMP])) * _MALI_OSK_MALI_PAGE_SIZE),
+                                   (unsigned int)((atomic_read(&session->mali_mem_array[MALI_MEM_DMA_BUF])) * _MALI_OSK_MALI_PAGE_SIZE),
+                                   (unsigned int)((atomic_read(&session->mali_mem_array[MALI_MEM_SWAP])) * _MALI_OSK_MALI_PAGE_SIZE)
                                   );
 #else
                _mali_osk_ctxprintf(print_ctx, "  %-25s  %-10u  %-10u  %-15u  %-15u  %-10u  %-10u  \n",
                                    session->comm, session->pid,
                                   );
 #else
                _mali_osk_ctxprintf(print_ctx, "  %-25s  %-10u  %-10u  %-15u  %-15u  %-10u  %-10u  \n",
                                    session->comm, session->pid,
-                                   (atomic_read(&session->mali_mem_allocated_pages)) * _MALI_OSK_MALI_PAGE_SIZE,
-                                   session->max_mali_mem_allocated_size,
-                                   (atomic_read(&session->mali_mem_array[MALI_MEM_EXTERNAL])) * _MALI_OSK_MALI_PAGE_SIZE,
-                                   (atomic_read(&session->mali_mem_array[MALI_MEM_UMP])) * _MALI_OSK_MALI_PAGE_SIZE,
-                                   (atomic_read(&session->mali_mem_array[MALI_MEM_DMA_BUF])) * _MALI_OSK_MALI_PAGE_SIZE
+                                   (unsigned int)((atomic_read(&session->mali_mem_allocated_pages)) * _MALI_OSK_MALI_PAGE_SIZE),
+                                   (unsigned int)session->max_mali_mem_allocated_size,
+                                   (unsigned int)((atomic_read(&session->mali_mem_array[MALI_MEM_EXTERNAL])) * _MALI_OSK_MALI_PAGE_SIZE),
+                                   (unsigned int)((atomic_read(&session->mali_mem_array[MALI_MEM_UMP])) * _MALI_OSK_MALI_PAGE_SIZE),
+                                   (unsigned int)((atomic_read(&session->mali_mem_array[MALI_MEM_DMA_BUF])) * _MALI_OSK_MALI_PAGE_SIZE)
                                   );
 #endif
        }
                                   );
 #endif
        }
index 36ac982e1df08a1ffcdb831ccc48f99a2c706f52..c76d1fef1ea7bc54f1f7e0fe14e20d4de8a1015f 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2014, 2016 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.
  * 
  * 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.
index f35394e6038466da03da371d5fd7a85bb7a48415..4dd05897b2e0c4d5c0e16aeaa936f62fa7f9a0fa 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2014, 2016 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.
  * 
  * 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.
index 178abaf43ba1ead6a3575f3ab828fd8e88175ee1..28e2e17112774eafa0653f4551f9d8f71aaafe73 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013, 2016 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.
  * 
  * 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.
index 6a62df850b2f562b96534057880443191f03183e..793875a0e7ed1f18a77300595aa7522135710052 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013, 2016 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.
  * 
  * 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.
index dccc303480026118a74e0f2ecc860f6211175574..998ff5b9bb0f0d4289a3c46e937f43cd3d0863ed 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2016 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.
  * 
  * 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.
@@ -1460,11 +1460,11 @@ void mali_timeline_debug_print_tracker(struct mali_timeline_tracker *tracker, _m
                                    is_waiting_on_timeline(tracker, MALI_TIMELINE_GP) ? "WaitGP" : " ", tracker->fence.points[0],
                                    is_waiting_on_timeline(tracker, MALI_TIMELINE_PP) ? "WaitPP" : " ", tracker->fence.points[1],
                                    is_waiting_on_timeline(tracker, MALI_TIMELINE_SOFT) ? "WaitSOFT" : " ", tracker->fence.points[2],
                                    is_waiting_on_timeline(tracker, MALI_TIMELINE_GP) ? "WaitGP" : " ", tracker->fence.points[0],
                                    is_waiting_on_timeline(tracker, MALI_TIMELINE_PP) ? "WaitPP" : " ", tracker->fence.points[1],
                                    is_waiting_on_timeline(tracker, MALI_TIMELINE_SOFT) ? "WaitSOFT" : " ", tracker->fence.points[2],
-                                   tracker->fence.sync_fd, tracker->sync_fence, tracker->job);
+                                   tracker->fence.sync_fd, (unsigned int)(uintptr_t)(tracker->sync_fence), (unsigned int)(uintptr_t)(tracker->job));
        } else {
                _mali_osk_ctxprintf(print_ctx, "TL:  %s %u %c  fd:%d  fence:(0x%08X)  job:(0x%08X)\n",
                                    tracker_type, tracker->point, state_char,
        } else {
                _mali_osk_ctxprintf(print_ctx, "TL:  %s %u %c  fd:%d  fence:(0x%08X)  job:(0x%08X)\n",
                                    tracker_type, tracker->point, state_char,
-                                   tracker->fence.sync_fd, tracker->sync_fence, tracker->job);
+                                   tracker->fence.sync_fd, (unsigned int)(uintptr_t)(tracker->sync_fence), (unsigned int)(uintptr_t)(tracker->job));
        }
 #else
        if (0 != tracker->trigger_ref_count) {
        }
 #else
        if (0 != tracker->trigger_ref_count) {
@@ -1473,11 +1473,11 @@ void mali_timeline_debug_print_tracker(struct mali_timeline_tracker *tracker, _m
                                    is_waiting_on_timeline(tracker, MALI_TIMELINE_GP) ? "WaitGP" : " ", tracker->fence.points[0],
                                    is_waiting_on_timeline(tracker, MALI_TIMELINE_PP) ? "WaitPP" : " ", tracker->fence.points[1],
                                    is_waiting_on_timeline(tracker, MALI_TIMELINE_SOFT) ? "WaitSOFT" : " ", tracker->fence.points[2],
                                    is_waiting_on_timeline(tracker, MALI_TIMELINE_GP) ? "WaitGP" : " ", tracker->fence.points[0],
                                    is_waiting_on_timeline(tracker, MALI_TIMELINE_PP) ? "WaitPP" : " ", tracker->fence.points[1],
                                    is_waiting_on_timeline(tracker, MALI_TIMELINE_SOFT) ? "WaitSOFT" : " ", tracker->fence.points[2],
-                                   tracker->job);
+                                   (unsigned int)(uintptr_t)(tracker->job));
        } else {
                _mali_osk_ctxprintf(print_ctx, "TL:  %s %u %c  job:(0x%08X)\n",
                                    tracker_type, tracker->point, state_char,
        } else {
                _mali_osk_ctxprintf(print_ctx, "TL:  %s %u %c  job:(0x%08X)\n",
                                    tracker_type, tracker->point, state_char,
-                                   tracker->job);
+                                   (unsigned int)(uintptr_t)(tracker->job));
        }
 #endif
 }
        }
 #endif
 }
index 58d83839f4fec391d8652df4cdf6cbdc6104532f..268676a6f2fabf9c63778c07b8b886e7c6b2b231 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2016 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.
  * 
  * 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.
index 3c58928dd3a2d4f188c4b5fc1f2814492199e3c3..1f5d42172c9f87d63c4958155eaeecd229a2d4fb 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2014, 2016 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.
  * 
  * 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.
index f5440ab6fc6d8c21875be6ba660a97324a51f69e..348652b4446a26b9ab1a3f7b90a4ca775111163b 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013, 2016 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.
  * 
  * 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.
index 73843f07c9905b2381f630d76cada013ea15bc04..a83252b7f8460b3d15f8371f5b43fc1a12b6884f 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013, 2016 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.
  * 
  * 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.
index 29a3822457e9b7535d216d7ad9ec3a2016359f80..6662b25b17bef82d1274375d237713553f7ca0cd 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013, 2016 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.
  * 
  * 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.
index 597685a53f3b6031f8e82cdee1dba210c9a21dec..79829b9d891e5717999d52e153900df5592e13d7 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2016 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.
  * 
  * 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.
index 54e1580fad1a9362ca4d4b8a066ecd37f1fdd715..a1a613fde3a9667af797ac1b556182aaa52ee0f5 100755 (executable)
@@ -1,5 +1,5 @@
 /**
 /**
- * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2014, 2016 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.
  * 
  * 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.
index 0732c3e56e2ad03ff47b2ac144dd486b8ffe2ad0..6828dc7b30d591030758dce5e2a795c4e70d8c1f 100755 (executable)
@@ -1,5 +1,5 @@
 /**
 /**
- * Copyright (C) 2012-2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2013, 2016 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.
  * 
  * 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.
index 4ea02fe65cb57eb4e4db0149c118acaa41d3c8e9..a2416a5724a712bfdea2f0423c6e4e97fb0b5acc 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2016 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.
  * 
  * 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.
 #define __MALI_UTGARD_H__
 
 #include "mali_osk_types.h"
 #define __MALI_UTGARD_H__
 
 #include "mali_osk_types.h"
+#ifdef CONFIG_MALI_DEVFREQ
+#include <linux/devfreq.h>
+#include "mali_pm_metrics.h"
+#ifdef CONFIG_DEVFREQ_THERMAL
+#include <linux/devfreq_cooling.h>
+#endif
+#endif
 
 #define MALI_GPU_NAME_UTGARD "mali-utgard"
 
 
 #define MALI_GPU_NAME_UTGARD "mali-utgard"
 
                void (*get_clock_info)(struct mali_gpu_clock **data);
                /* Function that get the current clock info, needed when CONFIG_MALI_DVFS enabled */
                int (*get_freq)(void);
                void (*get_clock_info)(struct mali_gpu_clock **data);
                /* Function that get the current clock info, needed when CONFIG_MALI_DVFS enabled */
                int (*get_freq)(void);
+               /* Function that init the mali gpu secure mode */
+               int (*secure_mode_init)(void);
+               /* Function that deinit the mali gpu secure mode */
+               void (*secure_mode_deinit)(void);
+               /* Function that enable the mali gpu secure mode */
+               int (*secure_mode_enable)(void);
+               /* Function that disable the mali gpu secure mode */
+               int (*secure_mode_disable)(void);
+               /* ipa related interface customer need register */
+#if defined(CONFIG_MALI_DEVFREQ) && defined(CONFIG_DEVFREQ_THERMAL)
+               struct devfreq_cooling_power *gpu_cooling_ops;
+#endif
        };
 
        /**
        };
 
        /**
index e8b96e271218defb3e3ab032416d1c9c88541b13..ea781903ca793e30df4d025e3cef5346937a5201 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2016 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.
  * 
  * 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.
index 279bf8ee38a4ecc61bec95813566b8384095e530..eea6dac92dd0e2d80ba36577196c01fbb7cd119b 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2016 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.
  * 
  * 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.
@@ -18,6 +18,7 @@
  * If you do not wish to do so, delete this exception statement from your version.
  */
 
  * If you do not wish to do so, delete this exception statement from your version.
  */
 
+
 #ifndef _MALI_UTGARD_PROFILING_EVENTS_H_
 #define _MALI_UTGARD_PROFILING_EVENTS_H_
 
 #ifndef _MALI_UTGARD_PROFILING_EVENTS_H_
 #define _MALI_UTGARD_PROFILING_EVENTS_H_
 
index b922187a0b88b6ea6d43c59e11342085975458aa..c82d8b1557b6ee8652981aa8e24f075dba9fe2c6 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013, 2015-2016 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.
  * 
  * 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.
index 071585b34c95331949f695305fc1c11400a44492..a3ac3a51711d3c83e633b0fcc6b2fa504ddbfa39 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2016 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.
  * 
  * 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.
@@ -283,8 +283,8 @@ typedef struct {
        _mali_uk_fence_t fence;             /**< [in] fence this job must wait on */
        u64 timeline_point_ptr;            /**< [in,out] pointer to u32: location where point on gp timeline for this job will be written */
        u32 varying_memsize;            /** < [in] size of varying memory to use deffer bind*/
        _mali_uk_fence_t fence;             /**< [in] fence this job must wait on */
        u64 timeline_point_ptr;            /**< [in,out] pointer to u32: location where point on gp timeline for this job will be written */
        u32 varying_memsize;            /** < [in] size of varying memory to use deffer bind*/
-       u32 varying_alloc_num;
-       u64 varying_alloc_list;         /** < [in] memory hanlde list of varying buffer to use deffer bind */
+       u32 deferred_mem_num;
+       u64 deferred_mem_list;         /** < [in] memory hanlde list of varying buffer to use deffer bind */
 } _mali_uk_gp_start_job_s;
 
 #define _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE (1<<0) /**< Enable performance counter SRC0 for a job */
 } _mali_uk_gp_start_job_s;
 
 #define _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE (1<<0) /**< Enable performance counter SRC0 for a job */
@@ -324,6 +324,7 @@ typedef struct {
 /** Flag for _mali_uk_pp_start_job_s */
 #define _MALI_PP_JOB_FLAG_NO_NOTIFICATION (1<<0)
 #define _MALI_PP_JOB_FLAG_IS_WINDOW_SURFACE (1<<1)
 /** Flag for _mali_uk_pp_start_job_s */
 #define _MALI_PP_JOB_FLAG_NO_NOTIFICATION (1<<0)
 #define _MALI_PP_JOB_FLAG_IS_WINDOW_SURFACE (1<<1)
+#define _MALI_PP_JOB_FLAG_PROTECTED (1<<2)
 
 /** @defgroup _mali_uk_ppstartjob_s Fragment Processor Start Job
  * @{ */
 
 /** @defgroup _mali_uk_ppstartjob_s Fragment Processor Start Job
  * @{ */
@@ -664,7 +665,7 @@ typedef struct {
  * The 16bit integer is stored twice in a 32bit integer
  * For example, for version 1 the value would be 0x00010001
  */
  * The 16bit integer is stored twice in a 32bit integer
  * For example, for version 1 the value would be 0x00010001
  */
-#define _MALI_API_VERSION 850
+#define _MALI_API_VERSION 900
 #define _MALI_UK_API_VERSION _MAKE_VERSION_ID(_MALI_API_VERSION)
 
 /**
 #define _MALI_UK_API_VERSION _MAKE_VERSION_ID(_MALI_API_VERSION)
 
 /**
@@ -770,6 +771,7 @@ typedef struct {
 #define _MALI_MEMORY_ALLOCATE_NO_BIND_GPU (1<<5) /*Not map to GPU when allocate, must call bind later*/
 #define _MALI_MEMORY_ALLOCATE_SWAPPABLE   (1<<6) /* Allocate swappale memory. */
 #define _MALI_MEMORY_ALLOCATE_DEFER_BIND (1<<7) /*Not map to GPU when allocate, must call bind later*/
 #define _MALI_MEMORY_ALLOCATE_NO_BIND_GPU (1<<5) /*Not map to GPU when allocate, must call bind later*/
 #define _MALI_MEMORY_ALLOCATE_SWAPPABLE   (1<<6) /* Allocate swappale memory. */
 #define _MALI_MEMORY_ALLOCATE_DEFER_BIND (1<<7) /*Not map to GPU when allocate, must call bind later*/
+#define _MALI_MEMORY_ALLOCATE_SECURE (1<<8) /* Allocate secure memory. */
 
 
 typedef struct {
 
 
 typedef struct {
@@ -779,6 +781,7 @@ typedef struct {
        u32 psize;                                        /**< [in] physical size of the allocation */
        u32 flags;
        u64 backend_handle;                               /**< [out] backend handle */
        u32 psize;                                        /**< [in] physical size of the allocation */
        u32 flags;
        u64 backend_handle;                               /**< [out] backend handle */
+       s32 secure_shared_fd;                           /** < [in] the mem handle for secure mem */
        struct {
                /* buffer types*/
                /* CPU read/write info*/
        struct {
                /* buffer types*/
                /* CPU read/write info*/
index c88c992e859b81b97ce4648909271c628af3fd86..264555dda2cf2acbd6aae94dcde6ba8aabfb0234 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2013, 2016 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.
  * 
  * This program is free software and is provided to you under the terms of the GNU General Public License version 2
  * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
diff --git a/drivers/gpu/arm/mali400/mali/linux/mali_devfreq.c b/drivers/gpu/arm/mali400/mali/linux/mali_devfreq.c
new file mode 100644 (file)
index 0000000..0b0ba14
--- /dev/null
@@ -0,0 +1,310 @@
+/*
+ * Copyright (C) 2011-2016 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_osk_mali.h"
+#include "mali_kernel_common.h"
+
+#include <linux/clk.h>
+#include <linux/devfreq.h>
+#include <linux/regulator/consumer.h>
+#include <linux/regulator/driver.h>
+#ifdef CONFIG_DEVFREQ_THERMAL
+#include <linux/devfreq_cooling.h>
+#endif
+
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)
+#include <linux/pm_opp.h>
+#else /* Linux >= 3.13 */
+/* In 3.13 the OPP include header file, types, and functions were all
+ * renamed. Use the old filename for the include, and define the new names to
+ * the old, when an old kernel is detected.
+ */
+#include <linux/opp.h>
+#define dev_pm_opp opp
+#define dev_pm_opp_get_voltage opp_get_voltage
+#define dev_pm_opp_get_opp_count opp_get_opp_count
+#define dev_pm_opp_find_freq_ceil opp_find_freq_ceil
+#endif /* Linux >= 3.13 */
+
+#include "mali_pm_metrics.h"
+
+static int
+mali_devfreq_target(struct device *dev, unsigned long *target_freq, u32 flags)
+{
+       struct mali_device *mdev = dev_get_drvdata(dev);
+       struct dev_pm_opp *opp;
+       unsigned long freq = 0;
+       unsigned long voltage;
+       int err;
+
+       freq = *target_freq;
+
+       rcu_read_lock();
+       opp = devfreq_recommended_opp(dev, &freq, flags);
+       voltage = dev_pm_opp_get_voltage(opp);
+       rcu_read_unlock();
+       if (IS_ERR_OR_NULL(opp)) {
+               MALI_PRINT_ERROR(("Failed to get opp (%ld)\n", PTR_ERR(opp)));
+               return PTR_ERR(opp);
+       }
+
+       MALI_DEBUG_PRINT(2, ("mali_devfreq_target:set_freq = %lld flags = 0x%x\n", freq, flags));
+       /*
+        * Only update if there is a change of frequency
+        */
+       if (mdev->current_freq == freq) {
+               *target_freq = freq;
+               mali_pm_reset_dvfs_utilisation(mdev);
+               return 0;
+       }
+
+#ifdef CONFIG_REGULATOR
+       if (mdev->regulator && mdev->current_voltage != voltage
+           && mdev->current_freq < freq) {
+               err = regulator_set_voltage(mdev->regulator, voltage, voltage);
+               if (err) {
+                       MALI_PRINT_ERROR(("Failed to increase voltage (%d)\n", err));
+                       return err;
+               }
+       }
+#endif
+
+       err = clk_set_rate(mdev->clock, freq);
+       if (err) {
+               MALI_PRINT_ERROR(("Failed to set clock %lu (target %lu)\n", freq, *target_freq));
+               return err;
+       }
+
+#ifdef CONFIG_REGULATOR
+       if (mdev->regulator && mdev->current_voltage != voltage
+           && mdev->current_freq > freq) {
+               err = regulator_set_voltage(mdev->regulator, voltage, voltage);
+               if (err) {
+                       MALI_PRINT_ERROR(("Failed to decrease voltage (%d)\n", err));
+                       return err;
+               }
+       }
+#endif
+
+       *target_freq = freq;
+       mdev->current_voltage = voltage;
+       mdev->current_freq = freq;
+
+       mali_pm_reset_dvfs_utilisation(mdev);
+
+       return err;
+}
+
+static int
+mali_devfreq_cur_freq(struct device *dev, unsigned long *freq)
+{
+       struct mali_device *mdev = dev_get_drvdata(dev);
+
+       *freq = mdev->current_freq;
+
+       MALI_DEBUG_PRINT(2, ("mali_devfreq_cur_freq: freq = %d \n", *freq));
+       return 0;
+}
+
+static int
+mali_devfreq_status(struct device *dev, struct devfreq_dev_status *stat)
+{
+       struct mali_device *mdev = dev_get_drvdata(dev);
+
+       stat->current_frequency = mdev->current_freq;
+
+       mali_pm_get_dvfs_utilisation(mdev,
+                                    &stat->total_time, &stat->busy_time);
+
+       stat->private_data = NULL;
+
+#ifdef CONFIG_DEVFREQ_THERMAL
+       memcpy(&mdev->devfreq->last_status, stat, sizeof(*stat));
+#endif
+
+       return 0;
+}
+
+/* setup platform specific opp in platform.c*/
+int __weak setup_opps(void)
+{
+       return 0;
+}
+
+/* term platform specific opp in platform.c*/
+int __weak term_opps(struct device *dev)
+{
+       return 0;
+}
+
+static int mali_devfreq_init_freq_table(struct mali_device *mdev,
+                                       struct devfreq_dev_profile *dp)
+{
+       int err, count;
+       int i = 0;
+       unsigned long freq = 0;
+       struct dev_pm_opp *opp;
+
+       err = setup_opps();
+       if (err)
+               return err;
+
+       rcu_read_lock();
+       count = dev_pm_opp_get_opp_count(mdev->dev);
+       if (count < 0) {
+               rcu_read_unlock();
+               return count;
+       }
+       rcu_read_unlock();
+
+       MALI_DEBUG_PRINT(2, ("mali devfreq table count %d\n", count));
+
+       dp->freq_table = kmalloc_array(count, sizeof(dp->freq_table[0]),
+                                      GFP_KERNEL);
+       if (!dp->freq_table)
+               return -ENOMEM;
+
+       rcu_read_lock();
+       for (i = 0; i < count; i++, freq++) {
+               opp = dev_pm_opp_find_freq_ceil(mdev->dev, &freq);
+               if (IS_ERR(opp))
+                       break;
+
+               dp->freq_table[i] = freq;
+               MALI_DEBUG_PRINT(2, ("mali devfreq table array[%d] = %d\n", i, freq));
+       }
+       rcu_read_unlock();
+
+       if (count != i)
+               MALI_PRINT_ERROR(("Unable to enumerate all OPPs (%d!=%d)\n",
+                                 count, i));
+
+       dp->max_state = i;
+
+       return 0;
+}
+
+static void mali_devfreq_term_freq_table(struct mali_device *mdev)
+{
+       struct devfreq_dev_profile *dp = mdev->devfreq->profile;
+
+       kfree(dp->freq_table);
+       term_opps(mdev->dev);
+}
+
+static void mali_devfreq_exit(struct device *dev)
+{
+       struct mali_device *mdev = dev_get_drvdata(dev);
+
+       mali_devfreq_term_freq_table(mdev);
+}
+
+int mali_devfreq_init(struct mali_device *mdev)
+{
+#ifdef CONFIG_DEVFREQ_THERMAL
+       struct devfreq_cooling_power *callbacks = NULL;
+       _mali_osk_device_data data;
+#endif
+       struct devfreq_dev_profile *dp;
+       int err;
+
+       MALI_DEBUG_PRINT(2, ("Init Mali devfreq\n"));
+
+       if (!mdev->clock)
+               return -ENODEV;
+
+       mdev->current_freq = clk_get_rate(mdev->clock);
+
+       dp = &mdev->devfreq_profile;
+
+       dp->initial_freq = mdev->current_freq;
+       dp->polling_ms = 100;
+       dp->target = mali_devfreq_target;
+       dp->get_dev_status = mali_devfreq_status;
+       dp->get_cur_freq = mali_devfreq_cur_freq;
+       dp->exit = mali_devfreq_exit;
+
+       if (mali_devfreq_init_freq_table(mdev, dp))
+               return -EFAULT;
+
+       mdev->devfreq = devfreq_add_device(mdev->dev, dp,
+                                          "simple_ondemand", NULL);
+       if (IS_ERR(mdev->devfreq)) {
+               mali_devfreq_term_freq_table(mdev);
+               return PTR_ERR(mdev->devfreq);
+       }
+
+       err = devfreq_register_opp_notifier(mdev->dev, mdev->devfreq);
+       if (err) {
+               MALI_PRINT_ERROR(("Failed to register OPP notifier (%d)\n", err));
+               goto opp_notifier_failed;
+       }
+
+#ifdef CONFIG_DEVFREQ_THERMAL
+       /* Initilization last_status it will be used when first power allocate called */
+       mdev->devfreq->last_status.current_frequency = mdev->current_freq;
+
+       if (_MALI_OSK_ERR_OK == _mali_osk_device_data_get(&data)) {
+               if (NULL != data.gpu_cooling_ops) {
+                       callbacks = data.gpu_cooling_ops;
+                       MALI_DEBUG_PRINT(2, ("Mali GPU Thermal: Callback handler installed \n"));
+               }
+       }
+
+       if (callbacks) {
+               mdev->devfreq_cooling = of_devfreq_cooling_register_power(
+                                               mdev->dev->of_node,
+                                               mdev->devfreq,
+                                               callbacks);
+               if (IS_ERR_OR_NULL(mdev->devfreq_cooling)) {
+                       err = PTR_ERR(mdev->devfreq_cooling);
+                       MALI_PRINT_ERROR(("Failed to register cooling device (%d)\n", err));
+                       goto cooling_failed;
+               } else {
+                       MALI_DEBUG_PRINT(2, ("Mali GPU Thermal Cooling installed \n"));
+               }
+       }
+#endif
+
+       return 0;
+
+#ifdef CONFIG_DEVFREQ_THERMAL
+cooling_failed:
+       devfreq_unregister_opp_notifier(mdev->dev, mdev->devfreq);
+#endif /* CONFIG_DEVFREQ_THERMAL */
+opp_notifier_failed:
+       err = devfreq_remove_device(mdev->devfreq);
+       if (err)
+               MALI_PRINT_ERROR(("Failed to terminate devfreq (%d)\n", err));
+       else
+               mdev->devfreq = NULL;
+
+       return err;
+}
+
+void mali_devfreq_term(struct mali_device *mdev)
+{
+       int err;
+
+       MALI_DEBUG_PRINT(2, ("Term Mali devfreq\n"));
+
+#ifdef CONFIG_DEVFREQ_THERMAL
+       devfreq_cooling_unregister(mdev->devfreq_cooling);
+#endif
+
+       devfreq_unregister_opp_notifier(mdev->dev, mdev->devfreq);
+
+       err = devfreq_remove_device(mdev->devfreq);
+       if (err)
+               MALI_PRINT_ERROR(("Failed to terminate devfreq (%d)\n", err));
+       else
+               mdev->devfreq = NULL;
+}
diff --git a/drivers/gpu/arm/mali400/mali/linux/mali_devfreq.h b/drivers/gpu/arm/mali400/mali/linux/mali_devfreq.h
new file mode 100644 (file)
index 0000000..faf84f2
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2011-2016 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_DEVFREQ_H_
+#define _MALI_DEVFREQ_H_
+
+int mali_devfreq_init(struct mali_device *mdev);
+
+void mali_devfreq_term(struct mali_device *mdev);
+
+#endif
index 37076a2eaf671b80c7541bb2b030a1e30d90ae68..cb2f702f15ae4cb377292707fe790e62e104e4d3 100755 (executable)
@@ -1,5 +1,5 @@
 /**
 /**
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
index ae4fad8d7588cc8fd6e4284236e46691cf14c024..412ea80b637fa91af7f94cc50d000e8e674f3da3 100755 (executable)
@@ -1,5 +1,5 @@
 /**
 /**
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2016 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.
  * 
  * 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.
@@ -28,6 +28,8 @@
 #include <linux/miscdevice.h>
 #include <linux/bug.h>
 #include <linux/of.h>
 #include <linux/miscdevice.h>
 #include <linux/bug.h>
 #include <linux/of.h>
+#include <linux/clk.h>
+#include <linux/regulator/consumer.h>
 
 #include <linux/mali/mali_utgard.h>
 #include "mali_kernel_common.h"
 
 #include <linux/mali/mali_utgard.h>
 #include "mali_kernel_common.h"
@@ -67,6 +69,29 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(mali_hw_counter);
 EXPORT_TRACEPOINT_SYMBOL_GPL(mali_sw_counters);
 #endif /* CONFIG_TRACEPOINTS */
 
 EXPORT_TRACEPOINT_SYMBOL_GPL(mali_sw_counters);
 #endif /* CONFIG_TRACEPOINTS */
 
+#ifdef CONFIG_MALI_DEVFREQ
+#include "mali_devfreq.h"
+#include "mali_osk_mali.h"
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)
+#include <linux/pm_opp.h>
+#else
+/* In 3.13 the OPP include header file, types, and functions were all
+ * renamed. Use the old filename for the include, and define the new names to
+ * the old, when an old kernel is detected.
+ */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)
+#include <linux/pm_opp.h>
+#else
+#include <linux/opp.h>
+#endif /* Linux >= 3.13*/
+#define dev_pm_opp_of_add_table of_init_opp_table
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
+#define dev_pm_opp_of_remove_table of_free_opp_table
+#endif /* Linux >= 3.19 */
+#endif /* Linux >= 4.4.0 */
+#endif
+
 /* from the __malidrv_build_info.c file that is generated during build */
 extern const char *__malidrv_build_info(void);
 
 /* from the __malidrv_build_info.c file that is generated during build */
 extern const char *__malidrv_build_info(void);
 
@@ -476,9 +501,24 @@ void mali_module_exit(void)
        MALI_PRINT(("Mali device driver unloaded\n"));
 }
 
        MALI_PRINT(("Mali device driver unloaded\n"));
 }
 
+#ifdef CONFIG_MALI_DEVFREQ
+struct mali_device *mali_device_alloc(void)
+{
+       return kzalloc(sizeof(struct mali_device), GFP_KERNEL);
+}
+
+void mali_device_free(struct mali_device *mdev)
+{
+       kfree(mdev);
+}
+#endif
+
 static int mali_probe(struct platform_device *pdev)
 {
        int err;
 static int mali_probe(struct platform_device *pdev)
 {
        int err;
+#ifdef CONFIG_MALI_DEVFREQ
+       struct mali_device *mdev;
+#endif
 
        MALI_DEBUG_PRINT(2, ("mali_probe(): Called for platform device %s\n", pdev->name));
 
 
        MALI_DEBUG_PRINT(2, ("mali_probe(): Called for platform device %s\n", pdev->name));
 
@@ -508,10 +548,66 @@ static int mali_probe(struct platform_device *pdev)
        err = mali_platform_device_init(mali_platform_device);
        if (0 != err) {
                MALI_PRINT_ERROR(("mali_probe(): Failed to initialize platform device."));
        err = mali_platform_device_init(mali_platform_device);
        if (0 != err) {
                MALI_PRINT_ERROR(("mali_probe(): Failed to initialize platform device."));
+               mali_platform_device = NULL;
                return -EFAULT;
        }
 #endif
 
                return -EFAULT;
        }
 #endif
 
+#ifdef CONFIG_MALI_DEVFREQ
+       mdev = mali_device_alloc();
+       if (!mdev) {
+               MALI_PRINT_ERROR(("Can't allocate mali device private data\n"));
+               return -ENOMEM;
+       }
+
+       mdev->dev = &pdev->dev;
+       dev_set_drvdata(mdev->dev, mdev);
+
+       /*Initilization clock and regulator*/
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)) && defined(CONFIG_OF) \
+                        && defined(CONFIG_REGULATOR)
+       mdev->regulator = regulator_get_optional(mdev->dev, "mali");
+       if (IS_ERR_OR_NULL(mdev->regulator)) {
+               MALI_DEBUG_PRINT(2, ("Continuing without Mali regulator control\n"));
+               mdev->regulator = NULL;
+               /* Allow probe to continue without regulator */
+       }
+#endif /* LINUX_VERSION_CODE >= 3, 12, 0 */
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)) && defined(CONFIG_OF) \
+                        && defined(CONFIG_PM_OPP)
+       /* Register the OPPs if they are available in device tree */
+       if (dev_pm_opp_of_add_table(mdev->dev) < 0)
+               MALI_DEBUG_PRINT(3, ("OPP table not found\n"));
+#endif
+
+       /* Need to name the gpu clock "clk_mali" in the device tree */
+       mdev->clock = clk_get(mdev->dev, "clk_mali");
+       if (IS_ERR_OR_NULL(mdev->clock)) {
+               MALI_DEBUG_PRINT(2, ("Continuing without Mali clock control\n"));
+               mdev->clock = NULL;
+               /* Allow probe to continue without clock. */
+       } else {
+               err = clk_prepare_enable(mdev->clock);
+               if (err) {
+                       MALI_PRINT_ERROR(("Failed to prepare and enable clock (%d)\n", err));
+                       goto clock_prepare_failed;
+               }
+       }
+
+       /* initilize pm metrics related */
+       if (mali_pm_metrics_init(mdev) < 0) {
+               MALI_DEBUG_PRINT(2, ("mali pm metrics init failed\n"));
+               goto pm_metrics_init_failed;
+       }
+
+       if (mali_devfreq_init(mdev) < 0) {
+               MALI_DEBUG_PRINT(2, ("mali devfreq init failed\n"));
+               goto devfreq_init_failed;
+       }
+#endif
+
+
        if (_MALI_OSK_ERR_OK == _mali_osk_wq_init()) {
                /* Initialize the Mali GPU HW specified by pdev */
                if (_MALI_OSK_ERR_OK == mali_initialize_subsystems()) {
        if (_MALI_OSK_ERR_OK == _mali_osk_wq_init()) {
                /* Initialize the Mali GPU HW specified by pdev */
                if (_MALI_OSK_ERR_OK == mali_initialize_subsystems()) {
@@ -539,17 +635,67 @@ static int mali_probe(struct platform_device *pdev)
                _mali_osk_wq_term();
        }
 
                _mali_osk_wq_term();
        }
 
+#ifdef CONFIG_MALI_DEVFREQ
+       mali_devfreq_term(mdev);
+devfreq_init_failed:
+       mali_pm_metrics_term(mdev);
+pm_metrics_init_failed:
+       clk_disable_unprepare(mdev->clock);
+clock_prepare_failed:
+       clk_put(mdev->clock);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) && defined(CONFIG_OF) \
+                        && defined(CONFIG_PM_OPP)
+       dev_pm_opp_of_remove_table(mdev->dev);
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)) && defined(CONFIG_OF) \
+                        && defined(CONFIG_REGULATOR)
+       regulator_put(mdev->regulator);
+#endif /* LINUX_VERSION_CODE >= 3, 12, 0 */
+       mali_device_free(mdev);
+#endif
+
+#ifdef CONFIG_MALI_DT
+       mali_platform_device_deinit(mali_platform_device);
+#endif
        mali_platform_device = NULL;
        return -EFAULT;
 }
 
 static int mali_remove(struct platform_device *pdev)
 {
        mali_platform_device = NULL;
        return -EFAULT;
 }
 
 static int mali_remove(struct platform_device *pdev)
 {
+#ifdef CONFIG_MALI_DEVFREQ
+       struct mali_device *mdev = dev_get_drvdata(&pdev->dev);
+#endif
+
        MALI_DEBUG_PRINT(2, ("mali_remove() called for platform device %s\n", pdev->name));
        mali_sysfs_unregister();
        mali_miscdevice_unregister();
        mali_terminate_subsystems();
        _mali_osk_wq_term();
        MALI_DEBUG_PRINT(2, ("mali_remove() called for platform device %s\n", pdev->name));
        mali_sysfs_unregister();
        mali_miscdevice_unregister();
        mali_terminate_subsystems();
        _mali_osk_wq_term();
+
+#ifdef CONFIG_MALI_DEVFREQ
+       mali_devfreq_term(mdev);
+
+       mali_pm_metrics_term(mdev);
+
+       if (mdev->clock) {
+               clk_disable_unprepare(mdev->clock);
+               clk_put(mdev->clock);
+               mdev->clock = NULL;
+       }
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) && defined(CONFIG_OF) \
+                        && defined(CONFIG_PM_OPP)
+       dev_pm_opp_of_remove_table(mdev->dev);
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)) && defined(CONFIG_OF) \
+                        && defined(CONFIG_REGULATOR)
+       regulator_put(mdev->regulator);
+#endif /* LINUX_VERSION_CODE >= 3, 12, 0 */
+       mali_device_free(mdev);
+#endif
+
 #ifdef CONFIG_MALI_DT
        mali_platform_device_deinit(mali_platform_device);
 #endif
 #ifdef CONFIG_MALI_DT
        mali_platform_device_deinit(mali_platform_device);
 #endif
@@ -581,6 +727,17 @@ static void mali_miscdevice_unregister(void)
 
 static int mali_driver_suspend_scheduler(struct device *dev)
 {
 
 static int mali_driver_suspend_scheduler(struct device *dev)
 {
+#ifdef CONFIG_MALI_DEVFREQ
+       struct mali_device *mdev = dev_get_drvdata(dev);
+       if (!mdev)
+               return -ENODEV;
+#endif
+
+#if defined(CONFIG_MALI_DEVFREQ) && \
+                (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
+       devfreq_suspend_device(mdev->devfreq);
+#endif
+
        mali_pm_os_suspend(MALI_TRUE);
        /* Tracing the frequency and voltage after mali is suspended */
        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
        mali_pm_os_suspend(MALI_TRUE);
        /* Tracing the frequency and voltage after mali is suspended */
        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
@@ -594,6 +751,12 @@ static int mali_driver_suspend_scheduler(struct device *dev)
 
 static int mali_driver_resume_scheduler(struct device *dev)
 {
 
 static int mali_driver_resume_scheduler(struct device *dev)
 {
+#ifdef CONFIG_MALI_DEVFREQ
+       struct mali_device *mdev = dev_get_drvdata(dev);
+       if (!mdev)
+               return -ENODEV;
+#endif
+
        /* Tracing the frequency and voltage after mali is resumed */
 #if defined(CONFIG_MALI400_PROFILING) && defined(CONFIG_MALI_DVFS)
        /* Just call mali_get_current_gpu_clk_item() once,to record current clk info.*/
        /* Tracing the frequency and voltage after mali is resumed */
 #if defined(CONFIG_MALI400_PROFILING) && defined(CONFIG_MALI_DVFS)
        /* Just call mali_get_current_gpu_clk_item() once,to record current clk info.*/
@@ -609,12 +772,24 @@ static int mali_driver_resume_scheduler(struct device *dev)
                                      0, 0, 0);
 #endif
        mali_pm_os_resume();
                                      0, 0, 0);
 #endif
        mali_pm_os_resume();
+
+#if defined(CONFIG_MALI_DEVFREQ) && \
+                (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
+       devfreq_resume_device(mdev->devfreq);
+#endif
+
        return 0;
 }
 
 #ifdef CONFIG_PM_RUNTIME
 static int mali_driver_runtime_suspend(struct device *dev)
 {
        return 0;
 }
 
 #ifdef CONFIG_PM_RUNTIME
 static int mali_driver_runtime_suspend(struct device *dev)
 {
+#ifdef CONFIG_MALI_DEVFREQ
+       struct mali_device *mdev = dev_get_drvdata(dev);
+       if (!mdev)
+               return -ENODEV;
+#endif
+
        if (MALI_TRUE == mali_pm_runtime_suspend()) {
                /* Tracing the frequency and voltage after mali is suspended */
                _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
        if (MALI_TRUE == mali_pm_runtime_suspend()) {
                /* Tracing the frequency and voltage after mali is suspended */
                _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
@@ -624,6 +799,12 @@ static int mali_driver_runtime_suspend(struct device *dev)
                                              0,
                                              0, 0, 0);
 
                                              0,
                                              0, 0, 0);
 
+#if defined(CONFIG_MALI_DEVFREQ) && \
+                (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
+               MALI_DEBUG_PRINT(4, ("devfreq_suspend_device: stop devfreq monitor\n"));
+               devfreq_suspend_device(mdev->devfreq);
+#endif
+
                return 0;
        } else {
                return -EBUSY;
                return 0;
        } else {
                return -EBUSY;
@@ -632,6 +813,12 @@ static int mali_driver_runtime_suspend(struct device *dev)
 
 static int mali_driver_runtime_resume(struct device *dev)
 {
 
 static int mali_driver_runtime_resume(struct device *dev)
 {
+#ifdef CONFIG_MALI_DEVFREQ
+       struct mali_device *mdev = dev_get_drvdata(dev);
+       if (!mdev)
+               return -ENODEV;
+#endif
+
        /* Tracing the frequency and voltage after mali is resumed */
 #if defined(CONFIG_MALI400_PROFILING) && defined(CONFIG_MALI_DVFS)
        /* Just call mali_get_current_gpu_clk_item() once,to record current clk info.*/
        /* Tracing the frequency and voltage after mali is resumed */
 #if defined(CONFIG_MALI400_PROFILING) && defined(CONFIG_MALI_DVFS)
        /* Just call mali_get_current_gpu_clk_item() once,to record current clk info.*/
@@ -648,6 +835,12 @@ static int mali_driver_runtime_resume(struct device *dev)
 #endif
 
        mali_pm_runtime_resume();
 #endif
 
        mali_pm_runtime_resume();
+
+#if defined(CONFIG_MALI_DEVFREQ) && \
+                (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
+       MALI_DEBUG_PRINT(4, ("devfreq_resume_device: start devfreq monitor\n"));
+       devfreq_resume_device(mdev->devfreq);
+#endif
        return 0;
 }
 
        return 0;
 }
 
index 4f06ca14bf48fb52e58bfad78c74ac804aac9ab4..3b50af6056678aa27e44d277c1cd9fd6b8b9bc92 100755 (executable)
@@ -1,5 +1,5 @@
 /**
 /**
- * Copyright (C) 2011-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2016 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.
  * 
  * 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.
index a36a0cea997278561a526a239d557955405d493e..9dad7f24ccadfbcde2fcecfedca9ed6890bd7218 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2011-2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2013, 2016 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.
  * 
  * 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.
index c6cd2bfb721790b2327713fa615fa37161364cbe..2c91ddcd82e544f0c638680c64b0ce812f12537e 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2014, 2016 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.
  * 
  * 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.
index 1e57bd6740429520e39dfceeb0c59e3c7a6f6854..95f04ed0223664f30460520bdcb39dc053e1822a 100755 (executable)
@@ -30,6 +30,9 @@
 #include "mali_memory_cow.h"
 #include "mali_memory_swap_alloc.h"
 #include "mali_memory_defer_bind.h"
 #include "mali_memory_cow.h"
 #include "mali_memory_swap_alloc.h"
 #include "mali_memory_defer_bind.h"
+#if defined(CONFIG_DMA_SHARED_BUFFER)
+#include "mali_memory_secure.h"
+#endif
 
 extern unsigned int mali_dedicated_mem_size;
 extern unsigned int mali_shared_mem_size;
 
 extern unsigned int mali_dedicated_mem_size;
 extern unsigned int mali_shared_mem_size;
@@ -121,6 +124,8 @@ static int mali_mem_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
                }
        } else {
                MALI_PRINT_ERROR(("Mali vma fault! It never happen, indicating some logic errors in caller.\n"));
                }
        } else {
                MALI_PRINT_ERROR(("Mali vma fault! It never happen, indicating some logic errors in caller.\n"));
+               /*NOT support yet or OOM*/
+               return VM_FAULT_OOM;
        }
        return VM_FAULT_NOPAGE;
 }
        }
        return VM_FAULT_NOPAGE;
 }
@@ -244,6 +249,13 @@ int mali_mmap(struct file *filp, struct vm_area_struct *vma)
                        (MALI_MEM_BACKEND_FLAG_SWAP_COWED == (mem_bkend->flags & MALI_MEM_BACKEND_FLAG_SWAP_COWED)))) {
                /*For swappable memory, CPU page table will be created by page fault handler. */
                ret = 0;
                        (MALI_MEM_BACKEND_FLAG_SWAP_COWED == (mem_bkend->flags & MALI_MEM_BACKEND_FLAG_SWAP_COWED)))) {
                /*For swappable memory, CPU page table will be created by page fault handler. */
                ret = 0;
+       } else if (mem_bkend->type == MALI_MEM_SECURE) {
+#if defined(CONFIG_DMA_SHARED_BUFFER)
+               ret = mali_mem_secure_cpu_map(mem_bkend, vma);
+#else
+               MALI_DEBUG_PRINT(1, ("DMA not supported for mali secure memory\n"));
+               return -EFAULT;
+#endif
        } else {
                /* Not support yet*/
                MALI_DEBUG_PRINT_ERROR(("Invalid type of backend memory! \n"));
        } else {
                /* Not support yet*/
                MALI_DEBUG_PRINT_ERROR(("Invalid type of backend memory! \n"));
index 3140c6c98d2c760071d8019f59ced8d43bd8544b..e5e4f66ec02e4553203a1adad5eb627776051dc4 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2016 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.
  * 
  * 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.
index 453ddda3080f5fe5e778cb3912f871be940312a8..deb2ee84f6e599874c05a04fdb514a1917750493 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2016 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.
  * 
  * 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.
index 129434de67df2f8d3f01be5a5f1b632232d62752..3e11ef25888e35ccbf2de014a2d5875b245536e8 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2013, 2015-2016 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.
  * 
  * 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.
index 65fb38b327b88a3fc2aba971b517b5e82394dce9..0a11f4b934bee13281f92d4e02121ae4037c503a 100644 (file)
@@ -600,8 +600,8 @@ u32 mali_mem_cow_release(mali_mem_backend *mem_bkend, mali_bool is_mali_mapped)
        alloc = mem_bkend->mali_allocation;\r
        MALI_DEBUG_ASSERT_POINTER(alloc);\r
 \r
        alloc = mem_bkend->mali_allocation;\r
        MALI_DEBUG_ASSERT_POINTER(alloc);\r
 \r
-        session = alloc->session;\r
-        MALI_DEBUG_ASSERT_POINTER(session);\r
+       session = alloc->session;\r
+       MALI_DEBUG_ASSERT_POINTER(session);\r
 \r
        if (MALI_MEM_BACKEND_FLAG_SWAP_COWED != (MALI_MEM_BACKEND_FLAG_SWAP_COWED & mem_bkend->flags)) {\r
                /* Unmap the memory from the mali virtual address space. */\r
 \r
        if (MALI_MEM_BACKEND_FLAG_SWAP_COWED != (MALI_MEM_BACKEND_FLAG_SWAP_COWED & mem_bkend->flags)) {\r
                /* Unmap the memory from the mali virtual address space. */\r
index c16ec7633c0af20d9afcfc0d338197233398f9d3..9b9e834915264c177d5600828bb26a5957fc3bd8 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
 /*\r
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2016 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.
  * 
  * 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.
index 2fa5028d8342a01144e1bf5ae84efce27ffb5326..f0d1e07be544dfd8a05332420b0349ffd50fa04c 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2016 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.
  * 
  * 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.
index 859d3849e6b34c8e812ecd44b57e737258734071..37b6f6b4368062ed2ae844ed82483c163d749586 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2011-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2016 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.
  * 
  * 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.
index dcc9a7590885e2e4a754c1b5a214ad1c087f3a9a..c0097f6706f8bf7edc9a6c2be70cdc84726ca367 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2016 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.
  * 
  * 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.
index 645580b51fc98947380b9e8af6177772b2f56743..ba387b8a270fedf0f3a1298707b12ec762041922 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
 
 /*
- * Copyright (C) 2011-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2016 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.
  * 
  * 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.
index b7479940f46125813c2d8fd959f9097bf23f6e0b..178abcfae37da6cbe4eb6e9e51a65a5f838140fa 100644 (file)
@@ -31,6 +31,7 @@
 #include "mali_memory_os_alloc.h"
 #if defined(CONFIG_DMA_SHARED_BUFFER)
 #include "mali_memory_dma_buf.h"
 #include "mali_memory_os_alloc.h"
 #if defined(CONFIG_DMA_SHARED_BUFFER)
 #include "mali_memory_dma_buf.h"
+#include "mali_memory_secure.h"
 #endif
 #if defined(CONFIG_MALI400_UMP)
 #include "mali_memory_ump.h"
 #endif
 #if defined(CONFIG_MALI400_UMP)
 #include "mali_memory_ump.h"
@@ -439,6 +440,8 @@ _mali_osk_errcode_t _mali_ukk_mem_allocate(_mali_uk_alloc_mem_s *args)
        } else if (args->flags & _MALI_MEMORY_ALLOCATE_RESIZEABLE) {
                mali_allocation->type = MALI_MEM_OS;
                mali_allocation->flags |= MALI_MEM_FLAG_CAN_RESIZE;
        } else if (args->flags & _MALI_MEMORY_ALLOCATE_RESIZEABLE) {
                mali_allocation->type = MALI_MEM_OS;
                mali_allocation->flags |= MALI_MEM_FLAG_CAN_RESIZE;
+       } else if (args->flags & _MALI_MEMORY_ALLOCATE_SECURE) {
+               mali_allocation->type = MALI_MEM_SECURE;
        } else if (MALI_TRUE == mali_memory_have_dedicated_memory()) {
                mali_allocation->type = MALI_MEM_BLOCK;
        } else {
        } else if (MALI_TRUE == mali_memory_have_dedicated_memory()) {
                mali_allocation->type = MALI_MEM_BLOCK;
        } else {
@@ -495,31 +498,47 @@ _mali_osk_errcode_t _mali_ukk_mem_allocate(_mali_uk_alloc_mem_s *args)
 
                goto done;
        }
 
                goto done;
        }
-       /**
-       *allocate physical memory
-       */
+
        if (likely(mali_allocation->psize > 0)) {
 
        if (likely(mali_allocation->psize > 0)) {
 
-               if (mem_backend->type == MALI_MEM_OS) {
-                       retval = mali_mem_os_alloc_pages(&mem_backend->os_mem, mem_backend->size);
-               } else if (mem_backend->type == MALI_MEM_BLOCK) {
-                       /* try to allocated from BLOCK memory first, then try OS memory if failed.*/
-                       if (mali_mem_block_alloc(&mem_backend->block_mem, mem_backend->size)) {
-                               retval = mali_mem_os_alloc_pages(&mem_backend->os_mem, mem_backend->size);
-                               mem_backend->type = MALI_MEM_OS;
-                               mali_allocation->type = MALI_MEM_OS;
+               if (MALI_MEM_SECURE == mem_backend->type) {
+#if defined(CONFIG_DMA_SHARED_BUFFER)
+                       ret = mali_mem_secure_attach_dma_buf(&mem_backend->secure_mem, mem_backend->size, args->secure_shared_fd);
+                       if (_MALI_OSK_ERR_OK != ret) {
+                               MALI_DEBUG_PRINT(1, ("Failed to attach dma buf for secure memory! \n"));
+                               goto failed_alloc_pages;
                        }
                        }
-               } else if (MALI_MEM_SWAP == mem_backend->type) {
-                       retval = mali_mem_swap_alloc_pages(&mem_backend->swap_mem, mali_allocation->mali_vma_node.vm_node.size, &mem_backend->start_idx);
+#else
+                       ret = _MALI_OSK_ERR_UNSUPPORTED;
+                       MALI_DEBUG_PRINT(1, ("DMA not supported for mali secure memory! \n"));
+                       goto failed_alloc_pages;
+#endif
                } else {
                } else {
-                       /* ONLY support mem_os type */
-                       MALI_DEBUG_ASSERT(0);
-               }
 
 
-               if (retval) {
-                       ret = _MALI_OSK_ERR_NOMEM;
-                       MALI_DEBUG_PRINT(1, (" can't allocate enough pages! \n"));
-                       goto failed_alloc_pages;
+                       /**
+                       *allocate physical memory
+                       */
+                       if (mem_backend->type == MALI_MEM_OS) {
+                               retval = mali_mem_os_alloc_pages(&mem_backend->os_mem, mem_backend->size);
+                       } else if (mem_backend->type == MALI_MEM_BLOCK) {
+                               /* try to allocated from BLOCK memory first, then try OS memory if failed.*/
+                               if (mali_mem_block_alloc(&mem_backend->block_mem, mem_backend->size)) {
+                                       retval = mali_mem_os_alloc_pages(&mem_backend->os_mem, mem_backend->size);
+                                       mem_backend->type = MALI_MEM_OS;
+                                       mali_allocation->type = MALI_MEM_OS;
+                               }
+                       } else if (MALI_MEM_SWAP == mem_backend->type) {
+                               retval = mali_mem_swap_alloc_pages(&mem_backend->swap_mem, mali_allocation->mali_vma_node.vm_node.size, &mem_backend->start_idx);
+                       }  else {
+                               /* ONLY support mem_os type */
+                               MALI_DEBUG_ASSERT(0);
+                       }
+
+                       if (retval) {
+                               ret = _MALI_OSK_ERR_NOMEM;
+                               MALI_DEBUG_PRINT(1, (" can't allocate enough pages! \n"));
+                               goto failed_alloc_pages;
+                       }
                }
        }
 
                }
        }
 
@@ -540,6 +559,10 @@ _mali_osk_errcode_t _mali_ukk_mem_allocate(_mali_uk_alloc_mem_s *args)
                } else if (mem_backend->type == MALI_MEM_SWAP) {
                        ret = mali_mem_swap_mali_map(&mem_backend->swap_mem, session, args->gpu_vaddr,
                                                     mali_allocation->mali_mapping.properties);
                } else if (mem_backend->type == MALI_MEM_SWAP) {
                        ret = mali_mem_swap_mali_map(&mem_backend->swap_mem, session, args->gpu_vaddr,
                                                     mali_allocation->mali_mapping.properties);
+               } else if (mem_backend->type == MALI_MEM_SECURE) {
+#if defined(CONFIG_DMA_SHARED_BUFFER)
+                       ret = mali_mem_secure_mali_map(&mem_backend->secure_mem, session, args->gpu_vaddr, mali_allocation->mali_mapping.properties);
+#endif
                } else { /* unsupport type */
                        MALI_DEBUG_ASSERT(0);
                }
                } else { /* unsupport type */
                        MALI_DEBUG_ASSERT(0);
                }
@@ -551,6 +574,8 @@ done:
                atomic_add(mem_backend->os_mem.count, &session->mali_mem_allocated_pages);
        } else if (MALI_MEM_BLOCK == mem_backend->type) {
                atomic_add(mem_backend->block_mem.count, &session->mali_mem_allocated_pages);
                atomic_add(mem_backend->os_mem.count, &session->mali_mem_allocated_pages);
        } else if (MALI_MEM_BLOCK == mem_backend->type) {
                atomic_add(mem_backend->block_mem.count, &session->mali_mem_allocated_pages);
+       } else if (MALI_MEM_SECURE == mem_backend->type) {
+               atomic_add(mem_backend->secure_mem.count, &session->mali_mem_allocated_pages);
        } else {
                MALI_DEBUG_ASSERT(MALI_MEM_SWAP == mem_backend->type);
                atomic_add(mem_backend->swap_mem.count, &session->mali_mem_allocated_pages);
        } else {
                MALI_DEBUG_ASSERT(MALI_MEM_SWAP == mem_backend->type);
                atomic_add(mem_backend->swap_mem.count, &session->mali_mem_allocated_pages);
index c454b93546768853c49e9029ef2261ff322085ed..0ced28026f3f0abefc50e54770eceae9fa4c67f7 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
 /*\r
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2016 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.
  * 
  * 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.
index f9ead166c45572c1a108dcd237b07e2c5c4487d6..b92fffe0dfecbb14527cfad523c5db90e7941680 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2016 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.
  * 
  * This program is free software and is provided to you under the terms of the GNU General Public License version 2
  * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
diff --git a/drivers/gpu/arm/mali400/mali/linux/mali_memory_secure.c b/drivers/gpu/arm/mali400/mali/linux/mali_memory_secure.c
new file mode 100644 (file)
index 0000000..7856ae6
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 2010-2016 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_memory.h"
+#include "mali_memory_secure.h"
+#include "mali_osk.h"
+#include <linux/mutex.h>
+#include <linux/dma-mapping.h>
+#include <linux/dma-buf.h>
+
+_mali_osk_errcode_t mali_mem_secure_attach_dma_buf(mali_mem_secure *secure_mem, u32 size, int mem_fd)
+{
+       struct dma_buf *buf;
+       MALI_DEBUG_ASSERT_POINTER(secure_mem);
+
+       /* get dma buffer */
+       buf = dma_buf_get(mem_fd);
+       if (IS_ERR_OR_NULL(buf)) {
+               MALI_DEBUG_PRINT_ERROR(("Failed to get dma buf!\n"));
+               return _MALI_OSK_ERR_FAULT;
+       }
+
+       if (size != buf->size) {
+               MALI_DEBUG_PRINT_ERROR(("The secure mem size not match to the dma buf size!\n"));
+               goto failed_alloc_mem;
+       }
+
+       secure_mem->buf =  buf;
+       secure_mem->attachment = dma_buf_attach(secure_mem->buf, &mali_platform_device->dev);
+       if (NULL == secure_mem->attachment) {
+               MALI_DEBUG_PRINT_ERROR(("Failed to get dma buf attachment!\n"));
+               goto failed_dma_attach;
+       }
+
+       secure_mem->sgt = dma_buf_map_attachment(secure_mem->attachment, DMA_BIDIRECTIONAL);
+       if (IS_ERR_OR_NULL(secure_mem->sgt)) {
+               MALI_DEBUG_PRINT_ERROR(("Failed to map dma buf attachment\n"));
+               goto  failed_dma_map;
+       }
+
+       secure_mem->count = size / MALI_MMU_PAGE_SIZE;
+
+       return _MALI_OSK_ERR_OK;
+
+failed_dma_map:
+       dma_buf_detach(secure_mem->buf, secure_mem->attachment);
+failed_dma_attach:
+failed_alloc_mem:
+       dma_buf_put(buf);
+       return _MALI_OSK_ERR_FAULT;
+}
+
+_mali_osk_errcode_t mali_mem_secure_mali_map(mali_mem_secure *secure_mem, struct mali_session_data *session, u32 vaddr, u32 props)
+{
+       struct mali_page_directory *pagedir;
+       struct scatterlist *sg;
+       u32 virt = vaddr;
+       u32 prop = props;
+       int i;
+
+       MALI_DEBUG_ASSERT_POINTER(secure_mem);
+       MALI_DEBUG_ASSERT_POINTER(secure_mem->sgt);
+       MALI_DEBUG_ASSERT_POINTER(session);
+
+       pagedir = session->page_directory;
+
+       for_each_sg(secure_mem->sgt->sgl, sg, secure_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_DEBUG_ASSERT(0 == (phys & ~(uintptr_t)0xFFFFFFFF));
+
+               mali_mmu_pagedir_update(pagedir, virt, phys, size, prop);
+
+               MALI_DEBUG_PRINT(3, ("The secure mem physical address: 0x%x gpu virtual address: 0x%x! \n", phys, virt));
+               virt += size;
+       }
+
+       return _MALI_OSK_ERR_OK;
+}
+
+void mali_mem_secure_mali_unmap(mali_mem_allocation *alloc)
+{
+       struct mali_session_data *session;
+       MALI_DEBUG_ASSERT_POINTER(alloc);
+       session = alloc->session;
+       MALI_DEBUG_ASSERT_POINTER(session);
+
+       mali_session_memory_lock(session);
+       mali_mem_mali_map_free(session, alloc->psize, alloc->mali_vma_node.vm_node.start,
+                              alloc->flags);
+       mali_session_memory_unlock(session);
+}
+
+
+int mali_mem_secure_cpu_map(mali_mem_backend *mem_bkend, struct vm_area_struct *vma)
+{
+
+       int ret = 0;
+       struct scatterlist *sg;
+       mali_mem_secure *secure_mem = &mem_bkend->secure_mem;
+       unsigned long addr = vma->vm_start;
+       int i;
+
+       MALI_DEBUG_ASSERT(mem_bkend->type == MALI_MEM_SECURE);
+
+       for_each_sg(secure_mem->sgt->sgl, sg, secure_mem->sgt->nents, i) {
+               phys_addr_t phys;
+               dma_addr_t dev_addr;
+               u32 size, j;
+               dev_addr = sg_dma_address(sg);
+#if defined(CONFIG_ARM64) ||LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)
+               phys =  dma_to_phys(&mali_platform_device->dev, dev_addr);
+#else
+               phys = page_to_phys(pfn_to_page(dma_to_pfn(&mali_platform_device->dev, dev_addr)));
+#endif
+               size = sg_dma_len(sg);
+               MALI_DEBUG_ASSERT(0 == size % _MALI_OSK_MALI_PAGE_SIZE);
+
+               for (j = 0; j < size / _MALI_OSK_MALI_PAGE_SIZE; j++) {
+                       ret = vm_insert_pfn(vma, addr, PFN_DOWN(phys));
+
+                       if (unlikely(0 != ret)) {
+                               return -EFAULT;
+                       }
+                       addr += _MALI_OSK_MALI_PAGE_SIZE;
+                       phys += _MALI_OSK_MALI_PAGE_SIZE;
+
+                       MALI_DEBUG_PRINT(3, ("The secure mem physical address: 0x%x , cpu virtual address: 0x%x! \n", phys, addr));
+               }
+       }
+       return ret;
+}
+
+u32 mali_mem_secure_release(mali_mem_backend *mem_bkend)
+{
+       struct mali_mem_secure *mem;
+       mali_mem_allocation *alloc = mem_bkend->mali_allocation;
+       u32 free_pages_nr = 0;
+       MALI_DEBUG_ASSERT(mem_bkend->type == MALI_MEM_SECURE);
+
+       mem = &mem_bkend->secure_mem;
+       MALI_DEBUG_ASSERT_POINTER(mem->attachment);
+       MALI_DEBUG_ASSERT_POINTER(mem->buf);
+       MALI_DEBUG_ASSERT_POINTER(mem->sgt);
+       /* Unmap the memory from the mali virtual address space. */
+       mali_mem_secure_mali_unmap(alloc);
+       mutex_lock(&mem_bkend->mutex);
+       dma_buf_unmap_attachment(mem->attachment, mem->sgt, DMA_BIDIRECTIONAL);
+       dma_buf_detach(mem->buf, mem->attachment);
+       dma_buf_put(mem->buf);
+       mutex_unlock(&mem_bkend->mutex);
+
+       free_pages_nr = mem->count;
+
+       return free_pages_nr;
+}
+
+
diff --git a/drivers/gpu/arm/mali400/mali/linux/mali_memory_secure.h b/drivers/gpu/arm/mali400/mali/linux/mali_memory_secure.h
new file mode 100644 (file)
index 0000000..64f40d4
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2010, 2013, 2015 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_MEMORY_SECURE_H__
+#define __MALI_MEMORY_SECURE_H__
+
+#include "mali_session.h"
+#include "mali_memory.h"
+#include <linux/spinlock.h>
+
+#include "mali_memory_types.h"
+
+_mali_osk_errcode_t mali_mem_secure_attach_dma_buf(mali_mem_secure *secure_mem, u32 size, int mem_fd);
+
+_mali_osk_errcode_t mali_mem_secure_mali_map(mali_mem_secure *secure_mem, struct mali_session_data *session, u32 vaddr, u32 props);
+
+void mali_mem_secure_mali_unmap(mali_mem_allocation *alloc);
+
+int mali_mem_secure_cpu_map(mali_mem_backend *mem_bkend, struct vm_area_struct *vma);
+
+u32 mali_mem_secure_release(mali_mem_backend *mem_bkend);
+
+#endif /* __MALI_MEMORY_SECURE_H__ */
index a46eb198c98f35feff1cdbc4fe06118c29fefb1f..47933283680cb63a8a48b7a059293cb3817c0975 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2016 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.
  * 
  * 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.
index a393ecce3a006c8aaaf7096fdaa51ab6e37f1d23..3624d710d78b970982f09b41f5494a373e664a3a 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
 /*\r
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2016 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.
  * 
  * 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.
index 82af8fed66c95db8143ea50f3d3de0961a77a1fd..f3a825d6b8b6caba4a19a8532b76709dc90d4efd 100755 (executable)
@@ -27,6 +27,7 @@ typedef enum mali_mem_type {
        MALI_MEM_UMP,
        MALI_MEM_BLOCK,
        MALI_MEM_COW,
        MALI_MEM_UMP,
        MALI_MEM_BLOCK,
        MALI_MEM_COW,
+       MALI_MEM_SECURE,
        MALI_MEM_TYPE_MAX,
 } mali_mem_type;
 
        MALI_MEM_TYPE_MAX,
 } mali_mem_type;
 
@@ -170,6 +171,15 @@ typedef struct mali_mem_swap {
        u32 count;
 } mali_mem_swap;
 
        u32 count;
 } mali_mem_swap;
 
+typedef struct mali_mem_secure {
+#if defined(CONFIG_DMA_SHARED_BUFFER)
+       struct dma_buf *buf;
+       struct dma_buf_attachment *attachment;
+       struct sg_table *sgt;
+#endif
+       u32 count;
+} mali_mem_secure;
+
 #define MALI_MEM_BACKEND_FLAG_COWED                   (0x1)  /* COW has happen on this backend */
 #define MALI_MEM_BACKEND_FLAG_COW_CPU_NO_WRITE        (0x2)  /* This is an COW backend, mapped as not allowed cpu to write */
 #define MALI_MEM_BACKEND_FLAG_SWAP_COWED              (0x4)  /* Mark the given backend is cowed from swappable memory. */
 #define MALI_MEM_BACKEND_FLAG_COWED                   (0x1)  /* COW has happen on this backend */
 #define MALI_MEM_BACKEND_FLAG_COW_CPU_NO_WRITE        (0x2)  /* This is an COW backend, mapped as not allowed cpu to write */
 #define MALI_MEM_BACKEND_FLAG_SWAP_COWED              (0x4)  /* Mark the given backend is cowed from swappable memory. */
@@ -192,6 +202,7 @@ typedef struct mali_mem_backend {
                mali_mem_block_mem block_mem; /**< MALI_MEM_BLOCK */
                mali_mem_cow cow_mem;
                mali_mem_swap swap_mem;
                mali_mem_block_mem block_mem; /**< MALI_MEM_BLOCK */
                mali_mem_cow cow_mem;
                mali_mem_swap swap_mem;
+               mali_mem_secure secure_mem;
        };
        mali_mem_allocation *mali_allocation;
        struct mutex mutex;
        };
        mali_mem_allocation *mali_allocation;
        struct mutex mutex;
index bacadc85e47e858197bdb43ca4e65f43742fa465..e4a29930d963c55fb9e3a5f0fbd84f65c04238e4 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2016 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.
  * 
  * 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.
index 4adb70df884e4d38156854973683dce59a8c3f41..7f03a49d8732e8ce76712f7fbcf651144d9e14dc 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2011-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2016 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.
  * 
  * 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.
index bcca43c09f0bb6a5950e84cc8fea4dfffb80a4d9..d5b39a962905c29bb1940e954c38c117fc19367f 100644 (file)
@@ -25,6 +25,7 @@
 #include "mali_memory_os_alloc.h"
 #if defined(CONFIG_DMA_SHARED_BUFFER)
 #include "mali_memory_dma_buf.h"
 #include "mali_memory_os_alloc.h"
 #if defined(CONFIG_DMA_SHARED_BUFFER)
 #include "mali_memory_dma_buf.h"
+#include "mali_memory_secure.h"
 #endif
 #if defined(CONFIG_MALI400_UMP)
 #include "mali_memory_ump.h"
 #endif
 #if defined(CONFIG_MALI400_UMP)
 #include "mali_memory_ump.h"
@@ -67,7 +68,7 @@ static u32 _mali_free_allocation_mem(mali_mem_allocation *mali_alloc)
                mali_mem_unbind_ump_buf(mem_bkend);
                atomic_sub(mem_bkend->size / MALI_MMU_PAGE_SIZE, &session->mali_mem_array[mem_bkend->type]);
 #else
                mali_mem_unbind_ump_buf(mem_bkend);
                atomic_sub(mem_bkend->size / MALI_MMU_PAGE_SIZE, &session->mali_mem_array[mem_bkend->type]);
 #else
-               MALI_DEBUG_PRINT(2, ("UMP not supported\n"));
+               MALI_DEBUG_PRINT(1, ("UMP not supported\n"));
 #endif
                break;
        case MALI_MEM_DMA_BUF:
 #endif
                break;
        case MALI_MEM_DMA_BUF:
@@ -75,7 +76,7 @@ static u32 _mali_free_allocation_mem(mali_mem_allocation *mali_alloc)
                mali_mem_unbind_dma_buf(mem_bkend);
                atomic_sub(mem_bkend->size / MALI_MMU_PAGE_SIZE, &session->mali_mem_array[mem_bkend->type]);
 #else
                mali_mem_unbind_dma_buf(mem_bkend);
                atomic_sub(mem_bkend->size / MALI_MMU_PAGE_SIZE, &session->mali_mem_array[mem_bkend->type]);
 #else
-               MALI_DEBUG_PRINT(2, ("DMA not supported\n"));
+               MALI_DEBUG_PRINT(1, ("DMA not supported\n"));
 #endif
                break;
        case MALI_MEM_EXTERNAL:
 #endif
                break;
        case MALI_MEM_EXTERNAL:
@@ -101,6 +102,14 @@ static u32 _mali_free_allocation_mem(mali_mem_allocation *mali_alloc)
                atomic_sub(free_pages_nr, &session->mali_mem_allocated_pages);
                atomic_sub(free_pages_nr, &session->mali_mem_array[mem_bkend->type]);
                break;
                atomic_sub(free_pages_nr, &session->mali_mem_allocated_pages);
                atomic_sub(free_pages_nr, &session->mali_mem_array[mem_bkend->type]);
                break;
+       case MALI_MEM_SECURE:
+#if defined(CONFIG_DMA_SHARED_BUFFER)
+               free_pages_nr = mali_mem_secure_release(mem_bkend);
+               atomic_sub(free_pages_nr, &session->mali_mem_allocated_pages);
+#else
+               MALI_DEBUG_PRINT(1, ("DMA not supported for mali secure memory\n"));
+#endif
+               break;
        default:
                MALI_DEBUG_PRINT(1, ("mem type %d is not in the mali_mem_type enum.\n", mem_bkend->type));
                break;
        default:
                MALI_DEBUG_PRINT(1, ("mem type %d is not in the mali_mem_type enum.\n", mem_bkend->type));
                break;
index 0d686979d7a8a29262d1996f8e6195a7686066c2..b3cc7e9eaa620f3dd6fa83610006807a45792cf3 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
 /*\r
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2016 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.
  * 
  * 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.
index 35f8f90a444dee715a62b5bea7a3f81ac143f55a..cb85ca23737d44419041a756bf456679ea2466a6 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
 /*\r
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2016 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.
  * 
  * 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.
index 3e2d48f44e28cb99a49bceb6c2946e99a7866ebd..9815f28f7ae116af1982b212f62891bd5e88f8f3 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
 /*\r
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2014, 2016 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.
  * 
  * 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.
index ba630e2730cf336ce491a6227638615b4eab5d08..03f4421ef1eab9d5e1e49d2e4ac9e2cb63f8f6c1 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2013-2014, 2016 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.
  * 
  * 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.
index 01ca38235b201fc03ef1e452d49f5dbd93ad7b0f..67cc7e42b83f6c0a1df093bb39bd406e2b35dd81 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
 /*\r
- * Copyright (C) 2010, 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2013-2016 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.
  * 
  * 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.
index 539832d9125af837080eb69977db09ab1f750912..4a75845ab044d161d7928778defac06cc33edfe3 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2016 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.
  * 
  * 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.
index 50c0a9d238190f858bc02637ff650639b9587682..4fa93981858e1491472db0f13c378590e2d31228 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
index aa32a81e7496bd8081fc02721c9fc14b89890104..a05586f0e12bdebbb0adbeebb8aab573353c7220 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
index c14e872a7d639107489bd747130cdd77d96344c4..bc713a175d2037a827386669ed07484a250d7b6f 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
index 1a6d257baa5a30a2a5aa847da1f49e295259d2e6..867814ef1489c182bea8bebbe42c313253d8c50a 100755 (executable)
 #include "mali_osk.h"           /* kernel side OS functions */
 #include "mali_kernel_linux.h"
 
 #include "mali_osk.h"           /* kernel side OS functions */
 #include "mali_kernel_linux.h"
 
+static mali_bool mali_secure_mode_enabled = MALI_FALSE;
+static mali_bool mali_secure_mode_supported = MALI_FALSE;
+
+/* Function that init the mali gpu secure mode */
+void (*mali_secure_mode_deinit)(void) = NULL;
+/* Function that enable the mali gpu secure mode */
+int (*mali_secure_mode_enable)(void) = NULL;
+/* Function that disable the mali gpu secure mode */
+int (*mali_secure_mode_disable)(void) = NULL;
 
 
 #ifdef CONFIG_MALI_DT
 
 
 #ifdef CONFIG_MALI_DT
@@ -409,3 +418,95 @@ mali_bool _mali_osk_shared_interrupts(void)
 
        return MALI_FALSE;
 }
 
        return MALI_FALSE;
 }
+
+_mali_osk_errcode_t _mali_osk_gpu_secure_mode_init(void)
+{
+       _mali_osk_device_data data = { 0, };
+
+       if (_MALI_OSK_ERR_OK ==  _mali_osk_device_data_get(&data)) {
+               if ((NULL != data.secure_mode_init) && (NULL != data.secure_mode_deinit)
+                   && (NULL != data.secure_mode_enable) && (NULL != data.secure_mode_disable)) {
+                       int err = data.secure_mode_init();
+                       if (err) {
+                               MALI_DEBUG_PRINT(1, ("Failed to init gpu secure mode.\n"));
+                               return _MALI_OSK_ERR_FAULT;
+                       }
+
+                       mali_secure_mode_deinit = data.secure_mode_deinit;
+                       mali_secure_mode_enable = data.secure_mode_enable;
+                       mali_secure_mode_disable = data.secure_mode_disable;
+
+                       mali_secure_mode_supported = MALI_TRUE;
+                       mali_secure_mode_enabled = MALI_FALSE;
+                       return _MALI_OSK_ERR_OK;
+               }
+       }
+       MALI_DEBUG_PRINT(3, ("GPU secure mode not supported.\n"));
+       return _MALI_OSK_ERR_UNSUPPORTED;
+
+}
+
+_mali_osk_errcode_t _mali_osk_gpu_secure_mode_deinit(void)
+{
+       if (NULL !=  mali_secure_mode_deinit) {
+               mali_secure_mode_deinit();
+               mali_secure_mode_enabled = MALI_FALSE;
+               mali_secure_mode_supported = MALI_FALSE;
+               return _MALI_OSK_ERR_OK;
+       }
+       MALI_DEBUG_PRINT(3, ("GPU secure mode not supported.\n"));
+       return _MALI_OSK_ERR_UNSUPPORTED;
+
+}
+
+
+_mali_osk_errcode_t _mali_osk_gpu_secure_mode_enable(void)
+{
+       /* the mali executor lock must be held before enter this function. */
+
+       MALI_DEBUG_ASSERT(MALI_FALSE == mali_secure_mode_enabled);
+
+       if (NULL !=  mali_secure_mode_enable) {
+               if (mali_secure_mode_enable()) {
+                       MALI_DEBUG_PRINT(1, ("Failed to enable gpu secure mode.\n"));
+                       return _MALI_OSK_ERR_FAULT;
+               }
+               mali_secure_mode_enabled = MALI_TRUE;
+               return _MALI_OSK_ERR_OK;
+       }
+       MALI_DEBUG_PRINT(1, ("GPU secure mode not supported.\n"));
+       return _MALI_OSK_ERR_UNSUPPORTED;
+}
+
+_mali_osk_errcode_t _mali_osk_gpu_secure_mode_disable(void)
+{
+       /* the mali executor lock must be held before enter this function. */
+
+       MALI_DEBUG_ASSERT(MALI_TRUE == mali_secure_mode_enabled);
+
+       if (NULL != mali_secure_mode_disable) {
+               if (mali_secure_mode_disable()) {
+                       MALI_DEBUG_PRINT(1, ("Failed to disable gpu secure mode.\n"));
+                       return _MALI_OSK_ERR_FAULT;
+               }
+               mali_secure_mode_enabled = MALI_FALSE;
+
+               return _MALI_OSK_ERR_OK;
+
+       }
+       MALI_DEBUG_PRINT(1, ("GPU secure mode not supported.\n"));
+       return _MALI_OSK_ERR_UNSUPPORTED;
+
+}
+
+mali_bool _mali_osk_gpu_secure_mode_is_enabled(void)
+{
+       return mali_secure_mode_enabled;
+}
+
+mali_bool _mali_osk_gpu_secure_mode_is_supported(void)
+{
+       return mali_secure_mode_supported;
+}
+
+
index 085ce76f7665f8cb025480e6d23a7be1e79e2264..3f06723ad062ccc8a19210b9432619a2221fc74c 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2013-2014, 2016 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.
  * 
  * 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.
index 390e613e186da50ef04f44a03f6d7071bb0c942c..ad5494d338d3aa9932225697b1a550673a49d9e8 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2011, 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2011, 2013-2014, 2016 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.
  * 
  * 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.
index 0a619e3fc27e24b0d03b71aa581fa9386c0e38a4..7dda2834c544ac48099eac3d0e1118bb2235ab93 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
@@ -42,17 +42,6 @@ u32 _mali_osk_snprintf(char *buf, u32 size, const char *fmt, ...)
        return res;
 }
 
        return res;
 }
 
-void _mali_osk_ctxprintf(_mali_osk_print_ctx *print_ctx, const char *fmt, ...)
-{
-       va_list args;
-       char buf[512];
-
-       va_start(args, fmt);
-       vscnprintf(buf, 512, fmt, args);
-       seq_printf(print_ctx, buf);
-       va_end(args);
-}
-
 void _mali_osk_abort(void)
 {
        /* make a simple fault by dereferencing a NULL pointer */
 void _mali_osk_abort(void)
 {
        /* make a simple fault by dereferencing a NULL pointer */
index e66fe83f35571df3aae88724ad85a58a0a2a7a22..58678417b34f48247c614bfcb2e86fea63247caa 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
index 0201e1ab56c26b246c7e20cce58610b0cdcd0a3c..35d1abcb49643aa324ec16d9b54227d6eaed2b4c 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2016 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.
  * 
  * 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.
@@ -254,8 +254,8 @@ static u32 _mali_profiling_read_packet_int(unsigned char *const buf, u32 *const
        u8 byte_value = ~0;
 
        while ((byte_value & 0x80) != 0) {
        u8 byte_value = ~0;
 
        while ((byte_value & 0x80) != 0) {
-               if ((*pos) >= packet_size);
-               return -1;
+               if ((*pos) >= packet_size)
+                       return -1;
                byte_value = buf[*pos];
                *pos += 1;
                int_value |= (u32)(byte_value & 0x7f) << shift;
                byte_value = buf[*pos];
                *pos += 1;
                int_value |= (u32)(byte_value & 0x7f) << shift;
index db034a5b3c7072829923412e0e78f5f2aa657a0f..adcca2937967b15994de180bf51b31224e2901c0 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2012-2014, 2016 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.
  * 
  * 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.
index 4deaa101e48f9ce390cc693a266b39020e4b1073..76876b61834f56e2760aad03a6e85faa5293bed6 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2013-2014, 2016 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.
  * 
  * 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.
index 6bbaee749d64d731aa42c9a47385e04c5a0ee4aa..8ada2da8d386b0659f7f13727b3cec1967b015bf 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
index 15d5ce250eb1996068b835ce6f8f78d04c5e0cbc..caa3abe109fb45c670f0ec514816b22f3821b88e 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2014, 2016 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.
  * 
  * 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.
index 2c34c91a7922d5e829dbc77b0ab9deb387b66f11..06afa04032c59469798bc687f48a6a119c55d16b 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
index 61ff5c8fdca85b9224a66c51a805447c7dbad860..48482a992dc5270e3e447ecd74bed5ab0e9780e7 100755 (executable)
@@ -1,5 +1,5 @@
 /**
 /**
- * Copyright (C) 2010, 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2012-2014, 2016 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.
  * 
  * 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.
index 0b90e8c5cf26f35cd41f9de9feefbefeb851346c..5e51095894e77c06ab93c1cc92db6ef6ac543647 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012, 2016 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.
  * 
  * 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.
index c98d127366babd06bd1179c43250efae9bfe8a39..e37197138f8d81f6339c539db8fb0c992d7ddea7 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012-2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2013, 2016 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.
  * 
  * 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.
index 12aef4194ff5301b9136d9c3fa945cede52f72fb..918caa07fd3bb82b558282d03a6a399787fece51 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2016 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.
  * 
  * 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.
index 1c6f4da691d24cfc2d8b3b39f06519b2de55d6d3..6e05ffdc927a2fe0cb6bc74275c3486420b4f8c8 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2014, 2016 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.
  * 
  * 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.
index 68868ca5b6bd03e8ab8a68c4b873b45f337a23df..8bec3a404bf6b5e07f5484488e94f3a3c0b4a609 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2016 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.
  * 
  * 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.
index 0c541ff9a2e0445ba87acb2bfaf0548856540b43..79efb8e652745918a97ff76af92129d4401d81b9 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2016 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.
  * 
  * 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.
index 1884cdbba42483b8b893c08b88d093b14a4f0615..00ba28b14300328e72cebf4b70f529b6d911eea0 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012, 2016 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.
  * 
  * 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.
index 4ca85a8273e66c2ebab1e07a927dfab43ec86c2e..5531d9ebf9e4766469d3eb1e450c4ae2b8a54ba4 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2016 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.
  * 
  * 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.
index d4144c0f5e48169a43103e960fa34cc2c22346c1..d7c5d2f973e538df44ae0be5a11f43f76d3eeabe 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2012-2014, 2016 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.
  * 
  * 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.
index ca1cba0585b3934ca398389bcf5bcb081fd40ad4..3dfe345f848310538e14bc1e9c70fcf939984bfa 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2016 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.
  * 
  * 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.
index 4c1c381cb90f9d8c1187ad4974e718fb38bba9e3..2c59bc72b6ad2480d6ddedb1f24a8f1cb30410bf 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2012-2014, 2016 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.
  * 
  * 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.
index 4f8bc92a2e026f7f512510b91643482aee948e82..2487bf3b505a5f4d13a0159b9f939021d7c5e961 100755 (executable)
@@ -120,7 +120,7 @@ int profiling_control_set_wrapper(struct mali_session_data *session_data, _mali_
 
        kargs.ctx = (uintptr_t)session_data;
 
 
        kargs.ctx = (uintptr_t)session_data;
 
-       
+
        /* Sanity check about the size */
        if (kargs.control_packet_size > PAGE_SIZE || kargs.response_packet_size > PAGE_SIZE)
                return -EINVAL;
        /* Sanity check about the size */
        if (kargs.control_packet_size > PAGE_SIZE || kargs.response_packet_size > PAGE_SIZE)
                return -EINVAL;
index 11c70060e489d447ec46d9f3db03630ab1e91f64..beeb7531a662c673b57c195a83cfdfd915a812c8 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2014, 2016 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.
  * 
  * 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.
index 484d4041c8694b143df4873b4cf4f82ee76e3608..f32d8b0d9cad3956e25bcf52a6638dd20c67954c 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013, 2016 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.
  * 
  * 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.
index 487c2478df4d67b8552c8c8e3f8b11d3bf4913a8..5b54fb987241054a4d8cd39b12d43a95476ccf9b 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2011-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2014, 2016 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.
  * 
  * 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.
index 504ed4be41235c82e3b16d01184a3fd417a06c2c..f86a32ce9e6afb05de6bcb895fa79c944c660a5d 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2016 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.
  * 
  * 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.
index 011f242071d24e8bc5eee5d111bfe6e52a0c25cd..33f35bee705183c8c2e97ee6e0e9638f05c073c9 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2012-2016 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.
  * 
  * 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.
 #include "arm_core_scaling.h"
 #include "mali_executor.h"
 
 #include "arm_core_scaling.h"
 #include "mali_executor.h"
 
+#if defined(CONFIG_MALI_DEVFREQ) && defined(CONFIG_DEVFREQ_THERMAL)
+#include <linux/devfreq_cooling.h>
+#include <linux/thermal.h>
+#endif
 
 static int mali_core_scaling_enable = 0;
 
 
 static int mali_core_scaling_enable = 0;
 
@@ -39,6 +43,77 @@ static u32 mali_read_phys(u32 phys_addr);
 static void mali_write_phys(u32 phys_addr, u32 value);
 #endif
 
 static void mali_write_phys(u32 phys_addr, u32 value);
 #endif
 
+#if defined(CONFIG_ARCH_VEXPRESS) && defined(CONFIG_ARM64)
+
+#define SECURE_MODE_CONTROL_HANDLER     0x6F02006C
+void *secure_mode_mapped_addr = NULL;
+/**
+ * Enable/Disable Mali secure mode.
+ * @Return value:
+ * 0: success
+ * non-0: failure.
+ */
+
+static int mali_secure_mode_enable_juno(void)
+{
+       u32 phys_offset    = SECURE_MODE_CONTROL_HANDLER & 0x00001FFF;
+       MALI_DEBUG_ASSERT(NULL != secure_mode_mapped_addr);
+
+       iowrite32(1, ((u8 *)secure_mode_mapped_addr) + phys_offset);
+
+       if (1 == (u32)ioread32(((u8 *)secure_mode_mapped_addr) + phys_offset)) {
+               MALI_DEBUG_PRINT(3, ("Mali enables secured mode successfully! \n"));
+               return 0;
+       }
+
+       MALI_PRINT_ERROR(("Failed to enable Mali secured mode !!! \n"));
+
+       return -1;
+
+}
+
+static int mali_secure_mode_disable_juno(void)
+{
+       u32 phys_offset    = SECURE_MODE_CONTROL_HANDLER & 0x00001FFF;
+       MALI_DEBUG_ASSERT(NULL != secure_mode_mapped_addr);
+
+       iowrite32(0, ((u8 *)secure_mode_mapped_addr) + phys_offset);
+
+       if (0 == (u32)ioread32(((u8 *)secure_mode_mapped_addr) + phys_offset)) {
+               MALI_DEBUG_PRINT(3, ("Mali disable secured mode successfully! \n"));
+               return 0;
+       }
+
+       MALI_PRINT_ERROR(("Failed to disable mali secured mode !!! \n"));
+       return -1;
+}
+
+static int mali_secure_mode_init_juno(void)
+{
+       u32 phys_addr_page = SECURE_MODE_CONTROL_HANDLER & 0xFFFFE000;
+       u32 phys_offset    = SECURE_MODE_CONTROL_HANDLER & 0x00001FFF;
+       u32 map_size       = phys_offset + sizeof(u32);
+
+       MALI_DEBUG_ASSERT(NULL == secure_mode_mapped_addr);
+
+       secure_mode_mapped_addr = ioremap_nocache(phys_addr_page, map_size);
+       if (NULL != secure_mode_mapped_addr) {
+               return mali_secure_mode_disable_juno();
+       }
+       MALI_DEBUG_PRINT(2, ("Failed to ioremap for Mali secured mode! \n"));
+       return -1;
+}
+
+static void mali_secure_mode_deinit_juno(void)
+{
+       if (NULL != secure_mode_mapped_addr) {
+               mali_secure_mode_disable_juno();
+               iounmap(secure_mode_mapped_addr);
+               secure_mode_mapped_addr = NULL;
+       }
+}
+#endif
+
 #ifndef CONFIG_MALI_DT
 static void mali_platform_device_release(struct device *device);
 
 #ifndef CONFIG_MALI_DT
 static void mali_platform_device_release(struct device *device);
 
@@ -101,14 +176,86 @@ static struct resource mali_gpu_resources_m400_mp2[] = {
 #endif
 #endif
 
 #endif
 #endif
 
+#if defined(CONFIG_MALI_DEVFREQ) && defined(CONFIG_DEVFREQ_THERMAL)
+
+#define FALLBACK_STATIC_TEMPERATURE 55000
+
+static struct thermal_zone_device *gpu_tz;
+
+/* Calculate gpu static power example for reference */
+static unsigned long arm_model_static_power(unsigned long voltage)
+{
+       int temperature, temp;
+       int temp_squared, temp_cubed, temp_scaling_factor;
+       const unsigned long coefficient = (410UL << 20) / (729000000UL >> 10);
+       const unsigned long voltage_cubed = (voltage * voltage * voltage) >> 10;
+       unsigned long static_power;
+
+       if (gpu_tz) {
+               int ret;
+
+               ret = gpu_tz->ops->get_temp(gpu_tz, &temperature);
+               if (ret) {
+                       MALI_DEBUG_PRINT(2, ("Error reading temperature for gpu thermal zone: %d\n", ret));
+                       temperature = FALLBACK_STATIC_TEMPERATURE;
+               }
+       } else {
+               temperature = FALLBACK_STATIC_TEMPERATURE;
+       }
+
+       /* Calculate the temperature scaling factor. To be applied to the
+        * voltage scaled power.
+        */
+       temp = temperature / 1000;
+       temp_squared = temp * temp;
+       temp_cubed = temp_squared * temp;
+       temp_scaling_factor =
+               (2 * temp_cubed)
+               - (80 * temp_squared)
+               + (4700 * temp)
+               + 32000;
+
+       static_power = (((coefficient * voltage_cubed) >> 20)
+                       * temp_scaling_factor)
+                      / 1000000;
+
+       return static_power;
+}
+
+/* Calculate gpu dynamic power example for reference */
+static unsigned long arm_model_dynamic_power(unsigned long freq,
+               unsigned long voltage)
+{
+       /* The inputs: freq (f) is in Hz, and voltage (v) in mV.
+        * The coefficient (c) is in mW/(MHz mV mV).
+        *
+        * This function calculates the dynamic power after this formula:
+        * Pdyn (mW) = c (mW/(MHz*mV*mV)) * v (mV) * v (mV) * f (MHz)
+        */
+       const unsigned long v2 = (voltage * voltage) / 1000; /* m*(V*V) */
+       const unsigned long f_mhz = freq / 1000000; /* MHz */
+       const unsigned long coefficient = 3600; /* mW/(MHz*mV*mV) */
+       unsigned long dynamic_power;
+
+       dynamic_power = (coefficient * v2 * f_mhz) / 1000000; /* mW */
+
+       return dynamic_power;
+}
+
+struct devfreq_cooling_power arm_cooling_ops = {
+       .get_static_power = arm_model_static_power,
+       .get_dynamic_power = arm_model_dynamic_power,
+};
+#endif
+
 static struct mali_gpu_device_data mali_gpu_data = {
 #ifndef CONFIG_MALI_DT
        .pmu_switch_delay = 0xFF, /* do not have to be this high on FPGA, but it is good for testing to have a delay */
 static struct mali_gpu_device_data mali_gpu_data = {
 #ifndef CONFIG_MALI_DT
        .pmu_switch_delay = 0xFF, /* do not have to be this high on FPGA, but it is good for testing to have a delay */
-       .max_job_runtime = 60000, /* 60 seconds */
 #if defined(CONFIG_ARCH_VEXPRESS)
        .shared_mem_size = 256 * 1024 * 1024, /* 256MB */
 #endif
 #endif
 #if defined(CONFIG_ARCH_VEXPRESS)
        .shared_mem_size = 256 * 1024 * 1024, /* 256MB */
 #endif
 #endif
+       .max_job_runtime = 60000, /* 60 seconds */
 
 #if defined(CONFIG_ARCH_REALVIEW)
        .dedicated_mem_start = 0x80000000, /* Physical start address (use 0xD0000000 for old indirect setup) */
 
 #if defined(CONFIG_ARCH_REALVIEW)
        .dedicated_mem_start = 0x80000000, /* Physical start address (use 0xD0000000 for old indirect setup) */
@@ -129,6 +276,20 @@ static struct mali_gpu_device_data mali_gpu_data = {
        .get_clock_info = NULL,
        .get_freq = NULL,
        .set_freq = NULL,
        .get_clock_info = NULL,
        .get_freq = NULL,
        .set_freq = NULL,
+#if defined(CONFIG_ARCH_VEXPRESS) && defined(CONFIG_ARM64)
+       .secure_mode_init = mali_secure_mode_init_juno,
+       .secure_mode_deinit = mali_secure_mode_deinit_juno,
+       .secure_mode_enable = mali_secure_mode_enable_juno,
+       .secure_mode_disable = mali_secure_mode_disable_juno,
+#else
+       .secure_mode_init = NULL,
+       .secure_mode_deinit = NULL,
+       .secure_mode_enable = NULL,
+       .secure_mode_disable = NULL,
+#endif
+#if defined(CONFIG_MALI_DEVFREQ) && defined(CONFIG_DEVFREQ_THERMAL)
+       .gpu_cooling_ops = &arm_cooling_ops,
+#endif
 };
 
 #ifndef CONFIG_MALI_DT
 };
 
 #ifndef CONFIG_MALI_DT
@@ -260,6 +421,9 @@ void mali_platform_device_unregister(void)
        MALI_DEBUG_PRINT(4, ("mali_platform_device_unregister() called\n"));
 
        mali_core_scaling_term();
        MALI_DEBUG_PRINT(4, ("mali_platform_device_unregister() called\n"));
 
        mali_core_scaling_term();
+#ifdef CONFIG_PM_RUNTIME
+       pm_runtime_disable(&(mali_gpu_device.dev));
+#endif
        platform_device_unregister(&mali_gpu_device);
 
        platform_device_put(&mali_gpu_device);
        platform_device_unregister(&mali_gpu_device);
 
        platform_device_put(&mali_gpu_device);
@@ -365,6 +529,18 @@ int mali_platform_device_init(struct platform_device *device)
                mali_core_scaling_init(num_pp_cores);
        }
 
                mali_core_scaling_init(num_pp_cores);
        }
 
+#if defined(CONFIG_MALI_DEVFREQ) && defined(CONFIG_DEVFREQ_THERMAL)
+       /* Get thermal zone */
+       gpu_tz = thermal_zone_get_zone_by_name("soc_thermal");
+       if (IS_ERR(gpu_tz)) {
+               MALI_DEBUG_PRINT(2, ("Error getting gpu thermal zone (%ld), not yet ready?\n",
+                                    PTR_ERR(gpu_tz)));
+               gpu_tz = NULL;
+
+               err =  -EPROBE_DEFER;
+       }
+#endif
+
        return err;
 }
 
        return err;
 }
 
@@ -375,6 +551,9 @@ int mali_platform_device_deinit(struct platform_device *device)
        MALI_DEBUG_PRINT(4, ("mali_platform_device_deinit() called\n"));
 
        mali_core_scaling_term();
        MALI_DEBUG_PRINT(4, ("mali_platform_device_deinit() called\n"));
 
        mali_core_scaling_term();
+#ifdef CONFIG_PM_RUNTIME
+       pm_runtime_disable(&(device->dev));
+#endif
 
 #if defined(CONFIG_ARCH_REALVIEW)
        mali_write_phys(0xC0010020, 0x9); /* Restore default (legacy) memory mapping */
 
 #if defined(CONFIG_ARCH_REALVIEW)
        mali_write_phys(0xC0010020, 0x9); /* Restore default (legacy) memory mapping */
index 2c24742eb4de4baeaecbf7fda1c85aefde09f728..37ab2ebf80e330a25791d2397ee1d92945c73892 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013-2014, 2016 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.
  * 
  * 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.
index 325b5b1c6894c0ce2b0919e15746f4135864af10..b2ae3835bca0abcb3fbcfc5c761e34d2c817a5bd 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2013, 2016 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.
  * 
  * This program is free software and is provided to you under the terms of the GNU General Public License version 2
  * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
diff --git a/drivers/gpu/arm/mali400/mali/platform/arm/juno_opp.c b/drivers/gpu/arm/mali400/mali/platform/arm/juno_opp.c
new file mode 100644 (file)
index 0000000..08be4e1
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2010, 2012-2016 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 juno_opp.c
+ * Example: Set up opp table
+ * Using ARM64 juno specific SCPI_PROTOCOL get frequence inform
+ * Customer need implement your own platform releated logic
+ */
+#ifdef CONFIG_ARCH_VEXPRESS
+#ifdef CONFIG_MALI_DEVFREQ
+#ifdef CONFIG_ARM64
+#ifdef CONFIG_ARM_SCPI_PROTOCOL
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/scpi_protocol.h>
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)
+#include <linux/pm_opp.h>
+#else /* Linux >= 3.13 */
+/* In 3.13 the OPP include header file, types, and functions were all
+ * renamed. Use the old filename for the include, and define the new names to
+ * the old, when an old kernel is detected.
+ */
+#include <linux/opp.h>
+#define dev_pm_opp_add opp_add
+#define dev_pm_opp_remove opp_remove
+#endif /* Linux >= 3.13 */
+
+#include "mali_kernel_common.h"
+
+static int init_juno_opps_from_scpi(struct device *dev)
+{
+       struct scpi_dvfs_info *sinfo;
+       struct scpi_ops *sops;
+
+       int i;
+
+       sops = get_scpi_ops();
+       if (NULL == sops) {
+               MALI_DEBUG_PRINT(2, ("Mali didn't get any scpi ops \n"));
+               return -1;
+       }
+
+       /* Hard coded for Juno. 2 is GPU domain */
+       sinfo = sops->dvfs_get_info(2);
+       if (IS_ERR_OR_NULL(sinfo))
+               return PTR_ERR(sinfo);
+
+       for (i = 0; i < sinfo->count; i++) {
+               struct scpi_opp *e = &sinfo->opps[i];
+
+               MALI_DEBUG_PRINT(2, ("Mali OPP from SCPI: %u Hz @ %u mV\n", e->freq, e->m_volt));
+
+               dev_pm_opp_add(dev, e->freq, e->m_volt * 1000);
+       }
+
+       return 0;
+}
+
+int setup_opps(void)
+{
+       struct device_node *np;
+       struct platform_device *pdev;
+       int err;
+
+       np = of_find_node_by_name(NULL, "gpu");
+       if (!np) {
+               pr_err("Failed to find DT entry for Mali\n");
+               return -EFAULT;
+       }
+
+       pdev = of_find_device_by_node(np);
+       if (!pdev) {
+               pr_err("Failed to find device for Mali\n");
+               of_node_put(np);
+               return -EFAULT;
+       }
+
+       err = init_juno_opps_from_scpi(&pdev->dev);
+
+       of_node_put(np);
+
+       return err;
+}
+
+int term_opps(struct device *dev)
+{
+       struct scpi_dvfs_info *sinfo;
+       struct scpi_ops *sops;
+
+       int i;
+
+       sops = get_scpi_ops();
+       if (NULL == sops) {
+               MALI_DEBUG_PRINT(2, ("Mali didn't get any scpi ops \n"));
+               return -1;
+       }
+
+       /* Hard coded for Juno. 2 is GPU domain */
+       sinfo = sops->dvfs_get_info(2);
+       if (IS_ERR_OR_NULL(sinfo))
+               return PTR_ERR(sinfo);
+
+       for (i = 0; i < sinfo->count; i++) {
+               struct scpi_opp *e = &sinfo->opps[i];
+
+               MALI_DEBUG_PRINT(2, ("Mali Remove OPP: %u Hz \n", e->freq));
+
+               dev_pm_opp_remove(dev, e->freq);
+       }
+
+       return 0;
+
+}
+#endif
+#endif
+#endif
+#endif
index e76f9926f5c0a81dd2e4e18929aeae095db0dd09..c904ad23b28dbb1cfd1d9dae403e108053546a0f 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2012-2016 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.
  * 
  * 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.
index 9c101f9ddd2232cf9a313fc5eeff6fc484b12c58..435953d46e8b54284f53775e364629fd5ede8640 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2012-2016 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.
  * 
  * 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.
index a486e2f7684f746997fb9fb3846278bc90f7f2f8..f7f7baf4d8be3f299fa101e0bfb16d7f4498faed 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2011, 2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2011, 2013, 2016 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.
  * 
  * 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.
index 65f3ab274c09bae8e7dd2ef43fde5bed22ad54f8..757f6433bf3d350f1aa55e86f103a75c9f579f67 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2011, 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2011, 2013-2014, 2016 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.
  * 
  * 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.
index a486e2f7684f746997fb9fb3846278bc90f7f2f8..f7f7baf4d8be3f299fa101e0bfb16d7f4498faed 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2011, 2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2011, 2013, 2016 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.
  * 
  * 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.
index 8ba47060828f031f68c4864f9c9a84cfaed2d280..21700fe3216f8cf240295edf40180d229bac6e5f 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2011, 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2011, 2013-2014, 2016 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.
  * 
  * 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.
index 3342d781756121f2626a252632caeb557154716b..a3067ba724590fa19769ab0b73c1b8d440baf18a 100755 (executable)
@@ -50,7 +50,7 @@ endif
 ccflags-y += -DSVN_REV=$(SVN_REV)
 ccflags-y += -DSVN_REV_STRING=\"$(DRIVER_REV)\"
 
 ccflags-y += -DSVN_REV=$(SVN_REV)
 ccflags-y += -DSVN_REV_STRING=\"$(DRIVER_REV)\"
 
-ccflags-y += -I$(src) -I$(src)/common -I$(src)/linux -I$(src)/../mali/common -I$(src)/../mali/linux -I$(src)/../../ump/include/ump
+ccflags-y += -I$(src) -I$(src)/common -I$(src)/linux -I$(src)/../mali/common -I$(src)/../mali/linux -I$(src)/include -I$(src)/../../ump/include/ump
 ccflags-y += -DMALI_STATE_TRACKING=0
 ccflags-y += -DMALI_ENABLE_CPU_CYCLES=0
 ccflags-$(CONFIG_UMP_DEBUG) += -DDEBUG
 ccflags-y += -DMALI_STATE_TRACKING=0
 ccflags-y += -DMALI_ENABLE_CPU_CYCLES=0
 ccflags-$(CONFIG_UMP_DEBUG) += -DDEBUG
@@ -78,12 +78,15 @@ ump-y = common/ump_kernel_common.o \
        linux/ump_osk_atomics.o \
        linux/ump_osk_low_level_mem.o \
        linux/ump_osk_misc.o \
        linux/ump_osk_atomics.o \
        linux/ump_osk_low_level_mem.o \
        linux/ump_osk_misc.o \
-       linux/ump_kernel_random_mapping.o \
-       $(UDD_FILE_PREFIX)linux/mali_osk_atomics.o \
-       $(UDD_FILE_PREFIX)linux/mali_osk_locks.o \
-       $(UDD_FILE_PREFIX)linux/mali_osk_memory.o \
-       $(UDD_FILE_PREFIX)linux/mali_osk_math.o \
-       $(UDD_FILE_PREFIX)linux/mali_osk_misc.o
+       linux/ump_kernel_random_mapping.o
+
+ifneq ($(CONFIG_MALI400),y)    
+ump-y += $(UDD_FILE_PREFIX)linux/mali_osk_atomics.o \
+        $(UDD_FILE_PREFIX)linux/mali_osk_locks.o \
+        $(UDD_FILE_PREFIX)linux/mali_osk_memory.o \
+        $(UDD_FILE_PREFIX)linux/mali_osk_math.o \
+        $(UDD_FILE_PREFIX)linux/mali_osk_misc.o
+endif
 
 obj-$(CONFIG_UMP) := ump.o
 
 
 obj-$(CONFIG_UMP) := ump.o
 
index f24bc6c82a0f5c531c84213994dc3b5b79d7888a..4d4f02b0fb6b7ebc374204874639dcc664f6c329 100755 (executable)
@@ -1,5 +1,5 @@
 #
 #
-# Copyright (C) 2010-2012, 2014-2015 ARM Limited. All rights reserved.
+# Copyright (C) 2010-2012, 2014, 2016 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.
 # 
 # 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.
index 6b3b8d1efde480a05c17c663182c2b3c72c0ee99..00153ded9f98c1fa1f678c8aa56600f8566414d9 100755 (executable)
@@ -1,5 +1,5 @@
 #
 #
-# Copyright (C) 2010-2011, 2013, 2015 ARM Limited. All rights reserved.
+# Copyright (C) 2010-2011, 2013, 2016 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.
 # 
 # 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.
index cfd2b34b53349438524c387648c8bd9050641d1c..ddecfbb91f0cf61d87838ce88b1bad3a1e223e6d 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2012, 2014-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2012, 2014, 2016 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.
  * 
  * 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.
index c2c56cf1c009c9efbd09c443032b9787b3e32cad..9160ce1cee80f1fb9b453f5aded0f9d22dc7bc64 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2013, 2016 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.
  * 
  * 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.
index 21dde81ef419f58bd4c142f786624f7c34d8085e..2ad4ae5780fbbe1a50c4adf1b37743663cc5924c 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
index ca410a8916c04d620bbce8134a0565de450ac40a..1f5ba47127255992740028ef6c415294d0afbdcb 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
index 2efe1ed1e78980e7af7381cd406b23d9d9794d89..1969c9734c87940065e4fc0b417a643cad0976a7 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
@@ -110,7 +110,7 @@ extern struct ump_dev device;
 
 _mali_osk_errcode_t ump_kernel_constructor(void);
 void ump_kernel_destructor(void);
 
 _mali_osk_errcode_t ump_kernel_constructor(void);
 void ump_kernel_destructor(void);
-int map_errcode(_mali_osk_errcode_t err);
+int ump_map_errcode(_mali_osk_errcode_t err);
 
 /**
  * variables from user space cannot be dereferenced from kernel space; tagging them
 
 /**
  * variables from user space cannot be dereferenced from kernel space; tagging them
index 45e2bb4f7bd7b97ab2e273bbf0d0469b86f24089..d22c049f0aa0cdfdad774afc3a1eae17f20dd807 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2011, 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2011, 2013-2014, 2016 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.
  * 
  * 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.
index 60d691739c08a0f0b65d4f69aaf3fcaabbceb4cd..bad215ab87a474dadf699f910559fb455eba38b7 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2011, 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2011, 2013-2014, 2016 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.
  * 
  * 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.
index 056244ebe1629f2a6676215e81e9133bf1b74c41..1b4fbc50f6dfcfd2e11fd2d681c893c9160174db 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2011, 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2011, 2013-2014, 2016 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.
  * 
  * 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.
index 37a682ac9ba43ab66f4b883585d98ebf9d1a42a7..39f32afdead64fa5cb76f70536bcff7496593aac 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
index 098ce1412738029ad315bb72760774b6418796e8..a1c9bd3449f3f4adf85a6cf81b46516c69749f9b 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
@@ -15,6 +15,9 @@
 #include "mali_osk.h"
 
 #include <linux/rbtree.h>
 #include "mali_osk.h"
 
 #include <linux/rbtree.h>
+#ifdef CONFIG_DMA_SHARED_BUFFER
+#include <linux/dma-buf.h>
+#endif
 
 typedef enum {
        UMP_USED_BY_CPU = 0,
 
 typedef enum {
        UMP_USED_BY_CPU = 0,
@@ -44,6 +47,10 @@ typedef struct ump_dd_mem {
        int is_cached;
        ump_hw_usage hw_device;
        ump_lock_usage lock_usage;
        int is_cached;
        ump_hw_usage hw_device;
        ump_lock_usage lock_usage;
+#ifdef CONFIG_DMA_SHARED_BUFFER
+       struct dma_buf_attachment *import_attach;
+       struct sg_table *sgt;
+#endif
 } ump_dd_mem;
 
 
 } ump_dd_mem;
 
 
index 6fe73662c6aeacc7086a85363723ca46aea76c8a..bd1aef5aab54a9e303bfce3fa567b53d1f9feb5d 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
index d91b0707d9360c384c01bb1bba147e6e1cb96001..0e42a89db01387dd420d9c13815901115975d651 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2012-2014, 2016 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.
  * 
  * 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.
@@ -48,6 +48,7 @@ typedef enum
        _UMP_IOC_SWITCH_HW_USAGE,
        _UMP_IOC_LOCK,
        _UMP_IOC_UNLOCK,
        _UMP_IOC_SWITCH_HW_USAGE,
        _UMP_IOC_LOCK,
        _UMP_IOC_UNLOCK,
+       _UMP_IOC_DMABUF_IMPORT,
 } _ump_uk_functions;
 
 typedef enum
 } _ump_uk_functions;
 
 typedef enum
@@ -186,6 +187,14 @@ typedef struct _ump_uk_unlock_s
        u32 secure_id;        /**< [in] secure_id that identifies the ump buffer */
 } _ump_uk_unlock_s;
 
        u32 secure_id;        /**< [in] secure_id that identifies the ump buffer */
 } _ump_uk_unlock_s;
 
+typedef struct _ump_uk_dmabuf_s
+{
+       void *ctx;            /**< [in,out] user-kernel context (trashed on output) */
+       int fd;               /**< [in] dmabuf_fd that identifies the dmabuf buffer */
+       size_t size;          /**< [in] size of the buffer */
+       u32 secure_id;        /**< [out] secure_id that identifies the ump buffer */
+} _ump_uk_dmabuf_s;
+
 #ifdef __cplusplus
 }
 #endif
 #ifdef __cplusplus
 }
 #endif
index ad097e8b209dc254dd4f3838b63b1219dba0fbc9..b8b1624b015f02c73c29d679ac271b9328660e37 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
index f562e5699e5f36f17cde9ffbc4fe298593d6c932..c0a1b838c60006b4588df170b2a7670d57a827db 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2013, 2016 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.
  * 
  * 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.
index 70db873c3d3be9621ea3fdaab6cc3d728b50184e..b3fe7d3661c479f3d80f3dbb292c9a432be32b6e 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2013, 2016 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.
  * 
  * 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.
@@ -55,6 +55,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)
 
 #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)
 
+#define UMP_IOC_DMABUF_IMPORT  _IOW(UMP_IOCTL_NR,  _UMP_IOC_DMABUF_IMPORT, _ump_uk_dmabuf_s)
 
 #ifdef __cplusplus
 }
 
 #ifdef __cplusplus
 }
index 77a5b21564c0335ba5e3c67c6e3aacc16d5a91fb..32a42ca6b6f7a2ef260320c8d24dc043e3c2578f 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
@@ -73,7 +73,7 @@ struct ump_device {
 
 /* The global variable containing the global device data */
 static struct ump_device ump_device;
 
 /* The global variable containing the global device data */
 static struct ump_device ump_device;
-
+struct device *ump_global_mdev = NULL;
 
 /* Forward declare static functions */
 static int ump_file_open(struct inode *inode, struct file *filp);
 
 /* Forward declare static functions */
 static int ump_file_open(struct inode *inode, struct file *filp);
@@ -112,7 +112,7 @@ static int ump_initialize_module(void)
        err = ump_kernel_constructor();
        if (_MALI_OSK_ERR_OK != err) {
                MSG_ERR(("UMP device driver init failed\n"));
        err = ump_kernel_constructor();
        if (_MALI_OSK_ERR_OK != err) {
                MSG_ERR(("UMP device driver init failed\n"));
-               return map_errcode(err);
+               return ump_map_errcode(err);
        }
 
        MSG(("UMP device driver %s loaded\n", SVN_REV_STRING));
        }
 
        MSG(("UMP device driver %s loaded\n", SVN_REV_STRING));
@@ -192,13 +192,12 @@ int ump_kernel_device_initialize(void)
                        if (IS_ERR(ump_device.ump_class)) {
                                err = PTR_ERR(ump_device.ump_class);
                        } else {
                        if (IS_ERR(ump_device.ump_class)) {
                                err = PTR_ERR(ump_device.ump_class);
                        } else {
-                               struct device *mdev;
-                               mdev = device_create(ump_device.ump_class, NULL, dev, NULL, ump_dev_name);
-                               if (!IS_ERR(mdev)) {
+                               ump_global_mdev = device_create(ump_device.ump_class, NULL, dev, NULL, ump_dev_name);
+                               if (!IS_ERR(ump_global_mdev)) {
                                        return 0;
                                }
 
                                        return 0;
                                }
 
-                               err = PTR_ERR(mdev);
+                               err = PTR_ERR(ump_global_mdev);
                        }
                        cdev_del(&ump_device.cdev);
 #else
                        }
                        cdev_del(&ump_device.cdev);
 #else
@@ -256,7 +255,7 @@ static int ump_file_open(struct inode *inode, struct file *filp)
        err = _ump_ukk_open((void **) &session_data);
        if (_MALI_OSK_ERR_OK != err) {
                MSG_ERR(("Ump failed to open a new session\n"));
        err = _ump_ukk_open((void **) &session_data);
        if (_MALI_OSK_ERR_OK != err) {
                MSG_ERR(("Ump failed to open a new session\n"));
-               return map_errcode(err);
+               return ump_map_errcode(err);
        }
 
        filp->private_data = (void *)session_data;
        }
 
        filp->private_data = (void *)session_data;
@@ -276,7 +275,7 @@ static int ump_file_release(struct inode *inode, struct file *filp)
 
        err = _ump_ukk_close((void **) &filp->private_data);
        if (_MALI_OSK_ERR_OK != err) {
 
        err = _ump_ukk_close((void **) &filp->private_data);
        if (_MALI_OSK_ERR_OK != err) {
-               return map_errcode(err);
+               return ump_map_errcode(err);
        }
 
        return 0;  /* success */
        }
 
        return 0;  /* success */
@@ -347,6 +346,15 @@ static int ump_file_ioctl(struct inode *inode, struct file *filp, unsigned int c
                err = ump_unlock_wrapper((u32 __user *)argument, session_data);
                break;
 
                err = ump_unlock_wrapper((u32 __user *)argument, session_data);
                break;
 
+       case UMP_IOC_DMABUF_IMPORT:
+               #ifdef CONFIG_DMA_SHARED_BUFFER
+               err = ump_dmabuf_import_wrapper((u32 __user *)argument, session_data);
+               #else
+               err = -EFAULT;
+               DBG_MSG(1, ("User space use dmabuf API, but kernel don't support DMA BUF\n"));
+               #endif
+               break;
+
        default:
                DBG_MSG(1, ("No handler for IOCTL. cmd: 0x%08x, arg: 0x%08lx\n", cmd, arg));
                err = -EFAULT;
        default:
                DBG_MSG(1, ("No handler for IOCTL. cmd: 0x%08x, arg: 0x%08lx\n", cmd, arg));
                err = -EFAULT;
@@ -356,7 +364,7 @@ static int ump_file_ioctl(struct inode *inode, struct file *filp, unsigned int c
        return err;
 }
 
        return err;
 }
 
-int map_errcode(_mali_osk_errcode_t err)
+int ump_map_errcode(_mali_osk_errcode_t err)
 {
        switch (err) {
        case _MALI_OSK_ERR_OK :
 {
        switch (err) {
        case _MALI_OSK_ERR_OK :
@@ -418,7 +426,7 @@ static int ump_file_mmap(struct file *filp, struct vm_area_struct *vma)
        err = _ump_ukk_map_mem(&args);
        if (_MALI_OSK_ERR_OK != err) {
                MSG_ERR(("_ump_ukk_map_mem() failed in function ump_file_mmap()"));
        err = _ump_ukk_map_mem(&args);
        if (_MALI_OSK_ERR_OK != err) {
                MSG_ERR(("_ump_ukk_map_mem() failed in function ump_file_mmap()"));
-               return map_errcode(err);
+               return ump_map_errcode(err);
        }
 
        return 0; /* success */
        }
 
        return 0; /* success */
index 41dae7988c49da11e766347c5017e3ba5b682122..f7c0a96beddbab59e6dd8dd9ff369fc0d1a48f84 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2013, 2016 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.
  * 
  * 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.
index 9f329e9524a1482a4e349193038f3e395fc31e19..517b46bbc04d424a546bb7407d3bc5965c0fef6f 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2011, 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2011, 2013-2014, 2016 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.
  * 
  * 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.
index 283dde793835525d2fe2db1ddfa4f638491ca7d0..8c1ea1e749f64ea72a1a075823b926f27d17772c 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2014-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2014, 2016 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.
  * 
  * 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.
index 763b6109e486b5e9a72cbd5bacdfd60713257bb3..f7791b0c07d74a8422bfc470051c494134d454d8 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2011, 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2011, 2013-2014, 2016 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.
  * 
  * 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.
index 22666573bec7d9348a5bba64c8d56b3a7054139d..2d62f4dd1448722383c6236541a689bb1ff351a9 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2014-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2014, 2016 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.
  * 
  * 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.
index 8fed5c38508a6ee61d2165259c9e178d5620c153..cd1c457ca75d4985b1ea9480b924b684d08979cf 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2011, 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2011, 2013-2014, 2016 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.
  * 
  * 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.
@@ -186,6 +186,21 @@ void ump_random_mapping_put(ump_dd_mem *mem)
        if (0 == new_ref) {
                DBG_MSG(3, ("Final release of memory. ID: %u\n", mem->secure_id));
 
        if (0 == new_ref) {
                DBG_MSG(3, ("Final release of memory. ID: %u\n", mem->secure_id));
 
+#ifdef CONFIG_DMA_SHARED_BUFFER
+               if (mem->import_attach) {
+                       struct dma_buf_attachment *attach = mem->import_attach;
+                       struct dma_buf *dma_buf;
+                        
+                       if (mem->sgt)
+                               dma_buf_unmap_attachment(attach, mem->sgt,
+                                                       DMA_BIDIRECTIONAL);
+
+                       dma_buf = attach->dmabuf;
+                       dma_buf_detach(attach->dmabuf, attach);
+                       dma_buf_put(dma_buf);
+
+               }
+#endif
                ump_random_mapping_remove_internal(device.secure_id_map, mem->secure_id);
 
                mem->release_func(mem->ctx, mem);
                ump_random_mapping_remove_internal(device.secure_id_map, mem->secure_id);
 
                mem->release_func(mem->ctx, mem);
index d304157b1ffbc640f21ac90bf854a72ef5b4f070..67d4a864bc478055c242e7f49848df147597e298 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2011, 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2011, 2013-2014, 2016 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.
  * 
  * 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.
index 3baa2ac4aa23518c7fd6bd99dc5da809039a28b9..87b141904cf1aae75cff0f8f29e4cfcf277ec98f 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2013-2014, 2016 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.
  * 
  * 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.
index 9fae2953308a34b7f49a2a63d571d08e7c4ebcd1..f9fc1943b14037ac3313f0162f2c21812671838f 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2014-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2014, 2016 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.
  * 
  * 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.
index 0d81fbe326b0643a44928b7127450cd53c62fefb..ef35052f68bca5db008175a39c84fb15927e7801 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
index bd985d3afb7267a464e9c1314268fe2cd688ee1b..ce0ab06f8e41d2f16d1dca087fcad2421ebea816 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2013-2014, 2016 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.
  * 
  * 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.
index 8350d3e0b75b6bd1e54088a7063f77a3297ba697..4a58e93e60dff5b6f44fa513c375d14cb8a93940 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2013-2014, 2016 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.
  * 
  * 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.
 #include "ump_uk_types.h"
 #include "ump_ukk.h"
 #include "ump_kernel_common.h"
 #include "ump_uk_types.h"
 #include "ump_ukk.h"
 #include "ump_kernel_common.h"
+#include <linux/scatterlist.h>
+#include "ump_kernel_interface_ref_drv.h"
+#include "mali_osk_list.h"
+
+extern struct device *ump_global_mdev;
 
 /*
  * IOCTL operation; Allocate UMP memory
 
 /*
  * IOCTL operation; Allocate UMP memory
@@ -46,7 +51,7 @@ int ump_allocate_wrapper(u32 __user *argument, struct ump_session_data   *sessio
        err = _ump_ukk_allocate(&user_interaction);
        if (_MALI_OSK_ERR_OK != err) {
                DBG_MSG(1, ("_ump_ukk_allocate() failed in ump_ioctl_allocate()\n"));
        err = _ump_ukk_allocate(&user_interaction);
        if (_MALI_OSK_ERR_OK != err) {
                DBG_MSG(1, ("_ump_ukk_allocate() failed in ump_ioctl_allocate()\n"));
-               return map_errcode(err);
+               return ump_map_errcode(err);
        }
        user_interaction.ctx = NULL;
 
        }
        user_interaction.ctx = NULL;
 
@@ -69,3 +74,157 @@ int ump_allocate_wrapper(u32 __user *argument, struct ump_session_data   *sessio
 
        return 0; /* success */
 }
 
        return 0; /* success */
 }
+
+#ifdef CONFIG_DMA_SHARED_BUFFER
+static ump_dd_handle get_ump_handle_from_dmabuf(struct ump_session_data *session_data,
+                                       struct dma_buf *dmabuf)
+{
+       ump_session_memory_list_element *session_mem, *tmp;
+       struct dma_buf_attachment *attach;
+       ump_dd_handle ump_handle;
+
+       DEBUG_ASSERT_POINTER(session_data);
+
+       _mali_osk_mutex_wait(session_data->lock);
+
+       _MALI_OSK_LIST_FOREACHENTRY(session_mem, tmp,
+                               &session_data->list_head_session_memory_list,
+                               ump_session_memory_list_element, list) {
+               if (session_mem->mem->import_attach) {
+                       attach = session_mem->mem->import_attach;
+                       if (attach->dmabuf == dmabuf) {
+                               _mali_osk_mutex_signal(session_data->lock);
+                               ump_handle = (ump_dd_handle)session_mem->mem;
+                               ump_random_mapping_get(device.secure_id_map, ump_dd_secure_id_get(ump_handle)); 
+                               return ump_handle;
+                       }
+               }
+       }
+
+       _mali_osk_mutex_signal(session_data->lock);
+
+       return NULL;
+}
+
+int ump_dmabuf_import_wrapper(u32 __user *argument,
+                               struct ump_session_data  *session_data)
+{
+       ump_session_memory_list_element *session = NULL;
+       _ump_uk_dmabuf_s ump_dmabuf;
+       ump_dd_handle ump_handle;
+       ump_dd_physical_block *blocks = NULL;
+       struct dma_buf_attachment *attach = NULL;
+       struct dma_buf *dma_buf;
+       struct sg_table *sgt = NULL;
+       struct scatterlist *sgl;
+       unsigned int i = 0; 
+       int ret = 0;
+
+       /* Sanity check input parameters */
+       if (!argument || !session_data) {
+               MSG_ERR(("NULL parameter.\n"));
+               return -EINVAL;
+       }
+
+       if (copy_from_user(&ump_dmabuf, argument,
+                               sizeof(_ump_uk_dmabuf_s))) {
+               MSG_ERR(("copy_from_user() failed.\n"));
+               return -EFAULT;
+       }
+
+       dma_buf = dma_buf_get(ump_dmabuf.fd);
+       if (IS_ERR(dma_buf))
+               return PTR_ERR(dma_buf);
+
+       /*
+        * if already imported then increase a refcount to the ump descriptor
+        * and call dma_buf_put() and then go to found to return previous
+        * ump secure id.
+        */
+       ump_handle = get_ump_handle_from_dmabuf(session_data, dma_buf);
+       if (ump_handle) {
+               dma_buf_put(dma_buf);
+               goto found;
+       }
+       
+       attach = dma_buf_attach(dma_buf, ump_global_mdev);
+       if (IS_ERR(attach)) {
+               ret = PTR_ERR(attach);
+               goto err_dma_buf_put;
+       }
+
+       sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
+       if (IS_ERR(sgt)) {
+               ret = PTR_ERR(sgt);
+               goto err_dma_buf_detach;
+       }
+
+       blocks = (ump_dd_physical_block *)_mali_osk_malloc(sizeof(ump_dd_physical_block) * sgt->nents);
+       if (!blocks) {
+               DBG_MSG(1, ("Failed to allocate blocks.\n"));
+                ret = -EFAULT;
+                goto err_dma_buf_unmap;
+       }
+       for_each_sg(sgt->sgl, sgl, sgt->nents, i) {
+               blocks[i].addr = sg_phys(sgl);
+               blocks[i].size = sg_dma_len(sgl);
+       }
+
+       /*
+        * Initialize the session memory list element, and add it
+        * to the session object
+        */
+       session = _mali_osk_calloc(1, sizeof(*session));
+       if (!session) {
+               DBG_MSG(1, ("Failed to allocate session.\n"));
+               ret = -EFAULT;
+               goto err_free_block;
+       }
+
+       ump_handle = ump_dd_handle_create_from_phys_blocks(blocks, i);
+       if (UMP_DD_HANDLE_INVALID == ump_handle) {
+               DBG_MSG(1, ("Failed to create ump handle.\n"));
+               ret = -EFAULT;
+               goto err_free_session;
+       }
+
+       session->mem = (ump_dd_mem *)ump_handle;
+       session->mem->import_attach = attach;
+       session->mem->sgt = sgt;
+
+       _mali_osk_mutex_wait(session_data->lock);
+       _mali_osk_list_add(&(session->list),
+                       &(session_data->list_head_session_memory_list));
+       _mali_osk_mutex_signal(session_data->lock);
+
+       _mali_osk_free(blocks);
+
+found:
+       ump_dmabuf.ctx = (void *)session_data;
+       ump_dmabuf.secure_id = ump_dd_secure_id_get(ump_handle);
+       ump_dmabuf.size = ump_dd_size_get(ump_handle);
+
+       if (copy_to_user(argument, &ump_dmabuf,
+                               sizeof(_ump_uk_dmabuf_s))) {
+               MSG_ERR(("copy_to_user() failed.\n"));
+               ret =  -EFAULT;
+               goto err_release_ump_handle;
+       }
+
+       return ret;
+
+err_release_ump_handle:
+       ump_dd_reference_release(ump_handle);
+err_free_session:
+       _mali_osk_free(session);
+err_free_block:
+       _mali_osk_free(blocks);
+err_dma_buf_unmap:
+       dma_buf_unmap_attachment(attach, sgt, DMA_BIDIRECTIONAL);
+err_dma_buf_detach:
+       dma_buf_detach(dma_buf, attach);
+err_dma_buf_put:
+       dma_buf_put(dma_buf);
+       return ret;
+}
+#endif
index d0cdbb5281ff15b135415284257992177381fb06..b8b2ccefe603a4b384bbf2aa8d723b556efe1ec2 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2013-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2013-2014, 2016 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.
  * 
  * 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.
@@ -25,7 +25,9 @@ extern "C" {
 
 
 int ump_allocate_wrapper(u32 __user *argument, struct ump_session_data   *session_data);
 
 
 int ump_allocate_wrapper(u32 __user *argument, struct ump_session_data   *session_data);
-
+#ifdef CONFIG_DMA_SHARED_BUFFER
+int ump_dmabuf_import_wrapper(u32 __user *argument, struct ump_session_data  *session_data);
+#endif
 
 #ifdef __cplusplus
 }
 
 #ifdef __cplusplus
 }
index 2616ebf2c81f954fbe55f523e266fbd3363ce5ad..2a88f50b545dc56ba69765c2b1c4de3bd2758a04 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2014, 2016 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.
  * 
  * 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.
@@ -44,7 +44,7 @@ int ump_get_api_version_wrapper(u32 __user *argument, struct ump_session_data *s
        err = _ump_uku_get_api_version(&version_info);
        if (_MALI_OSK_ERR_OK != err) {
                MSG_ERR(("_ump_uku_get_api_version() failed in ump_ioctl_get_api_version()\n"));
        err = _ump_uku_get_api_version(&version_info);
        if (_MALI_OSK_ERR_OK != err) {
                MSG_ERR(("_ump_uku_get_api_version() failed in ump_ioctl_get_api_version()\n"));
-               return map_errcode(err);
+               return ump_map_errcode(err);
        }
 
        version_info.ctx = NULL;
        }
 
        version_info.ctx = NULL;
@@ -83,7 +83,7 @@ int ump_release_wrapper(u32 __user *argument, struct ump_session_data   *session
        err = _ump_ukk_release(&release_args);
        if (_MALI_OSK_ERR_OK != err) {
                MSG_ERR(("_ump_ukk_release() failed in ump_ioctl_release()\n"));
        err = _ump_ukk_release(&release_args);
        if (_MALI_OSK_ERR_OK != err) {
                MSG_ERR(("_ump_ukk_release() failed in ump_ioctl_release()\n"));
-               return map_errcode(err);
+               return ump_map_errcode(err);
        }
 
 
        }
 
 
@@ -113,7 +113,7 @@ int ump_size_get_wrapper(u32 __user *argument, struct ump_session_data   *sessio
        err = _ump_ukk_size_get(&user_interaction);
        if (_MALI_OSK_ERR_OK != err) {
                MSG_ERR(("_ump_ukk_size_get() failed in ump_ioctl_size_get()\n"));
        err = _ump_ukk_size_get(&user_interaction);
        if (_MALI_OSK_ERR_OK != err) {
                MSG_ERR(("_ump_ukk_size_get() failed in ump_ioctl_size_get()\n"));
-               return map_errcode(err);
+               return ump_map_errcode(err);
        }
 
        user_interaction.ctx = NULL;
        }
 
        user_interaction.ctx = NULL;
index 05000804af0a94038d251e577214aa0c280c3752..1adad5b798c9f3c4864db7b22182dfbe28ef6bc4 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2010, 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2010, 2012-2014, 2016 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.
  * 
  * 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.
index 8b5a6d9be821325c5e9391764f26055eae456d33..d3dc0e3c0ad259ce397ff61a4662258c25db594b 100755 (executable)
@@ -1,5 +1,5 @@
 #
 #
-# Copyright (C) 2012, 2015 ARM Limited. All rights reserved.
+# Copyright (C) 2012, 2016 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.
 # 
 # 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.
index f117177fcc3e06d2bb60d0057a81e97c14e7b3b4..ccd96d3ecab809afbc6a4194c33ae8dd1c303076 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2016 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.
  * 
  * 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.
index f7d8176a7ed94b84550dd7517e5b2e679404ca93..32462f32ec72665d6f98829eb37e5c122243f48a 100755 (executable)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012-2013, 2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2012-2013, 2016 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.
  * 
  * 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.