summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Medhurst (Tixy) <tixy@linaro.org>2012-03-13 11:02:24 +0100
committerPhilippe Langlais <philippe.langlais@stericsson.com>2012-05-22 11:04:33 +0200
commit5f3c36076053d6b0d2bb45f80f3dd6747e419905 (patch)
tree96cbc173930a91e4b49eb73bd72819060dd9445c
parentea32f2b6dd4d6d0a785e42a2133a661da3634498 (diff)
snowball: android: mali: Add Streamline Support for Mali DDK
ARM's Streamline Performance Analyzer now supports Mali graphics. This requires support from the Mali kernel module which this patch adds. These changes were delivered by ARM Ltd in a patch file called: r2p3-01rel0_gpl_driver_streamline_support.patch that came with a README.txt which included the following... BUILDING THE DRIVER The driver can be built as normal. Profiling instrumentation is enabled by default by the patch. To disable it, use USING_PROFILING=0 in your build command. To revert to the old-style profiling code, use USING_INTERNAL_PROFILING=1 this option will disable the Streamline profiling support. KNOWN ISSUES * Attempting to read L2 cache counters when the hardware block is powered down could potentially lead to a hang due to a lack of locking. This will be addressed in a future driver update. Signed-off-by: Jon Medhurst <tixy@linaro.org>
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/Kbuild24
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_cinstr_profiling_events_m200.h117
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_GP2.c82
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_MALI200.c76
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_profiling.h121
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_rendercore.c8
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_osk.h9
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_osk_profiling.h183
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_kernel_linux.c9
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_kernel_sysfs.c32
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_linux_trace.h125
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_osk_misc.c8
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_osk_profiling_gator.c247
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_osk_profiling_internal.c (renamed from drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_profiling.c)81
-rw-r--r--drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_osk_specific.h100
15 files changed, 1000 insertions, 222 deletions
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/Kbuild b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/Kbuild
index 09418ab3124..e90137714d2 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/Kbuild
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/Kbuild
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+# Copyright (C) 2010-2012 ARM Limited. All rights reserved.
#
# This program is free software and is provided to you under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
@@ -28,7 +28,8 @@ USING_GPU_UTILIZATION ?= 0
USING_MALI_RUN_TIME_PM ?= 1
USING_MALI_PMM_TESTSUITE ?= 0
OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB ?= 6
-USING_PROFILING ?= 0
+USING_PROFILING ?= 1
+USING_INTERNAL_PROFILING ?= 0
DISABLE_PP0 ?= 0
DISABLE_PP1 ?= 0
DISABLE_PP2 ?= 0
@@ -60,6 +61,7 @@ DEFINES += -DUSING_UMP=$(USING_UMP)
DEFINES += -DUSING_HWMEM=$(USING_HWMEM)
DEFINES += -D_MALI_OSK_SPECIFIC_INDIRECT_MMAP
DEFINES += -DMALI_TIMELINE_PROFILING_ENABLED=$(USING_PROFILING)
+DEFINES += -DMALI_INTERNAL_TIMELINE_PROFILING_ENABLED=$(USING_INTERNAL_PROFILING)
DEFINES += -DDISABLE_PP0=$(DISABLE_PP0)
DEFINES += -DDISABLE_PP1=$(DISABLE_PP1)
DEFINES += -DDISABLE_PP2=$(DISABLE_PP2)
@@ -142,14 +144,25 @@ SRC = \
$(UKKFILES) \
__malidrv_build_info.c
+# Selecting files to compile by parsing the config file
+
+# Use Gator profiling by default
ifeq ($(USING_PROFILING),1)
-SRC += \
- common/mali_kernel_profiling.c \
+PROFILING_BACKEND_SOURCES = \
+ linux/mali_osk_profiling_gator.c
+endif
+
+# If internal profiling is selected, overwrite the PROFILING_BACKEND_SOURCES
+# to use it instead.
+ifeq ($(USING_INTERNAL_PROFILING),1)
+PROFILING_BACKEND_SOURCES = \
+ linux/mali_osk_profiling_internal.c \
timestamp-$(TIMESTAMP)/mali_timestamp.c
ccflags-y += -I$(DRIVER_DIR)/timestamp-$(TIMESTAMP)
endif
-# Selecting files to compile by parsing the config file
+# Add the profiling sources
+SRC += $(PROFILING_BACKEND_SOURCES)
ifeq ($(USING_PMM),1)
ifeq ($(USING_MALI_PMU),1)
@@ -250,6 +263,7 @@ VERSION_STRINGS += KDIR=$(KDIR)
VERSION_STRINGS += MALI_PLATFORM_FILE=$(MALI_PLATFORM_FILE)
VERSION_STRINGS += OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB=$(OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB)
VERSION_STRINGS += USING_PROFILING=$(USING_PROFILING)
+VERSION_STRINGS += USING_INTERNAL_PROFILING=$(USING_INTERNAL_PROFILING)
VERSION_STRINGS += USING_GPU_UTILIZATION=$(USING_GPU_UTILIZATION)
VERSION_STRINGS += USING_MALI_RUN_TIME_PM=$(USING_MALI_RUN_TIME_PM)
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_cinstr_profiling_events_m200.h b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_cinstr_profiling_events_m200.h
new file mode 100644
index 00000000000..dee50a359a1
--- /dev/null
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_cinstr_profiling_events_m200.h
@@ -0,0 +1,117 @@
+/**
+ * Copyright (C) 2010-2012 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation, and any use by you of this program is subject to the terms of
+ * such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained
+ * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _CINSTR_PROFILING_EVENTS_M200_H_
+#define _CINSTR_PROFILING_EVENTS_M200_H_
+
+/*
+ * The event ID is a 32 bit value consisting of different fields
+ * reserved, 4 bits, for future use
+ * event type, 4 bits, cinstr_profiling_event_type_t
+ * event channel, 8 bits, the source of the event.
+ * event data, 16 bit field, data depending on event type
+ */
+
+/**
+ * Specifies what kind of event this is
+ */
+typedef enum
+{
+ MALI_PROFILING_EVENT_TYPE_SINGLE = 0 << 24,
+ MALI_PROFILING_EVENT_TYPE_START = 1 << 24,
+ MALI_PROFILING_EVENT_TYPE_STOP = 2 << 24,
+ MALI_PROFILING_EVENT_TYPE_SUSPEND = 3 << 24,
+ MALI_PROFILING_EVENT_TYPE_RESUME = 4 << 24,
+} cinstr_profiling_event_type_t;
+
+
+/**
+ * Secifies the channel/source of the event
+ */
+typedef enum
+{
+ MALI_PROFILING_EVENT_CHANNEL_SOFTWARE = 0 << 16,
+ MALI_PROFILING_EVENT_CHANNEL_GP0 = 1 << 16,
+ MALI_PROFILING_EVENT_CHANNEL_PP0 = 5 << 16,
+ MALI_PROFILING_EVENT_CHANNEL_PP1 = 6 << 16,
+ MALI_PROFILING_EVENT_CHANNEL_PP2 = 7 << 16,
+ MALI_PROFILING_EVENT_CHANNEL_PP3 = 8 << 16,
+ MALI_PROFILING_EVENT_CHANNEL_PP4 = 9 << 16,
+ MALI_PROFILING_EVENT_CHANNEL_PP5 = 10 << 16,
+ MALI_PROFILING_EVENT_CHANNEL_PP6 = 11 << 16,
+ MALI_PROFILING_EVENT_CHANNEL_PP7 = 12 << 16,
+ MALI_PROFILING_EVENT_CHANNEL_GPU = 21 << 16,
+} cinstr_profiling_event_channel_t;
+
+
+#define MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(num) (((MALI_PROFILING_EVENT_CHANNEL_GP0 >> 16) + (num)) << 16)
+#define MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(num) (((MALI_PROFILING_EVENT_CHANNEL_PP0 >> 16) + (num)) << 16)
+
+/**
+ * These events are applicable when the type MALI_PROFILING_EVENT_TYPE_SINGLE is used from software channel
+ */
+typedef enum
+{
+ MALI_PROFILING_EVENT_REASON_SINGLE_SW_NONE = 0,
+ MALI_PROFILING_EVENT_REASON_SINGLE_SW_EGL_NEW_FRAME = 1,
+ MALI_PROFILING_EVENT_REASON_SINGLE_SW_FLUSH = 2,
+ MALI_PROFILING_EVENT_REASON_SINGLE_SW_EGL_SWAP_BUFFERS = 3,
+ MALI_PROFILING_EVENT_REASON_SINGLE_SW_FB_EVENT = 4
+} cinstr_profiling_event_reason_single_sw_t;
+
+/**
+ * These events are applicable when the type MALI_PROFILING_EVENT_TYPE_START/STOP is used from software channel
+ */
+typedef enum
+{
+ MALI_PROFILING_EVENT_REASON_START_STOP_SW_NONE = 0,
+ MALI_PROFILING_EVENT_REASON_START_STOP_MALI = 1,
+} cinstr_profiling_event_reason_start_stop_sw_t;
+
+/**
+ * These events are applicable when the type MALI_PROFILING_EVENT_TYPE_SUSPEND/RESUME is used from software channel
+ */
+typedef enum
+{
+ MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_NONE = 0,
+ MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_PIPELINE_FULL = 1,
+ MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_VSYNC = 26,
+ MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_FB_IFRAME_WAIT= 27,
+ MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_FB_IFRAME_SYNC= 28,
+ MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_VG_WAIT_FILTER_CLEANUP = 29,
+ MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_VG_WAIT_TEXTURE = 30,
+ MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_GLES_WAIT_MIPLEVEL = 31,
+ MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_GLES_WAIT_READPIXELS = 32,
+ MALI_PROFILING_EVENT_REASON_SUSPEND_RESUME_SW_EGL_WAIT_SWAP_IMMEDIATE= 33,
+} cinstr_profiling_event_reason_suspend_resume_sw_t;
+
+/**
+ * These events are applicable when the type MALI_PROFILING_EVENT_TYPE_SINGLE is used from a HW channel (GPx+PPx)
+ */
+typedef enum
+{
+ MALI_PROFILING_EVENT_REASON_SINGLE_HW_NONE = 0,
+ MALI_PROFILING_EVENT_REASON_SINGLE_HW_INTERRUPT = 1,
+ MALI_PROFILING_EVENT_REASON_SINGLE_HW_FLUSH = 2,
+} cinstr_profiling_event_reason_single_hw_t;
+
+/**
+ * These events are applicable when the type MALI_PROFILING_EVENT_TYPE_SINGLE is used from the GPU channel
+ */
+typedef enum
+{
+ MALI_PROFILING_EVENT_REASON_SINGLE_GPU_NONE = 0,
+ MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE = 1,
+} cinstr_profiling_event_reason_single_gpu_t;
+
+#endif /*_CINSTR_PROFILING_EVENTS_M200_H_*/
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_GP2.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_GP2.c
index 70f07343e66..dd357dec3b9 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_GP2.c
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_GP2.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2012 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
@@ -15,8 +15,8 @@
#include "mali_kernel_rendercore.h"
#include "mali_osk.h"
#include "mali_osk_list.h"
-#if MALI_TIMELINE_PROFILING_ENABLED
-#include "mali_kernel_profiling.h"
+#if MALI_TIMELINE_PROFILING_ENABLED
+#include "mali_osk_profiling.h"
#endif
#if defined(USING_MALI400_L2_CACHE)
#include "mali_kernel_l2_cache.h"
@@ -80,7 +80,7 @@ typedef struct maligp_job
u32 perf_counter_l2_val1;
#endif
-#if MALI_TIMELINE_PROFILING_ENABLED
+#if MALI_TIMELINE_PROFILING_ENABLED
u32 pid;
u32 tid;
#endif
@@ -628,6 +628,32 @@ static _mali_osk_errcode_t subsystem_maligp_start_job(mali_core_job * job, mali_
&(jobgp->user_input.frame_registers[0]),
sizeof(jobgp->user_input.frame_registers)/sizeof(jobgp->user_input.frame_registers[0]));
+#if MALI_TIMELINE_PROFILING_ENABLED
+ /*
+ * If the hardware counters are not turned on, ask the external profiler
+ * if they should be.
+ */
+ if (jobgp->user_input.perf_counter_flag == 0)
+ {
+ mali_bool src0_enabled = _mali_osk_profiling_query_hw_counter(COUNTER_VP_C0,
+ &(jobgp->user_input.perf_counter_src0));
+ mali_bool src1_enabled = _mali_osk_profiling_query_hw_counter(COUNTER_VP_C1,
+ &(jobgp->user_input.perf_counter_src1));
+
+ if (src0_enabled == MALI_TRUE)
+ {
+ jobgp->user_input.perf_counter_flag |=
+ _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE;
+ }
+
+ if (src1_enabled == MALI_TRUE)
+ {
+ jobgp->user_input.perf_counter_flag |=
+ _MALI_PERFORMANCE_COUNTER_FLAG_SRC1_ENABLE;
+ }
+ }
+#endif /* MALI_TIMELINE_PROFILING_ENABLED */
+
/* This selects which performance counters we are reading */
if ( 0 != jobgp->user_input.perf_counter_flag )
{
@@ -715,10 +741,10 @@ static _mali_osk_errcode_t subsystem_maligp_start_job(mali_core_job * job, mali_
startcmd);
_mali_osk_write_mem_barrier();
-#if MALI_TIMELINE_PROFILING_ENABLED
- _mali_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE | MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(core->core_number) | MALI_PROFILING_EVENT_REASON_SINGLE_HW_FLUSH,
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE | MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(core->core_number) | MALI_PROFILING_EVENT_REASON_SINGLE_HW_FLUSH,
jobgp->user_input.frame_builder_id, jobgp->user_input.flush_id, 0, 0, 0);
- _mali_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(core->core_number), jobgp->pid, jobgp->tid, 0, 0, 0);
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(core->core_number), jobgp->pid, jobgp->tid, 0, 0, 0);
#endif
MALI_SUCCESS;
@@ -742,8 +768,8 @@ static u32 subsystem_maligp_irq_handler_upper_half(mali_core_renderunit * core)
/* Mask out all IRQs from this core until IRQ is handled */
mali_core_renderunit_register_write(core, MALIGP2_REG_ADDR_MGMT_INT_MASK, MALIGP2_REG_VAL_IRQ_MASK_NONE);
-#if MALI_TIMELINE_PROFILING_ENABLED
- _mali_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(core->core_number)|MALI_PROFILING_EVENT_REASON_SINGLE_HW_INTERRUPT, irq_readout, 0, 0, 0, 0);
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(core->core_number)|MALI_PROFILING_EVENT_REASON_SINGLE_HW_INTERRUPT, irq_readout, 0, 0, 0, 0);
#endif
/* We do need to handle this in a bottom half, return 1 */
@@ -808,6 +834,12 @@ static int subsystem_maligp_irq_handler_bottom_half(mali_core_renderunit* core)
{
jobgp->perf_counter0 = mali_core_renderunit_register_read(core, MALIGP2_REG_ADDR_MGMT_PERF_CNT_0_VALUE);
jobgp->perf_counter1 = mali_core_renderunit_register_read(core, MALIGP2_REG_ADDR_MGMT_PERF_CNT_1_VALUE);
+
+#if MALI_TIMELINE_PROFILING_ENABLED
+ /* Report the hardware counter values to the external profiler */
+ _mali_osk_profiling_report_hw_counter(COUNTER_VP_C0, jobgp->perf_counter0);
+ _mali_osk_profiling_report_hw_counter(COUNTER_VP_C1, jobgp->perf_counter1);
+#endif /* MALI_TIMELINE_PROFILING_ENABLED */
}
#if defined(USING_MALI400_L2_CACHE)
@@ -839,8 +871,8 @@ static int subsystem_maligp_irq_handler_bottom_half(mali_core_renderunit* core)
}
#endif
-#if MALI_TIMELINE_PROFILING_ENABLED
- _mali_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(core->core_number), 0, 0, 0, 0, 0); /* add GP and L2 counters and return status? */
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(core->core_number), 0, 0, 0, 0, 0); /* add GP and L2 counters and return status? */
#endif
MALI_DEBUG_PRINT(2, ("Mali GP: Job aborted - userspace would not provide more heap memory.\n"));
@@ -869,6 +901,12 @@ static int subsystem_maligp_irq_handler_bottom_half(mali_core_renderunit* core)
{
jobgp->perf_counter0 = mali_core_renderunit_register_read(core, MALIGP2_REG_ADDR_MGMT_PERF_CNT_0_VALUE);
jobgp->perf_counter1 = mali_core_renderunit_register_read(core, MALIGP2_REG_ADDR_MGMT_PERF_CNT_1_VALUE);
+
+#if MALI_TIMELINE_PROFILING_ENABLED
+ /* Report the hardware counter values to the external profiler */
+ _mali_osk_profiling_report_hw_counter(COUNTER_VP_C0, jobgp->perf_counter0);
+ _mali_osk_profiling_report_hw_counter(COUNTER_VP_C1, jobgp->perf_counter1);
+#endif /* MALI_TIMELINE_PROFILING_ENABLED */
}
#if defined(USING_MALI400_L2_CACHE)
@@ -901,8 +939,8 @@ static int subsystem_maligp_irq_handler_bottom_half(mali_core_renderunit* core)
#endif
}
-#if MALI_TIMELINE_PROFILING_ENABLED
- _mali_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(core->core_number),
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(core->core_number),
jobgp->perf_counter0, jobgp->perf_counter1,
jobgp->user_input.perf_counter_src0 | (jobgp->user_input.perf_counter_src1 << 8)
#if defined(USING_MALI400_L2_CACHE)
@@ -937,8 +975,8 @@ static int subsystem_maligp_irq_handler_bottom_half(mali_core_renderunit* core)
{
/* no progress detected, killed by the watchdog */
-#if MALI_TIMELINE_PROFILING_ENABLED
- _mali_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(core->core_number), 0, 0, 0, 0, 0); /* add GP and L2 counters and return status? */
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(core->core_number), 0, 0, 0, 0, 0); /* add GP and L2 counters and return status? */
#endif
MALI_DEBUG_PRINT(1, ("Mali GP: SW-Timeout. Regs:\n"));
@@ -964,8 +1002,8 @@ static int subsystem_maligp_irq_handler_bottom_half(mali_core_renderunit* core)
_mali_osk_notification_t *notific;
_mali_uk_gp_job_suspended_s * suspended_job;
-#if MALI_TIMELINE_PROFILING_ENABLED
- _mali_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SUSPEND|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(core->core_number), 0, 0, 0, 0, 0); /* add GP and L2 counters and return status? */
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SUSPEND|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(core->core_number), 0, 0, 0, 0, 0); /* add GP and L2 counters and return status? */
#endif
session = job->session;
@@ -1045,8 +1083,8 @@ static int subsystem_maligp_irq_handler_bottom_half(mali_core_renderunit* core)
/* Else there must be some error */
else
{
-#if MALI_TIMELINE_PROFILING_ENABLED
- _mali_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(core->core_number), 0, 0, 0, 0, 0); /* add GP and L2 counters and return status? */
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(core->core_number), 0, 0, 0, 0, 0); /* add GP and L2 counters and return status? */
#endif
MALI_DEBUG_PRINT(1, ("Mali GP: Core crashed? *IRQ: 0x%x Status: 0x%x\n", irq_readout, core_status ));
@@ -1106,7 +1144,7 @@ static _mali_osk_errcode_t subsystem_maligp_get_new_job_from_user(struct mali_co
jobgp->is_stalled_waiting_for_more_memory = 0;
-#if MALI_TIMELINE_PROFILING_ENABLED
+#if MALI_TIMELINE_PROFILING_ENABLED
jobgp->pid = _mali_osk_get_pid();
jobgp->tid = _mali_osk_get_tid();
#endif
@@ -1247,8 +1285,8 @@ static _mali_osk_errcode_t subsystem_maligp_suspend_response(struct mali_core_se
mali_core_renderunit_register_write(core, MALIGP2_REG_ADDR_MGMT_CMD, MALIGP2_REG_VAL_CMD_UPDATE_PLBU_ALLOC);
_mali_osk_write_mem_barrier();
-#if MALI_TIMELINE_PROFILING_ENABLED
- _mali_profiling_add_event(MALI_PROFILING_EVENT_TYPE_RESUME|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(core->core_number), 0, 0, 0, 0, 0);
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_RESUME|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(core->core_number), 0, 0, 0, 0, 0);
#endif
MALI_DEBUG_PRINT(4, ("GP resumed with new heap\n"));
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_MALI200.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_MALI200.c
index 292c8f31f3d..d861b2288d3 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_MALI200.c
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_MALI200.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2012 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
@@ -15,8 +15,8 @@
#include "mali_kernel_core.h"
#include "regs/mali_200_regs.h"
#include "mali_kernel_rendercore.h"
-#if MALI_TIMELINE_PROFILING_ENABLED
-#include "mali_kernel_profiling.h"
+#if MALI_TIMELINE_PROFILING_ENABLED
+#include "mali_osk_profiling.h"
#endif
#ifdef USING_MALI400_L2_CACHE
#include "mali_kernel_l2_cache.h"
@@ -71,8 +71,8 @@ typedef struct mali200_job
u32 perf_counter_l2_val1_raw;
#endif
-#if MALI_TIMELINE_PROFILING_ENABLED
- u32 pid;
+#if MALI_TIMELINE_PROFILING_ENABLED
+ u32 pid;
u32 tid;
#endif
} mali200_job;
@@ -572,6 +572,38 @@ static _mali_osk_errcode_t subsystem_mali200_start_job(mali_core_job * job, mali
&(job200->user_input.wb2_registers[0]),
MALI200_NUM_REGS_WBx);
+#if MALI_TIMELINE_PROFILING_ENABLED
+ /*
+ * If the hardware counters are not turned on, ask the external profiler
+ * if they should be.
+ */
+ if (job200->user_input.perf_counter_flag == 0)
+ {
+ /*
+ * Work out the correct counter offset to use. Each fragment processor
+ * has two hardware counters.
+ */
+ u32 counter0_offset = MALI_PROFILING_PP_CORE_COUNTER0_OFFSET(core->core_number);
+ u32 counter1_offset = MALI_PROFILING_PP_CORE_COUNTER1_OFFSET(core->core_number);
+
+ mali_bool src0_enabled = _mali_osk_profiling_query_hw_counter(counter0_offset,
+ &(job200->user_input.perf_counter_src0));
+ mali_bool src1_enabled = _mali_osk_profiling_query_hw_counter(counter1_offset,
+ &(job200->user_input.perf_counter_src1));
+
+ if (src0_enabled == MALI_TRUE)
+ {
+ job200->user_input.perf_counter_flag |=
+ _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE;
+ }
+
+ if (src1_enabled == MALI_TRUE)
+ {
+ job200->user_input.perf_counter_flag |=
+ _MALI_PERFORMANCE_COUNTER_FLAG_SRC1_ENABLE;
+ }
+ }
+#endif /* MALI_TIMELINE_PROFILING_ENABLED */
/* This selects which performance counters we are reading */
if ( 0 != job200->user_input.perf_counter_flag )
@@ -643,8 +675,8 @@ static _mali_osk_errcode_t subsystem_mali200_start_job(mali_core_job * job, mali
_mali_osk_write_mem_barrier();
#if MALI_TIMELINE_PROFILING_ENABLED
- _mali_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE | MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_number) | MALI_PROFILING_EVENT_REASON_SINGLE_HW_FLUSH, job200->user_input.frame_builder_id, job200->user_input.flush_id, 0, 0, 0);
- _mali_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START|MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_number), job200->pid, job200->tid, 0, 0, 0);
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE | MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_number) | MALI_PROFILING_EVENT_REASON_SINGLE_HW_FLUSH, job200->user_input.frame_builder_id, job200->user_input.flush_id, 0, 0, 0);
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START|MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_number), job200->pid, job200->tid, 0, 0, 0);
#endif
MALI_SUCCESS;
@@ -665,8 +697,8 @@ static u32 subsystem_mali200_irq_handler_upper_half(mali_core_renderunit * core)
/* Mask out all IRQs from this core until IRQ is handled */
mali_core_renderunit_register_write(core, MALI200_REG_ADDR_MGMT_INT_MASK, MALI200_REG_VAL_IRQ_MASK_NONE);
-#if MALI_TIMELINE_PROFILING_ENABLED
- _mali_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE|MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_number)|MALI_PROFILING_EVENT_REASON_SINGLE_HW_INTERRUPT, irq_readout, 0, 0, 0, 0);
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE|MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_number)|MALI_PROFILING_EVENT_REASON_SINGLE_HW_INTERRUPT, irq_readout, 0, 0, 0, 0);
#endif
return 1;
@@ -723,8 +755,20 @@ static int subsystem_mali200_irq_handler_bottom_half(struct mali_core_renderunit
{
if (job200->user_input.perf_counter_flag & (_MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE|_MALI_PERFORMANCE_COUNTER_FLAG_SRC1_ENABLE) )
{
+#if MALI_TIMELINE_PROFILING_ENABLED
+ /* Work out the counter offsets for the core number */
+ u32 counter0_offset = MALI_PROFILING_PP_CORE_COUNTER0_OFFSET(core->core_number);
+ u32 counter1_offset = MALI_PROFILING_PP_CORE_COUNTER1_OFFSET(core->core_number);
+#endif /* MALI_TIMELINE_PROFILING_ENABLED */
+
job200->perf_counter0 = mali_core_renderunit_register_read(core, MALI200_REG_ADDR_MGMT_PERF_CNT_0_VALUE);
job200->perf_counter1 = mali_core_renderunit_register_read(core, MALI200_REG_ADDR_MGMT_PERF_CNT_1_VALUE);
+
+#if MALI_TIMELINE_PROFILING_ENABLED
+ /* Report the counter values */
+ _mali_osk_profiling_report_hw_counter(counter0_offset, job200->perf_counter0);
+ _mali_osk_profiling_report_hw_counter(counter1_offset, job200->perf_counter1);
+#endif /* MALI_TIMELINE_PROFILING_ENABLED */
}
#if defined(USING_MALI400_L2_CACHE)
@@ -762,8 +806,8 @@ static int subsystem_mali200_irq_handler_bottom_half(struct mali_core_renderunit
}
-#if MALI_TIMELINE_PROFILING_ENABLED
- _mali_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_number),
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_number),
job200->perf_counter0, job200->perf_counter1,
job200->user_input.perf_counter_src0 | (job200->user_input.perf_counter_src1 << 8)
#if defined(USING_MALI400_L2_CACHE)
@@ -787,8 +831,8 @@ static int subsystem_mali200_irq_handler_bottom_half(struct mali_core_renderunit
((CORE_HANG_CHECK_TIMEOUT == core->state) && (current_tile_addr == job200->last_tile_list_addr))
)
{
-#if MALI_TIMELINE_PROFILING_ENABLED
- _mali_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_number), 0, 0, 0, 0, 0); /* add GP and L2 counters and return status */
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_number), 0, 0, 0, 0, 0); /* add GP and L2 counters and return status */
#endif
/* no progress detected, killed by the watchdog */
MALI_DEBUG_PRINT(2, ("M200: SW-Timeout Rawstat: 0x%x Tile_addr: 0x%x Status: 0x%x.\n", irq_readout ,current_tile_addr ,core_status) );
@@ -823,8 +867,8 @@ static int subsystem_mali200_irq_handler_bottom_half(struct mali_core_renderunit
}
else
{
-#if MALI_TIMELINE_PROFILING_ENABLED
- _mali_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_number), 0, 0, 0, 0, 0); /* add GP and L2 counters and return status */
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_number), 0, 0, 0, 0, 0); /* add GP and L2 counters and return status */
#endif
MALI_DEBUG_PRINT(1, ("Mali PP: Job: 0x%08x CRASH? Rawstat: 0x%x Tile_addr: 0x%x Status: 0x%x\n",
@@ -902,7 +946,7 @@ static _mali_osk_errcode_t subsystem_mali200_get_new_job_from_user(struct mali_c
job_priority_set(job, job200->user_input.priority);
job_watchdog_set(job, job200->user_input.watchdog_msecs );
-#if MALI_TIMELINE_PROFILING_ENABLED
+#if MALI_TIMELINE_PROFILING_ENABLED
job200->pid = _mali_osk_get_pid();
job200->tid = _mali_osk_get_tid();
#endif
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_profiling.h b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_profiling.h
deleted file mode 100644
index fe650e81e41..00000000000
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_profiling.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
- *
- * This program is free software and is provided to you under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
- *
- * A copy of the licence is included with the program, and can also be obtained from Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef __MALI_KERNEL_PROFILING_H__
-#define __MALI_KERNEL_PROFILING_H__
-
-#if MALI_TIMELINE_PROFILING_ENABLED
-
-#include <../../../include/cinstr/mali_cinstr_profiling_events_m200.h>
-
-#define MALI_PROFILING_MAX_BUFFER_ENTRIES 1048576
-
-/**
- * Initialize the profiling module.
- * @return _MALI_OSK_ERR_OK on success, otherwise failure.
- */
-_mali_osk_errcode_t _mali_profiling_init(mali_bool auto_start);
-
-/*
- * Terminate the profiling module.
- */
-void _mali_profiling_term(void);
-
-/**
- * Start recording profiling data
- *
- * The specified limit will determine how large the capture buffer is.
- * MALI_PROFILING_MAX_BUFFER_ENTRIES determines the maximum size allowed by the device driver.
- *
- * @param limit The desired maximum number of events to record on input, the actual maximum on output.
- * @return _MALI_OSK_ERR_OK on success, otherwise failure.
- */
-_mali_osk_errcode_t _mali_profiling_start(u32 * limit);
-
-/**
- * Add an profiling event
- *
- * @param event_id The event identificator.
- * @param data0 First data parameter, depending on event_id specified.
- * @param data1 Second data parameter, depending on event_id specified.
- * @param data2 Third data parameter, depending on event_id specified.
- * @param data3 Fourth data parameter, depending on event_id specified.
- * @param data4 Fifth data parameter, depending on event_id specified.
- * @return _MALI_OSK_ERR_OK on success, otherwise failure.
- */
-_mali_osk_errcode_t _mali_profiling_add_event(u32 event_id, u32 data0, u32 data1, u32 data2, u32 data3, u32 data4);
-
-/**
- * Stop recording profiling data
- *
- * @param count Returns the number of recorded events.
- * @return _MALI_OSK_ERR_OK on success, otherwise failure.
- */
-_mali_osk_errcode_t _mali_profiling_stop(u32 * count);
-
-/**
- * Retrieves the number of events that can be retrieved
- *
- * @return The number of recorded events that can be retrieved.
- */
-u32 _mali_profiling_get_count(void);
-
-/**
- * Retrieve an event
- *
- * @param index Event index (start with 0 and continue until this function fails to retrieve all events)
- * @param timestamp The timestamp for the retrieved event will be stored here.
- * @param event_id The event ID for the retrieved event will be stored here.
- * @param data The 5 data values for the retrieved event will be stored here.
- * @return _MALI_OSK_ERR_OK on success, otherwise failure.
- */_mali_osk_errcode_t _mali_profiling_get_event(u32 index, u64* timestamp, u32* event_id, u32 data[5]);
-
-/**
- * Clear the recorded buffer.
- *
- * This is needed in order to start another recording.
- *
- * @return _MALI_OSK_ERR_OK on success, otherwise failure.
- */
-_mali_osk_errcode_t _mali_profiling_clear(void);
-
-/**
- * Checks if a recording of profiling data is in progress
- *
- * @return MALI_TRUE if recording of profiling data is in progress, MALI_FALSE if not
- */
-mali_bool _mali_profiling_is_recording(void);
-
-/**
- * Checks if profiling data is available for retrival
- *
- * @return MALI_TRUE if profiling data is avaiable, MALI_FALSE if not
- */
-mali_bool _mali_profiling_have_recording(void);
-
-/**
- * Enable or disable profiling events as default for new sessions (applications)
- *
- * @param enable MALI_TRUE if profiling events should be turned on, otherwise MALI_FALSE
- */
-void _mali_profiling_set_default_enable_state(mali_bool enable);
-
-/**
- * Get current default enable state for new sessions (applications)
- *
- * @return MALI_TRUE if profiling events should be turned on, otherwise MALI_FALSE
- */
-mali_bool _mali_profiling_get_default_enable_state(void);
-
-#endif /* MALI_TIMELINE_PROFILING_ENABLED */
-
-#endif /* __MALI_KERNEL_PROFILING_H__ */
-
-
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_rendercore.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_rendercore.c
index b123b4bc61b..f06b17bcb31 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_rendercore.c
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_rendercore.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2012 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
@@ -18,7 +18,7 @@
#include "mali_kernel_utilization.h"
#endif
#if MALI_TIMELINE_PROFILING_ENABLED
-#include "mali_kernel_profiling.h"
+#include "mali_osk_profiling.h"
#endif
#if USING_MMU
#include "mali_kernel_mem_mmu.h"
@@ -160,7 +160,7 @@ static _mali_osk_errcode_t rendercore_subsystem_startup(mali_kernel_subsystem_id
#endif
#if MALI_TIMELINE_PROFILING_ENABLED
- if (_mali_profiling_init(mali_boot_profiling ? MALI_TRUE : MALI_FALSE) != _MALI_OSK_ERR_OK)
+ if (_mali_osk_profiling_init(mali_boot_profiling ? MALI_TRUE : MALI_FALSE) != _MALI_OSK_ERR_OK)
{
/* No biggie if we wheren't able to initialize the profiling */
MALI_PRINT_ERROR(("Rendercore: Failed to initialize profiling, feature will be unavailable\n")) ;
@@ -190,7 +190,7 @@ static void rendercore_subsystem_terminate(mali_kernel_subsystem_identifier id)
MALI_DEBUG_ASSERT_POINTER( rendercores_global_mutex );
#if MALI_TIMELINE_PROFILING_ENABLED
- _mali_profiling_term();
+ _mali_osk_profiling_term();
#endif
#if MALI_GPU_UTILIZATION
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_osk.h b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_osk.h
index d1fb0a9a168..35737e68cb3 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_osk.h
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_osk.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2012 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
@@ -1684,8 +1684,13 @@ u32 _mali_osk_get_pid(void);
*/
u32 _mali_osk_get_tid(void);
-/** @} */ /* end group _mali_osk_miscellaneous */
+/** @brief Return a handle to the current task.
+ *
+ * @return An OS-specific handle to the current task.
+ */
+void * _mali_osk_get_task(void);
+/** @} */ /* end group _mali_osk_miscellaneous */
/** @} */ /* end group osuapi */
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_osk_profiling.h b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_osk_profiling.h
new file mode 100644
index 00000000000..a291bd1965b
--- /dev/null
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_osk_profiling.h
@@ -0,0 +1,183 @@
+/**
+ * Copyright (C) 2010-2012 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation, and any use by you of this program is subject to the terms of
+ * such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained
+ * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __MALI_OSK_PROFILING_H__
+#define __MALI_OSK_PROFILING_H__
+
+#if MALI_TIMELINE_PROFILING_ENABLED
+
+#if defined (CONFIG_TRACEPOINTS) && !MALI_INTERNAL_TIMELINE_PROFILING_ENABLED
+#include "mali_linux_trace.h"
+#endif /* CONFIG_TRACEPOINTS && !MALI_INTERNAL_TIMELINE_PROFILING_ENABLED */
+
+#include "mali_cinstr_profiling_events_m200.h"
+
+#define MALI_PROFILING_MAX_BUFFER_ENTRIES 1048576
+
+#define MALI_PROFILING_PP_CORE_COUNTER0_OFFSET(core_number) (((core_number) * 2) + COUNTER_FP0_C0)
+#define MALI_PROFILING_PP_CORE_COUNTER1_OFFSET(core_number) (((core_number) * 2) + COUNTER_FP0_C1)
+
+/** @defgroup _mali_osk_profiling External profiling connectivity
+ * @{ */
+
+/**
+ * Initialize the profiling module.
+ * @return _MALI_OSK_ERR_OK on success, otherwise failure.
+ */
+_mali_osk_errcode_t _mali_osk_profiling_init(mali_bool auto_start);
+
+/*
+ * Terminate the profiling module.
+ */
+void _mali_osk_profiling_term(void);
+
+/**
+ * Start recording profiling data
+ *
+ * The specified limit will determine how large the capture buffer is.
+ * MALI_PROFILING_MAX_BUFFER_ENTRIES determines the maximum size allowed by the device driver.
+ *
+ * @param limit The desired maximum number of events to record on input, the actual maximum on output.
+ * @return _MALI_OSK_ERR_OK on success, otherwise failure.
+ */
+_mali_osk_errcode_t _mali_osk_profiling_start(u32 * limit);
+
+/**
+ * Add an profiling event
+ *
+ * @param event_id The event identificator.
+ * @param data0 First data parameter, depending on event_id specified.
+ * @param data1 Second data parameter, depending on event_id specified.
+ * @param data2 Third data parameter, depending on event_id specified.
+ * @param data3 Fourth data parameter, depending on event_id specified.
+ * @param data4 Fifth data parameter, depending on event_id specified.
+ * @return _MALI_OSK_ERR_OK on success, otherwise failure.
+ */
+#if defined (CONFIG_TRACEPOINTS) && !MALI_INTERNAL_TIMELINE_PROFILING_ENABLED
+/*
+ * On platforms where we are using Linux tracepoints and we aren't forcing
+ * internal profiling we can call through to the tracepoint directly and
+ * avoid the overhead of the function call.
+ */
+#define _mali_osk_profiling_add_event(event_id, data0, data1, data2, data3, data4) \
+ trace_mali_timeline_event((event_id), (data0), (data1), (u32)_mali_osk_get_task(), (data3), (data4))
+#else
+void _mali_osk_profiling_add_event(u32 event_id, u32 data0, u32 data1, u32 data2, u32 data3, u32 data4);
+#endif /* CONFIG_TRACEPOINTS && !MALI_INTERNAL_TIMELINE_PROFILING_ENABLED */
+
+/**
+ * Report a hardware counter event.
+ *
+ * @param counter_id The ID of the counter.
+ * @param value The value of the counter.
+ */
+#if defined (CONFIG_TRACEPOINTS) && !MALI_INTERNAL_TIMELINE_PROFILING_ENABLED
+/*
+ * On platforms where we are using Linux tracepoints and we aren't forcing
+ * internal profiling we can call through to the tracepoint directly and
+ * avoid the overhead of the function call.
+ */
+#define _mali_osk_profiling_report_hw_counter trace_mali_hw_counter
+#else
+void _mali_osk_profiling_report_hw_counter(u32 counter_id, u32 value);
+#endif /* CONFIG_TRACEPOINTS && !MALI_INTERNAL_TIMELINE_PROFILING_ENABLED */
+
+/**
+ * Query a hardware counter. Given a counter ID, check which event the
+ * counter should report and update the given pointer with that event
+ * number before returning MALI_TRUE. If the counter has been disabled
+ * by the profiling tool, returns MALI_FALSE and does not update the
+ * pointer.
+ *
+ * MALI_FALSE is also returned if the counter is not a valid hardware
+ * counter ID. In this case the event value is not updated.
+ *
+ * @param counter_id The counter ID.
+ * @param event_id A pointer to a u32 value that will be updated with
+ * the event ID that should be counted, should the counter have been
+ * enabled by the profiling tool.
+ *
+ * @return MALI_TRUE if the counter should be enabled, MALI_FALSE otherwise.
+ */
+mali_bool _mali_osk_profiling_query_hw_counter(u32 counter_id, u32 *event_id);
+
+/**
+ * Stop recording profiling data
+ *
+ * @param count Returns the number of recorded events.
+ * @return _MALI_OSK_ERR_OK on success, otherwise failure.
+ */
+_mali_osk_errcode_t _mali_osk_profiling_stop(u32 * count);
+
+/**
+ * Retrieves the number of events that can be retrieved
+ *
+ * @return The number of recorded events that can be retrieved.
+ */
+u32 _mali_osk_profiling_get_count(void);
+
+/**
+ * Retrieve an event
+ *
+ * @param index Event index (start with 0 and continue until this function fails to retrieve all events)
+ * @param timestamp The timestamp for the retrieved event will be stored here.
+ * @param event_id The event ID for the retrieved event will be stored here.
+ * @param data The 5 data values for the retrieved event will be stored here.
+ * @return _MALI_OSK_ERR_OK on success, otherwise failure.
+ */
+_mali_osk_errcode_t _mali_osk_profiling_get_event(u32 index, u64* timestamp, u32* event_id, u32 data[5]);
+
+/**
+ * Clear the recorded buffer.
+ *
+ * This is needed in order to start another recording.
+ *
+ * @return _MALI_OSK_ERR_OK on success, otherwise failure.
+ */
+_mali_osk_errcode_t _mali_osk_profiling_clear(void);
+
+/**
+ * Checks if a recording of profiling data is in progress
+ *
+ * @return MALI_TRUE if recording of profiling data is in progress, MALI_FALSE if not
+ */
+mali_bool _mali_osk_profiling_is_recording(void);
+
+/**
+ * Checks if profiling data is available for retrival
+ *
+ * @return MALI_TRUE if profiling data is avaiable, MALI_FALSE if not
+ */
+mali_bool _mali_osk_profiling_have_recording(void);
+
+/**
+ * Enable or disable profiling events as default for new sessions (applications)
+ *
+ * @param enable MALI_TRUE if profiling events should be turned on, otherwise MALI_FALSE
+ */
+void _mali_osk_profiling_set_default_enable_state(mali_bool enable);
+
+/**
+ * Get current default enable state for new sessions (applications)
+ *
+ * @return MALI_TRUE if profiling events should be turned on, otherwise MALI_FALSE
+ */
+mali_bool _mali_osk_profiling_get_default_enable_state(void);
+
+/** @} */ /* end group _mali_osk_profiling */
+
+#endif /* MALI_TIMELINE_PROFILING_ENABLED */
+
+#endif /* __MALI_OSK_PROFILING_H__ */
+
+
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_kernel_linux.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_kernel_linux.c
index 25b08b5f661..96ebacced0f 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_kernel_linux.c
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_kernel_linux.c
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2012 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
@@ -38,6 +38,13 @@
/* */
#include "mali_kernel_license.h"
+/* Streamline support for the Mali driver */
+#if defined(CONFIG_TRACEPOINTS)
+/* Ask Linux to create the tracepoints */
+#define CREATE_TRACE_POINTS
+#include "mali_linux_trace.h"
+#endif /* CONFIG_TRACEPOINTS */
+
/* from the __malidrv_build_info.c file that is generated during build */
extern const char *__malidrv_build_info(void);
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_kernel_sysfs.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_kernel_sysfs.c
index 866598ca1c7..b1dca5f7ba5 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_kernel_sysfs.c
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_kernel_sysfs.c
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2011 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2012 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
@@ -29,7 +29,7 @@
#include <linux/slab.h>
#include "mali_kernel_subsystem.h"
#include "mali_kernel_sysfs.h"
-#include "mali_kernel_profiling.h"
+#include "mali_osk_profiling.h"
static struct dentry *mali_debugfs_dir = NULL;
@@ -73,13 +73,13 @@ static const struct file_operations mali_seq_internal_state_fops = {
#endif /* MALI_STATE_TRACKING */
-#if MALI_TIMELINE_PROFILING_ENABLED
+#if MALI_INTERNAL_TIMELINE_PROFILING_ENABLED
static ssize_t profiling_record_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
{
char buf[64];
int r;
- r = sprintf(buf, "%u\n", _mali_profiling_is_recording() ? 1 : 0);
+ r = sprintf(buf, "%u\n", _mali_osk_profiling_is_recording() ? 1 : 0);
return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
}
@@ -112,16 +112,16 @@ static ssize_t profiling_record_write(struct file *filp, const char __user *ubuf
u32 limit = MALI_PROFILING_MAX_BUFFER_ENTRIES; /* This can be made configurable at a later stage if we need to */
/* check if we are already recording */
- if (MALI_TRUE == _mali_profiling_is_recording())
+ if (MALI_TRUE == _mali_osk_profiling_is_recording())
{
MALI_DEBUG_PRINT(3, ("Recording of profiling events already in progress\n"));
return -EFAULT;
}
/* check if we need to clear out an old recording first */
- if (MALI_TRUE == _mali_profiling_have_recording())
+ if (MALI_TRUE == _mali_osk_profiling_have_recording())
{
- if (_MALI_OSK_ERR_OK != _mali_profiling_clear())
+ if (_MALI_OSK_ERR_OK != _mali_osk_profiling_clear())
{
MALI_DEBUG_PRINT(3, ("Failed to clear existing recording of profiling events\n"));
return -EFAULT;
@@ -129,7 +129,7 @@ static ssize_t profiling_record_write(struct file *filp, const char __user *ubuf
}
/* start recording profiling data */
- if (_MALI_OSK_ERR_OK != _mali_profiling_start(&limit))
+ if (_MALI_OSK_ERR_OK != _mali_osk_profiling_start(&limit))
{
MALI_DEBUG_PRINT(3, ("Failed to start recording of profiling events\n"));
return -EFAULT;
@@ -141,7 +141,7 @@ static ssize_t profiling_record_write(struct file *filp, const char __user *ubuf
{
/* stop recording profiling data */
u32 count = 0;
- if (_MALI_OSK_ERR_OK != _mali_profiling_stop(&count))
+ if (_MALI_OSK_ERR_OK != _mali_osk_profiling_stop(&count))
{
MALI_DEBUG_PRINT(2, ("Failed to stop recording of profiling events\n"));
return -EFAULT;
@@ -165,7 +165,7 @@ static void *profiling_events_start(struct seq_file *s, loff_t *pos)
loff_t *spos;
/* check if we have data avaiable */
- if (MALI_TRUE != _mali_profiling_have_recording())
+ if (MALI_TRUE != _mali_osk_profiling_have_recording())
{
return NULL;
}
@@ -185,13 +185,13 @@ static void *profiling_events_next(struct seq_file *s, void *v, loff_t *pos)
loff_t *spos = v;
/* check if we have data avaiable */
- if (MALI_TRUE != _mali_profiling_have_recording())
+ if (MALI_TRUE != _mali_osk_profiling_have_recording())
{
return NULL;
}
/* check if the next entry actually is avaiable */
- if (_mali_profiling_get_count() <= (u32)(*spos + 1))
+ if (_mali_osk_profiling_get_count() <= (u32)(*spos + 1))
{
return NULL;
}
@@ -216,7 +216,7 @@ static int profiling_events_show(struct seq_file *seq_file, void *v)
index = (u32)*spos;
/* Retrieve all events */
- if (_MALI_OSK_ERR_OK == _mali_profiling_get_event(index, &timestamp, &event_id, data))
+ if (_MALI_OSK_ERR_OK == _mali_osk_profiling_get_event(index, &timestamp, &event_id, data))
{
seq_printf(seq_file, "%llu %u %u %u %u %u %u\n", timestamp, event_id, data[0], data[1], data[2], data[3], data[4]);
return 0;
@@ -250,7 +250,7 @@ static ssize_t profiling_proc_default_enable_read(struct file *filp, char __user
char buf[64];
int r;
- r = sprintf(buf, "%u\n", _mali_profiling_get_default_enable_state() ? 1 : 0);
+ r = sprintf(buf, "%u\n", _mali_osk_profiling_get_default_enable_state() ? 1 : 0);
return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
}
@@ -278,7 +278,7 @@ static ssize_t profiling_proc_default_enable_write(struct file *filp, const char
return ret;
}
- _mali_profiling_set_default_enable_state(val != 0 ? MALI_TRUE : MALI_FALSE);
+ _mali_osk_profiling_set_default_enable_state(val != 0 ? MALI_TRUE : MALI_FALSE);
*ppos += cnt;
return cnt;
@@ -335,7 +335,7 @@ int mali_sysfs_register(struct mali_dev *device, dev_t dev, const char *mali_dev
if(NULL != mali_debugfs_dir)
{
/* Debugfs directory created successfully; create files now */
-#if MALI_TIMELINE_PROFILING_ENABLED
+#if MALI_INTERNAL_TIMELINE_PROFILING_ENABLED
struct dentry *mali_profiling_dir = debugfs_create_dir("profiling", mali_debugfs_dir);
if (mali_profiling_dir != NULL)
{
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_linux_trace.h b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_linux_trace.h
new file mode 100644
index 00000000000..64c2fd5269c
--- /dev/null
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_linux_trace.h
@@ -0,0 +1,125 @@
+/**
+ * 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.
+ */
+
+#if !defined (MALI_LINUX_TRACE_H) || defined (TRACE_HEADER_MULTI_READ)
+#define MALI_LINUX_TRACE_H
+
+#include <linux/stringify.h>
+#include <linux/tracepoint.h>
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM mali
+#define TRACE_SYSTEM_STRING __stringfy(TRACE_SYSTEM)
+
+#define TRACE_INCLUDE_PATH .
+#define TRACE_INCLUDE_FILE mali_linux_trace
+
+/**
+ * Define the tracepoint used to communicate the status of a GPU. Called
+ * when a GPU turns on or turns off.
+ *
+ * @param event_id The type of the event. This parameter is a bitfield
+ * encoding the type of the event.
+ *
+ * @param d0 First data parameter.
+ * @param d1 Second data parameter.
+ * @param d2 Third data parameter.
+ * @param d3 Fourth data parameter.
+ * @param d4 Fifth data parameter.
+ */
+TRACE_EVENT(mali_timeline_event,
+
+ TP_PROTO(unsigned int event_id, unsigned int d0, unsigned int d1,
+ unsigned int d2, unsigned int d3, unsigned int d4),
+
+ TP_ARGS(event_id, d0, d1, d2, d3, d4),
+
+ TP_STRUCT__entry(
+ __field(unsigned int, event_id)
+ __field(unsigned int, d0)
+ __field(unsigned int, d1)
+ __field(unsigned int, d2)
+ __field(unsigned int, d3)
+ __field(unsigned int, d4)
+ ),
+
+ TP_fast_assign(
+ __entry->event_id = event_id;
+ __entry->d0 = d0;
+ __entry->d1 = d1;
+ __entry->d2 = d2;
+ __entry->d3 = d3;
+ __entry->d4 = d4;
+ ),
+
+ TP_printk("event=%d", __entry->event_id)
+);
+
+/**
+ * Define a tracepoint used to regsiter the value of a hardware counter.
+ * Hardware counters belonging to the vertex or fragment processor are
+ * reported via this tracepoint each frame, whilst L2 cache hardware
+ * counters are reported continuously.
+ *
+ * @param counter_id The counter ID.
+ * @param value The value of the counter.
+ */
+TRACE_EVENT(mali_hw_counter,
+
+ TP_PROTO(unsigned int counter_id, unsigned int value),
+
+ TP_ARGS(counter_id, value),
+
+ TP_STRUCT__entry(
+ __field(unsigned int, counter_id)
+ __field(unsigned int, value)
+ ),
+
+ TP_fast_assign(
+ __entry->counter_id = counter_id;
+ __entry->value = value;
+ ),
+
+ TP_printk("event %d = %d", __entry->counter_id, __entry->value)
+);
+
+/**
+ * Define a tracepoint used to register the value of a software counter.
+ *
+ * @param counter_id The counter ID.
+ * @param value The value of the counter.
+ */
+TRACE_EVENT(mali_sw_counter,
+
+ TP_PROTO(unsigned int counter_id, signed long long value),
+
+ TP_ARGS(counter_id, value),
+
+ TP_STRUCT__entry(
+ __field(unsigned int, counter_id)
+ __field(signed long long, value)
+ ),
+
+ TP_fast_assign(
+ __entry->counter_id = counter_id;
+ __entry->value = value;
+ ),
+
+ TP_printk("event %d = %lld", __entry->counter_id, __entry->value)
+);
+
+#endif /* MALI_LINUX_TRACE_H */
+
+/* This part must exist outside the header guard. */
+#include <trace/define_trace.h>
+
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_osk_misc.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_osk_misc.c
index 12f4299ee9b..106308b58ba 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_osk_misc.c
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_osk_misc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2012 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
@@ -61,3 +61,9 @@ u32 _mali_osk_get_tid(void)
/* pid is actually identifying the thread on Linux */
return (u32)current->pid;
}
+
+void * _mali_osk_get_task(void)
+{
+ return current;
+}
+
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_osk_profiling_gator.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_osk_profiling_gator.c
new file mode 100644
index 00000000000..c4cd5826363
--- /dev/null
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_osk_profiling_gator.c
@@ -0,0 +1,247 @@
+/**
+ * Copyright (C) 2012 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation, and any use by you of this program is subject to the terms of
+ * such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained
+ * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <linux/module.h>
+
+#include "mali_kernel_common.h"
+#include "mali_osk.h"
+#include "mali_ukk.h"
+#include "mali_osk_profiling.h"
+#include "mali_linux_trace.h"
+
+#if defined(USING_MALI400_L2_CACHE)
+#include "mali_kernel_l2_cache.h"
+#endif /* USING_MALI400_L2_CACHE */
+
+#define COUNTER_DISABLED (-1)
+
+/**
+ * Since there are only two physical hardware counters per GPU block, we
+ * need to multiplex the range of possible events that can be collected by
+ * each counter. This multiplexing is achieved by means of the following
+ * table, which holds the event ID that should be collected by each hardware
+ * counter.
+ *
+ * Note that this table should be updated with any change to the above
+ * _mali_osk_counter_id enumeration.
+ */
+s32 _mali_osk_hw_counter_table[] = {
+ COUNTER_DISABLED, /* ACTIVITY_VP */
+ COUNTER_DISABLED, /* ACTIVITY_FP0 */
+ COUNTER_DISABLED, /* ACTIVITY_FP1 */
+ COUNTER_DISABLED, /* ACTIVITY_FP2 */
+ COUNTER_DISABLED, /* ACTIVITY_FP3 */
+ COUNTER_DISABLED, /* COUNTER_L2_C0 */
+ COUNTER_DISABLED, /* COUNTER_L2_C1 */
+ COUNTER_DISABLED, /* COUNTER_VP_C0 */
+ COUNTER_DISABLED, /* COUNTER_VP_C1 */
+ COUNTER_DISABLED, /* COUNTER_FP0_C0 */
+ COUNTER_DISABLED, /* COUNTER_FP0_C1 */
+ COUNTER_DISABLED, /* COUNTER_FP1_C0 */
+ COUNTER_DISABLED, /* COUNTER_FP1_C1 */
+ COUNTER_DISABLED, /* COUNTER_FP2_C0 */
+ COUNTER_DISABLED, /* COUNTER_FP2_C1 */
+ COUNTER_DISABLED, /* COUNTER_FP3_C0 */
+ COUNTER_DISABLED, /* COUNTER_FP3_C1 */
+};
+
+mali_bool _mali_osk_profiling_query_hw_counter(u32 counter_id, u32 *event_id)
+{
+ /* Check that the counter is in range... */
+ if (counter_id >= FIRST_HW_COUNTER && counter_id <= LAST_HW_COUNTER)
+ {
+ s32 id = _mali_osk_hw_counter_table[counter_id];
+
+ /* ...and enabled */
+ if (id != COUNTER_DISABLED)
+ {
+ /* Update the pointer to the event ID */
+ *event_id = (u32)id;
+
+ return MALI_TRUE;
+ }
+ }
+
+ /* The counter was disabled or out of range */
+ return MALI_FALSE;
+}
+
+_mali_osk_errcode_t _mali_osk_profiling_init(mali_bool auto_start)
+{
+ /* Nothing to do */
+ return _MALI_OSK_ERR_OK;
+}
+
+void _mali_osk_profiling_term(void)
+{
+ /* Nothing to do */
+}
+
+_mali_osk_errcode_t _mali_osk_profiling_start(u32 * limit)
+{
+ /* Nothing to do */
+ return _MALI_OSK_ERR_OK;
+}
+
+_mali_osk_errcode_t _mali_osk_profiling_stop(u32 *count)
+{
+ /* Nothing to do */
+ return _MALI_OSK_ERR_OK;
+}
+
+u32 _mali_osk_profiling_get_count(void)
+{
+ return 0;
+}
+
+_mali_osk_errcode_t _mali_osk_profiling_get_event(u32 index, u64* timestamp,
+ u32* event_id, u32 data[5])
+{
+ /* Nothing to do */
+ return _MALI_OSK_ERR_OK;
+}
+
+_mali_osk_errcode_t _mali_osk_profiling_clear(void)
+{
+ /* Nothing to do */
+ return _MALI_OSK_ERR_OK;
+}
+
+mali_bool _mali_osk_profiling_is_recording(void)
+{
+ return MALI_FALSE;
+}
+
+mali_bool _mali_osk_profiling_have_recording(void)
+{
+ return MALI_FALSE;
+}
+
+void _mali_osk_profiling_set_default_enable_state(mali_bool enable)
+{
+ /* Nothing to do */
+}
+
+mali_bool _mali_osk_profiling_get_default_enable_state(void)
+{
+ return MALI_FALSE;
+}
+
+_mali_osk_errcode_t _mali_ukk_profiling_start(_mali_uk_profiling_start_s *args)
+{
+ return _mali_osk_profiling_start(&args->limit);
+}
+
+_mali_osk_errcode_t _mali_ukk_profiling_add_event(_mali_uk_profiling_add_event_s *args)
+{
+ /* Always add process and thread identificator in the first two data elements for events from user space */
+ _mali_osk_profiling_add_event(args->event_id, _mali_osk_get_pid(), _mali_osk_get_tid(), args->data[2], args->data[3], args->data[4]);
+
+ return _MALI_OSK_ERR_OK;
+}
+
+_mali_osk_errcode_t _mali_ukk_profiling_stop(_mali_uk_profiling_stop_s *args)
+{
+ return _mali_osk_profiling_stop(&args->count);
+}
+
+_mali_osk_errcode_t _mali_ukk_profiling_get_event(_mali_uk_profiling_get_event_s *args)
+{
+ return _mali_osk_profiling_get_event(args->index, &args->timestamp, &args->event_id, args->data);
+}
+
+_mali_osk_errcode_t _mali_ukk_profiling_clear(_mali_uk_profiling_clear_s *args)
+{
+ return _mali_osk_profiling_clear();
+}
+
+_mali_osk_errcode_t _mali_ukk_profiling_get_config(_mali_uk_profiling_get_config_s *args)
+{
+ return _MALI_OSK_ERR_UNSUPPORTED;
+}
+
+/**
+ * Called by gator.ko to populate the _mali_osk_hw_counter_table.
+ *
+ * @param counter_id The counter ID.
+ * @param event_id Event ID that the counter should count.
+ *
+ * @return 1 on success, 0 on failure.
+ */
+int _mali_profiling_set_event(u32 counter_id, s32 event_id)
+{
+#if defined(USING_MALI400_L2_CACHE)
+ /*
+ * The L2 cache counters have special handling in the driver. Since we
+ * receive new event IDs for each counter one at a time, we need to know
+ * what the L2 counters are currently programmed to read. This way we
+ * can supply the current value to the counter we _aren't_ trying to
+ * program; mali_kernel_l2_cache_set_perf_counters will dutifully ignore
+ * that counter.
+ */
+ u32 current_src0, current_src1, current_val0, current_val1;
+
+ mali_kernel_l2_cache_get_perf_counters(&current_src0, &current_val0,
+ &current_src1, &current_val1);
+
+ if (counter_id == COUNTER_L2_C0)
+ {
+ mali_kernel_l2_cache_set_perf_counters(event_id, current_src1, 0);
+
+ return 1;
+ }
+ else if (counter_id == COUNTER_L2_C1)
+ {
+ mali_kernel_l2_cache_set_perf_counters(current_src0, event_id, 0);
+
+ return 1;
+ }
+#endif /* USING_MALI400_L2_CACHE */
+
+ /* Check that the counter is in range */
+ if (counter_id >= FIRST_HW_COUNTER && counter_id <= LAST_HW_COUNTER)
+ {
+ /*
+ * This does not actually update the hardware with the new event ID;
+ * it will query what event ID it should be counting on each frame
+ * via _mali_osk_profiling_query_hw_counter.
+ */
+ _mali_osk_hw_counter_table[counter_id] = event_id;
+
+ return 1;
+ }
+
+ return 0;
+}
+
+#if defined(USING_MALI400_L2_CACHE)
+/**
+ * Called by gator.ko to retrieve the L2 cache counter values. The L2 cache
+ * counters are unique in that they are polled by gator, rather than being
+ * transmitted via the tracepoint mechanism.
+ *
+ * @param src0 First L2 cache counter ID.
+ * @param val0 First L2 cache counter value.
+ * @param src1 Second L2 cache counter ID.
+ * @param val1 Second L2 cache counter value.
+ */
+void _mali_profiling_get_counters(u32 *src0, u32 *val0, u32 *src1, u32 *val1)
+{
+ mali_kernel_l2_cache_get_perf_counters(src0, val0, src1, val1);
+}
+
+EXPORT_SYMBOL(_mali_profiling_get_counters);
+#endif /* USING_MALI400_L2_CACHE */
+
+EXPORT_SYMBOL(_mali_profiling_set_event);
+
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_profiling.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_osk_profiling_internal.c
index 1f3eb4aa778..589e2ace6d8 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/mali_kernel_profiling.c
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_osk_profiling_internal.c
@@ -1,11 +1,14 @@
-/*
- * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+/**
+ * Copyright (C) 2010-2012 ARM Limited. All rights reserved.
*
- * This program is free software and is provided to you under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ * This program is free software and is provided to you under the terms of the
+ * GNU General Public License version 2 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.
+ * 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"
@@ -13,7 +16,7 @@
#include "mali_osk_mali.h"
#include "mali_ukk.h"
#include "mali_timestamp.h"
-#include "mali_kernel_profiling.h"
+#include "mali_osk_profiling.h"
typedef struct mali_profiling_entry
{
@@ -40,7 +43,7 @@ static _mali_osk_atomic_t profile_insert_index;
static _mali_osk_atomic_t profile_entries_written;
static mali_bool mali_profiling_default_enable = MALI_FALSE;
-_mali_osk_errcode_t _mali_profiling_init(mali_bool auto_start)
+_mali_osk_errcode_t _mali_osk_profiling_init(mali_bool auto_start)
{
profile_entries = NULL;
profile_entry_count = 0;
@@ -60,7 +63,7 @@ _mali_osk_errcode_t _mali_profiling_init(mali_bool auto_start)
u32 limit = MALI_PROFILING_MAX_BUFFER_ENTRIES; /* Use maximum buffer size */
mali_profiling_default_enable = MALI_TRUE; /* save this so user space can query this on their startup */
- if (_MALI_OSK_ERR_OK != _mali_profiling_start(&limit))
+ if (_MALI_OSK_ERR_OK != _mali_osk_profiling_start(&limit))
{
return _MALI_OSK_ERR_FAULT;
}
@@ -69,7 +72,7 @@ _mali_osk_errcode_t _mali_profiling_init(mali_bool auto_start)
return _MALI_OSK_ERR_OK;
}
-void _mali_profiling_term(void)
+void _mali_osk_profiling_term(void)
{
prof_state = MALI_PROFILING_STATE_UNINITIALIZED;
@@ -92,15 +95,23 @@ void _mali_profiling_term(void)
}
}
-inline _mali_osk_errcode_t _mali_profiling_start(u32 * limit)
+inline _mali_osk_errcode_t _mali_osk_profiling_start(u32 * limit)
{
_mali_osk_errcode_t ret;
+ mali_profiling_entry *new_profile_entries = _mali_osk_valloc(*limit * sizeof(mali_profiling_entry));
+
+ if(NULL == new_profile_entries)
+ {
+ return _MALI_OSK_ERR_NOMEM;
+ }
+
_mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW);
if (prof_state != MALI_PROFILING_STATE_IDLE)
{
_mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_vfree(new_profile_entries);
return _MALI_OSK_ERR_INVALID_ARGS; /* invalid to call this function in this state */
}
@@ -109,13 +120,8 @@ inline _mali_osk_errcode_t _mali_profiling_start(u32 * limit)
*limit = MALI_PROFILING_MAX_BUFFER_ENTRIES;
}
- profile_entries = _mali_osk_valloc(*limit * sizeof(mali_profiling_entry));
+ profile_entries = new_profile_entries;
profile_entry_count = *limit;
- if (NULL == profile_entries)
- {
- _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
- return _MALI_OSK_ERR_NOMEM;
- }
ret = _mali_timestamp_reset();
@@ -133,7 +139,7 @@ inline _mali_osk_errcode_t _mali_profiling_start(u32 * limit)
return ret;
}
-inline _mali_osk_errcode_t _mali_profiling_add_event(u32 event_id, u32 data0, u32 data1, u32 data2, u32 data3, u32 data4)
+inline void _mali_osk_profiling_add_event(u32 event_id, u32 data0, u32 data1, u32 data2, u32 data3, u32 data4)
{
u32 cur_index = _mali_osk_atomic_inc_return(&profile_insert_index) - 1;
@@ -144,7 +150,7 @@ inline _mali_osk_errcode_t _mali_profiling_add_event(u32 event_id, u32 data0, u3
* Decrement index again, and early out
*/
_mali_osk_atomic_dec(&profile_insert_index);
- return _MALI_OSK_ERR_FAULT;
+ return;
}
profile_entries[cur_index].timestamp = _mali_timestamp_get();
@@ -156,11 +162,19 @@ inline _mali_osk_errcode_t _mali_profiling_add_event(u32 event_id, u32 data0, u3
profile_entries[cur_index].data[4] = data4;
_mali_osk_atomic_inc(&profile_entries_written);
+}
- return _MALI_OSK_ERR_OK;
+inline void _mali_osk_profiling_report_hw_counter(u32 counter_id, u32 value)
+{
+ /* Not implemented */
}
-inline _mali_osk_errcode_t _mali_profiling_stop(u32 * count)
+inline mali_bool _mali_osk_profiling_query_hw_counter(u32 counter_id, u32 *event_id)
+{
+ return _MALI_OSK_ERR_UNSUPPORTED;
+}
+
+inline _mali_osk_errcode_t _mali_osk_profiling_stop(u32 * count)
{
_mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW);
@@ -186,7 +200,7 @@ inline _mali_osk_errcode_t _mali_profiling_stop(u32 * count)
return _MALI_OSK_ERR_OK;
}
-inline u32 _mali_profiling_get_count(void)
+inline u32 _mali_osk_profiling_get_count(void)
{
u32 retval = 0;
@@ -200,7 +214,7 @@ inline u32 _mali_profiling_get_count(void)
return retval;
}
-inline _mali_osk_errcode_t _mali_profiling_get_event(u32 index, u64* timestamp, u32* event_id, u32 data[5])
+inline _mali_osk_errcode_t _mali_osk_profiling_get_event(u32 index, u64* timestamp, u32* event_id, u32 data[5])
{
_mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW);
@@ -228,7 +242,7 @@ inline _mali_osk_errcode_t _mali_profiling_get_event(u32 index, u64* timestamp,
return _MALI_OSK_ERR_OK;
}
-inline _mali_osk_errcode_t _mali_profiling_clear(void)
+inline _mali_osk_errcode_t _mali_osk_profiling_clear(void)
{
_mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW);
@@ -252,50 +266,51 @@ inline _mali_osk_errcode_t _mali_profiling_clear(void)
return _MALI_OSK_ERR_OK;
}
-mali_bool _mali_profiling_is_recording(void)
+mali_bool _mali_osk_profiling_is_recording(void)
{
return prof_state == MALI_PROFILING_STATE_RUNNING ? MALI_TRUE : MALI_FALSE;
}
-mali_bool _mali_profiling_have_recording(void)
+mali_bool _mali_osk_profiling_have_recording(void)
{
return prof_state == MALI_PROFILING_STATE_RETURN ? MALI_TRUE : MALI_FALSE;
}
-void _mali_profiling_set_default_enable_state(mali_bool enable)
+void _mali_osk_profiling_set_default_enable_state(mali_bool enable)
{
mali_profiling_default_enable = enable;
}
-mali_bool _mali_profiling_get_default_enable_state(void)
+mali_bool _mali_osk_profiling_get_default_enable_state(void)
{
return mali_profiling_default_enable;
}
_mali_osk_errcode_t _mali_ukk_profiling_start(_mali_uk_profiling_start_s *args)
{
- return _mali_profiling_start(&args->limit);
+ return _mali_osk_profiling_start(&args->limit);
}
_mali_osk_errcode_t _mali_ukk_profiling_add_event(_mali_uk_profiling_add_event_s *args)
{
/* Always add process and thread identificator in the first two data elements for events from user space */
- return _mali_profiling_add_event(args->event_id, _mali_osk_get_pid(), _mali_osk_get_tid(), args->data[2], args->data[3], args->data[4]);
+ _mali_osk_profiling_add_event(args->event_id, _mali_osk_get_pid(), _mali_osk_get_tid(), args->data[2], args->data[3], args->data[4]);
+ return _MALI_OSK_ERR_OK;
}
_mali_osk_errcode_t _mali_ukk_profiling_stop(_mali_uk_profiling_stop_s *args)
{
- return _mali_profiling_stop(&args->count);
+ return _mali_osk_profiling_stop(&args->count);
}
_mali_osk_errcode_t _mali_ukk_profiling_get_event(_mali_uk_profiling_get_event_s *args)
{
- return _mali_profiling_get_event(args->index, &args->timestamp, &args->event_id, args->data);
+ return _mali_osk_profiling_get_event(args->index, &args->timestamp, &args->event_id, args->data);
}
_mali_osk_errcode_t _mali_ukk_profiling_clear(_mali_uk_profiling_clear_s *args)
{
- return _mali_profiling_clear();
+ return _mali_osk_profiling_clear();
}
_mali_osk_errcode_t _mali_ukk_profiling_get_config(_mali_uk_profiling_get_config_s *args)
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_osk_specific.h b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_osk_specific.h
index 6aacf17d387..fbf1dd59e27 100644
--- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_osk_specific.h
+++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/linux/mali_osk_specific.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2012 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
@@ -29,4 +29,102 @@ extern "C"
}
#endif
+/** The list of events supported by the Mali DDK. */
+typedef enum
+{
+ /* Vertex processor activity */
+ ACTIVITY_VP = 0,
+
+ /* Fragment processor activity */
+ ACTIVITY_FP0,
+ ACTIVITY_FP1,
+ ACTIVITY_FP2,
+ ACTIVITY_FP3,
+
+ /* L2 cache counters */
+ COUNTER_L2_C0,
+ COUNTER_L2_C1,
+
+ /* Vertex processor counters */
+ COUNTER_VP_C0,
+ COUNTER_VP_C1,
+
+ /* Fragment processor counters */
+ COUNTER_FP0_C0,
+ COUNTER_FP0_C1,
+ COUNTER_FP1_C0,
+ COUNTER_FP1_C1,
+ COUNTER_FP2_C0,
+ COUNTER_FP2_C1,
+ COUNTER_FP3_C0,
+ COUNTER_FP3_C1,
+
+ /*
+ * If more hardware counters are added, the _mali_osk_hw_counter_table
+ * below should also be updated.
+ */
+
+ /* EGL software counters */
+ COUNTER_EGL_BLIT_TIME,
+
+ /* GLES software counters */
+ COUNTER_GLES_DRAW_ELEMENTS_CALLS,
+ COUNTER_GLES_DRAW_ELEMENTS_NUM_INDICES,
+ COUNTER_GLES_DRAW_ELEMENTS_NUM_TRANSFORMED,
+ COUNTER_GLES_DRAW_ARRAYS_CALLS,
+ COUNTER_GLES_DRAW_ARRAYS_NUM_TRANSFORMED,
+ COUNTER_GLES_DRAW_POINTS,
+ COUNTER_GLES_DRAW_LINES,
+ COUNTER_GLES_DRAW_LINE_LOOP,
+ COUNTER_GLES_DRAW_LINE_STRIP,
+ COUNTER_GLES_DRAW_TRIANGLES,
+ COUNTER_GLES_DRAW_TRIANGLE_STRIP,
+ COUNTER_GLES_DRAW_TRIANGLE_FAN,
+ COUNTER_GLES_NON_VBO_DATA_COPY_TIME,
+ COUNTER_GLES_UNIFORM_BYTES_COPIED_TO_MALI,
+ COUNTER_GLES_UPLOAD_TEXTURE_TIME,
+ COUNTER_GLES_UPLOAD_VBO_TIME,
+ COUNTER_GLES_NUM_FLUSHES,
+ COUNTER_GLES_NUM_VSHADERS_GENERATED,
+ COUNTER_GLES_NUM_FSHADERS_GENERATED,
+ COUNTER_GLES_VSHADER_GEN_TIME,
+ COUNTER_GLES_FSHADER_GEN_TIME,
+ COUNTER_GLES_INPUT_TRIANGLES,
+ COUNTER_GLES_VXCACHE_HIT,
+ COUNTER_GLES_VXCACHE_MISS,
+ COUNTER_GLES_VXCACHE_COLLISION,
+ COUNTER_GLES_CULLED_TRIANGLES,
+ COUNTER_GLES_CULLED_LINES,
+ COUNTER_GLES_BACKFACE_TRIANGLES,
+ COUNTER_GLES_GBCLIP_TRIANGLES,
+ COUNTER_GLES_GBCLIP_LINES,
+ COUNTER_GLES_TRIANGLES_DRAWN,
+ COUNTER_GLES_DRAWCALL_TIME,
+ COUNTER_GLES_TRIANGLES_COUNT,
+ COUNTER_GLES_INDEPENDENT_TRIANGLES_COUNT,
+ COUNTER_GLES_STRIP_TRIANGLES_COUNT,
+ COUNTER_GLES_FAN_TRIANGLES_COUNT,
+ COUNTER_GLES_LINES_COUNT,
+ COUNTER_GLES_INDEPENDENT_LINES_COUNT,
+ COUNTER_GLES_STRIP_LINES_COUNT,
+ COUNTER_GLES_LOOP_LINES_COUNT,
+
+ /* Framebuffer capture pseudo-counter */
+ COUNTER_FILMSTRIP,
+
+ NUMBER_OF_EVENTS
+} _mali_osk_counter_id;
+
+#define FIRST_ACTIVITY_EVENT ACTIVITY_VP
+#define LAST_ACTIVITY_EVENT ACTIVITY_FP3
+
+#define FIRST_HW_COUNTER COUNTER_L2_C0
+#define LAST_HW_COUNTER COUNTER_FP3_C1
+
+#define FIRST_SW_COUNTER COUNTER_EGL_BLIT_TIME
+#define LAST_SW_COUNTER COUNTER_GLES_LOOP_LINES_COUNT
+
+#define FIRST_SPECIAL_COUNTER COUNTER_FILMSTRIP
+#define LAST_SPECIAL_COUNTER COUNTER_FILMSTRIP
+
#endif /* __MALI_OSK_SPECIFIC_H__ */