#
-# This confidential and proprietary software may be used only as
-# authorised by a licensing agreement from ARM Limited
-# (C) COPYRIGHT 2007-2011 ARM Limited
-# ALL RIGHTS RESERVED
-# The entire notice above must be reproduced on all authorised
-# copies and copies may only be made to the extent permitted
-# by a licensing agreement from ARM Limited.
+# Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+#
+# This program is free software and is provided to you under the terms of the GNU General Public License version 2
+# as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+#
+# A copy of the licence is included with the program, and can also be obtained from Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# This file is called by the Linux build system.
############## Kasin Added, for platform. ################
-TARGET_PLATFORM:=meson6pre
+TARGET_PLATFORM:=meson_m400
ifeq ($(CONFIG_ARCH_MESON8),y)
-TARGET_PLATFORM:= meson8
+TARGET_PLATFORM:= meson_m450
+endif
+ifeq ($(CONFIG_ARCH_MESON6TVD),y)
+TARGET_PLATFORM:= meson_m450
endif
##################### end Kasin Added. ###################
PROFILING_SKIP_PP_JOBS ?= 0
PROFILING_SKIP_PP_AND_GP_JOBS ?= 0
+############## Kasin Added, for platform. ################
ifeq ($(CONFIG_MALI400_DEBUG),y)
BUILD ?= debug
else
BUILD ?= release
endif
+##################### end Kasin Added. ###################
+############## Kasin Added, useless now. ################
ifeq ($(USING_UMP),1)
UMP_SYMVERS_FILE = ../ump/Module.symvers
KBUILD_EXTRA_SYMBOLS = $(srctree)/$(src)/$(UMP_SYMVERS_FILE)
endif
+##################### end Kasin Added. ###################
MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP ?= 0
MALI_PP_SCHEDULER_KEEP_SUB_JOB_STARTS_ALIGNED ?= 0
MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP_BETWEEN_APPS ?= 0
MALI_UPPER_HALF_SCHEDULING ?= 1
+############## Kasin Added, useless now. ################
# Get path to driver source from Linux build system
DRIVER_DIR=$(src)
+##################### end Kasin Added. ###################
+
MALI_ENABLE_CPU_CYCLES ?= 0
# For customer releases the Linux Device Drivers will be provided as ARM proprietary and GPL releases:
__malidrv_build_info.o
############## Kasin Added, for platform. ################
-ifeq ($(TARGET_PLATFORM),meson6pre)
-MALI_PLATFORM_FILES:= platform/meson6pre/mali_fix.c \
- platform/meson6pre/mali_platform.c \
- platform/meson6pre/meson_main.c \
- platform/meson6pre/mali_device_type.c
+mali-y += \
+ platform/meson_main.o \
+ platform/mali_pm_device.o \
+ platform/mali_clock.o \
+ platform/mpgpu.o \
+
+
+ifeq ($(TARGET_PLATFORM),meson_m400)
+MALI_PLATFORM_FILES:= \
+ platform/meson_m400/mali_fix.o \
+ platform/meson_m400/mali_platform.o \
+ platform/meson_m400/platform_mx.o
endif
-ifeq ($(TARGET_PLATFORM),meson8)
-MALI_PLATFORM_FILES:= platform/meson8/mali_scaling.c \
- platform/meson8/meson_main.c \
- platform/meson8/mali_clock.c \
- platform/meson8/mali_device_type.c \
- platform/mpgpu.c
+ifeq ($(TARGET_PLATFORM),meson_m450)
+MALI_PLATFORM_FILES:= \
+ platform/meson_m450/platform_m8.o \
+ platform/meson_m450/platform_m6tvd.o \
+ platform/meson_m450/scaling_m8.o \
+
endif
##################### end Kasin Added. ###################
---help---
This enables support for dynamic performance scaling of Mali with the goal of lowering power consumption.
-
-config MALI400_UTILIZATION
- bool "Enable Mali Utilization and Frequency and pp scaling."
- depends on MALI400
- default y
- ---help---
- This enables the frequency and pp scaling.
-
config MALI_DMA_BUF_MAP_ON_ATTACH
bool "Map dma-buf attachments on attach"
depends on MALI400 && DMA_SHARED_BUFFER
#
-# This confidential and proprietary software may be used only as
-# authorised by a licensing agreement from ARM Limited
-# (C) COPYRIGHT 2007-2013 ARM Limited
-# ALL RIGHTS RESERVED
-# The entire notice above must be reproduced on all authorised
-# copies and copies may only be made to the extent permitted
-# by a licensing agreement from ARM Limited.
+# Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+#
+# This program is free software and is provided to you under the terms of the GNU General Public License version 2
+# 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.
#
USE_UMPV2=0
$(warning "You have specified the CPU variable which is no longer in used. Use TARGET_PLATFORM instead.")
endif
-# KDIR not set when included by modpost
-ifneq ($(KBUILD_EXTMOD),)
- ifeq ($(KDIR),)
- KDIR := $(KBUILD_SRC)
- endif
-endif
-
# Include the mapping between TARGET_PLATFORM and KDIR + MALI_PLATFORM
-include MALI_CONFIGURATION
export KDIR ?= $(KDIR-$(TARGET_PLATFORM))
# Define host system directory
KDIR-$(shell uname -m):=/lib/modules/$(shell uname -r)/build
-# .config could be in an output directory, different than KDIR
-# and it's not needed during modpost
-ifeq ($(KBUILD_EXTMOD),)
- include $(KDIR)/.config
-endif
+include $(KDIR)/.config
ifeq ($(ARCH), arm)
# when compiling for ARM we're cross compiling
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_broadcast.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_dlbu.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_DLBU_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __MALI_DMA_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_gp.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_GP_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_gp_job.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_GP_JOB_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_gp_scheduler.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_GP_SCHEDULER_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//#if MESON_CPU_TYPE == MESON_CPU_TYPE_MESON6
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_GROUP_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_hw_core.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_HW_CORE_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2007-2010, 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010, 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __MALI_KERNEL_COMMON_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2007-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2007-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __MALI_KERNEL_CORE_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2010, 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010, 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2010, 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010, 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2010-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_utilization.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2010-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __MALI_KERNEL_UTILIZATION_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "mali_kernel_common.h"
#include "mali_osk.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __MALI_KERNEL_L2_CACHE_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_mem_validation.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_MEM_VALIDATION_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2007-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2007-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_MMU_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_MMU_PAGE_DIRECTORY_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2010, 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010, 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2010-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_OSK_PROFILING_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_DOMAIN_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2009-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2009-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_pp_job.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_PP_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_pp.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_PP_JOB_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_pp_scheduler.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_PP_SCHEDULER_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_scheduler.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_SCHEDULER_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_SCHEDULER_TYPES_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_SESSION_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_soft_job.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_SOFT_JOB_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_spinlock_reentrant.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_SPINLOCK_REENTRANT_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_timeline.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_TIMELINE_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_timeline_fence_wait.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_timeline_sync_fence.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/**
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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.h"
/**
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_USER_SETTINGS_DB_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2007-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_UTGARD_COUNTERS_H_
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2007-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_UTGARD_IOCTL_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2010-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_UTGARD_PROFILING_EVENTS_H_
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_UTGARD_PROFILING_GATOR_API_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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.
*/
/**
#define __MALI_KERNEL_LICENSE_H__
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
#define MALI_KERNEL_LINUX_LICENSE "GPL"
/**
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2010-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/**
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __MALI_KERNEL_LINUX_H__
/**
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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.
*/
.llseek = default_llseek,
};
-#if MESON_CPU_TYPE == MESON_CPU_TYPE_MESON8
-extern u32 get_mali_default_clock_idx(void);
-extern void set_mali_freq_idx(u32 idx);
-extern u32 get_mali_qq_for_sched(void);
-extern void set_mali_qq_for_sched(u32 pp_num);
-extern u32 get_mali_schel_mode(void);
-extern void set_mali_schel_mode(u32 mode);
-extern u32 get_max_pp_num(void);
-extern u32 set_max_pp_num(u32 num);
-extern u32 get_min_pp_num(void);
-extern u32 set_min_pp_num(u32 num);
-extern u32 get_max_mali_freq(void);
-extern u32 set_max_mali_freq(u32 idx);
-extern u32 get_min_mali_freq(void);
-extern u32 set_min_mali_freq(u32 idx);
-
-extern void enable_clock(void);
-extern void disable_clock(void);
-
-static ssize_t pp_for_sched_read(struct file *filp, char __user *buf, size_t count, loff_t *offp)
-{
- int r;
- char buffer[64];
- r = sprintf(buffer, "%d\n", get_mali_qq_for_sched());
-
- return simple_read_from_buffer(buf, count, offp, buffer, r);
-}
-
-static ssize_t pp_for_sched_write(struct file *filp, const char __user *buf, size_t count, loff_t *offp)
-{
- int ret;
- char buffer[32];
- unsigned long val;
-
- if (count >= sizeof(buffer))
- {
- return -ENOMEM;
- }
-
- if (copy_from_user(&buffer[0], buf, count))
- {
- return -EFAULT;
- }
- buffer[count] = '\0';
-
- ret = strict_strtoul(&buffer[0], 10, &val);
- if (0 != ret)
- {
- return -EINVAL;
- }
-
- set_mali_qq_for_sched(val);
-
- *offp += count;
- return count;
-}
-
-static const struct file_operations pp_for_sched_fops = {
- .owner = THIS_MODULE,
- .read = pp_for_sched_read,
- .write = pp_for_sched_write,
-};
-
-static ssize_t cur_freq_read (struct file *filp, char __user *buf, size_t count, loff_t *offp)
-{
- int r;
- char buffer[64];
- r = sprintf(buffer, "%d\n", get_mali_default_clock_idx());
-
- return simple_read_from_buffer(buf, count, offp, buffer, r);
-}
-
-static ssize_t cur_freq_write (struct file *filp, const char __user *buf, size_t count, loff_t *offp)
-{
- int ret;
- char buffer[32];
- unsigned long val;
-
- if (count >= sizeof(buffer))
- {
- return -ENOMEM;
- }
-
- if (copy_from_user(&buffer[0], buf, count))
- {
- return -EFAULT;
- }
- buffer[count] = '\0';
-
- ret = strict_strtoul(&buffer[0], 10, &val);
- if (0 != ret)
- {
- return -EINVAL;
- }
-
- set_mali_freq_idx(val);
-
- *offp += count;
- return count;
-}
-
-static const struct file_operations cur_freq_fops = {
- .owner = THIS_MODULE,
- .read = cur_freq_read,
- .write = cur_freq_write,
-};
-
-static ssize_t scale_mode_read(struct file *filp, char __user *buf, size_t count, loff_t *offp)
-{
- int r;
- char buffer[64];
- r = sprintf(buffer, "%d\n", get_mali_schel_mode());
-
- return simple_read_from_buffer(buf, count, offp, buffer, r);
-}
-
-static ssize_t scale_mode_write(struct file *filp, const char __user *buf, size_t count, loff_t *offp)
-{
- int ret;
- char buffer[32];
- unsigned long val;
-
- if (count >= sizeof(buffer))
- {
- return -ENOMEM;
- }
-
- if (copy_from_user(&buffer[0], buf, count))
- {
- return -EFAULT;
- }
- buffer[count] = '\0';
-
- ret = strict_strtoul(&buffer[0], 10, &val);
- if (0 != ret)
- {
- return -EINVAL;
- }
-
- set_mali_schel_mode(val);
-
- *offp += count;
- return count;
-}
-
-static const struct file_operations scale_mode_fops = {
- .owner = THIS_MODULE,
- .read = scale_mode_read,
- .write = scale_mode_write
-};
-
-static ssize_t domain_stat_read(struct file *filp, char __user *buf, size_t count, loff_t *offp)
-{
- int r;
- char buffer[64];
- r = sprintf(buffer, "%x\n", mali_pmu_get_status());
-
- return simple_read_from_buffer(buf, count, offp, buffer, r);
-}
-
-static const struct file_operations domain_stat_fops = {
- .owner = THIS_MODULE,
- .read = domain_stat_read,
-};
-
-static ssize_t max_pp_read(struct file *filp, char __user *buf, size_t count, loff_t *offp)
-{
- int r;
- char buffer[64];
- r = sprintf(buffer, "%d\n", get_max_pp_num());
-
- return simple_read_from_buffer(buf, count, offp, buffer, r);
-}
-
-static ssize_t max_pp_write(struct file *filp, const char __user *buf, size_t count, loff_t *offp)
-{
- int ret;
- char buffer[32];
- unsigned long val;
-
- if (count >= sizeof(buffer))
- {
- return -ENOMEM;
- }
-
- if (copy_from_user(&buffer[0], buf, count))
- {
- return -EFAULT;
- }
- buffer[count] = '\0';
-
- ret = strict_strtoul(&buffer[0], 10, &val);
- if (0 != ret)
- {
- return -EINVAL;
- }
-
- ret = set_max_pp_num(val);
-
- *offp += count;
- return count;
-}
-
-static const struct file_operations max_pp_fops = {
- .owner = THIS_MODULE,
- .read = max_pp_read,
- .write = max_pp_write
-};
-
-static ssize_t min_pp_read(struct file *filp, char __user *buf, size_t count, loff_t *offp)
-{
- int r;
- char buffer[64];
- r = sprintf(buffer, "%d\n", get_min_pp_num());
-
- return simple_read_from_buffer(buf, count, offp, buffer, r);
-}
-
-static ssize_t min_pp_write(struct file *filp, const char __user *buf, size_t count, loff_t *offp)
-{
- int ret;
- char buffer[32];
- unsigned long val;
-
- if (count >= sizeof(buffer))
- {
- return -ENOMEM;
- }
-
- if (copy_from_user(&buffer[0], buf, count))
- {
- return -EFAULT;
- }
- buffer[count] = '\0';
-
- ret = strict_strtoul(&buffer[0], 10, &val);
- if (0 != ret)
- {
- return -EINVAL;
- }
-
- ret = set_min_pp_num(val);
-
- *offp += count;
- return count;
-}
-
-static const struct file_operations min_pp_fops = {
- .owner = THIS_MODULE,
- .read = min_pp_read,
- .write = min_pp_write
-};
-
-
-static ssize_t max_freq_read(struct file *filp, char __user *buf, size_t count, loff_t *offp)
-{
- int r;
- char buffer[64];
- r = sprintf(buffer, "%d\n", get_max_mali_freq());
-
- return simple_read_from_buffer(buf, count, offp, buffer, r);
-}
-
-static ssize_t max_freq_write(struct file *filp, const char __user *buf, size_t count, loff_t *offp)
-{
- int ret;
- char buffer[32];
- unsigned long val;
-
- if (count >= sizeof(buffer))
- {
- return -ENOMEM;
- }
-
- if (copy_from_user(&buffer[0], buf, count))
- {
- return -EFAULT;
- }
- buffer[count] = '\0';
-
- ret = strict_strtoul(&buffer[0], 10, &val);
- if (0 != ret)
- {
- return -EINVAL;
- }
-
- ret = set_max_mali_freq(val);
-
- *offp += count;
- return count;
-}
-
-static const struct file_operations max_freq_fops = {
- .owner = THIS_MODULE,
- .read = max_freq_read,
- .write = max_freq_write
-};
-
-
-static ssize_t min_freq_read(struct file *filp, char __user *buf, size_t count, loff_t *offp)
-{
- int r;
- char buffer[64];
- r = sprintf(buffer, "%d\n", get_min_mali_freq());
-
- return simple_read_from_buffer(buf, count, offp, buffer, r);
-}
-
-static ssize_t min_freq_write(struct file *filp, const char __user *buf, size_t count, loff_t *offp)
-{
- int ret;
- char buffer[32];
- unsigned long val;
-
- if (count >= sizeof(buffer))
- {
- return -ENOMEM;
- }
-
- if (copy_from_user(&buffer[0], buf, count))
- {
- return -EFAULT;
- }
- buffer[count] = '\0';
-
- ret = strict_strtoul(&buffer[0], 10, &val);
- if (0 != ret)
- {
- return -EINVAL;
- }
-
- ret = set_min_mali_freq(val);
-
- *offp += count;
- return count;
-}
-
-static const struct file_operations min_freq_fops = {
- .owner = THIS_MODULE,
- .read = min_freq_read,
- .write = min_freq_write
-};
-
-
-#endif /* MESON_CPU_TYPE_MESON8 */
-
static ssize_t version_read(struct file *filp, char __user *buf, size_t count, loff_t *offp)
{
int r = 0;
#if MALI_STATE_TRACKING
debugfs_create_file("state_dump", 0400, mali_debugfs_dir, NULL, &mali_seq_internal_state_fops);
#endif
-
-#if MESON_CPU_TYPE == MESON_CPU_TYPE_MESON8
- /* kasin.li@amlogic.com. misc setting. */
- {
- struct dentry *mali_misc_setting_dir = debugfs_create_dir("misc", mali_debugfs_dir);
- if (mali_misc_setting_dir != NULL)
- {
- debugfs_create_file("pp_for_sched", 0600, mali_misc_setting_dir, NULL, &pp_for_sched_fops);
- debugfs_create_file("cur_freq", 0600, mali_misc_setting_dir, NULL, &cur_freq_fops);
- debugfs_create_file("scale_mode", 0600, mali_misc_setting_dir, NULL, &scale_mode_fops);
- debugfs_create_file("domain_stat", 0600, mali_misc_setting_dir, NULL, &domain_stat_fops);
- debugfs_create_file("max_pp", 0600, mali_misc_setting_dir, NULL, &max_pp_fops);
- debugfs_create_file("min_pp", 0600, mali_misc_setting_dir, NULL, &min_pp_fops);
- debugfs_create_file("max_freq", 0600, mali_misc_setting_dir, NULL, &max_freq_fops);
- debugfs_create_file("min_freq", 0600, mali_misc_setting_dir, NULL, &min_freq_fops);
-
- }
- }
-#endif /* MESON_CPU_TYPE_MESON8 */
-
if (mali_sysfs_user_settings_register()) {
/* Failed to create the debugfs entries for the user settings DB. */
MALI_DEBUG_PRINT(2, ("Failed to create user setting debugfs files. Ignoring...\n"));
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __MALI_KERNEL_SYSFS_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#if !defined (MALI_LINUX_TRACE_H) || defined (TRACE_HEADER_MULTI_READ)
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <linux/list.h>
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2010, 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010, 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_BLOCK_ALLOCATOR_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <linux/fs.h> /* file system operations */
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_DMA_BUF_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <linux/list.h>
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_OS_ALLOC_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_TYPES_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_ukk.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2010, 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010, 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2010, 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010, 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2011, 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2011, 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/**
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2010-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <linux/module.h>
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2010, 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010, 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2010, 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010, 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/**
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2010, 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010, 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __MALI_PROFILING_EVENTS_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __MALI_PROFILING_GATOR_API_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2010-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __MALI_PROFILING_INTERNAL_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_sync.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2012 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2012 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __MALI_UK_TYPES_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <linux/fs.h> /* file system operations */
#include <linux/slab.h> /* memort allocation functions */
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2010, 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010, 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <linux/fs.h> /* file system operations */
#include <asm/uaccess.h> /* user space access */
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <linux/fs.h> /* file system operations */
#include <asm/uaccess.h> /* user space access */
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2010, 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010, 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <linux/fs.h> /* file system operations */
#include <asm/uaccess.h> /* user space access */
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2010-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <linux/fs.h> /* file system operations */
#include <asm/uaccess.h> /* user space access */
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <linux/fs.h> /* file system operations */
#include <asm/uaccess.h> /* user space access */
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <linux/fs.h> /* file system operations */
#include <asm/uaccess.h> /* user space access */
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <linux/fs.h> /* file system operations */
#include <asm/uaccess.h> /* user space access */
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2008-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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.
*/
/**
--- /dev/null
+#include <linux/platform_device.h>
+#include <linux/version.h>
+#include <linux/pm.h>
+#include <mach/register.h>
+#include <mach/irqs.h>
+#include <linux/io.h>
+#include <mach/io.h>
+#include <plat/io.h>
+#include <asm/io.h>
+
+#include "meson_main.h"
+
+static DEFINE_SPINLOCK(lock);
+
+int mali_clock_init(u32 def_clk_idx)
+{
+ mali_clock_set(def_clk_idx);
+ return 0;
+}
+
+int mali_clock_critical(critical_t critical, u64 param)
+{
+ int ret = 0;
+ unsigned long flags;
+
+ spin_lock_irqsave(&lock, flags);
+ ret = critical(param);
+ spin_unlock_irqrestore(&lock, flags);
+ return ret;
+}
+
+static int critical_clock_set(u64 param)
+{
+ unsigned int idx = param;
+ clrbits_le32((u32)P_HHI_MALI_CLK_CNTL, 1 << 8);
+ clrbits_le32((u32)P_HHI_MALI_CLK_CNTL, (0x7F | (0x7 << 9)));
+ writel(mali_dvfs_clk[idx], (u32*)P_HHI_MALI_CLK_CNTL); /* set clock to 333MHZ.*/
+ setbits_le32((u32)P_HHI_MALI_CLK_CNTL, 1 << 8);
+ return 0;
+}
+
+int mali_clock_set(unsigned int clock)
+{
+ return mali_clock_critical(critical_clock_set, (u64)clock);
+}
+
+void disable_clock(void)
+{
+ unsigned long flags;
+ spin_lock_irqsave(&lock, flags);
+ clrbits_le32((u32)P_HHI_MALI_CLK_CNTL, 1 << 8);
+ spin_unlock_irqrestore(&lock, flags);
+ printk("## mali clock off----\n");
+}
+
+void enable_clock(void)
+{
+ u32 ret = 0;
+ unsigned long flags;
+ spin_lock_irqsave(&lock, flags);
+ setbits_le32((u32)P_HHI_MALI_CLK_CNTL, 1 << 8);
+ ret = readl((u32 *)P_HHI_MALI_CLK_CNTL) & (1 << 8);
+ spin_unlock_irqrestore(&lock, flags);
+ printk("## mali clock on :%x++++\n", ret);
+}
+
+u32 get_mali_freq(u32 idx)
+{
+ return mali_dvfs_clk_sample[idx];
+}
--- /dev/null
+#ifndef _MALI_CLOCK_H_
+#define _MALI_CLOCK_H_
+
+typedef int (*critical_t)(u64 param);
+int mali_clock_critical(critical_t critical, u64 param);
+
+int mali_clock_init(u32 def_clk_idx);
+int mali_clock_set(unsigned int index);
+void disable_clock(void);
+void enable_clock(void);
+u32 get_mali_freq(u32 idx);
+#endif /* _MALI_CLOCK_H_ */
#ifndef MALI_PLATFORM_H_
#define MALI_PLATFORM_H_
-#if MESON_CPU_TYPE < MESON_CPU_TYPE_MESON8
-#else
-#include "meson8/platform_api.h"
-#endif
#endif /* MALI_PLATFORM_H_ */
--- /dev/null
+#include <linux/platform_device.h>
+#include <linux/version.h>
+#include <linux/pm.h>
+#include <linux/of.h>
+#include <linux/module.h> /* kernel module definitions */
+#include <linux/ioport.h> /* request_mem_region */
+#include <linux/slab.h>
+#include <mach/register.h>
+#include <mach/irqs.h>
+#include <mach/io.h>
+#include "meson_main.h"
+#include <common/mali_kernel_common.h>
+#include <common/mali_osk_profiling.h>
+#include <common/mali_pmu.h>
+
+static int mali_os_suspend(struct device *device)
+{
+ int ret = 0;
+
+ MALI_DEBUG_PRINT(4, ("mali_os_suspend() called\n"));
+ ret = mali_deep_suspend(device);
+
+ return ret;
+}
+
+static int mali_os_resume(struct device *device)
+{
+ int ret = 0;
+
+ MALI_DEBUG_PRINT(4, ("mali_os_resume() called\n"));
+ ret = mali_deep_resume(device);
+
+ return ret;
+}
+
+static int mali_os_freeze(struct device *device)
+{
+ int ret = 0;
+
+ MALI_DEBUG_PRINT(4, ("mali_os_freeze() called\n"));
+
+ if (NULL != device->driver &&
+ NULL != device->driver->pm &&
+ NULL != device->driver->pm->freeze)
+ {
+ /* Need to notify Mali driver about this event */
+ ret = device->driver->pm->freeze(device);
+ }
+
+ return ret;
+}
+
+static int mali_os_thaw(struct device *device)
+{
+ int ret = 0;
+
+ MALI_DEBUG_PRINT(4, ("mali_os_thaw() called\n"));
+
+ if (NULL != device->driver &&
+ NULL != device->driver->pm &&
+ NULL != device->driver->pm->thaw)
+ {
+ /* Need to notify Mali driver about this event */
+ ret = device->driver->pm->thaw(device);
+ }
+
+ return ret;
+}
+
+#ifdef CONFIG_PM_RUNTIME
+static int mali_runtime_suspend(struct device *device)
+{
+ int ret = 0;
+
+ MALI_DEBUG_PRINT(4, ("mali_runtime_suspend() called\n"));
+ ret = mali_light_suspend(device);
+
+ return ret;
+}
+
+static int mali_runtime_resume(struct device *device)
+{
+ int ret = 0;
+
+ MALI_DEBUG_PRINT(4, ("mali_run time_resume() called\n"));
+ ret = mali_light_resume(device);
+
+ return ret;
+}
+
+static int mali_runtime_idle(struct device *device)
+{
+ MALI_DEBUG_PRINT(4, ("mali_runtime_idle() called\n"));
+
+ if (NULL != device->driver &&
+ NULL != device->driver->pm &&
+ NULL != device->driver->pm->runtime_idle)
+ {
+ /* Need to notify Mali driver about this event */
+ int ret = device->driver->pm->runtime_idle(device);
+ if (0 != ret)
+ {
+ return ret;
+ }
+ }
+
+ pm_runtime_suspend(device);
+
+ return 0;
+}
+#endif
+
+static struct dev_pm_ops mali_gpu_device_type_pm_ops =
+{
+ .suspend = mali_os_suspend,
+ .resume = mali_os_resume,
+ .freeze = mali_os_freeze,
+ .thaw = mali_os_thaw,
+#ifdef CONFIG_PM_RUNTIME
+ .runtime_suspend = mali_runtime_suspend,
+ .runtime_resume = mali_runtime_resume,
+ .runtime_idle = mali_runtime_idle,
+#endif
+};
+
+struct device_type mali_pm_device =
+{
+ .pm = &mali_gpu_device_type_pm_ops,
+};
--- /dev/null
+/*
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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 arm_core_scaling.h
+ * Example core scaling policy.
+ */
+
+#ifndef __ARM_CORE_SCALING_H__
+#define __ARM_CORE_SCALING_H__
+
+typedef struct mali_dvfs_threshold_table {
+ unsigned int freq_index;
+ unsigned int voltage;
+ unsigned int keep_count;
+ unsigned int downthreshold;
+ unsigned int upthreshold;
+} mali_dvfs_threshold_table_t;
+
+/**
+ * Initialize core scaling policy.
+ *
+ * @note The core scaling policy will assume that all PP cores are on initially.
+ *
+ * @param num_pp_cores Total number of PP cores.
+ */
+void mali_core_scaling_init(int pp, int clock_idx);
+
+/**
+ * Terminate core scaling policy.
+ */
+void mali_core_scaling_term(void);
+
+/**
+ * Update core scaling policy with new utilization data.
+ *
+ * @param data Utilization data.
+ */
+
+/**
+ * cancel and flush scaling job queue.
+ */
+void flush_scaling_job(void);
+
+u32 set_mali_dvfs_tbl_size(u32 size);
+u32 get_max_dvfs_tbl_size(void);
+uint32_t* get_mali_dvfs_tbl_addr(void);
+
+/* get or set the max/min number of pp cores. */
+u32 get_max_pp_num(void);
+u32 set_max_pp_num(u32 num);
+u32 get_min_pp_num(void);
+u32 set_min_pp_num(u32 num);
+
+/* get or set the max/min frequency of GPU. */
+u32 get_max_mali_freq(void);
+u32 set_max_mali_freq(u32 idx);
+u32 get_min_mali_freq(void);
+u32 set_min_mali_freq(u32 idx);
+
+/* get or set the scale mode. */
+u32 get_mali_schel_mode(void);
+void set_mali_schel_mode(u32 mode);
+
+/* preheat of the GPU. */
+void mali_plat_preheat(void);
+#endif /* __ARM_CORE_SCALING_H__ */
--- /dev/null
+/*
+ * AMLOGIC Mali fix driver.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the named License,
+ * or any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Author: Tim Yao <timyao@amlogic.com>
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/timer.h>
+#include <asm/io.h>
+#include <linux/ioport.h>
+#include <linux/dma-mapping.h>
+
+#include <linux/module.h>
+
+#include <mach/am_regs.h>
+#include <mach/clock.h>
+
+#include "mali_kernel_common.h"
+#include "mali_osk.h"
+#include "mali_platform.h"
+#include "mali_fix.h"
+
+#define MALI_MM1_REG_ADDR 0xd0064000
+#define MALI_MMU_REGISTER_INT_STATUS 0x0008
+#define MALI_MM2_REG_ADDR 0xd0065000
+#define MALI_MMU_REGISTER_INT_STATUS 0x0008
+#define MALI_MM_REG_SIZE 0x1000
+
+#define READ_MALI_MMU1_REG(r) (ioread32(((u8*)mali_mm1_regs) + r))
+#define READ_MALI_MMU2_REG(r) (ioread32(((u8*)mali_mm2_regs) + r))
+
+extern int mali_PP0_int_cnt(void);
+extern int mali_PP1_int_cnt(void);
+
+static ulong * mali_mm1_regs = NULL;
+static ulong * mali_mm2_regs = NULL;
+static struct timer_list timer;
+
+static u32 mali_pp1_int_count = 0;
+static u32 mali_pp2_int_count = 0;
+static u32 mali_pp1_mmu_int_count = 0;
+static u32 mali_pp2_mmu_int_count = 0;
+static u32 mali_mmu_int_process_state[2];
+
+static void timer_callback(ulong data)
+{
+ unsigned long mali_flags;
+
+ mali_pp1_int_count = mali_PP0_int_cnt();
+ mali_pp2_int_count = mali_PP1_int_cnt();
+
+ /* lock mali_clock_gating when access Mali registers */
+ mali_flags = mali_clock_gating_lock();
+
+ if (READ_CBUS_REG(HHI_MALI_CLK_CNTL) & 0x100) {
+ /* polling for PP1 MMU interrupt */
+ if (mali_mmu_int_process_state[0] == MMU_INT_NONE) {
+ if (READ_MALI_MMU1_REG(MALI_MMU_REGISTER_INT_STATUS) != 0) {
+ mali_pp1_mmu_int_count++;
+ MALI_DEBUG_PRINT(3, ("Mali MMU: core0 page fault emit \n"));
+ mali_mmu_int_process_state[0] = MMU_INT_HIT;
+ __raw_writel(1, P_ISA_TIMERC);
+ }
+ }
+
+ /* polling for PP2 MMU interrupt */
+ if (mali_mmu_int_process_state[1] == MMU_INT_NONE) {
+ if (READ_MALI_MMU2_REG(MALI_MMU_REGISTER_INT_STATUS) != 0) {
+ mali_pp2_mmu_int_count++;
+ MALI_DEBUG_PRINT(3, ("Mali MMU: core1 page fault emit \n"));
+ mali_mmu_int_process_state[1] = MMU_INT_HIT;
+ __raw_writel(1, P_ISA_TIMERC);
+ }
+ }
+ }
+
+ mali_clock_gating_unlock(mali_flags);
+
+ timer.expires = jiffies + HZ/100;
+
+ add_timer(&timer);
+}
+
+void malifix_set_mmu_int_process_state(int index, int state)
+{
+ if (index < 2)
+ mali_mmu_int_process_state[index] = state;
+}
+
+int malifix_get_mmu_int_process_state(int index)
+{
+ if (index < 2)
+ return mali_mmu_int_process_state[index];
+ return 0;
+}
+
+void malifix_init(void)
+{
+#if MESON_CPU_TYPE == MESON_CPU_TYPE_MESON6
+ if (!mali_meson_is_revb())
+ return;
+
+ if ((mali_mm1_regs) && (mali_mm2_regs)) return;
+ mali_mmu_int_process_state[0] = 0;
+ mali_mmu_int_process_state[1] = 0;
+
+ /* set up Timer C as a 1uS one-shot timer */
+ aml_clr_reg32_mask(P_ISA_TIMER_MUX, (1<<18)|(1<<14)|(3<<4));
+ aml_set_reg32_mask(P_ISA_TIMER_MUX, (1<<18)|(0<<14)|(0<<4));
+
+ setup_timer(&timer, timer_callback, 0);
+
+ mali_mm1_regs = (ulong *)ioremap_nocache(MALI_MM1_REG_ADDR, MALI_MM_REG_SIZE);
+ if (mali_mm1_regs)
+ printk("Mali pp1 MMU register mapped at %p...\n", mali_mm1_regs);
+
+ mali_mm2_regs = (ulong *)ioremap_nocache(MALI_MM2_REG_ADDR, MALI_MM_REG_SIZE);
+ if (mali_mm2_regs)
+ printk("Mali pp2 MMU register mapped at %p...\n", mali_mm2_regs);
+
+ if ((mali_mm1_regs != NULL) && (mali_mm2_regs != NULL))
+ mod_timer(&timer, jiffies + HZ/100);
+#endif
+}
+
+void malifix_exit(void)
+{
+#if MESON_CPU_TYPE == MESON_CPU_TYPE_MESON6
+ if (!mali_meson_is_revb())
+ return;
+
+ del_timer(&timer);
+
+ if (mali_mm1_regs != NULL)
+ iounmap(mali_mm1_regs);
+ mali_mm1_regs = NULL;
+
+ if (mali_mm2_regs != NULL)
+ iounmap(mali_mm2_regs);
+ mali_mm2_regs = NULL;
+
+#endif
+ return;
+}
+
+module_param(mali_pp1_int_count, uint, 0664);
+MODULE_PARM_DESC(mali_pp1_int_count, "Mali PP1 interrupt count\n");
+
+module_param(mali_pp2_int_count, uint, 0664);
+MODULE_PARM_DESC(mali_pp2_int_count, "Mali PP1 interrupt count\n");
+
+module_param(mali_pp1_mmu_int_count, uint, 0664);
+MODULE_PARM_DESC(mali_pp1_mmu_int_count, "Mali PP1 mmu interrupt count\n");
+
+module_param(mali_pp2_mmu_int_count, uint, 0664);
+MODULE_PARM_DESC(mali_pp2_mmu_int_count, "Mali PP2 mmu interrupt count\n");
+
+MODULE_DESCRIPTION("AMLOGIC mali fix driver");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Tim Yao <timyao@amlogic.com>");
--- /dev/null
+#ifndef MALI_FIX_H\r
+#define MALI_FIX_H\r
+\r
+#define MMU_INT_NONE 0\r
+#define MMU_INT_HIT 1\r
+#define MMU_INT_TOP 2\r
+#define MMU_INT_BOT 3\r
+\r
+extern void malifix_init(void);\r
+extern void malifix_exit(void);\r
+extern void malifix_set_mmu_int_process_state(int, int);\r
+extern int malifix_get_mmu_int_process_state(int);\r
+extern int mali_meson_is_revb(void);\r
+\r
+#endif /* MALI_FIX_H */\r
--- /dev/null
+/*
+ * This confidential and proprietary software may be used only as
+ * authorised by a licensing agreement from AMLOGIC, INC.
+ * (C) COPYRIGHT 2011 AMLOGIC, INC.
+ * ALL RIGHTS RESERVED
+ * The entire notice above must be reproduced on all authorised
+ * copies and copies may only be made to the extent permitted
+ * by a licensing agreement from AMLOGIC, INC.
+ */
+
+/**
+ * @file mali_platform.c
+ * Platform specific Mali driver functions for meson platform
+ */
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/slab.h>
+#include <linux/dma-mapping.h>
+#include <linux/spinlock.h>
+#include <linux/spinlock_types.h>
+#include <linux/delay.h>
+#include <linux/clk.h>
+#include <mach/am_regs.h>
+#include <mach/clock.h>
+
+#include "mali_kernel_common.h"
+#include "mali_osk.h"
+#include "mali_platform.h"
+#include "mali_poweron_reg.h"
+#include "mali_fix.h"
+#include "mali_platform.h"
+
+static int last_power_mode = -1;
+static int mali_init_flag = 0;
+static const u32 poweron_data[] =
+{
+/* commands */
+/* 000 */ 0x00000040, 0x20400000, 0x00000300, 0x30040000,
+/* 010 */ 0x00000400, 0x400a0000, 0x0f000033, 0x10000042,
+/* 020 */ 0x00300c00, 0x10000040, 0x4c000001, 0x00000000,
+/* 030 */ 0x00000000, 0x60000000, 0x00000000, 0x00000000,
+/* 040 */ 0x00004000, 0x00002000, 0x00000210, 0x0000203f,
+/* 050 */ 0x00000220, 0x0000203f, 0x00000230, 0x0000203f,
+/* 060 */ 0x00000240, 0x0000203f, 0x00000250, 0x0000203f,
+/* 070 */ 0x00000260, 0x0000203f, 0x00000270, 0x0000203f,
+/* 080 */ 0x00000280, 0x0000203f, 0x00000290, 0x0000203f,
+/* 090 */ 0x000002a0, 0x0000203f, 0x000002b0, 0x0000203f,
+/* 0a0 */ 0x000002c0, 0x0000203f, 0x000002d0, 0x0000203f,
+/* 0b0 */ 0x000002e0, 0x0000203f, 0x000002f0, 0x0000203f,
+/* 0c0 */ 0x00002000, 0x00002000, 0x00002010, 0x0000203f,
+/* 0d0 */ 0x00002020, 0x0000203f, 0x00002030, 0x0000203f,
+/* 0e0 */ 0x00002040, 0x0000203f, 0x00002050, 0x0000203f,
+/* 0f0 */ 0x00002060, 0x0000203f, 0x00002070, 0x0000203f,
+/* 100 */ 0x00002080, 0x0000203f, 0x00002090, 0x0000203f,
+/* 110 */ 0x000020a0, 0x0000203f, 0x000020b0, 0x0000203f,
+/* 120 */ 0x000020c0, 0x0000203f, 0x000020d0, 0x0000203f,
+/* 130 */ 0x000020e0, 0x0000203f, 0x000020f0, 0x0000203f,
+/* 140 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 150 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 160 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 170 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 180 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 190 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 1a0 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 1b0 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 1c0 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 1d0 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 1e0 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 1f0 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 200 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 210 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 220 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 230 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 240 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 250 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 260 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 270 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 280 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 290 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 2a0 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 2b0 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 2c0 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 2d0 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 2e0 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 2f0 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* const */
+/* 300 */ 0x3f2a6400, 0xbf317600, 0x3e8d8e00, 0x00000000,
+/* 310 */ 0x3f2f7000, 0x3f36e200, 0x3e10c500, 0x00000000,
+/* 320 */ 0xbe974e00, 0x3dc35300, 0x3f735800, 0x00000000,
+/* 330 */ 0x00000000, 0x00000000, 0x00000000, 0x3f800000,
+/* 340 */ 0x42b00000, 0x42dc0000, 0x3f800000, 0x3f800000,
+/* 350 */ 0x42b00000, 0x42dc0000, 0x00000000, 0x00000000,
+/* 360 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 370 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 380 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 390 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 3a0 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 3b0 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 3c0 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 3d0 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 3e0 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* 3f0 */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+/* inst */
+/* 400 */ 0xad4ad6b5, 0x438002b5, 0x0007ffe0, 0x00001e00,
+/* 410 */ 0xad4ad694, 0x038002b5, 0x0087ffe0, 0x00005030,
+/* 420 */ 0xad4bda56, 0x038002b5, 0x0007ffe0, 0x00001c10,
+/* 430 */ 0xad4ad6b5, 0x038002b5, 0x4007fee0, 0x00001c00
+};
+static DEFINE_SPINLOCK(lock);
+static struct clk *mali_clk = NULL;
+
+#if MESON_CPU_TYPE <= MESON_CPU_TYPE_MESON6
+
+#define OFFSET_MMU_DTE 0
+#define OFFSET_MMU_PTE 4096
+#define OFFSET_MMU_VIRTUAL_ZERO 8192
+
+#define INT_MALI_GP_BITS (1<<16)
+#define INT_MALI_PP_BITS (1<<18)
+#define INT_MALI_PP_MMU_BITS (1<<19)
+#define INT_ALL (0xffffffff)
+
+#define INT_MALI_PP_MMU_PAGE_FAULT (1<<0)
+
+#define MMU_FLAG_DTE_PRESENT 0x01
+#define MMU_FLAG_PTE_PAGE_PRESENT 0x01
+#define MMU_FLAG_PTE_RD_PERMISSION 0x02
+#define MMU_FLAG_PTE_WR_PERMISSION 0x04
+
+//static int mali_revb_flag = -1;
+extern int mali_revb_flag;
+int mali_meson_is_revb(void)
+{
+ printk("mail version=%d\n",mali_revb_flag);
+ if (mali_revb_flag == -1)
+ mali_revb_flag = 1;
+ else if (mali_revb_flag == 0)
+ panic("rev-a! you should neet earlier version of mali_driver.!\n");
+
+ return mali_revb_flag;
+}
+
+static void mali_meson_poweron(int first_poweron)
+{
+ unsigned long flags;
+ u32 p, p_aligned;
+ dma_addr_t p_phy;
+ int i;
+ unsigned int_mask;
+
+ if(!first_poweron) {
+ if ((last_power_mode != -1) && (last_power_mode != MALI_POWER_MODE_DEEP_SLEEP)) {
+ MALI_DEBUG_PRINT(3, ("Maybe your system not deep sleep now.......\n"));
+ //printk("Maybe your system not deep sleep now.......\n");
+ return;
+ }
+ }
+
+ MALI_DEBUG_PRINT(2, ("mali_meson_poweron: Mali APB bus accessing\n"));
+ if (READ_MALI_REG(MALI_PP_PP_VERSION) != MALI_PP_PP_VERSION_MAGIC) {
+ MALI_DEBUG_PRINT(3, ("mali_meson_poweron: Mali APB bus access failed\n"));
+ //printk("mali_meson_poweron: Mali APB bus access failed.");
+ return;
+ }
+ MALI_DEBUG_PRINT(2, ("..........accessing done.\n"));
+ if (READ_MALI_REG(MALI_MMU_DTE_ADDR) != 0) {
+ MALI_DEBUG_PRINT(3, ("mali_meson_poweron: Mali is not really powered off\n"));
+ //printk("mali_meson_poweron: Mali is not really powered off.");
+ return;
+ }
+
+ p = (u32)kcalloc(4096 * 4, 1, GFP_KERNEL);
+ if (!p) {
+ printk("mali_meson_poweron: NOMEM in meson_poweron\n");
+ return;
+ }
+
+ p_aligned = __ALIGN_MASK(p, 4096);
+
+ /* DTE */
+ *(u32 *)(p_aligned) = (virt_to_phys((void *)p_aligned) + OFFSET_MMU_PTE) | MMU_FLAG_DTE_PRESENT;
+ /* PTE */
+ for (i=0; i<1024; i++) {
+ *(u32 *)(p_aligned + OFFSET_MMU_PTE + i*4) =
+ (virt_to_phys((void *)p_aligned) + OFFSET_MMU_VIRTUAL_ZERO + 4096 * i) |
+ MMU_FLAG_PTE_PAGE_PRESENT |
+ MMU_FLAG_PTE_RD_PERMISSION;
+ }
+
+ /* command & data */
+ memcpy((void *)(p_aligned + OFFSET_MMU_VIRTUAL_ZERO), poweron_data, 4096);
+
+ p_phy = dma_map_single(NULL, (void *)p_aligned, 4096 * 3, DMA_TO_DEVICE);
+
+ /* Set up Mali GP MMU */
+ WRITE_MALI_REG(MALI_MMU_DTE_ADDR, p_phy);
+ WRITE_MALI_REG(MALI_MMU_CMD, 0);
+
+ if ((READ_MALI_REG(MALI_MMU_STATUS) & 1) != 1)
+ printk("mali_meson_poweron: MMU enabling failed.\n");
+
+ /* Set up Mali command registers */
+ WRITE_MALI_REG(MALI_APB_GP_VSCL_START, 0);
+ WRITE_MALI_REG(MALI_APB_GP_VSCL_END, 0x38);
+
+ spin_lock_irqsave(&lock, flags);
+
+ int_mask = READ_MALI_REG(MALI_APB_GP_INT_MASK);
+ WRITE_MALI_REG(MALI_APB_GP_INT_CLEAR, 0x707bff);
+ WRITE_MALI_REG(MALI_APB_GP_INT_MASK, 0);
+
+ /* Start GP */
+ WRITE_MALI_REG(MALI_APB_GP_CMD, 1);
+
+ for (i = 0; i<100; i++)
+ udelay(500);
+
+ /* check Mali GP interrupt */
+ if (READ_MALI_REG(MALI_APB_GP_INT_RAWSTAT) & 0x707bff)
+ printk("mali_meson_poweron: Interrupt received.\n");
+ else
+ printk("mali_meson_poweron: No interrupt received.\n");
+
+ /* force reset GP */
+ WRITE_MALI_REG(MALI_APB_GP_CMD, 1 << 5);
+
+ /* stop MMU paging and reset */
+ WRITE_MALI_REG(MALI_MMU_CMD, 1);
+ WRITE_MALI_REG(MALI_MMU_CMD, 6);
+
+ for (i = 0; i<100; i++)
+ udelay(500);
+
+ WRITE_MALI_REG(MALI_APB_GP_INT_CLEAR, 0x3ff);
+ WRITE_MALI_REG(MALI_MMU_INT_CLEAR, INT_ALL);
+ WRITE_MALI_REG(MALI_MMU_INT_MASK, 0);
+
+ WRITE_MALI_REG(MALI_APB_GP_INT_CLEAR, 0x707bff);
+ WRITE_MALI_REG(MALI_APB_GP_INT_MASK, int_mask);
+
+ spin_unlock_irqrestore(&lock, flags);
+
+ dma_unmap_single(NULL, p_phy, 4096 * 3, DMA_TO_DEVICE);
+
+ kfree((void *)p);
+
+ /* Mali revision detection */
+ if (last_power_mode == -1)
+ mali_revb_flag = mali_meson_is_revb();
+}
+#else
+static void mali_meson_poweron(int first_poweron) {
+ return;
+}
+#endif /*MESON_CPU_TYPE <= MESON_CPU_TYPE_MESON6 */
+
+_mali_osk_errcode_t mali_platform_init(void)
+{
+ mali_clk = clk_get_sys("mali", "pll_fixed");
+
+ if (mali_clk ) {
+ if (!mali_init_flag) {
+ clk_set_rate(mali_clk, 333000000);
+ mali_clk->enable(mali_clk);
+ malifix_init();
+ mali_meson_poweron(1);
+ mali_init_flag = 1;
+ }
+ MALI_SUCCESS;
+ }
+
+#if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON6
+ MALI_PRINT_ERROR(("Failed to lookup mali clock"));
+ MALI_ERROR(_MALI_OSK_ERR_FAULT);
+#else
+ MALI_SUCCESS;
+#endif /* CONFIG_ARCH_MESON6 */
+}
+
+_mali_osk_errcode_t mali_platform_deinit(void)
+{
+ mali_init_flag =0;
+ printk("MALI:mali_platform_deinit\n");
+ malifix_exit();
+
+ MALI_SUCCESS;
+}
+
+_mali_osk_errcode_t mali_platform_power_mode_change(mali_power_mode power_mode)
+{
+ unsigned long flags;
+ unsigned cpu_divider, mali_divider;
+ unsigned ddr_pll_setting, sys_pll_setting;
+ unsigned cpu_freq, ddr_freq;
+ int mali_flag;
+
+ MALI_DEBUG_PRINT(3, ( "mali_platform_power_mode_change power_mode=%d\n", power_mode));
+
+ switch (power_mode) {
+ case MALI_POWER_MODE_LIGHT_SLEEP:
+ case MALI_POWER_MODE_DEEP_SLEEP:
+ /* Turn off mali clock gating */
+ if (mali_clk) {
+ mali_clk->disable(mali_clk);
+ } else {
+ spin_lock_irqsave(&lock, flags);
+ CLEAR_CBUS_REG_MASK(HHI_MALI_CLK_CNTL, 1 << 8);
+ spin_unlock_irqrestore(&lock, flags);
+ }
+ break;
+
+ case MALI_POWER_MODE_ON:
+ /* Turn on MALI clock gating */
+ if (mali_clk) {
+ mali_clk->enable(mali_clk);
+ }
+ else {
+ spin_lock_irqsave(&lock, flags);
+ CLEAR_CBUS_REG_MASK(HHI_MALI_CLK_CNTL, 1 << 8);
+
+ sys_pll_setting = READ_MPEG_REG(HHI_SYS_PLL_CNTL);
+ cpu_freq = ((sys_pll_setting&0x1ff)*24)>>(sys_pll_setting>>16); // assume 24M xtal
+ cpu_divider = READ_MPEG_REG_BITS(HHI_SYS_CPU_CLK_CNTL, 2, 2);
+ if (cpu_divider == 3)
+ cpu_divider = 2; // now fix at /4
+ cpu_freq >>= cpu_divider;
+
+ ddr_pll_setting = READ_MPEG_REG(HHI_DDR_PLL_CNTL);
+ ddr_freq = ((ddr_pll_setting&0x1ff)*24)>>((ddr_pll_setting>>16)&3);
+
+ mali_divider = 1;
+ while ((mali_divider * cpu_freq < ddr_freq) || (264 * mali_divider < ddr_freq)) // assume mali max 264M
+ mali_divider++;
+ mali_flag = ((mali_divider-1) != (READ_MPEG_REG(HHI_MALI_CLK_CNTL)&0x7f));
+ if (mali_flag){
+ WRITE_CBUS_REG(HHI_MALI_CLK_CNTL,
+ (3 << 9) | // select ddr pll as clock source
+ ((mali_divider-1) << 0)); // ddr clk / divider
+ READ_CBUS_REG(HHI_MALI_CLK_CNTL); // delay
+ }
+ SET_CBUS_REG_MASK(HHI_MALI_CLK_CNTL, 1 << 8);
+ spin_unlock_irqrestore(&lock, flags);
+
+ if (mali_flag)
+ MALI_DEBUG_PRINT(3, ("(CTS_MALI_CLK) = %d/%d = %dMHz --- when mali gate on\n", ddr_freq, mali_divider, ddr_freq/mali_divider));
+
+ }
+ mali_meson_poweron(0);
+ break;
+ }
+ last_power_mode = power_mode;
+ MALI_SUCCESS;
+}
+
--- /dev/null
+/*
+ * Copyright (C) 2010-2012 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/**
+ * @file mali_platform.h
+ * Platform specific Mali driver functions
+ */
+
+#ifndef __MALI_PLATFORM_H__
+#define __MALI_PLATFORM_H__
+
+#include "mali_osk.h"
+
+/** @brief description of power change reasons
+ */
+typedef enum mali_power_mode_tag
+{
+ MALI_POWER_MODE_ON, /**< Power Mali on */
+ MALI_POWER_MODE_LIGHT_SLEEP, /**< Mali has been idle for a short time, or runtime PM suspend */
+ MALI_POWER_MODE_DEEP_SLEEP, /**< Mali has been idle for a long time, or OS suspend */
+} mali_power_mode;
+
+/** @brief Platform specific setup and initialisation of MALI
+ *
+ * This is called from the entrypoint of the driver to initialize the platform
+ *
+ * @return _MALI_OSK_ERR_OK on success otherwise, a suitable _mali_osk_errcode_t error.
+ */
+_mali_osk_errcode_t mali_platform_init(void);
+
+/** @brief Platform specific deinitialisation of MALI
+ *
+ * This is called on the exit of the driver to terminate the platform
+ *
+ * @return _MALI_OSK_ERR_OK on success otherwise, a suitable _mali_osk_errcode_t error.
+ */
+_mali_osk_errcode_t mali_platform_deinit(void);
+
+/** @brief Platform specific powerdown sequence of MALI
+ *
+ * Notification from the Mali device driver stating the new desired power mode.
+ * MALI_POWER_MODE_ON must be obeyed, while the other modes are optional.
+ * @param power_mode defines the power modes
+ * @return _MALI_OSK_ERR_OK on success otherwise, a suitable _mali_osk_errcode_t error.
+ */
+_mali_osk_errcode_t mali_platform_power_mode_change(mali_power_mode power_mode);
+
+
+/** @brief Platform specific handling of GPU utilization data
+ *
+ * When GPU utilization data is enabled, this function will be
+ * periodically called.
+ *
+ * @param utilization The workload utilization of the Mali GPU. 0 = no utilization, 256 = full utilization.
+ */
+void mali_gpu_utilization_handler(u32 utilization);
+
+/** @brief Setting the power domain of MALI
+ *
+ * This function sets the power domain of MALI if Linux run time power management is enabled
+ *
+ * @param dev Reference to struct platform_device (defined in linux) used by MALI GPU
+ */
+void set_mali_parent_power_domain(void* dev);
+
+#endif
--- /dev/null
+/*
+ * This confidential and proprietary software may be used only as
+ * authorised by a licensing agreement from AMLOGIC, INC.
+ * (C) COPYRIGHT 2011 AMLOGIC, INC.
+ * ALL RIGHTS RESERVED
+ * The entire notice above must be reproduced on all authorised
+ * copies and copies may only be made to the extent permitted
+ * by a licensing agreement from AMLOGIC, INC.
+ */
+
+#ifndef MALI_POWERON_REG_H
+#define MALI_POWERON_REG_H
+
+#define MALI_PP_PP_VERSION_MAGIC 0xCD070100UL
+
+#if defined(IO_APB2_BUS_PHY_BASE)
+#define WRITE_MALI_REG(reg, val) \
+ __raw_writel(val, reg - IO_APB2_BUS_PHY_BASE + IO_APB2_BUS_BASE)
+#define READ_MALI_REG(reg) \
+ __raw_readl(reg - IO_APB2_BUS_PHY_BASE + IO_APB2_BUS_BASE)
+#else
+#define WRITE_MALI_REG(reg, val) \
+ __raw_writel(val, reg - IO_APB_BUS_PHY_BASE + IO_APB_BUS_BASE)
+#define READ_MALI_REG(reg) \
+ __raw_readl(reg - IO_APB_BUS_PHY_BASE + IO_APB_BUS_BASE)
+#endif
+
+#define MALI_APB_GP_VSCL_START 0xd0060000
+#define MALI_APB_GP_VSCL_END 0xd0060004
+#define MALI_APB_GP_CMD 0xd0060020
+#define MALI_APB_GP_INT_RAWSTAT 0xd0060024
+#define MALI_APB_GP_INT_CLEAR 0xd0060028
+#define MALI_APB_GP_INT_MASK 0xd006002c
+#define MALI_APB_GP_INT_STAT 0xd0060030
+
+#define MALI_MMU_DTE_ADDR 0xd0063000
+#define MALI_MMU_STATUS 0xd0063004
+#define MALI_MMU_CMD 0xd0063008
+#define MALI_MMU_RAW_STATUS 0xd0064014
+#define MALI_MMU_INT_CLEAR 0xd0064018
+#define MALI_MMU_INT_MASK 0xd006401c
+#define MALI_MMU_INT_STATUS 0xd0064020
+
+#define MALI_PP_MMU_DTE_ADDR 0xd0064000
+#define MALI_PP_MMU_STATUS 0xd0064004
+#define MALI_PP_MMU_CMD 0xd0064008
+#define MALI_PP_MMU_RAW_STATUS 0xd0064014
+#define MALI_PP_MMU_INT_CLEAR 0xd0064018
+#define MALI_PP_MMU_INT_MASK 0xd006401c
+#define MALI_PP_MMU_INT_STATUS 0xd0064020
+
+#define MALI_APB_PP_REND_LIST_ADDR 0xd0068000
+#define MALI_APB_PP_REND_RSW_BASE 0xd0068004
+#define MALI_APB_PP_REND_VERTEX_BASE 0xd0068008
+#define MALI_APB_PPSUBPIXEL_SPECIFIER 0xd0068048
+#define MALI_APB_WB0_SOURCE_SELECT 0xd0068100
+#define MALI_APB_WB0_TARGET_ADDR 0xd0068104
+#define MALI_APB_WB0_TARGET_SCANLINE_LENGTH 0xd0068114
+
+#define MALI_PP_PP_VERSION 0xd0069000
+#define MALI_PP_STATUS 0xd0069008
+#define MALI_PP_CTRL_MGMT 0xd006900C
+#define MALI_PP_INT_RAWSTAT 0xd0069020
+#define MALI_PP_INT_CLEAR 0xd0069024
+#define MALI_PP_INT_MASK 0xd0069028
+#define MALI_PP_INT_STAT 0xd006902C
+
+#endif /* MALI_POWERON_REG_H */
--- /dev/null
+/*
+ * platform.c
+ *
+ * clock source setting and resource config
+ *
+ * Created on: Dec 4, 2013
+ * Author: amlogic
+ */
+
+#include <linux/platform_device.h>
+#include <linux/version.h>
+#include <linux/pm.h>
+#include <linux/of.h>
+#include <linux/module.h>
+#include <linux/ioport.h>
+#include <linux/slab.h>
+#include <mach/register.h>
+#include <mach/irqs.h>
+#include <mach/io.h>
+#include <asm/io.h>
+#include <linux/mali/mali_utgard.h>
+
+#include <common/mali_kernel_common.h>
+#include <common/mali_osk_profiling.h>
+#include <common/mali_pmu.h>
+
+#include "meson_main.h"
+#include "mali_fix.h"
+#include "mali_platform.h"
+
+/**
+ * For Meson 6tvd.
+ *
+ */
+
+#if MESON_CPU_TYPE <= MESON_CPU_TYPE_MESON6TV
+
+#if MESON_CPU_TYPE == MESON_CPU_TYPE_MESON6TV
+
+#define INT_MALI_GP (48+32)
+#define INT_MALI_GP_MMU (49+32)
+#define INT_MALI_PP (50+32)
+#define INT_MALI_PP2 (58+32)
+#define INT_MALI_PP3 (60+32)
+#define INT_MALI_PP4 (62+32)
+#define INT_MALI_PP_MMU (51+32)
+#define INT_MALI_PP2_MMU (59+32)
+#define INT_MALI_PP3_MMU (61+32)
+#define INT_MALI_PP4_MMU (63+32)
+
+#ifndef CONFIG_MALI400_4_PP
+static struct resource meson_mali_resources[] =
+{
+ MALI_GPU_RESOURCES_MALI400_MP2(0xd0060000,
+ INT_MALI_GP, INT_MALI_GP_MMU,
+ INT_MALI_PP, INT_MALI_PP_MMU,
+ INT_MALI_PP2, INT_MALI_PP2_MMU)
+};
+#else
+static struct resource meson_mali_resources[] =
+{
+ MALI_GPU_RESOURCES_MALI400_MP4(0xd0060000,
+ INT_MALI_GP, INT_MALI_GP_MMU,
+ INT_MALI_PP, INT_MALI_PP_MMU,
+ INT_MALI_PP2, INT_MALI_PP2_MMU,
+ INT_MALI_PP3, INT_MALI_PP3_MMU,
+ INT_MALI_PP4, INT_MALI_PP4_MMU
+ )
+};
+#endif
+
+#elif MESON_CPU_TYPE == MESON_CPU_TYPE_MESON6
+
+int static_pp_mmu_cnt;
+
+#define INT_MALI_GP (48+32)
+#define INT_MALI_GP_MMU (49+32)
+#define INT_MALI_PP (50+32)
+#define INT_MALI_PP_MMU (51+32)
+#define INT_MALI_PP2_MMU ( 6+32)
+
+static struct resource meson_mali_resources[] =
+{
+ MALI_GPU_RESOURCES_MALI400_MP2(0xd0060000,
+ INT_MALI_GP, INT_MALI_GP_MMU,
+ INT_MALI_PP, INT_MALI_PP2_MMU,
+ INT_MALI_PP_MMU, INT_MALI_PP2_MMU)
+};
+
+#else /* MESON_CPU_TYPE == MESON_CPU_TYPE_MESON3 */
+
+#define INT_MALI_GP 48
+#define INT_MALI_GP_MMU 49
+#define INT_MALI_PP 50
+#define INT_MALI_PP_MMU 51
+
+static struct resource meson_mali_resources[] =
+{
+ MALI_GPU_RESOURCES_MALI400_MP1(0xd0060000,
+ INT_MALI_GP, INT_MALI_GP_MMU, INT_MALI_PP, INT_MALI_PP_MMU)
+};
+#endif /* MESON_CPU_TYPE == MESON_CPU_TYPE_MESON6TV */
+
+void mali_gpu_utilization_callback(struct mali_gpu_utilization_data *data)
+{
+
+}
+
+int mali_meson_init_start(struct platform_device* ptr_plt_dev)
+{
+ /* for mali platform data. */
+ pdev->utilization_interval = 1000,
+ pdev->utilization_callback = mali_gpu_utilization_callback,
+
+ /* for resource data. */
+ ptr_plt_dev->num_resources = ARRAY_SIZE(mali_gpu_resources);
+ ptr_plt_dev->resource = mali_gpu_resources;
+ return 0;
+}
+
+int mali_meson_init_finish(struct platform_device* ptr_plt_dev)
+{
+ mali_platform_init();
+ return 0;
+}
+
+int mali_meson_uninit(struct platform_device* ptr_plt_dev)
+{
+ mali_platform_deinit();
+ return 0;
+}
+
+int mali_light_suspend(struct device *device)
+{
+ int ret = 0;
+
+ if (NULL != device->driver &&
+ NULL != device->driver->pm &&
+ NULL != device->driver->pm->runtime_suspend)
+ {
+ /* Need to notify Mali driver about this event */
+ ret = device->driver->pm->runtime_suspend(device);
+ }
+
+ mali_platform_power_mode_change(MALI_POWER_MODE_LIGHT_SLEEP);
+ return ret;
+}
+
+int mali_light_resume(struct device *device)
+{
+ int ret = 0;
+
+ mali_platform_power_mode_change(MALI_POWER_MODE_ON);
+
+ if (NULL != device->driver &&
+ NULL != device->driver->pm &&
+ NULL != device->driver->pm->runtime_resume)
+ {
+ /* Need to notify Mali driver about this event */
+ ret = device->driver->pm->runtime_resume(device);
+ }
+ return ret;
+}
+
+int mali_deep_suspend(struct device *device)
+{
+ int ret = 0;
+
+ if (NULL != device->driver &&
+ NULL != device->driver->pm &&
+ NULL != device->driver->pm->suspend)
+ {
+ /* Need to notify Mali driver about this event */
+ ret = device->driver->pm->suspend(device);
+ }
+
+ mali_platform_power_mode_change(MALI_POWER_MODE_DEEP_SLEEP);
+ return ret;
+}
+
+int mali_deep_resume(struct device *device)
+{
+ int ret = 0;
+
+ mali_platform_power_mode_change(MALI_POWER_MODE_ON);
+
+ if (NULL != device->driver &&
+ NULL != device->driver->pm &&
+ NULL != device->driver->pm->resume)
+ {
+ /* Need to notify Mali driver about this event */
+ ret = device->driver->pm->resume(device);
+ }
+ return ret;
+
+}
+#endif /* MESON_CPU_TYPE <= MESON_CPU_TYPE_MESON6 */
--- /dev/null
+/*
+ * platform.c
+ *
+ * clock source setting and resource config
+ *
+ * Created on: Dec 4, 2013
+ * Author: amlogic
+ */
+
+#include <linux/platform_device.h>
+#include <linux/version.h>
+#include <linux/pm.h>
+#include <linux/of.h>
+#include <linux/module.h> /* kernel module definitions */
+#include <linux/ioport.h> /* request_mem_region */
+#include <linux/slab.h>
+#include <mach/register.h>
+#include <mach/irqs.h>
+#include <mach/io.h>
+#include <asm/io.h>
+#include <linux/mali/mali_utgard.h>
+
+#include <common/mali_kernel_common.h>
+#include <common/mali_osk_profiling.h>
+#include <common/mali_pmu.h>
+
+#include "meson_main.h"
+
+/**
+ * For Meson 6tvd.
+ *
+ */
+
+#ifdef MESON_CPU_TYPE_MESON6TVD
+#if MESON_CPU_TYPE == MESON_CPU_TYPE_MESON6TVD
+
+u32 mali_clock_max_index = 3;
+u32 mali_default_clock_idx = 3;
+u32 mali_up_clock_idx = 3;
+
+/* fclk is 2Ghz. */
+#define FCLK_DEV5 (7 << 9) /* 400 Mhz */
+#define FCLK_DEV3 (6 << 9) /* 666 Mhz */
+#define FCLK_DEV2 (5 << 9) /* 1000 Mhz */
+#define FCLK_DEV7 (4 << 9) /* 285 Mhz */
+
+u32 mali_dvfs_clk[] = {
+ FCLK_DEV7 | 9, /* 100 Mhz */
+ FCLK_DEV2 | 4, /* 200 Mhz */
+ FCLK_DEV3 | 1, /* 333 Mhz */
+ FCLK_DEV5 | 0, /* 400 Mhz */
+};
+
+u32 mali_dvfs_clk_sample[] = {
+ 182, /* 182.1 Mhz */
+ 319, /* 318.7 Mhz */
+ 425, /* 425 Mhz */
+ 510, /* 510 Mhz */
+ 637, /* 637.5 Mhz */
+};
+
+#define MALI_PP_NUMBER 2
+#define MALI_USER_PP0 AM_IRQ4(31)
+
+static struct resource mali_gpu_resources[] =
+{
+MALI_GPU_RESOURCES_MALI450_MP2_PMU(0xC9140000, INT_MALI_GP, INT_MALI_GP_MMU,
+ MALI_USER_PP0, INT_MALI_PP_MMU,
+ INT_MALI_PP1, INT_MALI_PP_MMU1,
+ INT_MALI_PP)
+};
+
+int mali_meson_init_start(struct platform_device* ptr_plt_dev)
+{
+ ptr_plt_dev->num_resources = ARRAY_SIZE(mali_gpu_resources);
+ ptr_plt_dev->resource = mali_gpu_resources;
+ return mali_clock_init(mali_default_clock_idx);
+}
+
+int mali_meson_init_finish(struct platform_device* ptr_plt_dev)
+{
+ return 0;
+}
+
+int mali_meson_uninit(struct platform_device* ptr_plt_dev)
+{
+ return 0;
+}
+
+static int mali_cri_pmu_on_off(u64 param)
+{
+ struct mali_pmu_core *pmu;
+
+ MALI_DEBUG_PRINT(4, ("mali_os_suspend() called\n"));
+ pmu = mali_pmu_get_global_pmu_core();
+ if (param == 0)
+ mali_pmu_power_down_all(pmu);
+ else
+ mali_pmu_power_up_all(pmu);
+ return 0;
+}
+
+int mali_light_suspend(struct device *device)
+{
+ int ret = 0;
+#ifdef CONFIG_MALI400_PROFILING
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+ MALI_PROFILING_EVENT_CHANNEL_GPU |
+ MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
+ 0, 0, 0, 0, 0);
+#endif
+ if (NULL != device->driver &&
+ NULL != device->driver->pm &&
+ NULL != device->driver->pm->runtime_suspend)
+ {
+ /* Need to notify Mali driver about this event */
+ ret = device->driver->pm->runtime_suspend(device);
+ }
+
+ /* clock scaling. Kasin..*/
+ mali_clock_critical(mali_cri_pmu_on_off, 0);
+ disable_clock();
+ return ret;
+}
+
+int mali_light_resume(struct device *device)
+{
+ int ret = 0;
+ /* clock scaling. Kasin..*/
+ enable_clock();
+
+ mali_clock_critical(mali_cri_pmu_on_off, 1);
+#ifdef CONFIG_MALI400_PROFILING
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+ MALI_PROFILING_EVENT_CHANNEL_GPU |
+ MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
+ get_current_frequency(), 0, 0, 0, 0);
+#endif
+
+ if (NULL != device->driver &&
+ NULL != device->driver->pm &&
+ NULL != device->driver->pm->runtime_resume)
+ {
+ /* Need to notify Mali driver about this event */
+ ret = device->driver->pm->runtime_resume(device);
+ }
+ return ret;
+}
+
+int mali_deep_suspend(struct device *device)
+{
+ int ret = 0;
+ //enable_clock();
+ //flush_scaling_job();
+ if (NULL != device->driver &&
+ NULL != device->driver->pm &&
+ NULL != device->driver->pm->suspend)
+ {
+ /* Need to notify Mali driver about this event */
+ ret = device->driver->pm->suspend(device);
+ }
+
+ /* clock scaling off. Kasin... */
+ mali_clock_critical(mali_cri_pmu_on_off, 0);
+ disable_clock();
+ return ret;
+}
+
+int mali_deep_resume(struct device *device)
+{
+ int ret = 0;
+ /* clock scaling up. Kasin.. */
+ enable_clock();
+ mali_clock_critical(mali_cri_pmu_on_off, 1);
+ if (NULL != device->driver &&
+ NULL != device->driver->pm &&
+ NULL != device->driver->pm->resume)
+ {
+ /* Need to notify Mali driver about this event */
+ ret = device->driver->pm->resume(device);
+ }
+ return ret;
+
+}
+#endif /* MESON_CPU_TYPE == MESON_CPU_TYPE_MESON8 */
+#endif /* define MESON_CPU_TYPE_MESON6TVD */
--- /dev/null
+/*
+ * platform.c
+ *
+ * clock source setting and resource config
+ *
+ * Created on: Dec 4, 2013
+ * Author: amlogic
+ */
+
+#include <linux/platform_device.h>
+#include <linux/version.h>
+#include <linux/pm.h>
+#include <linux/of.h>
+#include <linux/module.h> /* kernel module definitions */
+#include <linux/ioport.h> /* request_mem_region */
+#include <linux/slab.h>
+#include <mach/register.h>
+#include <mach/irqs.h>
+#include <mach/io.h>
+#include <asm/io.h>
+#include <linux/mali/mali_utgard.h>
+
+#include <common/mali_kernel_common.h>
+#include <common/mali_osk_profiling.h>
+#include <common/mali_pmu.h>
+
+#include "meson_main.h"
+
+/**
+ * For Meson 8.
+ *
+ */
+
+#if MESON_CPU_TYPE == MESON_CPU_TYPE_MESON8
+u32 mali_clock_max_index = 4;
+u32 mali_default_clock_idx = 0;
+u32 mali_up_clock_idx = 3;
+
+/* fclk is 2550Mhz. */
+#define FCLK_DEV3 (6 << 9) /* 850 Mhz */
+#define FCLK_DEV4 (5 << 9) /* 637.5 Mhz */
+#define FCLK_DEV5 (7 << 9) /* 510 Mhz */
+#define FCLK_DEV7 (4 << 9) /* 364.3 Mhz */
+
+u32 mali_dvfs_clk[] = {
+ FCLK_DEV7 | 1, /* 182.1 Mhz */
+ FCLK_DEV4 | 1, /* 318.7 Mhz */
+ FCLK_DEV3 | 1, /* 425 Mhz */
+ FCLK_DEV5 | 0, /* 510 Mhz */
+ FCLK_DEV4 | 0, /* 637.5 Mhz */
+};
+
+u32 mali_dvfs_clk_sample[] = {
+ 182, /* 182.1 Mhz */
+ 319, /* 318.7 Mhz */
+ 425, /* 425 Mhz */
+ 510, /* 510 Mhz */
+ 637, /* 637.5 Mhz */
+};
+
+#define MALI_PP_NUMBER 6
+
+static struct resource mali_gpu_resources[] =
+{
+ MALI_GPU_RESOURCES_MALI450_MP6_PMU(IO_MALI_APB_PHY_BASE, INT_MALI_GP, INT_MALI_GP_MMU,
+ INT_MALI_PP0, INT_MALI_PP0_MMU,
+ INT_MALI_PP1, INT_MALI_PP1_MMU,
+ INT_MALI_PP2, INT_MALI_PP2_MMU,
+ INT_MALI_PP4, INT_MALI_PP4_MMU,
+ INT_MALI_PP5, INT_MALI_PP5_MMU,
+ INT_MALI_PP6, INT_MALI_PP6_MMU,
+ INT_MALI_PP)
+};
+
+void mali_gpu_utilization_callback(struct mali_gpu_utilization_data *data);
+int mali_meson_init_start(struct platform_device* ptr_plt_dev)
+{
+
+ struct mali_gpu_device_data* pdev = ptr_plt_dev->dev.platform_data;
+
+ /* for mali platform data. */
+ pdev->utilization_interval = 500,
+ pdev->utilization_callback = mali_gpu_utilization_callback,
+
+ /* for resource data. */
+ ptr_plt_dev->num_resources = ARRAY_SIZE(mali_gpu_resources);
+ ptr_plt_dev->resource = mali_gpu_resources;
+ return mali_clock_init(mali_default_clock_idx);
+}
+
+int mali_meson_init_finish(struct platform_device* ptr_plt_dev)
+{
+ mali_core_scaling_init(MALI_PP_NUMBER, mali_default_clock_idx);
+ return 0;
+}
+
+int mali_meson_uninit(struct platform_device* ptr_plt_dev)
+{
+ return 0;
+}
+
+static int mali_cri_pmu_on_off(u64 param)
+{
+ struct mali_pmu_core *pmu;
+
+ MALI_DEBUG_PRINT(4, ("mali_os_suspend() called\n"));
+ pmu = mali_pmu_get_global_pmu_core();
+ if (param == 0)
+ mali_pmu_power_down_all(pmu);
+ else
+ mali_pmu_power_up_all(pmu);
+ return 0;
+}
+
+int mali_light_suspend(struct device *device)
+{
+ int ret = 0;
+#ifdef CONFIG_MALI400_PROFILING
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+ MALI_PROFILING_EVENT_CHANNEL_GPU |
+ MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
+ 0, 0, 0, 0, 0);
+#endif
+ if (NULL != device->driver &&
+ NULL != device->driver->pm &&
+ NULL != device->driver->pm->runtime_suspend)
+ {
+ /* Need to notify Mali driver about this event */
+ ret = device->driver->pm->runtime_suspend(device);
+ }
+
+ /* clock scaling. Kasin..*/
+ mali_clock_critical(mali_cri_pmu_on_off, 0);
+ //disable_clock();
+ return ret;
+}
+
+int mali_light_resume(struct device *device)
+{
+ int ret = 0;
+ /* clock scaling. Kasin..*/
+ //enable_clock();
+
+ mali_clock_critical(mali_cri_pmu_on_off, 1);
+#ifdef CONFIG_MALI400_PROFILING
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+ MALI_PROFILING_EVENT_CHANNEL_GPU |
+ MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
+ get_current_frequency(), 0, 0, 0, 0);
+#endif
+
+ if (NULL != device->driver &&
+ NULL != device->driver->pm &&
+ NULL != device->driver->pm->runtime_resume)
+ {
+ /* Need to notify Mali driver about this event */
+ ret = device->driver->pm->runtime_resume(device);
+ }
+ return ret;
+}
+
+int mali_deep_suspend(struct device *device)
+{
+ int ret = 0;
+ enable_clock();
+ flush_scaling_job();
+ if (NULL != device->driver &&
+ NULL != device->driver->pm &&
+ NULL != device->driver->pm->suspend)
+ {
+ /* Need to notify Mali driver about this event */
+ ret = device->driver->pm->suspend(device);
+ }
+
+ /* clock scaling off. Kasin... */
+ mali_clock_critical(mali_cri_pmu_on_off, 0);
+ disable_clock();
+ return ret;
+}
+
+int mali_deep_resume(struct device *device)
+{
+ int ret = 0;
+ /* clock scaling up. Kasin.. */
+ enable_clock();
+ mali_clock_critical(mali_cri_pmu_on_off, 1);
+ if (NULL != device->driver &&
+ NULL != device->driver->pm &&
+ NULL != device->driver->pm->resume)
+ {
+ /* Need to notify Mali driver about this event */
+ ret = device->driver->pm->resume(device);
+ }
+ return ret;
+
+}
+#endif /* MESON_CPU_TYPE == MESON_CPU_TYPE_MESON8 */
+
--- /dev/null
+/*
+ * Copyright (C) 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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 arm_core_scaling.c
+ * Example core scaling policy.
+ */
+#include <linux/workqueue.h>
+#include <linux/mali/mali_utgard.h>
+#include <mach/smp.h>
+#include "mali_kernel_common.h"
+#include "common/mali_osk_profiling.h"
+#include "common/mali_kernel_utilization.h"
+#include "common/mali_pp_scheduler.h"
+
+#include "meson_main.h"
+
+#define MALI_TABLE_SIZE 6
+
+static int num_cores_total;
+static int num_cores_enabled;
+static int currentStep;
+static int lastStep;
+static struct work_struct wq_work;
+static u32 mali_turbo_mode = 0;
+
+unsigned int min_mali_clock = 0;
+unsigned int max_mali_clock = 3;
+unsigned int min_pp_num = 1;
+
+/* Configure dvfs mode */
+enum mali_scale_mode_t {
+ MALI_PP_SCALING,
+ MALI_PP_FS_SCALING,
+ MALI_SCALING_DISABLE,
+ MALI_TURBO_MODE,
+ MALI_SCALING_MODE_MAX
+};
+
+static int reseted_for_turbo = 0;
+
+static int scaling_mode = MALI_PP_FS_SCALING;
+module_param(scaling_mode, int, 0664);
+MODULE_PARM_DESC(scaling_mode, "0 disable, 1 pp, 2 fs, 4 double");
+
+enum mali_pp_scale_threshold_t {
+ MALI_PP_THRESHOLD_20,
+ MALI_PP_THRESHOLD_30,
+ MALI_PP_THRESHOLD_40,
+ MALI_PP_THRESHOLD_50,
+ MALI_PP_THRESHOLD_60,
+ MALI_PP_THRESHOLD_80,
+ MALI_PP_THRESHOLD_90,
+ MALI_PP_THRESHOLD_MAX,
+};
+static u32 mali_pp_scale_threshold [] = {
+ 51, /* 20% */
+ 77, /* 30% */
+ 102, /* 40% */
+ 128, /* 50% */
+ 154, /* 60% */
+ 205, /* 80% */
+ 230, /* 90% */
+};
+
+
+static u32 mali_dvfs_table_size = MALI_TABLE_SIZE;
+
+static struct mali_dvfs_threshold_table mali_dvfs_threshold[MALI_TABLE_SIZE]={
+ { 0, 0, 2, 0 , 200}, /* for 182.1 */
+ { 1, 1, 2, 152, 205}, /* for 318.7 */
+ { 2, 2, 2, 180, 212}, /* for 425.0 */
+ { 3, 3, 2, 205, 236}, /* for 510.0 */
+ { 4, 4, 2, 230, 256}, /* for 637.5 */
+ { 0, 0, 2, 0, 0}
+};
+
+u32 set_mali_dvfs_tbl_size(u32 size)
+{
+ if (size <= 0 && size > MALI_TABLE_SIZE) return -1;
+ mali_dvfs_table_size = size;
+ return 0;
+}
+
+u32 get_max_dvfs_tbl_size(void)
+{
+ return MALI_TABLE_SIZE;
+}
+
+uint32_t* get_mali_dvfs_tbl_addr(void)
+{
+ return (uint32_t*)mali_dvfs_threshold;
+}
+
+static void do_scaling(struct work_struct *work)
+{
+ int err = mali_perf_set_num_pp_cores(num_cores_enabled);
+ MALI_DEBUG_ASSERT(0 == err);
+ MALI_IGNORE(err);
+ if (mali_dvfs_threshold[currentStep].freq_index != mali_dvfs_threshold[lastStep].freq_index) {
+ mali_dev_pause();
+ mali_clock_set(mali_dvfs_threshold[currentStep].freq_index);
+ mali_dev_resume();
+ lastStep = currentStep;
+ }
+#ifdef CONFIG_MALI400_PROFILING
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+ MALI_PROFILING_EVENT_CHANNEL_GPU |
+ MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
+ get_mali_freq(),
+ 0, 0, 0, 0);
+#endif
+}
+
+void flush_scaling_job(void)
+{
+ cancel_work_sync(&wq_work);
+}
+
+static u32 enable_one_core(void)
+{
+ u32 ret = 0;
+ if (num_cores_enabled < num_cores_total)
+ {
+ ++num_cores_enabled;
+ ret = 1;
+ MALI_DEBUG_PRINT(3, ("Core scaling: Enabling one more core\n"));
+ }
+
+ MALI_DEBUG_ASSERT( 1 <= num_cores_enabled);
+ MALI_DEBUG_ASSERT(num_cores_total >= num_cores_enabled);
+ return ret;
+}
+
+static u32 disable_one_core(void)
+{
+ u32 ret = 0;
+ if (min_pp_num < num_cores_enabled)
+ {
+ --num_cores_enabled;
+ ret = 1;
+ MALI_DEBUG_PRINT(3, ("Core scaling: Disabling one core\n"));
+ }
+
+ MALI_DEBUG_ASSERT(min_pp_num <= num_cores_enabled);
+ MALI_DEBUG_ASSERT(num_cores_total >= num_cores_enabled);
+ return ret;
+}
+
+static u32 enable_max_num_cores(void)
+{
+ u32 ret = 0;
+ if (num_cores_enabled < num_cores_total)
+ {
+ num_cores_enabled = num_cores_total;
+ ret = 1;
+ MALI_DEBUG_PRINT(3, ("Core scaling: Enabling maximum number of cores\n"));
+ }
+
+ MALI_DEBUG_ASSERT(num_cores_total == num_cores_enabled);
+ return ret;
+}
+
+void mali_core_scaling_init(int pp, int clock_idx)
+{
+ INIT_WORK(&wq_work, do_scaling);
+
+ num_cores_total = pp;
+ num_cores_enabled = num_cores_total;
+
+ currentStep = clock_idx;
+ lastStep = currentStep;
+ /* NOTE: Mali is not fully initialized at this point. */
+}
+
+void mali_core_scaling_term(void)
+{
+ flush_scheduled_work();
+}
+
+void mali_pp_scaling_update(struct mali_gpu_utilization_data *data)
+{
+ int ret = 0;
+ currentStep = mali_up_clock_idx;
+
+ MALI_DEBUG_PRINT(3, ("Utilization: (%3d, %3d, %3d), cores enabled: %d/%d\n", data->utilization_gpu, data->utilization_gp, data->utilization_pp, num_cores_enabled, num_cores_total));
+
+ /* NOTE: this function is normally called directly from the utilization callback which is in
+ * timer context. */
+
+ if (mali_pp_scale_threshold[MALI_PP_THRESHOLD_90] < data->utilization_pp)
+ {
+ ret = enable_max_num_cores();
+ }
+ else if (mali_pp_scale_threshold[MALI_PP_THRESHOLD_50]< data->utilization_pp)
+ {
+ ret = enable_one_core();
+ }
+ else if (mali_pp_scale_threshold[MALI_PP_THRESHOLD_40]< data->utilization_pp)
+ {
+ #if 0
+ currentStep = MALI_CLOCK_425;
+ schedule_work(&wq_work);
+ #endif
+ }
+ else if (0 < data->utilization_pp)
+ {
+ ret = disable_one_core();
+ }
+ else
+ {
+ /* do nothing */
+ }
+ if (ret == 1)
+ schedule_work(&wq_work);
+}
+
+void mali_pp_fs_scaling_update(struct mali_gpu_utilization_data *data)
+{
+ u32 ret = 0;
+ u32 utilization = data->utilization_gpu;
+ //(data->utilization_pp < data->utilization_gp)?data->utilization_gp:data->utilization_pp;
+ u32 loading_complete = (1<<16);//mali_utilization_bw_get_period();
+ u32 mali_up_limit = mali_turbo_mode ? mali_clock_max_index : max_mali_clock;
+
+ if (loading_complete > (2<<16) &&
+ currentStep > min_mali_clock) {
+ currentStep --;
+ MALI_DEBUG_PRINT(3, (" active time vs command complete:%d\n", loading_complete));
+ goto exit;
+ }
+
+ if (utilization >= mali_dvfs_threshold[currentStep].upthreshold) {
+ if (utilization < mali_pp_scale_threshold[MALI_PP_THRESHOLD_80] && currentStep < mali_up_limit)
+ currentStep ++;
+ else
+ currentStep = mali_up_limit;
+
+ if (data->utilization_pp > MALI_PP_THRESHOLD_80) {
+ enable_max_num_cores();
+ } else {
+ enable_one_core();
+ }
+ MALI_DEBUG_PRINT(3, (" > utilization:%d currentStep:%d.pp:%d. upthreshold:%d.\n",
+ utilization, currentStep, num_cores_enabled, mali_dvfs_threshold[currentStep].upthreshold ));
+ } else if (utilization < mali_dvfs_threshold[currentStep].downthreshold && currentStep > min_mali_clock) {
+ currentStep--;
+ MALI_DEBUG_PRINT(3, (" < utilization:%d currentStep:%d. downthreshold:%d.\n",
+ utilization, currentStep,mali_dvfs_threshold[currentStep].downthreshold ));
+ } else {
+ if (data->utilization_pp < mali_pp_scale_threshold[MALI_PP_THRESHOLD_30])
+ ret = disable_one_core();
+ MALI_DEBUG_PRINT(3, (" < utilization:%d currentStep:%d. downthreshold:%d.pp:%d\n",
+ utilization, currentStep,mali_dvfs_threshold[currentStep].downthreshold, num_cores_enabled));
+ }
+
+exit:
+ if ((num_cores_enabled != num_cores_total) ||
+ (mali_dvfs_threshold[currentStep].freq_index != mali_dvfs_threshold[lastStep].freq_index))
+ schedule_work(&wq_work);
+#ifdef CONFIG_MALI400_PROFILING
+ else
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+ MALI_PROFILING_EVENT_CHANNEL_GPU |
+ MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
+ get_mali_freq(),
+ 0, 0, 0, 0);
+#endif
+}
+
+void reset_mali_scaling_stat(void)
+{
+ if (mali_turbo_mode)
+ currentStep = mali_clock_max_index;
+ else
+ currentStep = max_mali_clock;
+ enable_max_num_cores();
+ schedule_work(&wq_work);
+}
+
+u32 get_max_pp_num(void)
+{
+ return num_cores_total;
+}
+u32 set_max_pp_num(u32 num)
+{
+ if (num < min_pp_num)
+ return -1;
+ num_cores_total = num;
+ if (num_cores_enabled > num_cores_total) {
+ num_cores_enabled = num_cores_total;
+ schedule_work(&wq_work);
+ }
+
+ return 0;
+}
+
+u32 get_min_pp_num(void)
+{
+ return min_pp_num;
+}
+u32 set_min_pp_num(u32 num)
+{
+ if (num > num_cores_total)
+ return -1;
+ min_pp_num = num;
+ if (num_cores_enabled < min_pp_num) {
+ num_cores_enabled = min_pp_num;
+ schedule_work(&wq_work);
+ }
+
+ return 0;
+}
+
+u32 get_max_mali_freq(void)
+{
+ return max_mali_clock;
+}
+u32 set_max_mali_freq(u32 idx)
+{
+ if (idx >= mali_clock_max_index || idx < min_mali_clock )
+ return -1;
+ max_mali_clock = idx;
+ if (currentStep > max_mali_clock) {
+ currentStep = max_mali_clock;
+ schedule_work(&wq_work);
+ }
+
+ return 0;
+}
+
+u32 get_min_mali_freq(void)
+{
+ return min_mali_clock;
+}
+u32 set_min_mali_freq(u32 idx)
+{
+ if (idx > max_mali_clock)
+ return -1;
+ min_mali_clock = idx;
+ if (currentStep < min_mali_clock) {
+ currentStep = min_mali_clock;
+ schedule_work(&wq_work);
+ }
+
+ return 0;
+}
+
+void mali_plat_preheat(void)
+{
+ //printk(" aml mali test*************\n");
+ int ret;
+ ret = enable_max_num_cores();
+ if (ret)
+ schedule_work(&wq_work);
+}
+
+void set_turbo_mode(u32 mode)
+{
+ mali_turbo_mode = mode;
+}
+
+void mali_gpu_utilization_callback(struct mali_gpu_utilization_data *data)
+{
+ switch (scaling_mode) {
+ case MALI_PP_FS_SCALING:
+ reseted_for_turbo = 0;
+ set_turbo_mode(0);
+ mali_pp_fs_scaling_update(data);
+ break;
+ case MALI_PP_SCALING:
+ reseted_for_turbo = 0;
+ set_turbo_mode(0);
+ mali_pp_scaling_update(data);
+ break;
+ case MALI_TURBO_MODE:
+ set_turbo_mode(1);
+ //mali_pp_fs_scaling_update(data);
+ if (reseted_for_turbo == 0) {
+ reseted_for_turbo = 1;
+ reset_mali_scaling_stat();
+ }
+ break;
+ default:
+ set_turbo_mode(0);
+ reseted_for_turbo = 0;
+ }
+}
+
+u32 get_mali_schel_mode(void)
+{
+ return scaling_mode;
+}
+
+void set_mali_schel_mode(u32 mode)
+{
+ MALI_DEBUG_ASSERT(mode < MALI_SCALING_MODE_MAX);
+ if (mode >= MALI_SCALING_MODE_MAX)return;
+ scaling_mode = mode;
+ reset_mali_scaling_stat();
+}
+
+
--- /dev/null
+/*
+ * Copyright (C) 2010, 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <linux/version.h>
+#include <linux/dma-mapping.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/pm.h>
+#include <linux/of.h>
+#include <linux/ioport.h>
+#include <linux/slab.h>
+#include <mach/register.h>
+#include <mach/irqs.h>
+#include <mach/io.h>
+#include <asm/io.h>
+
+#include "meson_main.h"
+#include <linux/mali/mali_utgard.h>
+#include "mali_kernel_common.h"
+#include "common/mali_pmu.h"
+#include "common/mali_osk_profiling.h"
+
+static void mali_platform_device_release(struct device *device);
+
+static struct mali_gpu_device_data mali_gpu_data =
+{
+ .shared_mem_size = 1024 * 1024 * 1024,
+ .max_job_runtime = 60000, /* 60 seconds */
+ .pmu_switch_delay = 0xFFFF, /* do not have to be this high on FPGA, but it is good for testing to have a delay */
+ .pmu_domain_config = {0x1, 0x2, 0x4, 0x4, 0x4, 0x8, 0x8, 0x8, 0x8, 0x1, 0x2, 0x8},
+};
+
+static struct platform_device mali_gpu_device =
+{
+ .name = MALI_GPU_NAME_UTGARD,
+ .id = 0,
+ .dev.release = mali_platform_device_release,
+ .dev.coherent_dma_mask = DMA_BIT_MASK(32),
+ .dev.platform_data = &mali_gpu_data,
+ .dev.type = &mali_pm_device, /* We should probably use the pm_domain instead of type on newer kernels */
+};
+
+int mali_pdev_pre_init(struct platform_device* ptr_plt_dev)
+{
+ MALI_DEBUG_PRINT(4, ("mali_platform_device_register() called\n"));
+ if (mali_gpu_data.shared_mem_size < 10) {
+ MALI_DEBUG_PRINT(2, ("mali os memory didn't configered, set to default(512M)\n"));
+ mali_gpu_data.shared_mem_size = 1024 * 1024 *1024;
+ }
+ return mali_meson_init_start(ptr_plt_dev);
+}
+
+void mali_pdev_post_init(struct platform_device* pdev)
+{
+#ifdef CONFIG_PM_RUNTIME
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+ pm_runtime_set_autosuspend_delay(&(pdev->dev), 1000);
+ pm_runtime_use_autosuspend(&(pdev->dev));
+#endif
+ pm_runtime_enable(&(pdev->dev));
+#endif
+ mali_meson_init_finish(pdev);
+}
+
+int mali_pdev_dts_init(struct platform_device* mali_gpu_device)
+{
+ struct device_node *cfg_node = mali_gpu_device->dev.of_node;
+ struct device_node *child;
+ u32 prop_value;
+ int err;
+ mali_dvfs_threshold_table_t* tbl = NULL;
+ u32 tbl_size;
+ u32 tbl_size_in_byte;
+
+ for_each_child_of_node(cfg_node, child) {
+ err = of_property_read_u32(child, "shared_memory", &prop_value);
+ if (err == 0) {
+ MALI_DEBUG_PRINT(2, ("shared_memory configurate %d\n", prop_value));
+ mali_gpu_data.shared_mem_size = prop_value * 1024 * 1024;
+ }
+
+ err = of_property_read_u32(child, "dvfs_size", &prop_value);
+ if (err != 0 || prop_value < 0 || prop_value > get_max_dvfs_tbl_size()) {
+ MALI_DEBUG_PRINT(2, ("invalid recorde_number is.\n"));
+ goto def_start;
+ }
+
+ tbl_size = sizeof(mali_dvfs_threshold_table_t) * prop_value;
+ tbl_size_in_byte = tbl_size / sizeof(u32);
+ tbl = kzalloc(tbl_size, GFP_KERNEL);
+ if (!tbl)
+ goto def_start;
+
+ err = of_property_read_u32_array(child,
+ "dvfs_table",
+ (u32*)tbl,
+ tbl_size_in_byte);
+ if (err == 0) {
+ memcpy(get_mali_dvfs_tbl_addr(), tbl, tbl_size);
+ set_mali_dvfs_tbl_size(prop_value);
+ kfree(tbl);
+ }
+ }
+
+def_start:
+ err = mali_pdev_pre_init(mali_gpu_device);
+ if (err == 0)
+ mali_pdev_post_init(mali_gpu_device);
+ return err;
+}
+
+int mali_platform_device_register(void)
+{
+ int err = -1;
+ err = mali_pdev_pre_init(&mali_gpu_device);
+ if (err == 0) {
+ err = platform_device_register(&mali_gpu_device);
+ if (0 == err)
+ mali_pdev_post_init(&mali_gpu_device);
+ }
+ return err;
+}
+
+void mali_platform_device_unregister(void)
+{
+ MALI_DEBUG_PRINT(4, ("mali_platform_device_unregister() called\n"));
+
+ platform_device_unregister(&mali_gpu_device);
+ platform_device_put(&mali_gpu_device);
+}
+
+static void mali_platform_device_release(struct device *device)
+{
+ MALI_DEBUG_PRINT(4, ("mali_platform_device_release() called\n"));
+}
--- /dev/null
+/*
+ * mali_platform.h
+ *
+ * Created on: Nov 8, 2013
+ * Author: amlogic
+ */
+
+#ifndef MESON_MAIN_H_
+#define MESON_MAIN_H_
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#ifdef CONFIG_PM_RUNTIME
+#include <linux/pm_runtime.h>
+#endif
+#include <mach/cpu.h>
+
+#include "mali_scaling.h"
+#include "mali_clock.h"
+
+extern struct device_type mali_pm_device;
+extern u32 mali_dvfs_clk[];
+extern u32 mali_dvfs_clk_sample[];
+extern u32 mali_clock_max_index;
+extern u32 mali_default_clock_idx;
+extern u32 mali_up_clock_idx;
+
+int mali_meson_init_start(struct platform_device* ptr_plt_dev);
+int mali_meson_init_finish(struct platform_device* ptr_plt_dev);
+int mali_meson_uninit(struct platform_device* ptr_plt_dev);
+int mali_light_suspend(struct device *device);
+int mali_light_resume(struct device *device);
+int mali_deep_suspend(struct device *device);
+int mali_deep_resume(struct device *device);
+
+#endif /* MESON_MAIN_H_ */
*\r
*******************************************************************/\r
/* Standard Linux headers */\r
+#include <linux/platform_device.h>\r
+#include <linux/version.h>\r
#include <linux/types.h>\r
#include <linux/init.h>\r
#include <linux/module.h>\r
#include <linux/slab.h>\r
#include <linux/list.h>\r
\r
+#include <asm/io.h>\r
\r
-static ssize_t mpgpu_show(struct class *class,\r
- struct class_attribute *attr, char *buf)\r
+#include <linux/mali/mali_utgard.h>\r
+#include <common/mali_kernel_common.h>\r
+#include <common/mali_pmu.h>\r
+#include "meson_main.h"\r
+\r
+static ssize_t domain_stat_read(struct class *class, \r
+ struct class_attribute *attr, char *buf)\r
+{\r
+ return sprintf(buf, "%x\n", mali_pmu_get_status());\r
+}\r
+\r
+#if MESON_CPU_TYPE == MESON_CPU_TYPE_MESON8\r
+static ssize_t mpgpu_read(struct class *class, \r
+ struct class_attribute *attr, char *buf)\r
{\r
return 0;\r
}\r
\r
#define PREHEAT_CMD "preheat"\r
\r
-void mali_plat_preheat(void);\r
-static ssize_t mpgpu_store(struct class *class,\r
- struct class_attribute *attr, const char *buf, size_t count)\r
+static ssize_t mpgpu_write(struct class *class,\r
+ struct class_attribute *attr, const char *buf, size_t count)\r
{\r
if(!strncmp(buf,PREHEAT_CMD,strlen(PREHEAT_CMD)))\r
mali_plat_preheat();\r
return count;\r
}\r
\r
-static CLASS_ATTR(mpgpucmd, 0644, mpgpu_show, mpgpu_store);\r
+static ssize_t scale_mode_read(struct class *class, \r
+ struct class_attribute *attr, char *buf)\r
+{\r
+ return sprintf(buf, "%d\n", get_mali_schel_mode());\r
+}\r
+\r
+static ssize_t scale_mode_write(struct class *class,\r
+ struct class_attribute *attr, const char *buf, size_t count)\r
+{\r
+ int ret;\r
+ unsigned int val;\r
+\r
+ ret = kstrtouint(buf, 10, &val);\r
+ if (0 != ret)\r
+ {\r
+ return -EINVAL;\r
+ }\r
+ set_mali_schel_mode(val);\r
+\r
+ return count;\r
+}\r
+\r
+static ssize_t max_pp_read(struct class *class, \r
+ struct class_attribute *attr, char *buf)\r
+{\r
+ return sprintf(buf, "%d\n", get_max_pp_num());\r
+}\r
+\r
+static ssize_t max_pp_write(struct class *class,\r
+ struct class_attribute *attr, const char *buf, size_t count)\r
+{\r
+ int ret;\r
+ unsigned int val;\r
+\r
+ ret = kstrtouint(buf, 10, &val);\r
+ if (0 != ret)\r
+ {\r
+ return -EINVAL;\r
+ }\r
+ ret = set_max_pp_num(val);\r
+\r
+ return count;\r
+}\r
+\r
+static ssize_t min_pp_read(struct class *class, \r
+ struct class_attribute *attr, char *buf)\r
+{\r
+\r
+ return sprintf(buf, "%d\n", get_min_pp_num());\r
+}\r
+\r
+static ssize_t min_pp_write(struct class *class,\r
+ struct class_attribute *attr, const char *buf, size_t count)\r
+{\r
+ int ret;\r
+ unsigned int val;\r
+\r
+ ret = kstrtouint(buf, 10, &val);\r
+ if (0 != ret)\r
+ {\r
+ return -EINVAL;\r
+ }\r
+ ret = set_min_pp_num(val);\r
+\r
+ return count;\r
+}\r
+\r
+static ssize_t max_freq_read(struct class *class, \r
+ struct class_attribute *attr, char *buf)\r
+{\r
+ return sprintf(buf, "%d\n", get_max_mali_freq());\r
+}\r
+\r
+static ssize_t max_freq_write(struct class *class,\r
+ struct class_attribute *attr, const char *buf, size_t count)\r
+{\r
+ int ret;\r
+ unsigned int val;\r
+\r
+ ret = kstrtouint(buf, 10, &val);\r
+ if (0 != ret)\r
+ {\r
+ return -EINVAL;\r
+ }\r
+ ret = set_max_mali_freq(val);\r
+\r
+ return count;\r
+}\r
+\r
+static ssize_t min_freq_read(struct class *class, \r
+ struct class_attribute *attr, char *buf)\r
+{\r
+ return sprintf(buf, "%d\n", get_min_mali_freq());\r
+}\r
+\r
+static ssize_t min_freq_write(struct class *class,\r
+ struct class_attribute *attr, const char *buf, size_t count)\r
+{\r
+ int ret;\r
+ unsigned int val;\r
+\r
+ ret = kstrtouint(buf, 10, &val);\r
+ if (0 != ret)\r
+ {\r
+ return -EINVAL;\r
+ }\r
+ ret = set_min_mali_freq(val);\r
+ \r
+ return count;\r
+}\r
+#endif\r
+\r
+\r
+static struct class_attribute mali_class_attrs[] = {\r
+ __ATTR(domain_stat, 0644, domain_stat_read, NULL),\r
+#if MESON_CPU_TYPE == MESON_CPU_TYPE_MESON8\r
+ __ATTR(mpgpucmd, 0644, mpgpu_read, mpgpu_write),\r
+ __ATTR(scale_mode, 0644, scale_mode_read, scale_mode_write),\r
+ __ATTR(min_freq, 0644, min_freq_read, min_freq_write),\r
+ __ATTR(max_freq, 0644, max_freq_read, max_freq_write),\r
+ __ATTR(min_pp, 0644, min_pp_read, min_pp_write),\r
+ __ATTR(max_pp, 0644, max_pp_read, max_pp_write),\r
+#endif\r
+};\r
\r
static struct class mpgpu_class = {\r
.name = "mpgpu",\r
\r
int mpgpu_class_init(void)\r
{\r
- int error;\r
+ int ret = 0;\r
+ int i;\r
+ int attr_num = ARRAY_SIZE(mali_class_attrs);\r
\r
- error = class_register(&mpgpu_class);\r
- if (error) {\r
+ ret = class_register(&mpgpu_class);\r
+ if (ret) {\r
printk(KERN_ERR "%s: class_register failed\n", __func__);\r
- return error;\r
+ return ret;\r
}\r
- error = class_create_file(&mpgpu_class, &class_attr_mpgpucmd);\r
- if (error) {\r
- printk(KERN_ERR "%s: class_create_file failed\n", __func__);\r
- class_unregister(&mpgpu_class);\r
+ for (i = 0; i< attr_num; i++) {\r
+ ret = class_create_file(&mpgpu_class, &mali_class_attrs[i]);\r
+ if (ret) {\r
+ printk(KERN_ERR "%d ST: class item failed to register\n", i);\r
+ } \r
}\r
-\r
- return error;\r
-\r
+ return ret;\r
}\r
\r
void mpgpu_class_exit(void)\r
class_unregister(&mpgpu_class);\r
}\r
\r
-\r
+#if 0\r
static int __init mpgpu_init(void)\r
{\r
return mpgpu_class_init();\r
mpgpu_class_exit();\r
}\r
\r
-#ifndef MODULE\r
fs_initcall(mpgpu_init);\r
module_exit(mpgpu_exit);\r
\r
--- /dev/null
+Building the Mali Device Driver for Linux
+-----------------------------------------
+
+Build the Mali Device Driver for Linux by running the following make command:
+
+KDIR=<kdir_path> USING_UMP=<ump_option> BUILD=<build_option> make
+
+where
+ kdir_path: Path to your Linux Kernel directory
+ ump_option: 1 = Enable UMP support(*)
+ 0 = disable UMP support
+ build_option: debug = debug build of driver
+ release = release build of driver
+
+(*) For newer Linux Kernels, the Module.symvers file for the UMP device driver
+ must be available. The UMP_SYMVERS_FILE variable in the Makefile should
+ point to this file. This file is generated when the UMP driver is built.
+
+The result will be a mali.ko file, which can be loaded into the Linux kernel
+by using the insmod command.
+
+The kernel needs to be provided with a platform_device struct for the Mali GPU
+device. See the mali_utgard.h header file for how to set up the Mali GPU
+resources.
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2007-2010, 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010, 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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 _MALI200_REGS_H_
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2007-2010, 2012-2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010, 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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 _MALIGP2_CONROL_REGS_H_
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2010-2011, 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2011, 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_timestamp.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2010-2011, 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2011, 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_TIMESTAMP_H__
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2010-2011, 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2011, 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_timestamp.h"
/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2010-2011, 2013 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
+ * Copyright (C) 2010-2011, 2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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_TIMESTAMP_H__
--- /dev/null
+r4p0-00rel0
ccflags-y += -DSVN_REV_STRING=\"$(SVN_REV)\"
ccflags-y += -I$(src) -I$(TOP_KBUILD_SRC)$(src)/common -I$(TOP_KBUILD_SRC)$(src)/linux -I$(TOP_KBUILD_SRC)$(src)/../mali/common -I$(src)/../mali/linux -I$(src)/../ump/include/ump
+ccflags-y += -I$(srctree)/drivers/staging/android
ccflags-y += -DMALI_STATE_TRACKING=0
+ccflags-y += -DMALI_ENABLE_CPU_CYCLES=0
ccflags-$(CONFIG_UMP_DEBUG) += -DDEBUG
# For customer releases the Linux Device Drivers will be provided as ARM proprietary and GPL releases:
menu "Mali 400 UMP device driver"
config UMP
tristate "UMP support"
+ depends on m
default n
---help---
This enables support for the UMP memory allocation and sharing API.
--- /dev/null
+/*
+ * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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 __ARCH_CONFIG_H__
+#define __ARCH_CONFIG_H__
+
+#define ARCH_UMP_BACKEND_DEFAULT 0
+#define ARCH_UMP_MEMORY_ADDRESS_DEFAULT 0xE1000000
+#define ARCH_UMP_MEMORY_SIZE_DEFAULT 16UL * 1024UL * 1024UL
+
+#endif /* __ARCH_CONFIG_H__ */
{
ump_dd_mem * mem;
- _mali_osk_lock_wait(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_wait(device.secure_id_map_lock);
DBG_MSG(5, ("Getting handle from secure ID. ID: %u\n", secure_id));
- if (0 != ump_descriptor_mapping_get(device.secure_id_map, (int)secure_id, (void**)&mem))
- {
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ if (0 != ump_descriptor_mapping_get(device.secure_id_map, (int)secure_id, (void**)&mem)) {
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
DBG_MSG(1, ("Secure ID not found. ID: %u\n", secure_id));
return UMP_DD_HANDLE_INVALID;
}
ump_dd_reference_add(mem);
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
return (ump_dd_handle)mem;
}
DEBUG_ASSERT_POINTER(mem);
- if (blocks == NULL)
- {
+ if (blocks == NULL) {
DBG_MSG(1, ("NULL parameter in ump_dd_phys_blocks_get()\n"));
return UMP_DD_INVALID;
}
- if (mem->nr_blocks != num_blocks)
- {
+ if (mem->nr_blocks != num_blocks) {
DBG_MSG(1, ("Specified number of blocks do not match actual number of blocks\n"));
return UMP_DD_INVALID;
}
DEBUG_ASSERT_POINTER(mem);
- if (block == NULL)
- {
+ if (block == NULL) {
DBG_MSG(1, ("NULL parameter in ump_dd_phys_block_get()\n"));
return UMP_DD_INVALID;
}
- if (index >= mem->nr_blocks)
- {
+ if (index >= mem->nr_blocks) {
DBG_MSG(5, ("Invalid index specified in ump_dd_phys_block_get()\n"));
return UMP_DD_INVALID;
}
that elements in the ump_descriptor_mapping table is always valid. If they
are not, userspace may accidently map in this secure_ids right before its freed
giving a mapped backdoor into unallocated memory.*/
- _mali_osk_lock_wait(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_wait(device.secure_id_map_lock);
new_ref = _ump_osk_atomic_dec_and_read(&mem->ref_count);
DBG_MSG(5, ("Memory reference decremented. ID: %u, new value: %d\n", mem->secure_id, new_ref));
- if (0 == new_ref)
- {
+ if (0 == new_ref) {
DBG_MSG(3, ("Final release of memory. ID: %u\n", mem->secure_id));
ump_descriptor_mapping_free(device.secure_id_map, (int)mem->secure_id);
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
mem->release_func(mem->ctx, mem);
_mali_osk_free(mem);
- }
- else
- {
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ } else {
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
}
}
session_data = (ump_session_data *)args->ctx;
/* check compatability */
- if (args->version == UMP_IOCTL_API_VERSION)
- {
+ if (args->version == UMP_IOCTL_API_VERSION) {
DBG_MSG(3, ("API version set to newest %d (compatible)\n", GET_VERSION(args->version)));
args->compatible = 1;
session_data->api_version = args->version;
- }
- else if (args->version == MAKE_VERSION_ID(1))
- {
+ } else if (args->version == MAKE_VERSION_ID(1)) {
DBG_MSG(2, ("API version set to depricated: %d (compatible)\n", GET_VERSION(args->version)));
args->compatible = 1;
session_data->api_version = args->version;
- }
- else
- {
+ } else {
DBG_MSG(2, ("API version set to %d (incompatible with client version %d)\n", GET_VERSION(UMP_IOCTL_API_VERSION), GET_VERSION(args->version)));
args->compatible = 0;
args->version = UMP_IOCTL_API_VERSION; /* report our version */
DBG_MSG(4, ("Releasing memory with IOCTL, ID: %u\n", secure_id));
/* Iterate through the memory list looking for the requested secure ID */
- _mali_osk_lock_wait(session_data->lock, _MALI_OSK_LOCKMODE_RW);
- _MALI_OSK_LIST_FOREACHENTRY(session_memory_element, tmp, &session_data->list_head_session_memory_list, ump_session_memory_list_element, list)
- {
- if ( session_memory_element->mem->secure_id == secure_id)
- {
+ _mali_osk_mutex_wait(session_data->lock);
+ _MALI_OSK_LIST_FOREACHENTRY(session_memory_element, tmp, &session_data->list_head_session_memory_list, ump_session_memory_list_element, list) {
+ if ( session_memory_element->mem->secure_id == secure_id) {
ump_dd_mem *release_mem;
release_mem = session_memory_element->mem;
}
}
- _mali_osk_lock_signal(session_data->lock, _MALI_OSK_LOCKMODE_RW);
- DBG_MSG_IF(1, _MALI_OSK_ERR_OK != ret, ("UMP memory with ID %u does not belong to this session.\n", secure_id));
+ _mali_osk_mutex_signal(session_data->lock);
+ DBG_MSG_IF(1, _MALI_OSK_ERR_OK != ret, ("UMP memory with ID %u does not belong to this session.\n", secure_id));
DBG_MSG(4, ("_ump_ukk_release() returning 0x%x\n", ret));
return ret;
DEBUG_ASSERT_POINTER( user_interaction );
/* We lock the mappings so things don't get removed while we are looking for the memory */
- _mali_osk_lock_wait(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
- if (0 == ump_descriptor_mapping_get(device.secure_id_map, (int)user_interaction->secure_id, (void**)&mem))
- {
+ _mali_osk_mutex_wait(device.secure_id_map_lock);
+ if (0 == ump_descriptor_mapping_get(device.secure_id_map, (int)user_interaction->secure_id, (void**)&mem)) {
user_interaction->size = mem->size_bytes;
DBG_MSG(4, ("Returning size. ID: %u, size: %lu ", (ump_secure_id)user_interaction->secure_id, (unsigned long)user_interaction->size));
ret = _MALI_OSK_ERR_OK;
- }
- else
- {
- user_interaction->size = 0;
+ } else {
+ user_interaction->size = 0;
DBG_MSG(1, ("Failed to look up mapping in ump_ioctl_size_get(). ID: %u\n", (ump_secure_id)user_interaction->secure_id));
}
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
return ret;
}
u32 size = 0;
u32 offset = 0;
- _mali_osk_lock_wait(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_wait(device.secure_id_map_lock);
ump_descriptor_mapping_get(device.secure_id_map, (int)args->secure_id, (void**)&mem);
- if (NULL == mem)
- {
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ if (NULL == mem) {
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
DBG_MSG(1, ("Failed to look up mapping in _ump_ukk_msync(). ID: %u\n", (ump_secure_id)args->secure_id));
return;
}
/* Ensure the memory doesn't dissapear when we are flushing it. */
ump_dd_reference_add(mem);
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
/* Returns the cache settings back to Userspace */
args->is_cached=mem->is_cached;
/* If this flag is the only one set, we should not do the actual flush, only the readout */
- if ( _UMP_UK_MSYNC_READOUT_CACHE_ENABLED==args->op )
- {
+ if ( _UMP_UK_MSYNC_READOUT_CACHE_ENABLED==args->op ) {
DBG_MSG(3, ("_ump_ukk_msync READOUT ID: %u Enabled: %d\n", (ump_secure_id)args->secure_id, mem->is_cached));
goto msync_release_and_return;
}
/* Nothing to do if the memory is not caches */
- if ( 0==mem->is_cached )
- {
+ if ( 0==mem->is_cached ) {
DBG_MSG(3, ("_ump_ukk_msync IGNORING ID: %u Enabled: %d OP: %d\n", (ump_secure_id)args->secure_id, mem->is_cached, args->op));
goto msync_release_and_return;
}
DBG_MSG(3, ("UMP[%02u] _ump_ukk_msync Flush OP: %d Address: 0x%08x Mapping: 0x%08x\n",
(ump_secure_id)args->secure_id, args->op, args->address, args->mapping));
- if ( args->address )
- {
+ if ( args->address ) {
virtual = (void *)((u32)args->address);
offset = (u32)((args->address) - (args->mapping));
} else {
/* Flush entire mapping when no address is specified. */
virtual = args->mapping;
}
- if ( args->size )
- {
+ if ( args->size ) {
size = args->size;
} else {
/* Flush entire mapping when no size is specified. */
size = mem->size_bytes - offset;
}
- if ( (offset + size) > mem->size_bytes )
- {
+ if ( (offset + size) > mem->size_bytes ) {
DBG_MSG(1, ("Trying to flush more than the entire UMP allocation: offset: %u + size: %u > %u\n", offset, size, mem->size_bytes));
goto msync_release_and_return;
}
op = args->op;
session_data = (ump_session_data *)args->ctx;
- _mali_osk_lock_wait(session_data->lock, _MALI_OSK_LOCKMODE_RW);
- if ( op== _UMP_UK_CACHE_OP_START )
- {
+ _mali_osk_mutex_wait(session_data->lock);
+ if ( op== _UMP_UK_CACHE_OP_START ) {
session_data->cache_operations_ongoing++;
DBG_MSG(4, ("Cache ops start\n" ));
- if ( session_data->cache_operations_ongoing != 1 )
- {
+ if ( session_data->cache_operations_ongoing != 1 ) {
DBG_MSG(2, ("UMP: Number of simultanious cache control ops: %d\n", session_data->cache_operations_ongoing) );
}
- }
- else if ( op== _UMP_UK_CACHE_OP_FINISH )
- {
+ } else if ( op== _UMP_UK_CACHE_OP_FINISH ) {
DBG_MSG(4, ("Cache ops finish\n"));
session_data->cache_operations_ongoing--;
- #if 0
- if ( session_data->has_pending_level1_cache_flush)
- {
+#if 0
+ if ( session_data->has_pending_level1_cache_flush) {
/* This function will set has_pending_level1_cache_flush=0 */
_ump_osk_msync( NULL, NULL, 0, 0, _UMP_UK_MSYNC_FLUSH_L1, session_data);
}
- #endif
+#endif
/* to be on the safe side: always flush l1 cache when cache operations are done */
_ump_osk_msync( NULL, NULL, 0, 0, _UMP_UK_MSYNC_FLUSH_L1, session_data);
DBG_MSG(4, ("Cache ops finish end\n" ));
- }
- else
- {
+ } else {
DBG_MSG(1, ("Illegal call to %s at line %d\n", __FUNCTION__, __LINE__));
}
- _mali_osk_lock_signal(session_data->lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_signal(session_data->lock);
}
session_data = (ump_session_data *)args->ctx;
- _mali_osk_lock_wait(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_wait(device.secure_id_map_lock);
ump_descriptor_mapping_get(device.secure_id_map, (int)args->secure_id, (void**)&mem);
- if (NULL == mem)
- {
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ if (NULL == mem) {
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
DBG_MSG(1, ("Failed to look up mapping in _ump_ukk_switch_hw_usage(). ID: %u\n", (ump_secure_id)args->secure_id));
return;
}
DBG_MSG(3, ("UMP[%02u] Switch usage Start New: %s Prev: %s.\n", (ump_secure_id)args->secure_id, args->new_user?"MALI":"CPU",old_user?"MALI":"CPU"));
- if ( ! mem->is_cached )
- {
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ if ( ! mem->is_cached ) {
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
DBG_MSG(3, ("UMP[%02u] Changing owner of uncached memory. Cache flushing not needed.\n", (ump_secure_id)args->secure_id));
return;
}
- if ( old_user == args->new_user)
- {
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ if ( old_user == args->new_user) {
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
DBG_MSG(4, ("UMP[%02u] Setting the new_user equal to previous for. Cache flushing not needed.\n", (ump_secure_id)args->secure_id));
return;
}
if (
- /* Previous AND new is both different from CPU */
- (old_user != _UMP_UK_USED_BY_CPU) && (args->new_user != _UMP_UK_USED_BY_CPU )
- )
- {
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ /* Previous AND new is both different from CPU */
+ (old_user != _UMP_UK_USED_BY_CPU) && (args->new_user != _UMP_UK_USED_BY_CPU )
+ ) {
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
DBG_MSG(4, ("UMP[%02u] Previous and new user is not CPU. Cache flushing not needed.\n", (ump_secure_id)args->secure_id));
return;
}
- if ( (old_user != _UMP_UK_USED_BY_CPU ) && (args->new_user==_UMP_UK_USED_BY_CPU) )
- {
+ if ( (old_user != _UMP_UK_USED_BY_CPU ) && (args->new_user==_UMP_UK_USED_BY_CPU) ) {
cache_op =_UMP_UK_MSYNC_INVALIDATE;
DBG_MSG(4, ("UMP[%02u] Cache invalidation needed\n", (ump_secure_id)args->secure_id));
#ifdef UMP_SKIP_INVALIDATION
#error
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
DBG_MSG(4, ("UMP[%02u] Performing Cache invalidation SKIPPED\n", (ump_secure_id)args->secure_id));
return;
#endif
}
/* Ensure the memory doesn't dissapear when we are flushing it. */
ump_dd_reference_add(mem);
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
/* Take lock to protect: session->cache_operations_ongoing and session->has_pending_level1_cache_flush */
- _mali_osk_lock_wait(session_data->lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_wait(session_data->lock);
/* Actual cache flush */
_ump_osk_msync( mem, NULL, 0, mem->size_bytes, cache_op, session_data);
- _mali_osk_lock_signal(session_data->lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_signal(session_data->lock);
ump_dd_reference_release(mem);
DBG_MSG(4, ("UMP[%02u] Switch usage Finish\n", (ump_secure_id)args->secure_id));
{
ump_dd_mem * mem = NULL;
- _mali_osk_lock_wait(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_wait(device.secure_id_map_lock);
ump_descriptor_mapping_get(device.secure_id_map, (int)args->secure_id, (void**)&mem);
- if (NULL == mem)
- {
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ if (NULL == mem) {
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
DBG_MSG(1, ("UMP[%02u] Failed to look up mapping in _ump_ukk_lock(). ID: %u\n", (ump_secure_id)args->secure_id));
return;
}
ump_dd_reference_add(mem);
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
DBG_MSG(1, ("UMP[%02u] Lock. New lock flag: %d. Old Lock flag:\n", (u32)args->secure_id, (u32)args->lock_usage, (u32) mem->lock_usage ));
{
ump_dd_mem * mem = NULL;
- _mali_osk_lock_wait(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_wait(device.secure_id_map_lock);
ump_descriptor_mapping_get(device.secure_id_map, (int)args->secure_id, (void**)&mem);
- if (NULL == mem)
- {
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ if (NULL == mem) {
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
DBG_MSG(1, ("Failed to look up mapping in _ump_ukk_unlock(). ID: %u\n", (ump_secure_id)args->secure_id));
return;
}
ump_dd_reference_add(mem);
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
DBG_MSG(1, ("UMP[%02u] Unlocking. Old Lock flag:\n", (u32)args->secure_id, (u32) mem->lock_usage ));
/* Perform OS Specific initialization */
err = _ump_osk_init();
- if( _MALI_OSK_ERR_OK != err )
- {
+ if( _MALI_OSK_ERR_OK != err ) {
MSG_ERR(("Failed to initiaze the UMP Device Driver"));
return err;
}
_mali_osk_memset(&device, 0, sizeof(device) );
/* Create the descriptor map, which will be used for mapping secure ID to ump_dd_mem structs */
- device.secure_id_map_lock = _mali_osk_lock_init(_MALI_OSK_LOCKFLAG_NONINTERRUPTABLE, 0 , 0);
- if (NULL == device.secure_id_map_lock)
- {
+ device.secure_id_map_lock = _mali_osk_mutex_init(_MALI_OSK_LOCKFLAG_UNORDERED, 0);
+ if (NULL == device.secure_id_map_lock) {
MSG_ERR(("Failed to create OSK lock for secure id lookup table\n"));
return _MALI_OSK_ERR_NOMEM;
}
device.secure_id_map = ump_descriptor_mapping_create(UMP_SECURE_ID_TABLE_ENTRIES_INITIAL, UMP_SECURE_ID_TABLE_ENTRIES_MAXIMUM);
- if (NULL == device.secure_id_map)
- {
- _mali_osk_lock_term(device.secure_id_map_lock);
+ if (NULL == device.secure_id_map) {
+ _mali_osk_mutex_term(device.secure_id_map_lock);
MSG_ERR(("Failed to create secure id lookup table\n"));
return _MALI_OSK_ERR_NOMEM;
}
/* Init memory backend */
device.backend = ump_memory_backend_create();
- if (NULL == device.backend)
- {
+ if (NULL == device.backend) {
MSG_ERR(("Failed to create memory backend\n"));
- _mali_osk_lock_term(device.secure_id_map_lock);
+ _mali_osk_mutex_term(device.secure_id_map_lock);
ump_descriptor_mapping_destroy(device.secure_id_map);
return _MALI_OSK_ERR_NOMEM;
}
DEBUG_ASSERT_POINTER(device.secure_id_map);
DEBUG_ASSERT_POINTER(device.secure_id_map_lock);
- _mali_osk_lock_term(device.secure_id_map_lock);
+ _mali_osk_mutex_term(device.secure_id_map_lock);
device.secure_id_map_lock = NULL;
ump_descriptor_mapping_destroy(device.secure_id_map);
/* allocated struct to track this session */
session_data = (struct ump_session_data *)_mali_osk_malloc(sizeof(struct ump_session_data));
- if (NULL == session_data)
- {
+ if (NULL == session_data) {
MSG_ERR(("Failed to allocate ump_session_data in ump_file_open()\n"));
return _MALI_OSK_ERR_NOMEM;
}
- session_data->lock = _mali_osk_lock_init(_MALI_OSK_LOCKFLAG_NONINTERRUPTABLE, 0, 0);
- if( NULL == session_data->lock )
- {
+ session_data->lock = _mali_osk_mutex_init(_MALI_OSK_LOCKFLAG_UNORDERED, 0);
+ if( NULL == session_data->lock ) {
MSG_ERR(("Failed to initialize lock for ump_session_data in ump_file_open()\n"));
_mali_osk_free(session_data);
return _MALI_OSK_ERR_NOMEM;
session_data->cookies_map = ump_descriptor_mapping_create( UMP_COOKIES_PER_SESSION_INITIAL, UMP_COOKIES_PER_SESSION_MAXIMUM );
- if ( NULL == session_data->cookies_map )
- {
+ if ( NULL == session_data->cookies_map ) {
MSG_ERR(("Failed to create descriptor mapping for _ump_ukk_map_mem cookies\n"));
- _mali_osk_lock_term( session_data->lock );
+ _mali_osk_mutex_term(session_data->lock);
_mali_osk_free( session_data );
return _MALI_OSK_ERR_NOMEM;
}
ump_session_memory_list_element * tmp;
session_data = (struct ump_session_data *)*context;
- if (NULL == session_data)
- {
+ if (NULL == session_data) {
MSG_ERR(("Session data is NULL in _ump_ukk_close()\n"));
return _MALI_OSK_ERR_INVALID_ARGS;
}
/* Unmap any descriptors mapped in. */
- if (0 == _mali_osk_list_empty(&session_data->list_head_session_memory_mappings_list))
- {
+ if (0 == _mali_osk_list_empty(&session_data->list_head_session_memory_mappings_list)) {
ump_memory_allocation *descriptor;
ump_memory_allocation *temp;
DBG_MSG(1, ("Memory mappings found on session usage list during session termination\n"));
/* use the 'safe' list iterator, since freeing removes the active block from the list we're iterating */
- _MALI_OSK_LIST_FOREACHENTRY(descriptor, temp, &session_data->list_head_session_memory_mappings_list, ump_memory_allocation, list)
- {
+ _MALI_OSK_LIST_FOREACHENTRY(descriptor, temp, &session_data->list_head_session_memory_mappings_list, ump_memory_allocation, list) {
_ump_uk_unmap_mem_s unmap_args;
DBG_MSG(4, ("Freeing block with phys address 0x%x size 0x%x mapped in user space at 0x%x\n",
descriptor->phys_addr, descriptor->size, descriptor->mapping));
* can fail silently. */
DEBUG_ASSERT( _mali_osk_list_empty(&session_data->list_head_session_memory_mappings_list) );
- _MALI_OSK_LIST_FOREACHENTRY(item, tmp, &session_data->list_head_session_memory_list, ump_session_memory_list_element, list)
- {
+ _MALI_OSK_LIST_FOREACHENTRY(item, tmp, &session_data->list_head_session_memory_list, ump_session_memory_list_element, list) {
_mali_osk_list_del(&item->list);
DBG_MSG(2, ("Releasing UMP memory %u as part of file close\n", item->mem->secure_id));
ump_dd_reference_release(item->mem);
ump_descriptor_mapping_destroy( session_data->cookies_map );
- _mali_osk_lock_term(session_data->lock);
+ _mali_osk_mutex_term(session_data->lock);
_mali_osk_free(session_data);
DBG_MSG(2, ("Session closed\n"));
int map_id;
session_data = (ump_session_data *)args->ctx;
- if( NULL == session_data )
- {
+ if( NULL == session_data ) {
MSG_ERR(("Session data is NULL in _ump_ukk_map_mem()\n"));
return _MALI_OSK_ERR_INVALID_ARGS;
}
descriptor = (ump_memory_allocation*) _mali_osk_calloc( 1, sizeof(ump_memory_allocation));
- if (NULL == descriptor)
- {
+ if (NULL == descriptor) {
MSG_ERR(("ump_ukk_map_mem: descriptor allocation failed\n"));
return _MALI_OSK_ERR_NOMEM;
}
handle = ump_dd_handle_create_from_secure_id(args->secure_id);
- if ( UMP_DD_HANDLE_INVALID == handle)
- {
+ if ( UMP_DD_HANDLE_INVALID == handle) {
_mali_osk_free(descriptor);
DBG_MSG(1, ("Trying to map unknown secure ID %u\n", args->secure_id));
return _MALI_OSK_ERR_FAULT;
mem = (ump_dd_mem*)handle;
DEBUG_ASSERT(mem);
- if (mem->size_bytes != args->size)
- {
+ if (mem->size_bytes != args->size) {
_mali_osk_free(descriptor);
ump_dd_reference_release(handle);
DBG_MSG(1, ("Trying to map too much or little. ID: %u, virtual size=%lu, UMP size: %lu\n", args->secure_id, args->size, mem->size_bytes));
map_id = ump_descriptor_mapping_allocate_mapping( session_data->cookies_map, (void*) descriptor );
- if (map_id < 0)
- {
+ if (map_id < 0) {
_mali_osk_free(descriptor);
ump_dd_reference_release(handle);
DBG_MSG(1, ("ump_ukk_map_mem: unable to allocate a descriptor_mapping for return cookie\n"));
descriptor->ump_session = session_data;
descriptor->cookie = (u32)map_id;
- if ( mem->is_cached )
- {
+ if ( mem->is_cached ) {
descriptor->is_cached = 1;
args->is_cached = 1;
DBG_MSG(3, ("Mapping UMP secure_id: %d as cached.\n", args->secure_id));
- }
- else
- {
+ } else {
descriptor->is_cached = 0;
args->is_cached = 0;
DBG_MSG(3, ("Mapping UMP secure_id: %d as Uncached.\n", args->secure_id));
_mali_osk_list_init( &descriptor->list );
err = _ump_osk_mem_mapregion_init( descriptor );
- if( _MALI_OSK_ERR_OK != err )
- {
+ if( _MALI_OSK_ERR_OK != err ) {
DBG_MSG(1, ("Failed to initialize memory mapping in _ump_ukk_map_mem(). ID: %u\n", args->secure_id));
ump_descriptor_mapping_free( session_data->cookies_map, map_id );
_mali_osk_free(descriptor);
}
DBG_MSG(4, ("Mapping virtual to physical memory: ID: %u, size:%lu, first physical addr: 0x%08lx, number of regions: %lu\n",
- mem->secure_id,
- mem->size_bytes,
- ((NULL != mem->block_array) ? mem->block_array->addr : 0),
- mem->nr_blocks));
+ mem->secure_id,
+ mem->size_bytes,
+ ((NULL != mem->block_array) ? mem->block_array->addr : 0),
+ mem->nr_blocks));
left = descriptor->size;
/* loop over all blocks and map them in */
- for (block = 0; block < mem->nr_blocks; block++)
- {
+ for (block = 0; block < mem->nr_blocks; block++) {
unsigned long size_to_map;
- if (left > mem->block_array[block].size)
- {
+ if (left > mem->block_array[block].size) {
size_to_map = mem->block_array[block].size;
- }
- else
- {
+ } else {
size_to_map = left;
}
- if (_MALI_OSK_ERR_OK != _ump_osk_mem_mapregion_map(descriptor, offset, (u32 *)&(mem->block_array[block].addr), size_to_map ) )
- {
+ if (_MALI_OSK_ERR_OK != _ump_osk_mem_mapregion_map(descriptor, offset, (u32 *)&(mem->block_array[block].addr), size_to_map ) ) {
DBG_MSG(1, ("WARNING: _ump_ukk_map_mem failed to map memory into userspace\n"));
ump_descriptor_mapping_free( session_data->cookies_map, map_id );
ump_dd_reference_release(mem);
}
/* Add to the ump_memory_allocation tracking list */
- _mali_osk_lock_wait(session_data->lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_wait(session_data->lock);
_mali_osk_list_add( &descriptor->list, &session_data->list_head_session_memory_mappings_list );
- _mali_osk_lock_signal(session_data->lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_signal(session_data->lock);
args->mapping = descriptor->mapping;
args->cookie = descriptor->cookie;
session_data = (ump_session_data *)args->ctx;
- if( NULL == session_data )
- {
+ if( NULL == session_data ) {
MSG_ERR(("Session data is NULL in _ump_ukk_map_mem()\n"));
return;
}
- if (0 != ump_descriptor_mapping_get( session_data->cookies_map, (int)args->cookie, (void**)&descriptor) )
- {
+ if (0 != ump_descriptor_mapping_get( session_data->cookies_map, (int)args->cookie, (void**)&descriptor) ) {
MSG_ERR(("_ump_ukk_map_mem: cookie 0x%X not found for this session\n", args->cookie ));
return;
}
DEBUG_ASSERT_POINTER(descriptor);
handle = descriptor->handle;
- if ( UMP_DD_HANDLE_INVALID == handle)
- {
+ if ( UMP_DD_HANDLE_INVALID == handle) {
DBG_MSG(1, ("WARNING: Trying to unmap unknown handle: UNKNOWN\n"));
return;
}
/* Remove the ump_memory_allocation from the list of tracked mappings */
- _mali_osk_lock_wait(session_data->lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_wait(session_data->lock);
_mali_osk_list_del( &descriptor->list );
- _mali_osk_lock_signal(session_data->lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_signal(session_data->lock);
ump_descriptor_mapping_free( session_data->cookies_map, (int)args->cookie );
#ifdef DEBUG
- extern int ump_debug_level;
- #define UMP_DEBUG_PRINT(args) _mali_osk_dbgmsg args
- #define UMP_DEBUG_CODE(args) args
- #define DBG_MSG(level,args) do { /* args should be in brackets */ \
+extern int ump_debug_level;
+#define UMP_DEBUG_PRINT(args) _mali_osk_dbgmsg args
+#define UMP_DEBUG_CODE(args) args
+#define DBG_MSG(level,args) do { /* args should be in brackets */ \
((level) <= ump_debug_level)?\
UMP_DEBUG_PRINT(("UMP<" #level ">: ")), \
UMP_DEBUG_PRINT(args):0; \
} while (0)
- #define DBG_MSG_IF(level,condition,args) /* args should be in brackets */ \
+#define DBG_MSG_IF(level,condition,args) /* args should be in brackets */ \
if((condition)&&((level) <= ump_debug_level)) {\
UMP_DEBUG_PRINT(("UMP<" #level ">: ")); \
UMP_DEBUG_PRINT(args); \
}
- #define DBG_MSG_ELSE(level,args) /* args should be in brackets */ \
+#define DBG_MSG_ELSE(level,args) /* args should be in brackets */ \
else if((level) <= ump_debug_level) { \
UMP_DEBUG_PRINT(("UMP<" #level ">: ")); \
UMP_DEBUG_PRINT(args); \
}
- #define DEBUG_ASSERT_POINTER(pointer) do {if( (pointer)== NULL) MSG_ERR(("NULL pointer " #pointer)); } while(0)
- #define DEBUG_ASSERT(condition) do {if(!(condition)) MSG_ERR(("ASSERT failed: " #condition)); } while(0)
+#define DEBUG_ASSERT_POINTER(pointer) do {if( (pointer)== NULL) MSG_ERR(("NULL pointer " #pointer)); } while(0)
+#define DEBUG_ASSERT(condition) do {if(!(condition)) MSG_ERR(("ASSERT failed: " #condition)); } while(0)
#else /* DEBUG */
- #define UMP_DEBUG_PRINT(args) do {} while(0)
- #define UMP_DEBUG_CODE(args)
- #define DBG_MSG(level,args) do {} while(0)
- #define DBG_MSG_IF(level,condition,args) do {} while(0)
- #define DBG_MSG_ELSE(level,args) do {} while(0)
- #define DEBUG_ASSERT(condition) do {} while(0)
- #define DEBUG_ASSERT_POINTER(pointer) do {} while(0)
+#define UMP_DEBUG_PRINT(args) do {} while(0)
+#define UMP_DEBUG_CODE(args)
+#define DBG_MSG(level,args) do {} while(0)
+#define DBG_MSG_IF(level,condition,args) do {} while(0)
+#define DBG_MSG_ELSE(level,args) do {} while(0)
+#define DEBUG_ASSERT(condition) do {} while(0)
+#define DEBUG_ASSERT_POINTER(pointer) do {} while(0)
#endif /* DEBUG */
#define MSG_ERR(args) do{ /* args should be in brackets */ \
* A session is created when someone open() the device, and
* closed when someone close() it or the user space application terminates.
*/
-typedef struct ump_session_data
-{
+typedef struct ump_session_data {
_mali_osk_list_t list_head_session_memory_list; /**< List of ump allocations made by the process (elements are ump_session_memory_list_element) */
_mali_osk_list_t list_head_session_memory_mappings_list; /**< List of ump_memory_allocations mapped in */
int api_version;
- _mali_osk_lock_t * lock;
+ _mali_osk_mutex_t *lock;
ump_descriptor_mapping * cookies_map; /**< Secure mapping of cookies from _ump_ukk_map_mem() */
int cache_operations_ongoing;
int has_pending_level1_cache_flush;
* We need to track this in order to be able to clean up after user space processes
* which don't do it themself (e.g. due to a crash or premature termination).
*/
-typedef struct ump_session_memory_list_element
-{
+typedef struct ump_session_memory_list_element {
struct ump_dd_mem * mem;
_mali_osk_list_t list;
} ump_session_memory_list_element;
/*
* Device specific data, created when device driver is loaded, and then kept as the global variable device.
*/
-typedef struct ump_dev
-{
- _mali_osk_lock_t * secure_id_map_lock;
+typedef struct ump_dev {
+ _mali_osk_mutex_t *secure_id_map_lock;
ump_descriptor_mapping * secure_id_map;
ump_memory_backend * backend;
} ump_dev;
init_entries = MALI_PAD_INT(init_entries);
max_entries = MALI_PAD_INT(max_entries);
- if (NULL != map)
- {
+ if (NULL != map) {
map->table = descriptor_table_alloc(init_entries);
- if (NULL != map->table)
- {
- map->lock = _mali_osk_lock_init(_MALI_OSK_LOCKFLAG_NONINTERRUPTABLE | _MALI_OSK_LOCKFLAG_READERWRITER, 0 , 0);
- if ( NULL != map->lock )
- {
+ if (NULL != map->table) {
+ map->lock = _mali_osk_mutex_rw_init(_MALI_OSK_LOCKFLAG_UNORDERED, 0);
+ if ( NULL != map->lock ) {
_mali_osk_set_nonatomic_bit(0, map->table->usage); /* reserve bit 0 to prevent NULL/zero logic to kick in */
map->max_nr_mappings_allowed = max_entries;
map->current_nr_mappings = init_entries;
void ump_descriptor_mapping_destroy(ump_descriptor_mapping * map)
{
descriptor_table_free(map->table);
- _mali_osk_lock_term( map->lock );
+ _mali_osk_mutex_rw_term(map->lock);
_mali_osk_free(map);
}
int ump_descriptor_mapping_allocate_mapping(ump_descriptor_mapping * map, void * target)
{
- int descriptor = -1;/*-EFAULT;*/
- _mali_osk_lock_wait(map->lock, _MALI_OSK_LOCKMODE_RW);
- descriptor = _mali_osk_find_first_zero_bit(map->table->usage, map->current_nr_mappings);
- if (descriptor == map->current_nr_mappings)
- {
+ int descriptor = -1;/*-EFAULT;*/
+ _mali_osk_mutex_rw_wait(map->lock, _MALI_OSK_LOCKMODE_RW);
+ descriptor = _mali_osk_find_first_zero_bit(map->table->usage, map->current_nr_mappings);
+ if (descriptor == map->current_nr_mappings) {
int nr_mappings_new;
/* no free descriptor, try to expand the table */
ump_descriptor_table * new_table;
ump_descriptor_table * old_table = map->table;
nr_mappings_new= map->current_nr_mappings *2;
- if (map->current_nr_mappings >= map->max_nr_mappings_allowed)
- {
+ if (map->current_nr_mappings >= map->max_nr_mappings_allowed) {
descriptor = -1;
goto unlock_and_exit;
}
new_table = descriptor_table_alloc(nr_mappings_new);
- if (NULL == new_table)
- {
+ if (NULL == new_table) {
descriptor = -1;
goto unlock_and_exit;
}
- _mali_osk_memcpy(new_table->usage, old_table->usage, (sizeof(unsigned long)*map->current_nr_mappings) / BITS_PER_LONG);
- _mali_osk_memcpy(new_table->mappings, old_table->mappings, map->current_nr_mappings * sizeof(void*));
+ _mali_osk_memcpy(new_table->usage, old_table->usage, (sizeof(unsigned long)*map->current_nr_mappings) / BITS_PER_LONG);
+ _mali_osk_memcpy(new_table->mappings, old_table->mappings, map->current_nr_mappings * sizeof(void*));
map->table = new_table;
map->current_nr_mappings = nr_mappings_new;
descriptor_table_free(old_table);
map->table->mappings[descriptor] = target;
unlock_and_exit:
- _mali_osk_lock_signal(map->lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_rw_signal(map->lock, _MALI_OSK_LOCKMODE_RW);
return descriptor;
}
int ump_descriptor_mapping_get(ump_descriptor_mapping * map, int descriptor, void** target)
{
- int result = -1;/*-EFAULT;*/
- DEBUG_ASSERT(map);
- _mali_osk_lock_wait(map->lock, _MALI_OSK_LOCKMODE_RO);
- if ( (descriptor >= 0) && (descriptor < map->current_nr_mappings) && _mali_osk_test_bit(descriptor, map->table->usage) )
- {
+ int result = -1;/*-EFAULT;*/
+ DEBUG_ASSERT(map);
+ _mali_osk_mutex_rw_wait(map->lock, _MALI_OSK_LOCKMODE_RO);
+ if ((descriptor > 0) && (descriptor < map->current_nr_mappings) && _mali_osk_test_bit(descriptor, map->table->usage)) {
*target = map->table->mappings[descriptor];
result = 0;
- }
- else *target = NULL;
- _mali_osk_lock_signal(map->lock, _MALI_OSK_LOCKMODE_RO);
+ } else *target = NULL;
+ _mali_osk_mutex_rw_signal(map->lock, _MALI_OSK_LOCKMODE_RO);
return result;
}
int ump_descriptor_mapping_set(ump_descriptor_mapping * map, int descriptor, void * target)
{
- int result = -1;/*-EFAULT;*/
- _mali_osk_lock_wait(map->lock, _MALI_OSK_LOCKMODE_RO);
- if ( (descriptor >= 0) && (descriptor < map->current_nr_mappings) && _mali_osk_test_bit(descriptor, map->table->usage) )
- {
+ int result = -1;/*-EFAULT;*/
+ _mali_osk_mutex_rw_wait(map->lock, _MALI_OSK_LOCKMODE_RO);
+ if ((descriptor > 0) && (descriptor < map->current_nr_mappings) && _mali_osk_test_bit(descriptor, map->table->usage)) {
map->table->mappings[descriptor] = target;
result = 0;
}
- _mali_osk_lock_signal(map->lock, _MALI_OSK_LOCKMODE_RO);
+ _mali_osk_mutex_rw_signal(map->lock, _MALI_OSK_LOCKMODE_RO);
return result;
}
void ump_descriptor_mapping_free(ump_descriptor_mapping * map, int descriptor)
{
- _mali_osk_lock_wait(map->lock, _MALI_OSK_LOCKMODE_RW);
- if ( (descriptor >= 0) && (descriptor < map->current_nr_mappings) && _mali_osk_test_bit(descriptor, map->table->usage) )
- {
+ _mali_osk_mutex_rw_wait(map->lock, _MALI_OSK_LOCKMODE_RW);
+ if ((descriptor > 0) && (descriptor < map->current_nr_mappings) && _mali_osk_test_bit(descriptor, map->table->usage)) {
map->table->mappings[descriptor] = NULL;
_mali_osk_clear_nonatomic_bit(descriptor, map->table->usage);
}
- _mali_osk_lock_signal(map->lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_rw_signal(map->lock, _MALI_OSK_LOCKMODE_RW);
}
static ump_descriptor_table * descriptor_table_alloc(int count)
table = _mali_osk_calloc(1, sizeof(ump_descriptor_table) + ((sizeof(unsigned long) * count)/BITS_PER_LONG) + (sizeof(void*) * count) );
- if (NULL != table)
- {
+ if (NULL != table) {
table->usage = (u32*)((u8*)table + sizeof(ump_descriptor_table));
table->mappings = (void**)((u8*)table + sizeof(ump_descriptor_table) + ((sizeof(unsigned long) * count)/BITS_PER_LONG));
}
/**
* The actual descriptor mapping table, never directly accessed by clients
*/
-typedef struct ump_descriptor_table
-{
+typedef struct ump_descriptor_table {
u32 * usage; /**< Pointer to bitpattern indicating if a descriptor is valid/used or not */
void** mappings; /**< Array of the pointers the descriptors map to */
} ump_descriptor_table;
* The descriptor mapping object
* Provides a separate namespace where we can map an integer to a pointer
*/
-typedef struct ump_descriptor_mapping
-{
- _mali_osk_lock_t *lock; /**< Lock protecting access to the mapping object */
+typedef struct ump_descriptor_mapping {
+ _mali_osk_mutex_rw_t *lock; /**< Lock protecting access to the mapping object */
int max_nr_mappings_allowed; /**< Max number of mappings to support in this namespace */
int current_nr_mappings; /**< Current number of possible mappings */
ump_descriptor_table * table; /**< Pointer to the current mapping table */
#include "ump_kernel_types.h"
-typedef struct ump_memory_allocation
-{
+typedef struct ump_memory_allocation {
void * phys_addr;
void * mapping;
unsigned long size;
u32 is_cached;
} ump_memory_allocation;
-typedef struct ump_memory_backend
-{
+typedef struct ump_memory_backend {
int (*allocate)(void* ctx, ump_dd_mem * descriptor);
void (*release)(void* ctx, ump_dd_mem * descriptor);
void (*shutdown)(struct ump_memory_backend * backend);
u32 i;
/* Go through the input blocks and verify that they are sane */
- for (i=0; i < num_blocks; i++)
- {
+ for (i=0; i < num_blocks; i++) {
unsigned long addr = blocks[i].addr;
unsigned long size = blocks[i].size;
DBG_MSG(5, ("Adding physical memory to new handle. Address: 0x%08lx, size: %lu\n", addr, size));
size_total += blocks[i].size;
- if (0 != UMP_ADDR_ALIGN_OFFSET(addr))
- {
+ if (0 != UMP_ADDR_ALIGN_OFFSET(addr)) {
MSG_ERR(("Trying to create UMP memory from unaligned physical address. Address: 0x%08lx\n", addr));
return UMP_DD_HANDLE_INVALID;
}
- if (0 != UMP_ADDR_ALIGN_OFFSET(size))
- {
+ if (0 != UMP_ADDR_ALIGN_OFFSET(size)) {
MSG_ERR(("Trying to create UMP memory with unaligned size. Size: %lu\n", size));
return UMP_DD_HANDLE_INVALID;
}
/* Allocate the ump_dd_mem struct for this allocation */
mem = _mali_osk_malloc(sizeof(*mem));
- if (NULL == mem)
- {
+ if (NULL == mem) {
DBG_MSG(1, ("Could not allocate ump_dd_mem in ump_dd_handle_create_from_phys_blocks()\n"));
return UMP_DD_HANDLE_INVALID;
}
/* Find a secure ID for this allocation */
- _mali_osk_lock_wait(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_wait(device.secure_id_map_lock);
map_id = ump_descriptor_mapping_allocate_mapping(device.secure_id_map, (void*) mem);
- if (map_id < 0)
- {
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ if (map_id < 0) {
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
_mali_osk_free(mem);
DBG_MSG(1, ("Failed to allocate secure ID in ump_dd_handle_create_from_phys_blocks()\n"));
return UMP_DD_HANDLE_INVALID;
/* Now, make a copy of the block information supplied by the user */
mem->block_array = _mali_osk_malloc(sizeof(ump_dd_physical_block)* num_blocks);
- if (NULL == mem->block_array)
- {
+ if (NULL == mem->block_array) {
ump_descriptor_mapping_free(device.secure_id_map, map_id);
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
_mali_osk_free(mem);
DBG_MSG(1, ("Could not allocate a mem handle for function ump_dd_handle_create_from_phys_blocks().\n"));
return UMP_DD_HANDLE_INVALID;
mem->hw_device = _UMP_UK_USED_BY_CPU;
mem->lock_usage = UMP_NOT_LOCKED;
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
DBG_MSG(3, ("UMP memory created. ID: %u, size: %lu\n", mem->secure_id, mem->size_bytes));
return (ump_dd_handle)mem;
session_data = (ump_session_data *) user_interaction->ctx;
session_memory_element = _mali_osk_calloc( 1, sizeof(ump_session_memory_list_element));
- if (NULL == session_memory_element)
- {
+ if (NULL == session_memory_element) {
DBG_MSG(1, ("Failed to allocate ump_session_memory_list_element in ump_ioctl_allocate()\n"));
return _MALI_OSK_ERR_NOMEM;
}
new_allocation = _mali_osk_calloc( 1, sizeof(ump_dd_mem));
- if (NULL==new_allocation)
- {
+ if (NULL==new_allocation) {
_mali_osk_free(session_memory_element);
DBG_MSG(1, ("Failed to allocate ump_dd_mem in _ump_ukk_allocate()\n"));
return _MALI_OSK_ERR_NOMEM;
}
/* Create a secure ID for this allocation */
- _mali_osk_lock_wait(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_wait(device.secure_id_map_lock);
map_id = ump_descriptor_mapping_allocate_mapping(device.secure_id_map, (void*)new_allocation);
- if (map_id < 0)
- {
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ if (map_id < 0) {
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
_mali_osk_free(session_memory_element);
_mali_osk_free(new_allocation);
DBG_MSG(1, ("Failed to allocate secure ID in ump_ioctl_allocate()\n"));
new_allocation->secure_id = (ump_secure_id)map_id;
_mali_osk_atomic_init(&new_allocation->ref_count,1);
if ( 0==(UMP_REF_DRV_UK_CONSTRAINT_USE_CACHE & user_interaction->constraints) )
- new_allocation->is_cached = 0;
+ new_allocation->is_cached = 0;
else new_allocation->is_cached = 1;
/* special case a size of 0, we should try to emulate what malloc does in this case, which is to return a valid pointer that must be freed, but can't be dereferences */
- if (0 == user_interaction->size)
- {
+ if (0 == user_interaction->size) {
user_interaction->size = 1; /* emulate by actually allocating the minimum block size */
}
new_allocation->lock_usage = UMP_NOT_LOCKED;
/* Now, ask the active memory backend to do the actual memory allocation */
- if (!device.backend->allocate( device.backend->ctx, new_allocation ) )
- {
+ if (!device.backend->allocate( device.backend->ctx, new_allocation ) ) {
DBG_MSG(3, ("OOM: No more UMP memory left. Failed to allocate memory in ump_ioctl_allocate(). Size: %lu, requested size: %lu\n", new_allocation->size_bytes, (unsigned long)user_interaction->size));
ump_descriptor_mapping_free(device.secure_id_map, map_id);
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
_mali_osk_free(new_allocation);
_mali_osk_free(session_memory_element);
return _MALI_OSK_ERR_INVALID_FUNC;
new_allocation->ctx = device.backend->ctx;
new_allocation->release_func = device.backend->release;
- _mali_osk_lock_signal(device.secure_id_map_lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_signal(device.secure_id_map_lock);
/* Initialize the session_memory_element, and add it to the session object */
session_memory_element->mem = new_allocation;
- _mali_osk_lock_wait(session_data->lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_wait(session_data->lock);
_mali_osk_list_add(&(session_memory_element->list), &(session_data->list_head_session_memory_list));
- _mali_osk_lock_signal(session_data->lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_mutex_signal(session_data->lock);
user_interaction->secure_id = new_allocation->secure_id;
user_interaction->size = new_allocation->size_bytes;
#include "mali_osk.h"
-typedef enum
-{
+typedef enum {
UMP_USED_BY_CPU = 0,
UMP_USED_BY_MALI = 1,
UMP_USED_BY_UNKNOWN_DEVICE= 100,
} ump_hw_usage;
-typedef enum
-{
+typedef enum {
UMP_NOT_LOCKED = 0,
UMP_READ = 1,
UMP_READ_WRITE = 3,
/*
* This struct is what is "behind" a ump_dd_handle
*/
-typedef struct ump_dd_mem
-{
+typedef struct ump_dd_mem {
ump_secure_id secure_id;
_mali_osk_atomic_t ref_count;
unsigned long size_bytes;
#include "ump_kernel_common.h"
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
_mali_osk_errcode_t _ump_osk_init( void );
#define __UMP_UK_TYPES_H__
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
/* Helpers for API version handling */
_UMP_IOC_SWITCH_HW_USAGE,
_UMP_IOC_LOCK,
_UMP_IOC_UNLOCK,
-}_ump_uk_functions;
+} _ump_uk_functions;
typedef enum
{
{
_UMP_UK_USED_BY_CPU = 0,
_UMP_UK_USED_BY_MALI = 1,
- _UMP_UK_USED_BY_UNKNOWN_DEVICE= 100,
+ _UMP_UK_USED_BY_UNKNOWN_DEVICE = 100,
} ump_uk_user;
/**
void *phys_addr; /**< [in] physical address */
unsigned long size; /**< [in] size */
u32 secure_id; /**< [in] secure_id to assign to mapping */
- void * _ukk_private; /**< Only used inside linux port between kernel frontend and common part to store vma */
+ void *_ukk_private; /**< Only used inside linux port between kernel frontend and common part to store vma */
u32 cookie;
u32 is_cached; /**< [in,out] caching of CPU mappings */
} _ump_uk_map_mem_s;
void *ctx; /**< [in,out] user-kernel context (trashed on output) */
void *mapping;
u32 size;
- void * _ukk_private;
+ void *_ukk_private;
u32 cookie;
} _ump_uk_unmap_mem_s;
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
/**
* External representation of a UMP handle in kernel space.
*/
-typedef void * ump_dd_handle;
+typedef void *ump_dd_handle;
/**
* Typedef for a secure ID, a system wide identificator for UMP memory buffers.
*
* @return UMP_DD_SUCCESS indicates success, UMP_DD_INVALID indicates failure.
*/
-UMP_KERNEL_API_EXPORT ump_dd_status_code ump_dd_phys_blocks_get(ump_dd_handle mem, ump_dd_physical_block * blocks, unsigned long num_blocks);
+UMP_KERNEL_API_EXPORT ump_dd_status_code ump_dd_phys_blocks_get(ump_dd_handle mem, ump_dd_physical_block *blocks, unsigned long num_blocks);
/**
*
* @return UMP_DD_SUCCESS indicates success, UMP_DD_INVALID indicates failure.
*/
-UMP_KERNEL_API_EXPORT ump_dd_status_code ump_dd_phys_block_get(ump_dd_handle mem, unsigned long index, ump_dd_physical_block * block);
+UMP_KERNEL_API_EXPORT ump_dd_status_code ump_dd_phys_block_get(ump_dd_handle mem, unsigned long index, ump_dd_physical_block *block);
/**
#endif
/** Turn specified physical memory into UMP memory. */
-UMP_KERNEL_API_EXPORT ump_dd_handle ump_dd_handle_create_from_phys_blocks(ump_dd_physical_block * blocks, unsigned long num_blocks);
+UMP_KERNEL_API_EXPORT ump_dd_handle ump_dd_handle_create_from_phys_blocks(ump_dd_physical_block *blocks, unsigned long num_blocks);
#ifdef __cplusplus
}
/*
- * Copyright (C) 2010, 2013 ARM Limited. All rights reserved.
+ * Copyright (C) 2010 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
#define __UMP_KERNEL_LICENSE_H__
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
#define UMP_KERNEL_LINUX_LICENSE "GPL"
#define __UMP_IOCTL_H__
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
#include <linux/types.h>
* Each memory mapping has a reference to the UMP memory it maps.
* We release this reference when the last memory mapping is unmapped.
*/
-typedef struct ump_vma_usage_tracker
-{
+typedef struct ump_vma_usage_tracker {
int references;
ump_dd_handle handle;
} ump_vma_usage_tracker;
-struct ump_device
-{
+struct ump_device {
struct cdev cdev;
#if UMP_LICENSE_IS_GPL
struct class * ump_class;
/* This variable defines the file operations this UMP device driver offer */
-static struct file_operations ump_fops =
-{
+static struct file_operations ump_fops = {
.owner = THIS_MODULE,
.open = ump_file_open,
.release = ump_file_release,
DBG_MSG(2, ("Inserting UMP device driver. Compiled: %s, time: %s\n", __DATE__, __TIME__));
err = ump_kernel_constructor();
- if (_MALI_OSK_ERR_OK != err)
- {
+ if (_MALI_OSK_ERR_OK != err) {
MSG_ERR(("UMP device driver init failed\n"));
return map_errcode(err);
}
static ssize_t ump_memory_used_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
{
- char buf[64];
- size_t r;
- u32 mem = _ump_ukk_report_memory_usage();
+ char buf[64];
+ size_t r;
+ u32 mem = _ump_ukk_report_memory_usage();
- r = snprintf(buf, 64, "%u\n", mem);
- return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
+ r = snprintf(buf, 64, "%u\n", mem);
+ return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
}
static const struct file_operations ump_memory_usage_fops = {
- .owner = THIS_MODULE,
- .read = ump_memory_used_read,
+ .owner = THIS_MODULE,
+ .read = ump_memory_used_read,
};
/*
dev_t dev = 0;
#if UMP_LICENSE_IS_GPL
ump_debugfs_dir = debugfs_create_dir(ump_dev_name, NULL);
- if (ERR_PTR(-ENODEV) == ump_debugfs_dir)
- {
- ump_debugfs_dir = NULL;
- }
- else
- {
+ if (ERR_PTR(-ENODEV) == ump_debugfs_dir) {
+ ump_debugfs_dir = NULL;
+ } else {
debugfs_create_file("memory_usage", 0400, ump_debugfs_dir, NULL, &ump_memory_usage_fops);
}
#endif
- if (0 == ump_major)
- {
+ if (0 == ump_major) {
/* auto select a major */
err = alloc_chrdev_region(&dev, 0, 1, ump_dev_name);
ump_major = MAJOR(dev);
- }
- else
- {
+ } else {
/* use load time defined major number */
dev = MKDEV(ump_major, 0);
err = register_chrdev_region(dev, 1, ump_dev_name);
}
- if (0 == err)
- {
+ if (0 == err) {
memset(&ump_device, 0, sizeof(ump_device));
/* initialize our char dev data */
/* register char dev with the kernel */
err = cdev_add(&ump_device.cdev, dev, 1/*count*/);
- if (0 == err)
- {
+ if (0 == err) {
#if UMP_LICENSE_IS_GPL
ump_device.ump_class = class_create(THIS_MODULE, ump_dev_name);
- if (IS_ERR(ump_device.ump_class))
- {
+ if (IS_ERR(ump_device.ump_class)) {
err = PTR_ERR(ump_device.ump_class);
- }
- else
- {
+ } else {
struct device * mdev;
mdev = device_create(ump_device.ump_class, NULL, dev, NULL, ump_dev_name);
- if (!IS_ERR(mdev))
- {
+ if (!IS_ERR(mdev)) {
return 0;
}
_mali_osk_errcode_t err;
/* input validation */
- if (0 != MINOR(inode->i_rdev))
- {
+ if (0 != MINOR(inode->i_rdev)) {
MSG_ERR(("Minor not zero in ump_file_open()\n"));
return -ENODEV;
}
/* Call the OS-Independent UMP Open function */
err = _ump_ukk_open((void**) &session_data );
- if( _MALI_OSK_ERR_OK != err )
- {
+ if( _MALI_OSK_ERR_OK != err ) {
MSG_ERR(("Ump failed to open a new session\n"));
return map_errcode( err );
}
_mali_osk_errcode_t err;
err = _ump_ukk_close((void**) &filp->private_data );
- if( _MALI_OSK_ERR_OK != err )
- {
+ if( _MALI_OSK_ERR_OK != err ) {
return map_errcode( err );
}
#endif
session_data = (struct ump_session_data *)filp->private_data;
- if (NULL == session_data)
- {
+ if (NULL == session_data) {
MSG_ERR(("No session data attached to file object\n"));
return -ENOTTY;
}
/* interpret the argument as a user pointer to something */
argument = (void __user *)arg;
- switch (cmd)
- {
- case UMP_IOC_QUERY_API_VERSION:
- err = ump_get_api_version_wrapper((u32 __user *)argument, session_data);
- break;
+ switch (cmd) {
+ case UMP_IOC_QUERY_API_VERSION:
+ err = ump_get_api_version_wrapper((u32 __user *)argument, session_data);
+ break;
- case UMP_IOC_ALLOCATE :
- err = ump_allocate_wrapper((u32 __user *)argument, session_data);
- break;
+ case UMP_IOC_ALLOCATE :
+ err = ump_allocate_wrapper((u32 __user *)argument, session_data);
+ break;
- case UMP_IOC_RELEASE:
- err = ump_release_wrapper((u32 __user *)argument, session_data);
- break;
+ case UMP_IOC_RELEASE:
+ err = ump_release_wrapper((u32 __user *)argument, session_data);
+ break;
- case UMP_IOC_SIZE_GET:
- err = ump_size_get_wrapper((u32 __user *)argument, session_data);
- break;
+ case UMP_IOC_SIZE_GET:
+ err = ump_size_get_wrapper((u32 __user *)argument, session_data);
+ break;
- case UMP_IOC_MSYNC:
- err = ump_msync_wrapper((u32 __user *)argument, session_data);
- break;
+ case UMP_IOC_MSYNC:
+ err = ump_msync_wrapper((u32 __user *)argument, session_data);
+ break;
- case UMP_IOC_CACHE_OPERATIONS_CONTROL:
- err = ump_cache_operations_control_wrapper((u32 __user *)argument, session_data);
- break;
+ case UMP_IOC_CACHE_OPERATIONS_CONTROL:
+ err = ump_cache_operations_control_wrapper((u32 __user *)argument, session_data);
+ break;
- case UMP_IOC_SWITCH_HW_USAGE:
- err = ump_switch_hw_usage_wrapper((u32 __user *)argument, session_data);
- break;
+ case UMP_IOC_SWITCH_HW_USAGE:
+ err = ump_switch_hw_usage_wrapper((u32 __user *)argument, session_data);
+ break;
- case UMP_IOC_LOCK:
- err = ump_lock_wrapper((u32 __user *)argument, session_data);
- break;
+ case UMP_IOC_LOCK:
+ err = ump_lock_wrapper((u32 __user *)argument, session_data);
+ break;
- case UMP_IOC_UNLOCK:
- err = ump_unlock_wrapper((u32 __user *)argument, session_data);
- break;
+ case UMP_IOC_UNLOCK:
+ err = ump_unlock_wrapper((u32 __user *)argument, session_data);
+ break;
- default:
- DBG_MSG(1, ("No handler for IOCTL. cmd: 0x%08x, arg: 0x%08lx\n", cmd, arg));
- err = -EFAULT;
- break;
+ default:
+ DBG_MSG(1, ("No handler for IOCTL. cmd: 0x%08x, arg: 0x%08lx\n", cmd, arg));
+ err = -EFAULT;
+ break;
}
return err;
int map_errcode( _mali_osk_errcode_t err )
{
- switch(err)
- {
- case _MALI_OSK_ERR_OK : return 0;
- case _MALI_OSK_ERR_FAULT: return -EFAULT;
- case _MALI_OSK_ERR_INVALID_FUNC: return -ENOTTY;
- case _MALI_OSK_ERR_INVALID_ARGS: return -EINVAL;
- case _MALI_OSK_ERR_NOMEM: return -ENOMEM;
- case _MALI_OSK_ERR_TIMEOUT: return -ETIMEDOUT;
- case _MALI_OSK_ERR_RESTARTSYSCALL: return -ERESTARTSYS;
- case _MALI_OSK_ERR_ITEM_NOT_FOUND: return -ENOENT;
- default: return -EFAULT;
- }
+ switch(err) {
+ case _MALI_OSK_ERR_OK :
+ return 0;
+ case _MALI_OSK_ERR_FAULT:
+ return -EFAULT;
+ case _MALI_OSK_ERR_INVALID_FUNC:
+ return -ENOTTY;
+ case _MALI_OSK_ERR_INVALID_ARGS:
+ return -EINVAL;
+ case _MALI_OSK_ERR_NOMEM:
+ return -ENOMEM;
+ case _MALI_OSK_ERR_TIMEOUT:
+ return -ETIMEDOUT;
+ case _MALI_OSK_ERR_RESTARTSYSCALL:
+ return -ERESTARTSYS;
+ case _MALI_OSK_ERR_ITEM_NOT_FOUND:
+ return -ENOENT;
+ default:
+ return -EFAULT;
+ }
}
/*
/* Validate the session data */
session_data = (struct ump_session_data *)filp->private_data;
- if (NULL == session_data)
- {
+ if (NULL == session_data) {
MSG_ERR(("mmap() called without any session data available\n"));
return -EFAULT;
}
args.secure_id = vma->vm_pgoff;
args.is_cached = 0;
- if (!(vma->vm_flags & VM_SHARED))
- {
+ if (!(vma->vm_flags & VM_SHARED)) {
args.is_cached = 1;
vma->vm_flags = vma->vm_flags | VM_SHARED | VM_MAYSHARE ;
DBG_MSG(3, ("UMP Map function: Forcing the CPU to use cache\n"));
/* Call the common mmap handler */
err = _ump_ukk_map_mem( &args );
- if ( _MALI_OSK_ERR_OK != err)
- {
+ if ( _MALI_OSK_ERR_OK != err) {
MSG_ERR(("_ump_ukk_map_mem() failed in function ump_file_mmap()"));
return map_errcode( err );
}
-typedef struct block_info
-{
+typedef struct block_info {
struct block_info * next;
} block_info;
-typedef struct block_allocator
-{
+typedef struct block_allocator {
struct semaphore mutex;
block_info * all_blocks;
block_info * first_free;
usable_size = (size + UMP_BLOCK_SIZE - 1) & ~(UMP_BLOCK_SIZE - 1);
num_blocks = usable_size / UMP_BLOCK_SIZE;
- if (0 == usable_size)
- {
+ if (0 == usable_size) {
DBG_MSG(1, ("Memory block of size %u is unusable\n", size));
return NULL;
}
DBG_MSG(6, ("%u usable bytes which becomes %u blocks\n", usable_size, num_blocks));
backend = kzalloc(sizeof(ump_memory_backend), GFP_KERNEL);
- if (NULL != backend)
- {
+ if (NULL != backend) {
allocator = kmalloc(sizeof(block_allocator), GFP_KERNEL);
- if (NULL != allocator)
- {
- allocator->all_blocks = kmalloc(sizeof(block_allocator) * num_blocks, GFP_KERNEL);
- if (NULL != allocator->all_blocks)
- {
+ if (NULL != allocator) {
+ allocator->all_blocks = kmalloc(sizeof(block_info) * num_blocks, GFP_KERNEL);
+ if (NULL != allocator->all_blocks) {
int i;
allocator->first_free = NULL;
allocator->base = base_address;
sema_init(&allocator->mutex, 1);
- for (i = 0; i < num_blocks; i++)
- {
+ for (i = 0; i < num_blocks; i++) {
allocator->all_blocks[i].next = allocator->first_free;
allocator->first_free = &allocator->all_blocks[i];
}
mem->nr_blocks = ((left + UMP_BLOCK_SIZE - 1) & ~(UMP_BLOCK_SIZE - 1)) / UMP_BLOCK_SIZE;
mem->block_array = (ump_dd_physical_block*)vmalloc(sizeof(ump_dd_physical_block) * mem->nr_blocks);
- if (NULL == mem->block_array)
- {
+ if (NULL == mem->block_array) {
MSG_ERR(("Failed to allocate block array\n"));
return 0;
}
- if (down_interruptible(&allocator->mutex))
- {
+ if (down_interruptible(&allocator->mutex)) {
MSG_ERR(("Could not get mutex to do block_allocate\n"));
return 0;
}
mem->size_bytes = 0;
- while ((left > 0) && (allocator->first_free))
- {
+ while ((left > 0) && (allocator->first_free)) {
block_info * block;
block = allocator->first_free;
else left -= UMP_BLOCK_SIZE;
}
- if (left)
- {
+ if (left) {
block_info * block;
/* release all memory back to the pool */
- while (last_allocated)
- {
+ while (last_allocated) {
block = last_allocated->next;
last_allocated->next = allocator->first_free;
allocator->first_free = last_allocated;
block = (block_info*)handle->backend_info;
BUG_ON(!block);
- if (down_interruptible(&allocator->mutex))
- {
+ if (down_interruptible(&allocator->mutex)) {
MSG_ERR(("Allocator release: Failed to get mutex - memory leak\n"));
return;
}
- while (block)
- {
+ while (block) {
next = block->next;
BUG_ON( (block < allocator->all_blocks) || (block > (allocator->all_blocks + allocator->num_blocks)));
/*
- * Copyright (C) 2010, 2013 ARM Limited. All rights reserved.
+ * Copyright (C) 2010 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
-typedef struct os_allocator
-{
+typedef struct os_allocator {
struct semaphore mutex;
u32 num_pages_max; /**< Maximum number of pages to allocate from the OS */
u32 num_pages_allocated; /**< Number of pages allocated from the OS */
os_allocator * info;
info = kmalloc(sizeof(os_allocator), GFP_KERNEL);
- if (NULL == info)
- {
+ if (NULL == info) {
return NULL;
}
sema_init(&info->mutex, 1);
backend = kmalloc(sizeof(ump_memory_backend), GFP_KERNEL);
- if (NULL == backend)
- {
+ if (NULL == backend) {
kfree(info);
return NULL;
}
left = descriptor->size_bytes;
is_cached = descriptor->is_cached;
- if (down_interruptible(&info->mutex))
- {
+ if (down_interruptible(&info->mutex)) {
DBG_MSG(1, ("Failed to get mutex in os_free\n"));
return 0; /* failure */
}
DBG_MSG(5, ("Allocating page array. Size: %lu\n", descriptor->nr_blocks * sizeof(ump_dd_physical_block)));
descriptor->block_array = (ump_dd_physical_block *)vmalloc(sizeof(ump_dd_physical_block) * descriptor->nr_blocks);
- if (NULL == descriptor->block_array)
- {
+ if (NULL == descriptor->block_array) {
up(&info->mutex);
DBG_MSG(1, ("Block array could not be allocated\n"));
return 0; /* failure */
}
- while (left > 0 && ((info->num_pages_allocated + pages_allocated) < info->num_pages_max))
- {
+ while (left > 0 && ((info->num_pages_allocated + pages_allocated) < info->num_pages_max)) {
struct page * new_page;
- if (is_cached)
- {
+ if (is_cached) {
new_page = alloc_page(GFP_HIGHUSER | __GFP_ZERO | __GFP_REPEAT | __GFP_NOWARN);
- } else
- {
+ } else {
new_page = alloc_page(GFP_HIGHUSER | __GFP_ZERO | __GFP_REPEAT | __GFP_NOWARN | __GFP_COLD);
}
- if (NULL == new_page)
- {
+ if (NULL == new_page) {
break;
}
/* Ensure page caches are flushed. */
- if ( is_cached )
- {
+ if ( is_cached ) {
descriptor->block_array[pages_allocated].addr = page_to_phys(new_page);
descriptor->block_array[pages_allocated].size = PAGE_SIZE;
- } else
- {
+ } else {
descriptor->block_array[pages_allocated].addr = dma_map_page(NULL, new_page, 0, PAGE_SIZE, DMA_BIDIRECTIONAL );
descriptor->block_array[pages_allocated].size = PAGE_SIZE;
}
DBG_MSG(5, ("Allocated page 0x%08lx cached: %d\n", descriptor->block_array[pages_allocated].addr, is_cached));
- if (left < PAGE_SIZE)
- {
+ if (left < PAGE_SIZE) {
left = 0;
- }
- else
- {
+ } else {
left -= PAGE_SIZE;
}
DBG_MSG(5, ("Alloce for ID:%2d got %d pages, cached: %d\n", descriptor->secure_id, pages_allocated));
- if (left)
- {
+ if (left) {
DBG_MSG(1, ("Failed to allocate needed pages\n"));
- while(pages_allocated)
- {
+ while(pages_allocated) {
pages_allocated--;
- if ( !is_cached )
- {
+ if ( !is_cached ) {
dma_unmap_page(NULL, descriptor->block_array[pages_allocated].addr, PAGE_SIZE, DMA_BIDIRECTIONAL);
}
__free_page(pfn_to_page(descriptor->block_array[pages_allocated].addr >> PAGE_SHIFT) );
BUG_ON(descriptor->nr_blocks > info->num_pages_allocated);
- if (down_interruptible(&info->mutex))
- {
+ if (down_interruptible(&info->mutex)) {
DBG_MSG(1, ("Failed to get mutex in os_free\n"));
return;
}
up(&info->mutex);
- for ( i = 0; i < descriptor->nr_blocks; i++)
- {
+ for ( i = 0; i < descriptor->nr_blocks; i++) {
DBG_MSG(6, ("Freeing physical page. Address: 0x%08lx\n", descriptor->block_array[i].addr));
- if ( ! descriptor->is_cached)
- {
+ if ( ! descriptor->is_cached) {
dma_unmap_page(NULL, descriptor->block_array[i].addr, PAGE_SIZE, DMA_BIDIRECTIONAL);
}
__free_page(pfn_to_page(descriptor->block_array[i].addr>>PAGE_SHIFT) );
/*
- * Copyright (C) 2010, 2013 ARM Limited. All rights reserved.
+ * Copyright (C) 2010 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
ump_memory_backend * backend = NULL;
/* Create the dynamic memory allocator backend */
- if (0 == ump_backend)
- {
+ if (0 == ump_backend) {
DBG_MSG(2, ("Using dedicated memory backend\n"));
DBG_MSG(2, ("Requesting dedicated memory: 0x%08x, size: %u\n", ump_memory_address, ump_memory_size));
/* Ask the OS if we can use the specified physical memory */
- if (NULL == request_mem_region(ump_memory_address, ump_memory_size, "UMP Memory"))
- {
+ if (NULL == request_mem_region(ump_memory_address, ump_memory_size, "UMP Memory")) {
MSG_ERR(("Failed to request memory region (0x%08X - 0x%08X). Is Mali DD already loaded?\n", ump_memory_address, ump_memory_address + ump_memory_size - 1));
return NULL;
}
backend = ump_block_allocator_create(ump_memory_address, ump_memory_size);
- }
- else if (1 == ump_backend)
- {
+ } else if (1 == ump_backend) {
DBG_MSG(2, ("Using OS memory backend, allocation limit: %d\n", ump_memory_size));
backend = ump_os_memory_backend_create(ump_memory_size);
}
void ump_memory_backend_destroy( void )
{
- if (0 == ump_backend)
- {
+ if (0 == ump_backend) {
DBG_MSG(2, ("Releasing dedicated memory: 0x%08x\n", ump_memory_address));
release_mem_region(ump_memory_address, ump_memory_size);
}
/*
- * Copyright (C) 2010, 2013 ARM Limited. All rights reserved.
+ * Copyright (C) 2010 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
#include <asm/cacheflush.h>
#include <linux/dma-mapping.h>
-typedef struct ump_vma_usage_tracker
-{
+typedef struct ump_vma_usage_tracker {
atomic_t references;
ump_memory_allocation *descriptor;
} ump_vma_usage_tracker;
static unsigned long ump_cpu_page_fault_handler(struct vm_area_struct * vma, unsigned long address);
#endif
-static struct vm_operations_struct ump_vm_ops =
-{
+static struct vm_operations_struct ump_vm_ops = {
.open = ump_vma_open,
.close = ump_vma_close,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
DBG_MSG(4, ("VMA close, VMA reference count decremented. VMA: 0x%08lx, reference count: %d\n", (unsigned long)vma, new_val));
- if (0 == new_val)
- {
+ if (0 == new_val) {
ump_memory_allocation * descriptor;
descriptor = vma_usage_tracker->descriptor;
if (NULL == descriptor) return _MALI_OSK_ERR_FAULT;
vma_usage_tracker = kmalloc(sizeof(ump_vma_usage_tracker), GFP_KERNEL);
- if (NULL == vma_usage_tracker)
- {
+ if (NULL == vma_usage_tracker) {
DBG_MSG(1, ("Failed to allocate memory for ump_vma_usage_tracker in _mali_osk_mem_mapregion_init\n"));
return -_MALI_OSK_ERR_FAULT;
}
vma = (struct vm_area_struct*)descriptor->process_mapping_info;
- if (NULL == vma )
- {
+ if (NULL == vma ) {
kfree(vma_usage_tracker);
return _MALI_OSK_ERR_FAULT;
}
#endif
- if (0==descriptor->is_cached)
- {
+ if (0==descriptor->is_cached) {
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
}
DBG_MSG(3, ("Mapping with page_prot: 0x%x\n", vma->vm_page_prot ));
retval = remap_pfn_range( vma, ((u32)descriptor->mapping) + offset, (*phys_addr) >> PAGE_SHIFT, size, vma->vm_page_prot) ? _MALI_OSK_ERR_FAULT : _MALI_OSK_ERR_OK;;
- DBG_MSG(4, ("Mapping virtual to physical memory. ID: %u, vma: 0x%08lx, virtual addr:0x%08lx, physical addr: 0x%08lx, size:%lu, prot:0x%x, vm_flags:0x%x RETVAL: 0x%x\n",
- ump_dd_secure_id_get(descriptor->handle),
- (unsigned long)vma,
- (unsigned long)(vma->vm_start + offset),
- (unsigned long)*phys_addr,
- size,
- (unsigned int)vma->vm_page_prot, vma->vm_flags, retval));
+ DBG_MSG(4, ("Mapping virtual to physical memory. ID: %u, vma: 0x%08lx, virtual addr:0x%08lx, physical addr: 0x%08lx, size:%lu, prot:0x%x, vm_flags:0x%x RETVAL: 0x%x\n",
+ ump_dd_secure_id_get(descriptor->handle),
+ (unsigned long)vma,
+ (unsigned long)(vma->vm_start + offset),
+ (unsigned long)*phys_addr,
+ size,
+ (unsigned int)vma->vm_page_prot, vma->vm_flags, retval));
return retval;
}
/* Flush L1 using virtual address, the entire range in one go.
* Only flush if user space process has a valid write mapping on given address. */
- if( (mem) && (virt!=NULL) && (access_ok(VERIFY_WRITE, virt, size)) )
- {
+ if( (mem) && (virt!=NULL) && (access_ok(VERIFY_WRITE, virt, size)) ) {
__cpuc_flush_dcache_area(virt, size);
DBG_MSG(3, ("UMP[%02u] Flushing CPU L1 Cache. CPU address: %x, size: %x\n", mem->secure_id, virt, size));
- }
- else
- {
- if (session_data)
- {
- if (op == _UMP_UK_MSYNC_FLUSH_L1 )
- {
+ } else {
+ if (session_data) {
+ if (op == _UMP_UK_MSYNC_FLUSH_L1 ) {
DBG_MSG(4, ("UMP Pending L1 cache flushes: %d\n", session_data->has_pending_level1_cache_flush));
session_data->has_pending_level1_cache_flush = 0;
level1_cache_flush_all();
return;
- }
- else
- {
- if (session_data->cache_operations_ongoing)
- {
+ } else {
+ if (session_data->cache_operations_ongoing) {
session_data->has_pending_level1_cache_flush++;
DBG_MSG(4, ("UMP[%02u] Defering the L1 flush. Nr pending:%d\n", mem->secure_id, session_data->has_pending_level1_cache_flush) );
- }
- else
- {
+ } else {
/* Flushing the L1 cache for each switch_user() if ump_cache_operations_control(START) is not called */
level1_cache_flush_all();
}
}
- }
- else
- {
+ } else {
DBG_MSG(4, ("Unkown state %s %d\n", __FUNCTION__, __LINE__));
level1_cache_flush_all();
}
if ( NULL == mem ) return;
- if ( mem->size_bytes==size)
- {
+ if ( mem->size_bytes==size) {
DBG_MSG(3, ("UMP[%02u] Flushing CPU L2 Cache\n",mem->secure_id));
- }
- else
- {
+ } else {
DBG_MSG(3, ("UMP[%02u] Flushing CPU L2 Cache. Blocks:%u, TotalSize:%u. FlushSize:%u Offset:0x%x FirstPaddr:0x%08x\n",
- mem->secure_id, mem->nr_blocks, mem->size_bytes, size, offset, mem->block_array[0].addr));
+ mem->secure_id, mem->nr_blocks, mem->size_bytes, size, offset, mem->block_array[0].addr));
}
/* Flush L2 using physical addresses, block for block. */
- for (i=0 ; i < mem->nr_blocks; i++)
- {
+ for (i=0 ; i < mem->nr_blocks; i++) {
u32 start_p, end_p;
ump_dd_physical_block *block;
block = &mem->block_array[i];
- if(offset >= block->size)
- {
+ if(offset >= block->size) {
offset -= block->size;
continue;
}
- if(offset)
- {
+ if(offset) {
start_p = (u32)block->addr + offset;
/* We'll zero the offset later, after using it to calculate end_p. */
- }
- else
- {
+ } else {
start_p = (u32)block->addr;
}
- if(size < block->size - offset)
- {
+ if(size < block->size - offset) {
end_p = start_p + size - 1;
size = 0;
- }
- else
- {
- if(offset)
- {
+ } else {
+ if(offset) {
end_p = start_p + (block->size - offset - 1);
size -= block->size - offset;
offset = 0;
- }
- else
- {
+ } else {
end_p = start_p + block->size - 1;
size -= block->size;
}
}
- switch(op)
- {
- case _UMP_UK_MSYNC_CLEAN:
- outer_clean_range(start_p, end_p);
- break;
- case _UMP_UK_MSYNC_CLEAN_AND_INVALIDATE:
- outer_flush_range(start_p, end_p);
- break;
- case _UMP_UK_MSYNC_INVALIDATE:
- outer_inv_range(start_p, end_p);
- break;
- default:
- break;
+ switch(op) {
+ case _UMP_UK_MSYNC_CLEAN:
+ outer_clean_range(start_p, end_p);
+ break;
+ case _UMP_UK_MSYNC_CLEAN_AND_INVALIDATE:
+ outer_flush_range(start_p, end_p);
+ break;
+ case _UMP_UK_MSYNC_INVALIDATE:
+ outer_inv_range(start_p, end_p);
+ break;
+ default:
+ break;
}
- if(0 == size)
- {
+ if(0 == size) {
/* Nothing left to flush. */
break;
}
/* is called from ump_kernel_constructor in common code */
_mali_osk_errcode_t _ump_osk_init( void )
{
- if (0 != ump_kernel_device_initialize())
- {
+ if (0 != ump_kernel_device_initialize()) {
return _MALI_OSK_ERR_FAULT;
}
_mali_osk_errcode_t err;
/* Sanity check input parameters */
- if (NULL == argument || NULL == session_data)
- {
+ if (NULL == argument || NULL == session_data) {
MSG_ERR(("NULL parameter in ump_ioctl_allocate()\n"));
return -ENOTTY;
}
/* Copy the user space memory to kernel space (so we safely can read it) */
- if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction)))
- {
+ if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction))) {
MSG_ERR(("copy_from_user() in ump_ioctl_allocate()\n"));
return -EFAULT;
}
user_interaction.ctx = (void *) session_data;
err = _ump_ukk_allocate( &user_interaction );
- if( _MALI_OSK_ERR_OK != err )
- {
+ if( _MALI_OSK_ERR_OK != err ) {
DBG_MSG(1, ("_ump_ukk_allocate() failed in ump_ioctl_allocate()\n"));
return map_errcode(err);
}
user_interaction.ctx = NULL;
- if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction)))
- {
+ if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction))) {
/* If the copy fails then we should release the memory. We can use the IOCTL release to accomplish this */
_ump_uk_release_s release_args;
release_args.secure_id = user_interaction.secure_id;
err = _ump_ukk_release( &release_args );
- if(_MALI_OSK_ERR_OK != err)
- {
+ if(_MALI_OSK_ERR_OK != err) {
MSG_ERR(("_ump_ukk_release() also failed when trying to release newly allocated memory in ump_ioctl_allocate()\n"));
}
#include "ump_kernel_common.h"
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
_mali_osk_errcode_t err;
/* Sanity check input parameters */
- if (NULL == argument || NULL == session_data)
- {
+ if (NULL == argument || NULL == session_data) {
MSG_ERR(("NULL parameter in ump_ioctl_get_api_version()\n"));
return -ENOTTY;
}
/* Copy the user space memory to kernel space (so we safely can read it) */
- if (0 != copy_from_user(&version_info, argument, sizeof(version_info)))
- {
+ if (0 != copy_from_user(&version_info, argument, sizeof(version_info))) {
MSG_ERR(("copy_from_user() in ump_ioctl_get_api_version()\n"));
return -EFAULT;
}
version_info.ctx = (void*) session_data;
err = _ump_uku_get_api_version( &version_info );
- if( _MALI_OSK_ERR_OK != err )
- {
+ 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);
}
version_info.ctx = NULL;
/* Copy ouput data back to user space */
- if (0 != copy_to_user(argument, &version_info, sizeof(version_info)))
- {
+ if (0 != copy_to_user(argument, &version_info, sizeof(version_info))) {
MSG_ERR(("copy_to_user() failed in ump_ioctl_get_api_version()\n"));
return -EFAULT;
}
_mali_osk_errcode_t err;
/* Sanity check input parameters */
- if (NULL == session_data)
- {
+ if (NULL == session_data) {
MSG_ERR(("NULL parameter in ump_ioctl_release()\n"));
return -ENOTTY;
}
/* Copy the user space memory to kernel space (so we safely can read it) */
- if (0 != copy_from_user(&release_args, argument, sizeof(release_args)))
- {
+ if (0 != copy_from_user(&release_args, argument, sizeof(release_args))) {
MSG_ERR(("copy_from_user() in ump_ioctl_get_api_version()\n"));
return -EFAULT;
}
release_args.ctx = (void*) session_data;
err = _ump_ukk_release( &release_args );
- if( _MALI_OSK_ERR_OK != err )
- {
+ if( _MALI_OSK_ERR_OK != err ) {
MSG_ERR(("_ump_ukk_release() failed in ump_ioctl_release()\n"));
return map_errcode(err);
}
_mali_osk_errcode_t err;
/* Sanity check input parameters */
- if (NULL == argument || NULL == session_data)
- {
+ if (NULL == argument || NULL == session_data) {
MSG_ERR(("NULL parameter in ump_ioctl_size_get()\n"));
return -ENOTTY;
}
- if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction)))
- {
+ if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction))) {
MSG_ERR(("copy_from_user() in ump_ioctl_size_get()\n"));
return -EFAULT;
}
user_interaction.ctx = (void *) session_data;
err = _ump_ukk_size_get( &user_interaction );
- if( _MALI_OSK_ERR_OK != err )
- {
+ if( _MALI_OSK_ERR_OK != err ) {
MSG_ERR(("_ump_ukk_size_get() failed in ump_ioctl_size_get()\n"));
return map_errcode(err);
}
user_interaction.ctx = NULL;
- if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction)))
- {
+ if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction))) {
MSG_ERR(("copy_to_user() failed in ump_ioctl_size_get()\n"));
return -EFAULT;
}
_ump_uk_msync_s user_interaction;
/* Sanity check input parameters */
- if (NULL == argument || NULL == session_data)
- {
+ if (NULL == argument || NULL == session_data) {
MSG_ERR(("NULL parameter in ump_ioctl_size_get()\n"));
return -ENOTTY;
}
- if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction)))
- {
+ if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction))) {
MSG_ERR(("copy_from_user() in ump_ioctl_msync()\n"));
return -EFAULT;
}
user_interaction.ctx = NULL;
- if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction)))
- {
+ if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction))) {
MSG_ERR(("copy_to_user() failed in ump_ioctl_msync()\n"));
return -EFAULT;
}
_ump_uk_cache_operations_control_s user_interaction;
/* Sanity check input parameters */
- if (NULL == argument || NULL == session_data)
- {
+ if (NULL == argument || NULL == session_data) {
MSG_ERR(("NULL parameter in ump_ioctl_size_get()\n"));
return -ENOTTY;
}
- if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction)))
- {
+ if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction))) {
MSG_ERR(("copy_from_user() in ump_ioctl_cache_operations_control()\n"));
return -EFAULT;
}
user_interaction.ctx = NULL;
#if 0 /* No data to copy back */
- if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction)))
- {
+ if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction))) {
MSG_ERR(("copy_to_user() failed in ump_ioctl_cache_operations_control()\n"));
return -EFAULT;
}
_ump_uk_switch_hw_usage_s user_interaction;
/* Sanity check input parameters */
- if (NULL == argument || NULL == session_data)
- {
+ if (NULL == argument || NULL == session_data) {
MSG_ERR(("NULL parameter in ump_ioctl_size_get()\n"));
return -ENOTTY;
}
- if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction)))
- {
+ if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction))) {
MSG_ERR(("copy_from_user() in ump_ioctl_switch_hw_usage()\n"));
return -EFAULT;
}
user_interaction.ctx = NULL;
#if 0 /* No data to copy back */
- if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction)))
- {
+ if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction))) {
MSG_ERR(("copy_to_user() failed in ump_ioctl_switch_hw_usage()\n"));
return -EFAULT;
}
_ump_uk_lock_s user_interaction;
/* Sanity check input parameters */
- if (NULL == argument || NULL == session_data)
- {
+ if (NULL == argument || NULL == session_data) {
MSG_ERR(("NULL parameter in ump_ioctl_size_get()\n"));
return -ENOTTY;
}
- if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction)))
- {
+ if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction))) {
MSG_ERR(("copy_from_user() in ump_ioctl_switch_hw_usage()\n"));
return -EFAULT;
}
user_interaction.ctx = NULL;
#if 0 /* No data to copy back */
- if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction)))
- {
+ if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction))) {
MSG_ERR(("copy_to_user() failed in ump_ioctl_switch_hw_usage()\n"));
return -EFAULT;
}
_ump_uk_unlock_s user_interaction;
/* Sanity check input parameters */
- if (NULL == argument || NULL == session_data)
- {
+ if (NULL == argument || NULL == session_data) {
MSG_ERR(("NULL parameter in ump_ioctl_size_get()\n"));
return -ENOTTY;
}
- if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction)))
- {
+ if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction))) {
MSG_ERR(("copy_from_user() in ump_ioctl_switch_hw_usage()\n"));
return -EFAULT;
}
user_interaction.ctx = NULL;
#if 0 /* No data to copy back */
- if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction)))
- {
+ if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction))) {
MSG_ERR(("copy_to_user() failed in ump_ioctl_switch_hw_usage()\n"));
return -EFAULT;
}
#include "ump_kernel_common.h"
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
--- /dev/null
+#
+# Copyright (C) 2012 ARM Limited. All rights reserved.
+#
+# This program is free software and is provided to you under the terms of the GNU General Public License version 2
+# as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+#
+# A copy of the licence is included with the program, and can also be obtained from Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+
+# default to building for the host
+ARCH ?= $(shell uname -m)
+
+# linux build system integration
+
+ifneq ($(KERNELRELEASE),)
+# Inside the kernel build system
+
+EXTRA_CFLAGS += -I$(KBUILD_EXTMOD)
+
+SRC = umplock_driver.c
+
+MODULE:=umplock.ko
+
+obj-m := $(MODULE:.ko=.o)
+$(MODULE:.ko=-y) := $(SRC:.c=.o)
+
+$(MODULE:.ko=-objs) := $(SRC:.c=.o)
+
+else
+# Outside the kernel build system
+#
+#
+
+# Get any user defined KDIR-<names> or maybe even a hardcoded KDIR
+-include KDIR_CONFIGURATION
+
+# Define host system directory
+KDIR-$(shell uname -m):=/lib/modules/$(shell uname -r)/build
+
+ifeq ($(ARCH), arm)
+ # when compiling for ARM we're cross compiling
+ export CROSS_COMPILE ?= arm-none-linux-gnueabi-
+ CONFIG ?= arm
+else
+ # Compiling for the host
+ CONFIG ?= $(shell uname -m)
+endif
+
+# default cpu to select
+CPU ?= $(shell uname -m)
+
+# look up KDIR based om CPU selection
+KDIR ?= $(KDIR-$(CPU))
+
+ifeq ($(KDIR),)
+$(error No KDIR found for platform $(CPU))
+endif
+
+all:
+ $(MAKE) ARCH=$(ARCH) -C $(KDIR) M=$(CURDIR)
+
+kernelrelease:
+ $(MAKE) -C $(KDIR) kernelrelease
+
+clean:
+ $(MAKE) ARCH=$(ARCH) -C $(KDIR) M=$(CURDIR) clean
+
+endif
--- /dev/null
+/*
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/slab.h>
+#include <linux/cdev.h>
+#include <linux/device.h>
+#include <asm/uaccess.h>
+#include "umplock_ioctl.h"
+#include <linux/sched.h>
+
+#define MAX_ITEMS 1024
+#define MAX_PIDS 128
+
+typedef struct lock_cmd_priv {
+ uint32_t msg[128]; /*ioctl args*/
+ u32 pid; /*process id*/
+} _lock_cmd_priv;
+
+typedef struct lock_ref {
+ int ref_count;
+ u32 pid;
+} _lock_ref;
+
+typedef struct umplock_item {
+ u32 secure_id;
+ /*u32 references;*/
+ _lock_access_usage usage;
+ _lock_ref references[MAX_PIDS];
+ struct semaphore item_lock;
+} umplock_item;
+
+typedef struct umplock_device_private {
+ struct mutex item_list_lock;
+ atomic_t sessions;
+ umplock_item items[MAX_ITEMS];
+ u32 pids[MAX_PIDS];
+} umplock_device_private;
+
+struct umplock_device {
+ struct cdev cdev;
+ struct class *umplock_class;
+};
+
+static char umplock_dev_name[] = "umplock";
+
+int umplock_major = 0;
+module_param(umplock_major, int, S_IRUGO); /* r--r--r-- */
+MODULE_PARM_DESC(umplock_major, "Device major number");
+
+static int umplock_driver_open( struct inode *inode, struct file *filp );
+static int umplock_driver_release( struct inode *inode, struct file *filp );
+static long umplock_driver_ioctl( struct file *f, unsigned int cmd, unsigned long arg );
+
+static struct file_operations umplock_fops = {
+ .owner = THIS_MODULE,
+ .open = umplock_driver_open,
+ .release = umplock_driver_release,
+ .unlocked_ioctl = umplock_driver_ioctl,
+};
+
+static struct umplock_device umplock_device;
+static umplock_device_private device;
+
+void umplock_init_locklist( void )
+{
+ memset(&device.items, 0, sizeof(umplock_item)*MAX_ITEMS);
+ atomic_set(&device.sessions, 0);
+}
+
+void umplock_deinit_locklist( void )
+{
+ memset(&device.items, 0, sizeof(umplock_item)*MAX_ITEMS);
+}
+
+int umplock_device_initialize( void )
+{
+ int err;
+ dev_t dev = 0;
+
+ if ( 0 == umplock_major ) {
+ err = alloc_chrdev_region(&dev, 0, 1, umplock_dev_name);
+ umplock_major = MAJOR(dev);
+ } else {
+ dev = MKDEV(umplock_major, 0);
+ err = register_chrdev_region(dev, 1, umplock_dev_name);
+ }
+
+ if ( 0 == err ) {
+ memset(&umplock_device, 0, sizeof(umplock_device));
+ cdev_init(&umplock_device.cdev, &umplock_fops);
+ umplock_device.cdev.owner = THIS_MODULE;
+ umplock_device.cdev.ops = &umplock_fops;
+
+ err = cdev_add(&umplock_device.cdev, dev, 1);
+ if ( 0 == err ) {
+ umplock_device.umplock_class = class_create(THIS_MODULE, umplock_dev_name);
+ if ( IS_ERR(umplock_device.umplock_class ) ) {
+ err = PTR_ERR(umplock_device.umplock_class);
+ } else {
+ struct device *mdev;
+ mdev = device_create(umplock_device.umplock_class, NULL, dev, NULL, umplock_dev_name);
+ if ( !IS_ERR(mdev) ) {
+ return 0; /* all ok */
+ }
+
+ err = PTR_ERR(mdev);
+ class_destroy(umplock_device.umplock_class);
+ }
+ cdev_del(&umplock_device.cdev);
+ }
+
+ unregister_chrdev_region(dev, 1);
+ }
+
+ return 1;
+}
+
+void umplock_device_terminate(void)
+{
+ dev_t dev = MKDEV(umplock_major, 0);
+
+ device_destroy(umplock_device.umplock_class, dev);
+ class_destroy(umplock_device.umplock_class);
+
+ cdev_del(&umplock_device.cdev);
+ unregister_chrdev_region(dev, 1);
+}
+
+int umplock_constructor(void)
+{
+ mutex_init(&device.item_list_lock);
+ if ( !umplock_device_initialize() ) return 1;
+ umplock_init_locklist();
+
+ return 0;
+}
+
+void umplock_destructor(void)
+{
+ umplock_deinit_locklist();
+ umplock_device_terminate();
+ mutex_destroy(&device.item_list_lock);
+}
+
+int umplock_find_item( u32 secure_id )
+{
+ int i;
+ for ( i=0; i<MAX_ITEMS; i++ ) {
+ if ( device.items[i].secure_id == secure_id ) return i;
+ }
+
+ return -1;
+}
+
+int umplock_find_slot( void )
+{
+ int i;
+ for ( i=0; i<MAX_ITEMS; i++ ) {
+ if ( device.items[i].secure_id == 0 ) return i;
+ }
+
+ return -1;
+}
+
+static int umplock_find_item_by_pid( _lock_cmd_priv *lock_cmd, int *item_slot, int *ref_slot)
+{
+ _lock_item_s *lock_item;
+ int i,j;
+
+ lock_item = (_lock_item_s *)&lock_cmd->msg;
+
+ i = umplock_find_item(lock_item->secure_id);
+
+ if ( i < 0)
+ return -1;
+
+ for(j=0; j<MAX_PIDS; j++) {
+ if(device.items[i].references[j].pid == lock_cmd->pid) {
+ *item_slot = i;
+ *ref_slot = j;
+ return 0;
+ }
+ }
+ return -1 ;
+}
+
+static int umplock_find_client_valid(u32 pid)
+{
+ int i;
+
+ if(pid == 0)
+ return -1;
+
+ for(i=0; i<MAX_PIDS; i++) {
+ if(device.pids[i] == pid) return i;
+ }
+
+ return -1;
+}
+
+static int do_umplock_create_locked( _lock_cmd_priv *lock_cmd)
+{
+ int i_index,ref_index;
+ int ret;
+ _lock_item_s *lock_item = (_lock_item_s *)&lock_cmd->msg;
+
+ i_index = ref_index = -1;
+
+#if 0
+ if ( lock_item->usage == 1 ) printk( KERN_DEBUG "UMPLOCK: C 0x%x GPU SURFACE\n", lock_item->secure_id );
+ else if ( lock_item->usage == 2 ) printk( KERN_DEBUG "UMPLOCK: C 0x%x GPU TEXTURE\n", lock_item->secure_id );
+ else printk( KERN_DEBUG "UMPLOCK: C 0x%x CPU\n", lock_item->secure_id );
+#endif
+
+ ret = umplock_find_client_valid( lock_cmd->pid );
+ if( ret < 0 ) {
+ /*lock request from an invalid client pid, do nothing*/
+ return 0;
+ }
+
+ ret = umplock_find_item_by_pid( lock_cmd, &i_index, &ref_index );
+ if ( ret >= 0 ) {
+ if (device.items[i_index].references[ref_index].ref_count == 0)
+ device.items[i_index].references[ref_index].ref_count = 1;
+ } else if ( (i_index = umplock_find_item( lock_item->secure_id)) >= 0 ) {
+ for ( ref_index = 0; ref_index < MAX_PIDS; ref_index++) {
+ if (device.items[i_index].references[ref_index].pid == 0) break;
+ }
+ if ( ref_index < MAX_PIDS ) {
+ device.items[i_index].references[ref_index].pid = lock_cmd->pid;
+ device.items[i_index].references[ref_index].ref_count = 1;
+ } else {
+ printk( KERN_ERR "UMPLOCK: whoops, item ran out of available reference slot\n" );
+ }
+ } else {
+ i_index = umplock_find_slot();
+
+ if ( i_index >= 0 ) {
+ device.items[i_index].secure_id = lock_item->secure_id;
+ device.items[i_index].usage = lock_item->usage;
+ device.items[i_index].references[0].pid = lock_cmd->pid;
+ device.items[i_index].references[0].ref_count = 1;
+ sema_init(&device.items[i_index].item_lock, 1);
+ } else {
+ printk( KERN_ERR "UMPLOCK: whoops, ran out of available slots\n" );
+ }
+ }
+
+ return 0;
+}
+/** IOCTLs **/
+
+static int do_umplock_create(_lock_cmd_priv *lock_cmd)
+{
+ int ret = 0;
+ mutex_lock(&device.item_list_lock);
+ ret = do_umplock_create_locked(lock_cmd);
+ mutex_unlock(&device.item_list_lock);
+ return ret;
+}
+
+static int do_umplock_process( _lock_cmd_priv *lock_cmd )
+{
+ int ret, i_index, ref_index, ref_count;
+ _lock_item_s *lock_item = (_lock_item_s *)&lock_cmd->msg;
+
+ mutex_lock(&device.item_list_lock);
+
+ do_umplock_create_locked(lock_cmd);
+
+ ret = umplock_find_client_valid( lock_cmd->pid );
+ if( ret < 0 ) {
+ /*lock request from an invalid client pid, do nothing*/
+ mutex_unlock(&device.item_list_lock);
+ return 0;
+ }
+
+ ret = umplock_find_item_by_pid( lock_cmd, &i_index, &ref_index );
+ ref_count = device.items[i_index].references[ref_index].ref_count;
+ if ( ret >= 0 ) {
+ if (ref_count == 1) {
+ /*add ref before down to wait for the umplock*/
+ device.items[i_index].references[ref_index].ref_count++;
+ mutex_unlock(&device.item_list_lock);
+ if ( down_interruptible(&device.items[i_index].item_lock) ) {
+ /*wait up without hold the umplock. restore previous state and return*/
+ mutex_lock(&device.item_list_lock);
+ device.items[i_index].references[ref_index].ref_count--;
+ mutex_unlock(&device.item_list_lock);
+ return -ERESTARTSYS;
+ }
+ mutex_lock(&device.item_list_lock);
+ } else {
+ /*already got the umplock, add ref*/
+ device.items[i_index].references[ref_index].ref_count++;
+ }
+#if 0
+ if ( lock_item->usage == 1 ) printk( KERN_DEBUG "UMPLOCK: P 0x%x GPU SURFACE\n", lock_item->secure_id );
+ else if ( lock_item->usage == 2 ) printk( KERN_DEBUG "UMPLOCK: P 0x%x GPU TEXTURE\n", lock_item->secure_id );
+ else printk( KERN_DEBUG "UMPLOCK: P 0x%x CPU\n", lock_item->secure_id );
+#endif
+ } else {
+ /*fail to find a item*/
+ printk(KERN_ERR "UMPLOCK: IOCTL_UMPLOCK_PROCESS called with invalid parameter\n");
+ mutex_unlock(&device.item_list_lock);
+ return -EINVAL;
+ }
+ mutex_unlock(&device.item_list_lock);
+ return 0;
+}
+
+static int do_umplock_release( _lock_cmd_priv *lock_cmd )
+{
+ int i_index,ref_index, ref_count;
+ int ret;
+ _lock_item_s *lock_item = (_lock_item_s *)&lock_cmd->msg;
+
+ mutex_lock(&device.item_list_lock);
+ ret = umplock_find_client_valid( lock_cmd->pid );
+ if( ret < 0 ) {
+ /*lock request from an invalid client pid, do nothing*/
+ mutex_unlock(&device.item_list_lock);
+ return 0;
+ }
+
+ i_index = ref_index = -1;
+
+ ret = umplock_find_item_by_pid( lock_cmd, &i_index, &ref_index );
+
+ if ( ret >= 0 ) {
+ device.items[i_index].references[ref_index].ref_count--;
+ ref_count = device.items[i_index].references[ref_index].ref_count;
+
+#if 0
+ if ( lock_item->usage == 1 ) printk( KERN_DEBUG "UMPLOCK: R 0x%x GPU SURFACE\n", lock_item->secure_id );
+ else if ( lock_item->usage == 2 ) printk( KERN_DEBUG "UMPLOCK: R 0x%x GPU TEXTURE\n", lock_item->secure_id );
+ else printk( KERN_DEBUG "UMPLOCK: R 0x%x CPU\n", lock_item->secure_id );
+#endif
+ /*reached the last reference to the umplock*/
+ if ( ref_count == 1 ) {
+ /*release the umplock*/
+ up( &device.items[i_index].item_lock );
+
+ device.items[i_index].references[ref_index].ref_count = 0;
+ device.items[i_index].references[ref_index].pid = 0;
+ }
+ } else {
+ /*fail to find item*/
+ printk(KERN_ERR "UMPLOCK: IOCTL_UMPLOCK_RELEASE called with invalid parameter\n");
+ mutex_unlock(&device.item_list_lock);
+ return -EINVAL;
+ }
+ mutex_unlock(&device.item_list_lock);
+ return 0;
+}
+
+static int do_umplock_zap( void )
+{
+ int i;
+
+ printk( KERN_DEBUG "UMPLOCK: ZAP ALL ENTRIES!\n" );
+
+ mutex_lock(&device.item_list_lock);
+
+ for ( i=0; i<MAX_ITEMS; i++ ) {
+ device.items[i].secure_id = 0;
+ memset(&device.items[i].references, 0, sizeof(_lock_ref)*MAX_PIDS);
+ sema_init(&device.items[i].item_lock, 1);
+ }
+ mutex_unlock(&device.item_list_lock);
+
+ for ( i=0; i<MAX_PIDS; i++) {
+ device.pids[i] = 0;
+ }
+ return 0;
+}
+
+static int do_umplock_dump( void )
+{
+ int i, j;
+
+ printk("dump all the items\n");
+
+ mutex_lock(&device.item_list_lock);
+ for (i = 0; i < MAX_ITEMS; i++) {
+ for (j = 0; j < MAX_PIDS; j++) {
+ if (device.items[i].secure_id != 0 && device.items[i].references[j].pid != 0) {
+ printk("item[%d]->secure_id=%d\t reference[%d].ref_count=%d.pid=%d\n",
+ i,
+ device.items[i].secure_id,
+ j,
+ device.items[i].references[j].ref_count,
+ device.items[i].references[j].pid);
+ }
+ }
+ }
+ mutex_unlock(&device.item_list_lock);
+
+ return 0;
+}
+
+int do_umplock_client_add (_lock_cmd_priv *lock_cmd )
+{
+ int i;
+ mutex_lock(&device.item_list_lock);
+ for ( i= 0; i<MAX_PIDS; i++) {
+ if(device.pids[i] == lock_cmd->pid) {
+ return 0;
+ }
+ }
+ for ( i=0; i<MAX_PIDS; i++) {
+ if(device.pids[i]==0) {
+ device.pids[i] = lock_cmd->pid;
+ break;
+ }
+ }
+ mutex_unlock(&device.item_list_lock);
+ if( i==MAX_PIDS) {
+ printk(KERN_ERR "Oops, Run out of cient slots\n ");
+ }
+ return 0;
+}
+
+int do_umplock_client_delete (_lock_cmd_priv *lock_cmd )
+{
+ int p_index=-1, i_index=-1,ref_index=-1;
+ int ret;
+ _lock_item_s *lock_item;
+ lock_item = (_lock_item_s *)&lock_cmd->msg;
+
+ mutex_lock(&device.item_list_lock);
+ p_index = umplock_find_client_valid( lock_cmd->pid );
+ /*lock item pid is not valid.*/
+ if ( p_index<0 ) {
+ mutex_unlock(&device.item_list_lock);
+ return 0;
+ }
+
+ /*walk through umplock item list and release reference attached to this client*/
+ for(i_index = 0; i_index< MAX_ITEMS; i_index++ ) {
+ lock_item->secure_id = device.items[i_index].secure_id;
+ /*find the item index and reference slot for the lock_item*/
+ ret = umplock_find_item_by_pid(lock_cmd, &i_index, &ref_index);
+
+ if(ret < 0) {
+ /*client has no reference on this umplock item, skip*/
+ continue;
+ }
+ while(device.items[i_index].references[ref_index].ref_count) {
+ /*release references on this client*/
+ mutex_unlock(&device.item_list_lock);
+ do_umplock_release(lock_cmd);
+ mutex_lock(&device.item_list_lock);
+ }
+ }
+
+ /*remove the pid from umplock valid pid list*/
+ device.pids[p_index] = 0;
+ mutex_unlock(&device.item_list_lock);
+
+ return 0;
+}
+
+static long umplock_driver_ioctl( struct file *f, unsigned int cmd, unsigned long arg )
+{
+ int ret;
+ uint32_t size = _IOC_SIZE(cmd);
+ _lock_cmd_priv lock_cmd ;
+
+ if (_IOC_TYPE(cmd) != LOCK_IOCTL_GROUP ) {
+ return -ENOTTY;
+ }
+
+ if (_IOC_NR(cmd) >= LOCK_IOCTL_MAX_CMDS ) {
+ return -ENOTTY;
+ }
+
+ switch ( cmd ) {
+ case LOCK_IOCTL_CREATE:
+ if (size != sizeof(_lock_item_s)) {
+ return -ENOTTY;
+ }
+
+ if (copy_from_user(&lock_cmd.msg, (void __user *)arg, size)) {
+ return -EFAULT;
+ }
+ lock_cmd.pid = (u32)current->tgid;
+ ret = do_umplock_create(&lock_cmd);
+ if (ret) {
+ return ret;
+ }
+ return 0;
+
+ case LOCK_IOCTL_PROCESS:
+ if (size != sizeof(_lock_item_s)) {
+ return -ENOTTY;
+ }
+
+ if (copy_from_user(&lock_cmd.msg, (void __user *)arg, size)) {
+ return -EFAULT;
+ }
+ lock_cmd.pid = (u32)current->tgid;
+ return do_umplock_process(&lock_cmd);
+
+ case LOCK_IOCTL_RELEASE:
+ if (size != sizeof(_lock_item_s)) {
+ return -ENOTTY;
+ }
+
+ if (copy_from_user(&lock_cmd.msg, (void __user *)arg, size)) {
+ return -EFAULT;
+ }
+ lock_cmd.pid = (u32)current->tgid;
+ ret = do_umplock_release( &lock_cmd );
+ if (ret) {
+ return ret;
+ }
+ return 0;
+
+ case LOCK_IOCTL_ZAP:
+ do_umplock_zap();
+ return 0;
+
+ case LOCK_IOCTL_DUMP:
+ do_umplock_dump();
+ return 0;
+ }
+
+ return -ENOIOCTLCMD;
+}
+
+static int umplock_driver_open( struct inode *inode, struct file *filp )
+{
+ _lock_cmd_priv lock_cmd;
+
+ atomic_inc(&device.sessions);
+ printk( KERN_DEBUG "UMPLOCK: OPEN SESSION (%i references)\n", atomic_read(&device.sessions) );
+
+ lock_cmd.pid = (u32)current->tgid;
+ do_umplock_client_add(&lock_cmd);
+
+ return 0;
+}
+
+static int umplock_driver_release( struct inode *inode, struct file *filp )
+{
+ _lock_cmd_priv lock_cmd;
+
+ lock_cmd.pid = (u32)current->tgid;
+ do_umplock_client_delete(&lock_cmd);
+
+ atomic_dec(&device.sessions);
+ printk( KERN_DEBUG "UMPLOCK: CLOSE SESSION (%i references)\n", atomic_read(&device.sessions) );
+ if ( atomic_read(&device.sessions) == 0 ) {
+ do_umplock_zap();
+ }
+
+ return 0;
+}
+
+static int __init umplock_initialize_module( void )
+{
+ printk( KERN_DEBUG "Inserting UMP lock device driver. Compiled: %s, time: %s\n", __DATE__, __TIME__ );
+
+ if ( !umplock_constructor() ) {
+ printk( KERN_ERR "UMP lock device driver init failed\n");
+ return -ENOTTY;
+ }
+
+ printk( KERN_DEBUG "UMP lock device driver loaded\n" );
+
+ return 0;
+}
+
+static void __exit umplock_cleanup_module( void )
+{
+ printk( KERN_DEBUG "unloading UMP lock module\n" );
+ umplock_destructor();
+ printk( KERN_DEBUG "UMP lock module unloaded\n" );
+}
+
+module_init(umplock_initialize_module);
+module_exit(umplock_cleanup_module);
+
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("ARM Ltd.");
+MODULE_DESCRIPTION("ARM UMP locker");
--- /dev/null
+/*
+ * Copyright (C) 2012-2013 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * 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 __UMPLOCK_IOCTL_H__
+#define __UMPLOCK_IOCTL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <linux/types.h>
+#include <linux/ioctl.h>
+
+#ifndef __user
+#define __user
+#endif
+
+
+/**
+ * @file umplock_ioctl.h
+ * This file describes the interface needed to use the Linux device driver.
+ * The interface is used by the userpace Mali DDK.
+ */
+
+typedef enum {
+ _LOCK_ACCESS_RENDERABLE = 1,
+ _LOCK_ACCESS_TEXTURE,
+ _LOCK_ACCESS_CPU_WRITE,
+ _LOCK_ACCESS_CPU_READ,
+} _lock_access_usage;
+
+typedef struct _lock_item_s {
+ unsigned int secure_id;
+ _lock_access_usage usage;
+} _lock_item_s;
+
+
+#define LOCK_IOCTL_GROUP 0x91
+
+#define _LOCK_IOCTL_CREATE_CMD 0 /* create kernel lock item */
+#define _LOCK_IOCTL_PROCESS_CMD 1 /* process kernel lock item */
+#define _LOCK_IOCTL_RELEASE_CMD 2 /* release kernel lock item */
+#define _LOCK_IOCTL_ZAP_CMD 3 /* clean up all kernel lock items */
+#define _LOCK_IOCTL_DUMP_CMD 4 /* dump all the items */
+
+#define LOCK_IOCTL_MAX_CMDS 5
+
+#define LOCK_IOCTL_CREATE _IOW( LOCK_IOCTL_GROUP, _LOCK_IOCTL_CREATE_CMD, _lock_item_s )
+#define LOCK_IOCTL_PROCESS _IOW( LOCK_IOCTL_GROUP, _LOCK_IOCTL_PROCESS_CMD, _lock_item_s )
+#define LOCK_IOCTL_RELEASE _IOW( LOCK_IOCTL_GROUP, _LOCK_IOCTL_RELEASE_CMD, _lock_item_s )
+#define LOCK_IOCTL_ZAP _IO ( LOCK_IOCTL_GROUP, _LOCK_IOCTL_ZAP_CMD )
+#define LOCK_IOCTL_DUMP _IO ( LOCK_IOCTL_GROUP, _LOCK_IOCTL_DUMP_CMD )
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UMPLOCK_IOCTL_H__ */
+