summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Beykun <rzk333@gmail.com>2012-10-21 20:16:25 +0400
committerDmitriy Beykun <rzk333@gmail.com>2012-10-21 20:16:25 +0400
commit0bd92ce52c1259f3533515c34540660553fb895f (patch)
treec75dcbd4fa7d4f0211c6a00babad89b0f91ecaac
parenta6dea94fe2da2cf1ce58828a7361ee063d09f0bd (diff)
downloadmali-400-kernel-drivers-r3p1-01rel1.tar.xz
added r3p1-01rel1 kernel driversr3p1-01rel1
-rw-r--r--driver/src/devicedrv/mali/.version2
-rw-r--r--driver/src/devicedrv/mali/Kbuild21
-rw-r--r--driver/src/devicedrv/mali/common/mali_gp.c45
-rw-r--r--driver/src/devicedrv/mali/common/mali_gp_job.c18
-rw-r--r--driver/src/devicedrv/mali/common/mali_gp_job.h38
-rw-r--r--driver/src/devicedrv/mali/common/mali_gp_scheduler.c18
-rw-r--r--driver/src/devicedrv/mali/common/mali_hw_core.h33
-rw-r--r--driver/src/devicedrv/mali/common/mali_kernel_core.c4
-rw-r--r--driver/src/devicedrv/mali/common/mali_osk.h11
-rw-r--r--driver/src/devicedrv/mali/common/mali_osk_profiling.h22
-rw-r--r--driver/src/devicedrv/mali/common/mali_pp.c117
-rw-r--r--driver/src/devicedrv/mali/common/mali_pp_job.c59
-rw-r--r--driver/src/devicedrv/mali/common/mali_pp_job.h103
-rw-r--r--driver/src/devicedrv/mali/common/mali_pp_scheduler.c248
-rw-r--r--driver/src/devicedrv/mali/common/mali_pp_scheduler.h1
-rw-r--r--driver/src/devicedrv/mali/common/mali_ukk.h10
-rw-r--r--driver/src/devicedrv/mali/include/linux/mali/mali_utgard_profiling_events.h24
-rw-r--r--driver/src/devicedrv/mali/linux/mali_kernel_linux.c19
-rw-r--r--driver/src/devicedrv/mali/linux/mali_kernel_sysfs.c22
-rw-r--r--driver/src/devicedrv/mali/linux/mali_osk_locks.c27
-rw-r--r--driver/src/devicedrv/mali/linux/mali_osk_notification.c43
-rw-r--r--driver/src/devicedrv/mali/linux/mali_osk_profiling.c (renamed from driver/src/devicedrv/mali/linux/mali_osk_profiling_gator.c)0
-rw-r--r--driver/src/devicedrv/mali/linux/mali_osk_profiling_internal.c324
-rw-r--r--driver/src/devicedrv/mali/linux/mali_osk_specific.h14
-rw-r--r--driver/src/devicedrv/mali/linux/mali_profiling_internal.c294
-rw-r--r--driver/src/devicedrv/mali/linux/mali_profiling_internal.h36
-rw-r--r--driver/src/devicedrv/mali/linux/mali_ukk_gp.c37
-rw-r--r--driver/src/devicedrv/mali/linux/mali_ukk_pp.c13
-rw-r--r--driver/src/devicedrv/mali/regs/mali_gp_regs.h2
-rw-r--r--driver/src/devicedrv/ump/.version2
-rw-r--r--driver/src/egl/x11/drm_module/mali_drm/KDIR_CONFIGURATION9
-rw-r--r--driver/src/egl/x11/drm_module/mali_drm/Makefile77
-rw-r--r--driver/src/egl/x11/drm_module/mali_drm/include/Kbuild11
-rw-r--r--driver/src/egl/x11/drm_module/mali_drm/include/mali_drm.h43
-rw-r--r--driver/src/egl/x11/drm_module/mali_drm/mali/Makefile19
-rw-r--r--driver/src/egl/x11/drm_module/mali_drm/mali/mali_drv.c150
-rw-r--r--driver/src/egl/x11/drm_module/mali_drm/mali/mali_drv.h39
-rw-r--r--driver/src/egl/x11/drm_module/mali_drm/mali/mali_mm.c265
-rw-r--r--driver/src/egl/x11/drm_module/readme8
-rw-r--r--driver/src/shared/essl_compiler/src/frontend/Makefile.offline3
-rw-r--r--driver/src/shared/essl_compiler/src/middle/proactive_calculations.c87
-rw-r--r--driver/src/shared/m200_fbdump.c10
-rw-r--r--driver/src/shared/m200_plbuheap.c100
-rw-r--r--driver/src/shared/m200_plbuheap.h74
-rw-r--r--driver/src/shared/m200_projob.c12
45 files changed, 1513 insertions, 1001 deletions
diff --git a/driver/src/devicedrv/mali/.version b/driver/src/devicedrv/mali/.version
index 266ae67..26def88 100644
--- a/driver/src/devicedrv/mali/.version
+++ b/driver/src/devicedrv/mali/.version
@@ -1 +1 @@
-r3p1-01rel0
+r3p1-01rel1
diff --git a/driver/src/devicedrv/mali/Kbuild b/driver/src/devicedrv/mali/Kbuild
index cd32917..6fcc361 100644
--- a/driver/src/devicedrv/mali/Kbuild
+++ b/driver/src/devicedrv/mali/Kbuild
@@ -55,19 +55,12 @@ endif
ifeq ($(USING_PROFILING),1)
-ifeq ($(USING_INTERNAL_PROFILING),0)
ifndef CONFIG_TRACEPOINTS
# Should default to gator profiling, but we dont have the kernel feature required, so disable profiling
override USING_PROFILING = 0
$(warning "CONFIG_TRACEPOINTS required for USING_PROFILING")
endif
endif
-endif
-
-ifeq ($(USING_PROFILING),0)
-# make sure user hasnt selected incompatible flags
-override USING_INTERNAL_PROFILING = 0
-endif
MALI_RELEASE_NAME=$(shell cat $(DRIVER_DIR)/.version 2> /dev/null)
@@ -219,22 +212,18 @@ SRC = \
__malidrv_build_info.c
# Selecting files to compile by parsing the config file
+ifeq ($(USING_PROFILING),1)
+SRC += \
+ linux/mali_osk_profiling.c
ifeq ($(USING_INTERNAL_PROFILING),1)
-PROFILING_BACKEND_SOURCES = \
- linux/mali_osk_profiling_internal.c \
+SRC += \
+ linux/mali_profiling_internal.c \
timestamp-$(TIMESTAMP)/mali_timestamp.c
ccflags-y += -I$(DRIVER_DIR)/timestamp-$(TIMESTAMP)
-else
-ifeq ($(USING_PROFILING),1)
-PROFILING_BACKEND_SOURCES = \
- linux/mali_osk_profiling_gator.c
endif
endif
-# Add the profiling sources
-SRC += $(PROFILING_BACKEND_SOURCES)
-
ifeq ($(USING_MALI_PMM_TESTSUITE),1)
ccflags-y += -I$(DRIVER_DIR)/platform/mali_pmu_testing
endif
diff --git a/driver/src/devicedrv/mali/common/mali_gp.c b/driver/src/devicedrv/mali/common/mali_gp.c
index 1624e46..2110471 100644
--- a/driver/src/devicedrv/mali/common/mali_gp.c
+++ b/driver/src/devicedrv/mali/common/mali_gp.c
@@ -361,8 +361,8 @@ void mali_gp_job_start(struct mali_gp_core *core, struct mali_gp_job *job)
#if MALI_TIMELINE_PROFILING_ENABLED
_mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE | MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(0) | MALI_PROFILING_EVENT_REASON_SINGLE_HW_FLUSH,
- job->frame_builder_id, job->flush_id, 0, 0, 0);
- _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(0), job->pid, job->tid, 0, 0, 0);
+ mali_gp_job_get_frame_builder_id(job), mali_gp_job_get_flush_id(job), 0, 0, 0);
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START|MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(0), mali_gp_job_get_pid(job), mali_gp_job_get_tid(job), 0, 0, 0);
#endif
core->running_job = job;
@@ -480,9 +480,7 @@ static void mali_gp_bottom_half(void *data)
u32 irq_errors;
#if MALI_TIMELINE_PROFILING_ENABLED
-#if 0 /* Bottom half TLP logging is currently not supported */
- _mali_osk_profiling_add_event( MALI_PROFILING_EVENT_TYPE_START| MALI_PROFILING_EVENT_CHANNEL_SOFTWARE , _mali_osk_get_pid(), _mali_osk_get_tid()+11000, 0, 0, 0);
-#endif
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP(0), 0, 0);
#endif
mali_group_lock(core->group); /* Group lock grabbed in core handlers, but released in common group handler */
@@ -491,6 +489,9 @@ static void mali_gp_bottom_half(void *data)
{
MALI_PRINT_ERROR(("Interrupt bottom half of %s when core is OFF.", core->hw_core.description));
mali_group_unlock(core->group);
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0);
+#endif
return;
}
@@ -505,6 +506,9 @@ static void mali_gp_bottom_half(void *data)
mali_gp_post_process_job(core, MALI_FALSE);
MALI_DEBUG_PRINT(4, ("Mali GP: Job completed, calling group handler\n"));
mali_group_bottom_half(core->group, GROUP_EVENT_GP_JOB_COMPLETED); /* Will release group lock */
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0);
+#endif
return;
}
}
@@ -519,6 +523,9 @@ static void mali_gp_bottom_half(void *data)
mali_gp_post_process_job(core, MALI_FALSE);
MALI_PRINT_ERROR(("Mali GP: Unknown interrupt 0x%08X from core %s, aborting job\n", irq_readout, core->hw_core.description));
mali_group_bottom_half(core->group, GROUP_EVENT_GP_JOB_FAILED); /* Will release group lock */
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0);
+#endif
return;
}
else if (MALI_TRUE == core->core_timed_out) /* SW timeout */
@@ -530,6 +537,9 @@ static void mali_gp_bottom_half(void *data)
mali_group_bottom_half(core->group, GROUP_EVENT_GP_JOB_TIMED_OUT);
}
core->core_timed_out = MALI_FALSE;
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0);
+#endif
return;
}
else if (irq_readout & MALIGP2_REG_VAL_IRQ_PLBU_OUT_OF_MEM)
@@ -546,25 +556,30 @@ static void mali_gp_bottom_half(void *data)
mali_gp_post_process_job(core, MALI_TRUE);
MALI_DEBUG_PRINT(3, ("Mali GP: PLBU needs more heap memory\n"));
mali_group_bottom_half(core->group, GROUP_EVENT_GP_OOM); /* Will release group lock */
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0);
+#endif
return;
}
else if (irq_readout & MALIGP2_REG_VAL_IRQ_HANG)
{
- /* Just ignore hang interrupts, the job timer will detect hanging jobs anyways */
- mali_hw_core_register_write(&core->hw_core, MALIGP2_REG_ADDR_MGMT_INT_CLEAR, MALIGP2_REG_VAL_IRQ_HANG);
+ /* we mask hang interrupts, so this should never happen... */
+ MALI_DEBUG_ASSERT( 0 );
}
- /*
- * The only way to get here is if we got a HANG interrupt, which we ignore, or only one of two needed END_CMD_LST interrupts.
- * Re-enable interrupts and let core continue to run.
- */
- mali_hw_core_register_write(&core->hw_core, MALIGP2_REG_ADDR_MGMT_INT_MASK, MALIGP2_REG_VAL_IRQ_MASK_USED);
+ /* The only way to get here is if we only got one of two needed END_CMD_LST
+ * interrupts. Disable the interrupt that has been received and continue to
+ * run. */
+ mali_hw_core_register_write(&core->hw_core, MALIGP2_REG_ADDR_MGMT_INT_MASK,
+ MALIGP2_REG_VAL_IRQ_MASK_USED &
+ ((irq_readout & MALIGP2_REG_VAL_IRQ_PLBU_END_CMD_LST)
+ ? ~MALIGP2_REG_VAL_IRQ_PLBU_END_CMD_LST
+ : ~MALIGP2_REG_VAL_IRQ_VS_END_CMD_LST
+ ));
mali_group_unlock(core->group);
#if MALI_TIMELINE_PROFILING_ENABLED
-#if 0 /* Bottom half TLP logging is currently not supported */
- _mali_osk_profiling_add_event( MALI_PROFILING_EVENT_TYPE_STOP| MALI_PROFILING_EVENT_CHANNEL_SOFTWARE , _mali_osk_get_pid(), _mali_osk_get_tid()+11000, 0, 0, 0);
-#endif
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0);
#endif
}
diff --git a/driver/src/devicedrv/mali/common/mali_gp_job.c b/driver/src/devicedrv/mali/common/mali_gp_job.c
index abe1d93..2e445d6 100644
--- a/driver/src/devicedrv/mali/common/mali_gp_job.c
+++ b/driver/src/devicedrv/mali/common/mali_gp_job.c
@@ -13,29 +13,27 @@
#include "mali_osk_list.h"
#include "mali_uk_types.h"
-struct mali_gp_job *mali_gp_job_create(struct mali_session_data *session, _mali_uk_gp_start_job_s *args, u32 id)
+struct mali_gp_job *mali_gp_job_create(struct mali_session_data *session, _mali_uk_gp_start_job_s *uargs, u32 id)
{
struct mali_gp_job *job;
job = _mali_osk_malloc(sizeof(struct mali_gp_job));
if (NULL != job)
{
+ if (0 != copy_from_user(&job->uargs, uargs, sizeof(_mali_uk_gp_start_job_s)))
+ {
+ _mali_osk_free(job);
+ return NULL;
+ }
+
_mali_osk_list_init(&job->list);
job->session = session;
job->id = id;
- job->user_id = args->user_job_ptr;
- _mali_osk_memcpy(job->frame_registers, args->frame_registers, sizeof(job->frame_registers));
- job->heap_current_addr = args->frame_registers[4];
- job->perf_counter_flag = args->perf_counter_flag;
- job->perf_counter_src0 = args->perf_counter_src0;
- job->perf_counter_src1 = args->perf_counter_src1;
+ job->heap_current_addr = job->uargs.frame_registers[4];
job->perf_counter_value0 = 0;
job->perf_counter_value1 = 0;
-
job->pid = _mali_osk_get_pid();
job->tid = _mali_osk_get_tid();
- job->frame_builder_id = args->frame_builder_id;
- job->flush_id = args->flush_id;
return job;
}
diff --git a/driver/src/devicedrv/mali/common/mali_gp_job.h b/driver/src/devicedrv/mali/common/mali_gp_job.h
index 9c29f1c..7b45552 100644
--- a/driver/src/devicedrv/mali/common/mali_gp_job.h
+++ b/driver/src/devicedrv/mali/common/mali_gp_job.h
@@ -25,22 +25,16 @@ struct mali_gp_job
{
_mali_osk_list_t list; /**< Used to link jobs together in the scheduler queue */
struct mali_session_data *session; /**< Session which submitted this job */
+ _mali_uk_gp_start_job_s uargs; /**< Arguments from user space */
u32 id; /**< identifier for this job in kernel space (sequential numbering) */
- u32 user_id; /**< identifier for the job in user space */
- u32 frame_registers[MALIGP2_NUM_REGS_FRAME]; /**< core specific registers associated with this job, see ARM DDI0415A */
u32 heap_current_addr; /**< Holds the current HEAP address when the job has completed */
- u32 perf_counter_flag; /**< bitmask indicating which performance counters to enable, see \ref _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE and related macro definitions */
- u32 perf_counter_src0; /**< source id for performance counter 0 (see ARM DDI0415A, Table 3-60) */
- u32 perf_counter_src1; /**< source id for performance counter 1 (see ARM DDI0415A, Table 3-60) */
u32 perf_counter_value0; /**< Value of performance counter 0 (to be returned to user space) */
u32 perf_counter_value1; /**< Value of performance counter 1 (to be returned to user space) */
u32 pid; /**< Process ID of submitting process */
u32 tid; /**< Thread ID of submitting thread */
- u32 frame_builder_id; /**< id of the originating frame builder */
- u32 flush_id; /**< flush id within the originating frame builder */
};
-struct mali_gp_job *mali_gp_job_create(struct mali_session_data *session, _mali_uk_gp_start_job_s *args, u32 id);
+struct mali_gp_job *mali_gp_job_create(struct mali_session_data *session, _mali_uk_gp_start_job_s *uargs, u32 id);
void mali_gp_job_delete(struct mali_gp_job *job);
MALI_STATIC_INLINE u32 mali_gp_job_get_id(struct mali_gp_job *job)
@@ -50,22 +44,32 @@ MALI_STATIC_INLINE u32 mali_gp_job_get_id(struct mali_gp_job *job)
MALI_STATIC_INLINE u32 mali_gp_job_get_user_id(struct mali_gp_job *job)
{
- return job->user_id;
+ return job->uargs.user_job_ptr;
}
MALI_STATIC_INLINE u32 mali_gp_job_get_frame_builder_id(struct mali_gp_job *job)
{
- return job->frame_builder_id;
+ return job->uargs.frame_builder_id;
}
MALI_STATIC_INLINE u32 mali_gp_job_get_flush_id(struct mali_gp_job *job)
{
- return job->flush_id;
+ return job->uargs.flush_id;
+}
+
+MALI_STATIC_INLINE u32 mali_gp_job_get_pid(struct mali_gp_job *job)
+{
+ return job->pid;
+}
+
+MALI_STATIC_INLINE u32 mali_gp_job_get_tid(struct mali_gp_job *job)
+{
+ return job->tid;
}
MALI_STATIC_INLINE u32* mali_gp_job_get_frame_registers(struct mali_gp_job *job)
{
- return job->frame_registers;
+ return job->uargs.frame_registers;
}
MALI_STATIC_INLINE struct mali_session_data *mali_gp_job_get_session(struct mali_gp_job *job)
@@ -75,12 +79,12 @@ MALI_STATIC_INLINE struct mali_session_data *mali_gp_job_get_session(struct mali
MALI_STATIC_INLINE mali_bool mali_gp_job_has_vs_job(struct mali_gp_job *job)
{
- return (job->frame_registers[0] != job->frame_registers[1]) ? MALI_TRUE : MALI_FALSE;
+ return (job->uargs.frame_registers[0] != job->uargs.frame_registers[1]) ? MALI_TRUE : MALI_FALSE;
}
MALI_STATIC_INLINE mali_bool mali_gp_job_has_plbu_job(struct mali_gp_job *job)
{
- return (job->frame_registers[2] != job->frame_registers[3]) ? MALI_TRUE : MALI_FALSE;
+ return (job->uargs.frame_registers[2] != job->uargs.frame_registers[3]) ? MALI_TRUE : MALI_FALSE;
}
MALI_STATIC_INLINE u32 mali_gp_job_get_current_heap_addr(struct mali_gp_job *job)
@@ -95,17 +99,17 @@ MALI_STATIC_INLINE void mali_gp_job_set_current_heap_addr(struct mali_gp_job *jo
MALI_STATIC_INLINE u32 mali_gp_job_get_perf_counter_flag(struct mali_gp_job *job)
{
- return job->perf_counter_flag;
+ return job->uargs.perf_counter_flag;
}
MALI_STATIC_INLINE u32 mali_gp_job_get_perf_counter_src0(struct mali_gp_job *job)
{
- return job->perf_counter_src0;
+ return job->uargs.perf_counter_src0;
}
MALI_STATIC_INLINE u32 mali_gp_job_get_perf_counter_src1(struct mali_gp_job *job)
{
- return job->perf_counter_src1;
+ return job->uargs.perf_counter_src1;
}
MALI_STATIC_INLINE u32 mali_gp_job_get_perf_counter_value0(struct mali_gp_job *job)
diff --git a/driver/src/devicedrv/mali/common/mali_gp_scheduler.c b/driver/src/devicedrv/mali/common/mali_gp_scheduler.c
index f06d899..52fa15b 100644
--- a/driver/src/devicedrv/mali/common/mali_gp_scheduler.c
+++ b/driver/src/devicedrv/mali/common/mali_gp_scheduler.c
@@ -274,25 +274,17 @@ void mali_gp_scheduler_resume(void)
mali_gp_scheduler_unlock();
}
-_mali_osk_errcode_t _mali_ukk_gp_start_job(_mali_uk_gp_start_job_s *args)
+_mali_osk_errcode_t _mali_ukk_gp_start_job(void *ctx, _mali_uk_gp_start_job_s *uargs)
{
struct mali_session_data *session;
struct mali_gp_job *job;
- MALI_DEBUG_ASSERT_POINTER(args);
-
- if (NULL == args->ctx)
- {
- return _MALI_OSK_ERR_INVALID_ARGS;
- }
+ MALI_DEBUG_ASSERT_POINTER(uargs);
+ MALI_DEBUG_ASSERT_POINTER(ctx);
- session = (struct mali_session_data*)args->ctx;
- if (NULL == session)
- {
- return _MALI_OSK_ERR_FAULT;
- }
+ session = (struct mali_session_data*)ctx;
- job = mali_gp_job_create(session, args, mali_scheduler_get_new_id());
+ job = mali_gp_job_create(session, uargs, mali_scheduler_get_new_id());
if (NULL == job)
{
return _MALI_OSK_ERR_NOMEM;
diff --git a/driver/src/devicedrv/mali/common/mali_hw_core.h b/driver/src/devicedrv/mali/common/mali_hw_core.h
index c797804..b62e843 100644
--- a/driver/src/devicedrv/mali/common/mali_hw_core.h
+++ b/driver/src/devicedrv/mali/common/mali_hw_core.h
@@ -48,6 +48,20 @@ MALI_STATIC_INLINE void mali_hw_core_register_write_relaxed(struct mali_hw_core
_mali_osk_mem_iowrite32_relaxed(core->mapped_registers, relative_address, new_val);
}
+/* Conditionally write a register.
+ * The register will only be written if the new value is different from the old_value.
+ * If the new value is different, the old value will also be updated */
+MALI_STATIC_INLINE void mali_hw_core_register_write_relaxed_conditional(struct mali_hw_core *core, u32 relative_address, u32 new_val, const u32 old_val)
+{
+ MALI_DEBUG_PRINT(6, ("register_write_relaxed for core %s, relative addr=0x%04X, val=0x%08X\n",
+ core->description, relative_address, new_val));
+ if(old_val != new_val)
+ {
+ _mali_osk_mem_iowrite32_relaxed(core->mapped_registers, relative_address, new_val);
+ }
+}
+
+
MALI_STATIC_INLINE void mali_hw_core_register_write(struct mali_hw_core *core, u32 relative_address, u32 new_val)
{
MALI_DEBUG_PRINT(6, ("register_write for core %s, relative addr=0x%04X, val=0x%08X\n",
@@ -68,4 +82,23 @@ MALI_STATIC_INLINE void mali_hw_core_register_write_array_relaxed(struct mali_hw
}
}
+/* Conditionally write a set of registers.
+ * The register will only be written if the new value is different from the old_value.
+ * If the new value is different, the old value will also be updated */
+MALI_STATIC_INLINE void mali_hw_core_register_write_array_relaxed_conditional(struct mali_hw_core *core, u32 relative_address, u32 *write_array, u32 nr_of_regs, const u32* old_array)
+{
+ u32 i;
+ MALI_DEBUG_PRINT(6, ("register_write_array: for core %s, relative addr=0x%04X, nr of regs=%u\n",
+ core->description,relative_address, nr_of_regs));
+
+ /* Do not use burst writes against the registers */
+ for (i = 0; i< nr_of_regs; i++)
+ {
+ if(old_array[i] != write_array[i])
+ {
+ mali_hw_core_register_write_relaxed(core, relative_address + i*4, write_array[i]);
+ }
+ }
+}
+
#endif /* __MALI_HW_CORE_H__ */
diff --git a/driver/src/devicedrv/mali/common/mali_kernel_core.c b/driver/src/devicedrv/mali/common/mali_kernel_core.c
index 52cd8ea..f31c505 100644
--- a/driver/src/devicedrv/mali/common/mali_kernel_core.c
+++ b/driver/src/devicedrv/mali/common/mali_kernel_core.c
@@ -35,6 +35,10 @@
#if MALI_TIMELINE_PROFILING_ENABLED
#include "mali_osk_profiling.h"
#endif
+#if MALI_INTERNAL_TIMELINE_PROFILING_ENABLED
+#include "mali_profiling_internal.h"
+#endif
+
/** Pointer to table of resource definitions available to the Mali driver.
* _mali_osk_resources_init() sets up the pointer to this table.
diff --git a/driver/src/devicedrv/mali/common/mali_osk.h b/driver/src/devicedrv/mali/common/mali_osk.h
index e32d15d..c478057 100644
--- a/driver/src/devicedrv/mali/common/mali_osk.h
+++ b/driver/src/devicedrv/mali/common/mali_osk.h
@@ -1422,17 +1422,6 @@ void _mali_osk_notification_queue_term( _mali_osk_notification_queue_t *queue );
*/
void _mali_osk_notification_queue_send( _mali_osk_notification_queue_t *queue, _mali_osk_notification_t *object );
-#if MALI_STATE_TRACKING
-/** @brief Receive a notification from a queue
- *
- * Check if a notification queue is empty.
- *
- * @param queue The queue to check.
- * @return MALI_TRUE if queue is empty, otherwise MALI_FALSE.
- */
-mali_bool _mali_osk_notification_queue_is_empty( _mali_osk_notification_queue_t *queue );
-#endif
-
/** @brief Receive a notification from a queue
*
* Receives a single notification from the given queue.
diff --git a/driver/src/devicedrv/mali/common/mali_osk_profiling.h b/driver/src/devicedrv/mali/common/mali_osk_profiling.h
index fd9a8fb..bf1cf8c 100644
--- a/driver/src/devicedrv/mali/common/mali_osk_profiling.h
+++ b/driver/src/devicedrv/mali/common/mali_osk_profiling.h
@@ -11,12 +11,9 @@
#ifndef __MALI_OSK_PROFILING_H__
#define __MALI_OSK_PROFILING_H__
-#if MALI_TIMELINE_PROFILING_ENABLED
+#if MALI_TIMELINE_PROFILING_ENABLED && defined (CONFIG_TRACEPOINTS)
-#if defined (CONFIG_TRACEPOINTS) && !MALI_INTERNAL_TIMELINE_PROFILING_ENABLED
#include "mali_linux_trace.h"
-#endif /* CONFIG_TRACEPOINTS && !MALI_INTERNAL_TIMELINE_PROFILING_ENABLED */
-
#include "mali_profiling_events.h"
#define MALI_PROFILING_MAX_BUFFER_ENTRIES 1048576
@@ -59,13 +56,8 @@ _mali_osk_errcode_t _mali_osk_profiling_start(u32 * limit);
* @param data4 Fifth data parameter, depending on event_id specified.
* @return _MALI_OSK_ERR_OK on success, otherwise failure.
*/
-#if defined (CONFIG_TRACEPOINTS) && !MALI_INTERNAL_TIMELINE_PROFILING_ENABLED
/* Call Linux tracepoint directly */
#define _mali_osk_profiling_add_event(event_id, data0, data1, data2, data3, data4) trace_mali_timeline_event((event_id), (data0), (data1), (data2), (data3), (data4))
-#else
-/* Internal profiling is handled like a plain function call */
-void _mali_osk_profiling_add_event(u32 event_id, u32 data0, u32 data1, u32 data2, u32 data3, u32 data4);
-#endif
/**
* Report a hardware counter event.
@@ -74,13 +66,8 @@ void _mali_osk_profiling_add_event(u32 event_id, u32 data0, u32 data1, u32 data2
* @param value The value of the counter.
*/
-#if defined (CONFIG_TRACEPOINTS) && !MALI_INTERNAL_TIMELINE_PROFILING_ENABLED
/* Call Linux tracepoint directly */
#define _mali_osk_profiling_report_hw_counter(counter_id, value) trace_mali_hw_counter(counter_id, value)
-#else
-/* Internal profiling is handled like a plain function call */
-void _mali_osk_profiling_report_hw_counter(u32 counter_id, u32 value);
-#endif
/**
* Report SW counters
@@ -140,7 +127,12 @@ mali_bool _mali_osk_profiling_have_recording(void);
/** @} */ /* end group _mali_osk_profiling */
-#endif /* MALI_TIMELINE_PROFILING_ENABLED */
+#else
+ /* Dummy add_event, for when profiling is disabled. */
+
+#define _mali_osk_profiling_add_event(event_id, data0, data1, data2, data3, data4)
+
+#endif /* MALI_TIMELINE_PROFILING_ENABLED && defined(CONFIG_TRACEPOINTS*/
#endif /* __MALI_OSK_PROFILING_H__ */
diff --git a/driver/src/devicedrv/mali/common/mali_pp.c b/driver/src/devicedrv/mali/common/mali_pp.c
index 2b2846b..b525063 100644
--- a/driver/src/devicedrv/mali/common/mali_pp.c
+++ b/driver/src/devicedrv/mali/common/mali_pp.c
@@ -12,6 +12,7 @@
#include "mali_hw_core.h"
#include "mali_group.h"
#include "mali_osk.h"
+#include "mali_pp_scheduler.h"
#include "regs/mali_200_regs.h"
#include "mali_kernel_common.h"
#include "mali_kernel_core.h"
@@ -194,6 +195,55 @@ _mali_osk_errcode_t mali_pp_stop_bus_wait(struct mali_pp_core *core)
return _MALI_OSK_ERR_OK;
}
+/* Frame register reset values.
+ * Taken from the Mali400 TRM, 3.6. Pixel processor control register summary */
+static const u32 mali_frame_registers_reset_values[_MALI_PP_MAX_FRAME_REGISTERS] =
+{
+ 0x0, /* Renderer List Address Register */
+ 0x0, /* Renderer State Word Base Address Register */
+ 0x0, /* Renderer Vertex Base Register */
+ 0x2, /* Feature Enable Register */
+ 0x0, /* Z Clear Value Register */
+ 0x0, /* Stencil Clear Value Register */
+ 0x0, /* ABGR Clear Value 0 Register */
+ 0x0, /* ABGR Clear Value 1 Register */
+ 0x0, /* ABGR Clear Value 2 Register */
+ 0x0, /* ABGR Clear Value 3 Register */
+ 0x0, /* Bounding Box Left Right Register */
+ 0x0, /* Bounding Box Bottom Register */
+ 0x0, /* FS Stack Address Register */
+ 0x0, /* FS Stack Size and Initial Value Register */
+ 0x0, /* Reserved */
+ 0x0, /* Reserved */
+ 0x0, /* Origin Offset X Register */
+ 0x0, /* Origin Offset Y Register */
+ 0x75, /* Subpixel Specifier Register */
+ 0x0, /* Tiebreak mode Register */
+ 0x0, /* Polygon List Format Register */
+ 0x0, /* Scaling Register */
+ 0x0 /* Tilebuffer configuration Register */
+};
+
+/* WBx register reset values */
+static const u32 mali_wb_registers_reset_values[_MALI_PP_MAX_WB_REGISTERS] =
+{
+ 0x0, /* WBx Source Select Register */
+ 0x0, /* WBx Target Address Register */
+ 0x0, /* WBx Target Pixel Format Register */
+ 0x0, /* WBx Target AA Format Register */
+ 0x0, /* WBx Target Layout */
+ 0x0, /* WBx Target Scanline Length */
+ 0x0, /* WBx Target Flags Register */
+ 0x0, /* WBx MRT Enable Register */
+ 0x0, /* WBx MRT Offset Register */
+ 0x0, /* WBx Global Test Enable Register */
+ 0x0, /* WBx Global Test Reference Value Register */
+ 0x0 /* WBx Global Test Compare Function Register */
+};
+
+/* Performance Counter 0 Enable Register reset value */
+static const u32 mali_perf_cnt_enable_reset_value = 0;
+
_mali_osk_errcode_t mali_pp_hard_reset(struct mali_pp_core *core)
{
/* Bus must be stopped before calling this function */
@@ -251,6 +301,7 @@ _mali_osk_errcode_t mali_pp_reset(struct mali_pp_core *core)
mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_INT_MASK, 0); /* disable the IRQs */
+
#if defined(USING_MALI200)
/* On Mali-200, stop the bus, then do a hard reset of the core */
@@ -319,7 +370,10 @@ void mali_pp_job_start(struct mali_pp_core *core, struct mali_pp_job *job, u32 s
MALI_DEBUG_ASSERT_POINTER(core);
MALI_ASSERT_GROUP_LOCKED(core->group);
- mali_hw_core_register_write_array_relaxed(&core->hw_core, MALI200_REG_ADDR_FRAME, frame_registers, MALI200_NUM_REGS_FRAME);
+ mali_hw_core_register_write_array_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_FRAME, frame_registers, MALI200_NUM_REGS_FRAME, mali_frame_registers_reset_values);
+
+ _mali_osk_mem_barrier();
+
if (0 != sub_job)
{
/*
@@ -328,22 +382,34 @@ void mali_pp_job_start(struct mali_pp_core *core, struct mali_pp_job *job, u32 s
* but we need to patch these for all other sub jobs
*/
mali_hw_core_register_write_relaxed(&core->hw_core, MALI200_REG_ADDR_FRAME, mali_pp_job_get_addr_frame(job, sub_job));
- mali_hw_core_register_write_relaxed(&core->hw_core, MALI200_REG_ADDR_STACK, mali_pp_job_get_addr_stack(job, sub_job));
+ mali_hw_core_register_write_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_STACK, mali_pp_job_get_addr_stack(job, sub_job), mali_frame_registers_reset_values[MALI200_REG_ADDR_STACK/4]);
}
if (wb0_registers[0]) /* M200_WB0_REG_SOURCE_SELECT register */
{
- mali_hw_core_register_write_array_relaxed(&core->hw_core, MALI200_REG_ADDR_WB0, wb0_registers, MALI200_NUM_REGS_WBx);
+ mali_hw_core_register_write_array_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_WB0, wb0_registers, MALI200_NUM_REGS_WBx, mali_wb_registers_reset_values);
+ }
+ else
+ {
+ mali_hw_core_register_write_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_WB0, 0, mali_wb_registers_reset_values[0] );
}
if (wb1_registers[0]) /* M200_WB1_REG_SOURCE_SELECT register */
{
- mali_hw_core_register_write_array_relaxed(&core->hw_core, MALI200_REG_ADDR_WB1, wb1_registers, MALI200_NUM_REGS_WBx);
+ mali_hw_core_register_write_array_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_WB1, wb1_registers, MALI200_NUM_REGS_WBx, mali_wb_registers_reset_values);
+ }
+ else
+ {
+ mali_hw_core_register_write_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_WB1, 0, mali_wb_registers_reset_values[0] );
}
if (wb2_registers[0]) /* M200_WB2_REG_SOURCE_SELECT register */
{
- mali_hw_core_register_write_array_relaxed(&core->hw_core, MALI200_REG_ADDR_WB2, wb2_registers, MALI200_NUM_REGS_WBx);
+ mali_hw_core_register_write_array_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_WB2, wb2_registers, MALI200_NUM_REGS_WBx, mali_wb_registers_reset_values);
+ }
+ else
+ {
+ mali_hw_core_register_write_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_WB2, 0, mali_wb_registers_reset_values[0] );
}
/* This selects which performance counters we are reading */
@@ -352,13 +418,14 @@ void mali_pp_job_start(struct mali_pp_core *core, struct mali_pp_job *job, u32 s
/* global_config has enabled HW counters, this will override anything specified by user space */
if (MALI_HW_CORE_NO_COUNTER != core->counter_src0_used)
{
- mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_0_SRC, core->counter_src0_used);
- mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_0_ENABLE, MALI200_REG_VAL_PERF_CNT_ENABLE);
+ mali_hw_core_register_write_relaxed(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_0_SRC, core->counter_src0_used);
+ mali_hw_core_register_write_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_0_ENABLE, MALI200_REG_VAL_PERF_CNT_ENABLE, mali_perf_cnt_enable_reset_value);
+
}
if (MALI_HW_CORE_NO_COUNTER != core->counter_src1_used)
{
- mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_1_SRC, core->counter_src1_used);
- mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_1_ENABLE, MALI200_REG_VAL_PERF_CNT_ENABLE);
+ mali_hw_core_register_write_relaxed(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_1_SRC, core->counter_src1_used);
+ mali_hw_core_register_write_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_1_ENABLE, MALI200_REG_VAL_PERF_CNT_ENABLE, mali_perf_cnt_enable_reset_value);
}
}
else
@@ -370,15 +437,15 @@ void mali_pp_job_start(struct mali_pp_core *core, struct mali_pp_job *job, u32 s
if (perf_counter_flag & _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE)
{
core->counter_src0_used = mali_pp_job_get_perf_counter_src0(job);
- mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_0_SRC, core->counter_src0_used);
- mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_0_ENABLE, MALI200_REG_VAL_PERF_CNT_ENABLE);
+ mali_hw_core_register_write_relaxed(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_0_SRC, core->counter_src0_used);
+ mali_hw_core_register_write_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_0_ENABLE, MALI200_REG_VAL_PERF_CNT_ENABLE, mali_perf_cnt_enable_reset_value);
}
if (perf_counter_flag & _MALI_PERFORMANCE_COUNTER_FLAG_SRC1_ENABLE)
{
core->counter_src1_used = mali_pp_job_get_perf_counter_src1(job);
- mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_1_SRC, core->counter_src1_used);
- mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_1_ENABLE, MALI200_REG_VAL_PERF_CNT_ENABLE);
+ mali_hw_core_register_write_relaxed(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_1_SRC, core->counter_src1_used);
+ mali_hw_core_register_write_relaxed_conditional(&core->hw_core, MALI200_REG_ADDR_MGMT_PERF_CNT_1_ENABLE, MALI200_REG_VAL_PERF_CNT_ENABLE, mali_perf_cnt_enable_reset_value);
}
}
}
@@ -399,8 +466,8 @@ void mali_pp_job_start(struct mali_pp_core *core, struct mali_pp_job *job, u32 s
core->timeout_job_id = mali_pp_job_get_id(job);
#if MALI_TIMELINE_PROFILING_ENABLED
- _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE | MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_id) | MALI_PROFILING_EVENT_REASON_SINGLE_HW_FLUSH, job->frame_builder_id, job->flush_id, 0, 0, 0);
- _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START|MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_id), job->pid, job->tid, 0, 0, 0);
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE | MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_id) | MALI_PROFILING_EVENT_REASON_SINGLE_HW_FLUSH, mali_pp_job_get_frame_builder_id(job), mali_pp_job_get_flush_id(job), 0, 0, 0);
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START|MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(core->core_id), mali_pp_job_get_pid(job), mali_pp_job_get_tid(job), 0, 0, 0);
#endif
core->running_job = job;
@@ -498,9 +565,7 @@ static void mali_pp_bottom_half(void *data)
u32 irq_errors;
#if MALI_TIMELINE_PROFILING_ENABLED
-#if 0 /* Bottom half TLP logging is currently not supported */
- _mali_osk_profiling_add_event( MALI_PROFILING_EVENT_TYPE_START| MALI_PROFILING_EVENT_CHANNEL_SOFTWARE , _mali_osk_get_pid(), _mali_osk_get_tid(), 0, 0, 0);
-#endif
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP(core->core_id), 0, 0);
#endif
mali_group_lock(core->group); /* Group lock grabbed in core handlers, but released in common group handler */
@@ -509,6 +574,9 @@ static void mali_pp_bottom_half(void *data)
{
MALI_PRINT_ERROR(("Interrupt bottom half of %s when core is OFF.", core->hw_core.description));
mali_group_unlock(core->group);
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0);
+#endif
return;
}
@@ -521,6 +589,9 @@ static void mali_pp_bottom_half(void *data)
mali_pp_post_process_job(core);
MALI_DEBUG_PRINT(3, ("Mali PP: Job completed, calling group handler\n"));
mali_group_bottom_half(core->group, GROUP_EVENT_PP_JOB_COMPLETED); /* Will release group lock */
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0);
+#endif
return;
}
@@ -535,6 +606,9 @@ static void mali_pp_bottom_half(void *data)
MALI_PRINT_ERROR(("Mali PP: Unknown interrupt 0x%08X from core %s, aborting job\n",
irq_readout, core->hw_core.description));
mali_group_bottom_half(core->group, GROUP_EVENT_PP_JOB_FAILED); /* Will release group lock */
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0);
+#endif
return;
}
else if (MALI_TRUE == core->core_timed_out) /* SW timeout */
@@ -551,6 +625,9 @@ static void mali_pp_bottom_half(void *data)
mali_group_unlock(core->group);
}
core->core_timed_out = MALI_FALSE;
+#if MALI_TIMELINE_PROFILING_ENABLED
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0);
+#endif
return;
}
else if (irq_readout & MALI200_REG_VAL_IRQ_HANG)
@@ -567,9 +644,7 @@ static void mali_pp_bottom_half(void *data)
mali_group_unlock(core->group);
#if MALI_TIMELINE_PROFILING_ENABLED
-#if 0 /* Bottom half TLP logging is currently not supported */
- _mali_osk_profiling_add_event( MALI_PROFILING_EVENT_TYPE_STOP| MALI_PROFILING_EVENT_CHANNEL_SOFTWARE , _mali_osk_get_pid(), _mali_osk_get_tid(), 0, 0, 0);
-#endif
+ _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF, 0, _mali_osk_get_tid(), 0, 0, 0);
#endif
}
diff --git a/driver/src/devicedrv/mali/common/mali_pp_job.c b/driver/src/devicedrv/mali/common/mali_pp_job.c
index 47b8a0a..3c23637 100644
--- a/driver/src/devicedrv/mali/common/mali_pp_job.c
+++ b/driver/src/devicedrv/mali/common/mali_pp_job.c
@@ -14,65 +14,41 @@
#include "mali_kernel_common.h"
#include "mali_uk_types.h"
-struct mali_pp_job *mali_pp_job_create(struct mali_session_data *session, _mali_uk_pp_start_job_s *args, u32 id)
+struct mali_pp_job *mali_pp_job_create(struct mali_session_data *session, _mali_uk_pp_start_job_s *uargs, u32 id)
{
struct mali_pp_job *job;
- if (args->num_cores > _MALI_PP_MAX_SUB_JOBS)
- {
- MALI_PRINT_ERROR(("Mali PP job: Too many sub jobs specified in job object\n"));
- return NULL;
- }
-
job = _mali_osk_malloc(sizeof(struct mali_pp_job));
if (NULL != job)
{
u32 i;
- _mali_osk_list_init(&job->list);
- job->session = session;
- job->id = id;
- job->user_id = args->user_job_ptr;
- job->barrier = args->flags & _MALI_PP_JOB_FLAG_BARRIER ? MALI_TRUE : MALI_FALSE;
- job->active_barrier = job->barrier;
- job->no_notification = args->flags & _MALI_PP_JOB_FLAG_NO_NOTIFICATION ? MALI_TRUE : MALI_FALSE;
- _mali_osk_memcpy(job->frame_registers, args->frame_registers, sizeof(job->frame_registers));
- _mali_osk_memcpy(job->frame_registers_addr_frame, args->frame_registers_addr_frame, sizeof(job->frame_registers_addr_frame));
- _mali_osk_memcpy(job->frame_registers_addr_stack, args->frame_registers_addr_stack, sizeof(job->frame_registers_addr_stack));
- /* Only copy write back registers for the units that are enabled */
- job->wb0_registers[0] = 0;
- job->wb1_registers[0] = 0;
- job->wb2_registers[0] = 0;
- if (args->wb0_registers[0]) /* M200_WB0_REG_SOURCE_SELECT register */
- {
- _mali_osk_memcpy(job->wb0_registers, args->wb0_registers, sizeof(job->wb0_registers));
- }
- if (args->wb1_registers[0]) /* M200_WB1_REG_SOURCE_SELECT register */
+ if (0 != _mali_osk_copy_from_user(&job->uargs, uargs, sizeof(_mali_uk_pp_start_job_s)))
{
- _mali_osk_memcpy(job->wb1_registers, args->wb1_registers, sizeof(job->wb1_registers));
+ _mali_osk_free(job);
+ return NULL;
}
- if (args->wb2_registers[0]) /* M200_WB2_REG_SOURCE_SELECT register */
+
+ if (job->uargs.num_cores > _MALI_PP_MAX_SUB_JOBS)
{
- _mali_osk_memcpy(job->wb2_registers, args->wb2_registers, sizeof(job->wb2_registers));
+ MALI_PRINT_ERROR(("Mali PP job: Too many sub jobs specified in job object\n"));
+ _mali_osk_free(job);
+ return NULL;
}
- job->perf_counter_flag = args->perf_counter_flag;
- job->perf_counter_src0 = args->perf_counter_src0;
- job->perf_counter_src1 = args->perf_counter_src1;
- for (i = 0; i < args->num_cores; i++)
+ _mali_osk_list_init(&job->list);
+ job->session = session;
+ job->id = id;
+ for (i = 0; i < job->uargs.num_cores; i++)
{
job->perf_counter_value0[i] = 0;
job->perf_counter_value1[i] = 0;
}
- job->sub_job_count = args->num_cores;
job->sub_jobs_started = 0;
job->sub_jobs_completed = 0;
job->sub_job_errors = 0;
-
job->pid = _mali_osk_get_pid();
job->tid = _mali_osk_get_tid();
- job->frame_builder_id = args->frame_builder_id;
- job->flush_id = args->flush_id;
return job;
}
@@ -84,12 +60,3 @@ void mali_pp_job_delete(struct mali_pp_job *job)
{
_mali_osk_free(job);
}
-
-_mali_osk_errcode_t mali_pp_job_check(struct mali_pp_job *job)
-{
- if ((0 == job->frame_registers[0]) || (0 == job->frame_registers[1]))
- {
- return _MALI_OSK_ERR_FAULT;
- }
- return _MALI_OSK_ERR_OK;
-}
diff --git a/driver/src/devicedrv/mali/common/mali_pp_job.h b/driver/src/devicedrv/mali/common/mali_pp_job.h
index 4399c1d..7e25504 100644
--- a/driver/src/devicedrv/mali/common/mali_pp_job.h
+++ b/driver/src/devicedrv/mali/common/mali_pp_job.h
@@ -27,40 +27,28 @@ struct mali_pp_job
{
_mali_osk_list_t list; /**< Used to link jobs together in the scheduler queue */
struct mali_session_data *session; /**< Session which submitted this job */
+ _mali_uk_pp_start_job_s uargs; /**< Arguments from user space */
u32 id; /**< identifier for this job in kernel space (sequencial numbering) */
- u32 user_id; /**< identifier for the job in user space */
- u32 frame_registers[_MALI_PP_MAX_FRAME_REGISTERS]; /**< core specific registers associated with this job, see ARM DDI0415A */
- u32 frame_registers_addr_frame[_MALI_PP_MAX_SUB_JOBS - 1]; /**< ADDR_FRAME registers for sub job 1-7 */
- u32 frame_registers_addr_stack[_MALI_PP_MAX_SUB_JOBS - 1]; /**< ADDR_STACK registers for sub job 1-7 */
- u32 wb0_registers[_MALI_PP_MAX_WB_REGISTERS]; /**< Write back unit 0 registers */
- u32 wb1_registers[_MALI_PP_MAX_WB_REGISTERS]; /**< Write back unit 1 registers */
- u32 wb2_registers[_MALI_PP_MAX_WB_REGISTERS]; /**< Write back unit 2 registers */
- u32 perf_counter_flag; /**< bitmask indicating which performance counters to enable, see \ref _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE and related macro definitions */
- u32 perf_counter_src0; /**< Source id for performance counter 0 (see ARM DDI0415A, Table 3-60) */
- u32 perf_counter_src1; /**< Source id for performance counter 1 (see ARM DDI0415A, Table 3-60) */
u32 perf_counter_value0[_MALI_PP_MAX_SUB_JOBS]; /**< Value of performance counter 0 (to be returned to user space), one for each sub job */
- u32 perf_counter_value1[_MALI_PP_MAX_SUB_JOBS]; /**< Value of performance counter 1 (to be returned to user space), one for each sub job */
- u32 sub_job_count; /**< Total number of sub-jobs in this superjob */
+ u32 perf_counter_value1[_MALI_PP_MAX_SUB_JOBS]; /**< Value of performance counter 1 (to be returned to user space), one for each sub job */
u32 sub_jobs_started; /**< Total number of sub-jobs started (always started in ascending order) */
u32 sub_jobs_completed; /**< Number of completed sub-jobs in this superjob */
u32 sub_job_errors; /**< Bitfield with errors (errors for each single sub-job is or'ed together) */
u32 pid; /**< Process ID of submitting process */
u32 tid; /**< Thread ID of submitting thread */
- u32 frame_builder_id; /**< id of the originating frame builder */
- u32 flush_id; /**< flush id within the originating frame builder */
- mali_bool barrier; /**< [in] MALI_TRUE means wait for all my previous jobs to complete before scheduling this one */
- mali_bool active_barrier; /**< [in] Changes from MALI_TRUE to MALI_FALSE when barrier has been resolved */
- mali_bool no_notification; /**< [in] MALI_TRUE means do not notify user space when this job has completed */
};
-struct mali_pp_job *mali_pp_job_create(struct mali_session_data *session, _mali_uk_pp_start_job_s *args, u32 id);
+struct mali_pp_job *mali_pp_job_create(struct mali_session_data *session, _mali_uk_pp_start_job_s *uargs, u32 id);
void mali_pp_job_delete(struct mali_pp_job *job);
-_mali_osk_errcode_t mali_pp_job_check(struct mali_pp_job *job);
-
-/******************************************************
- * simple utility functions for dealing with pp jobs:
- *****************************************************/
+MALI_STATIC_INLINE _mali_osk_errcode_t mali_pp_job_check(struct mali_pp_job *job)
+{
+ if ((0 == job->uargs.frame_registers[0]) || (0 == job->uargs.frame_registers[1]))
+ {
+ return _MALI_OSK_ERR_FAULT;
+ }
+ return _MALI_OSK_ERR_OK;
+}
MALI_STATIC_INLINE u32 mali_pp_job_get_id(struct mali_pp_job *job)
{
@@ -69,33 +57,43 @@ MALI_STATIC_INLINE u32 mali_pp_job_get_id(struct mali_pp_job *job)
MALI_STATIC_INLINE u32 mali_pp_job_get_user_id(struct mali_pp_job *job)
{
- return job->user_id;
+ return job->uargs.user_job_ptr;
}
MALI_STATIC_INLINE u32 mali_pp_job_get_frame_builder_id(struct mali_pp_job *job)
{
- return job->frame_builder_id;
+ return job->uargs.frame_builder_id;
}
MALI_STATIC_INLINE u32 mali_pp_job_get_flush_id(struct mali_pp_job *job)
{
- return job->flush_id;
+ return job->uargs.flush_id;
+}
+
+MALI_STATIC_INLINE u32 mali_pp_job_get_pid(struct mali_pp_job *job)
+{
+ return job->pid;
+}
+
+MALI_STATIC_INLINE u32 mali_pp_job_get_tid(struct mali_pp_job *job)
+{
+ return job->tid;
}
MALI_STATIC_INLINE u32* mali_pp_job_get_frame_registers(struct mali_pp_job *job)
{
- return job->frame_registers;
+ return job->uargs.frame_registers;
}
MALI_STATIC_INLINE u32 mali_pp_job_get_addr_frame(struct mali_pp_job *job, u32 sub_job)
{
if (sub_job == 0)
{
- return job->frame_registers[MALI200_REG_ADDR_FRAME / sizeof(u32)];
+ return job->uargs.frame_registers[MALI200_REG_ADDR_FRAME / sizeof(u32)];
}
else if (sub_job < _MALI_PP_MAX_SUB_JOBS)
{
- return job->frame_registers_addr_frame[sub_job - 1];
+ return job->uargs.frame_registers_addr_frame[sub_job - 1];
}
return 0;
@@ -105,11 +103,11 @@ MALI_STATIC_INLINE u32 mali_pp_job_get_addr_stack(struct mali_pp_job *job, u32 s
{
if (sub_job == 0)
{
- return job->frame_registers[MALI200_REG_ADDR_STACK / sizeof(u32)];
+ return job->uargs.frame_registers[MALI200_REG_ADDR_STACK / sizeof(u32)];
}
else if (sub_job < _MALI_PP_MAX_SUB_JOBS)
{
- return job->frame_registers_addr_stack[sub_job - 1];
+ return job->uargs.frame_registers_addr_stack[sub_job - 1];
}
return 0;
@@ -117,32 +115,32 @@ MALI_STATIC_INLINE u32 mali_pp_job_get_addr_stack(struct mali_pp_job *job, u32 s
MALI_STATIC_INLINE u32* mali_pp_job_get_wb0_registers(struct mali_pp_job *job)
{
- return job->wb0_registers;
+ return job->uargs.wb0_registers;
}
MALI_STATIC_INLINE u32* mali_pp_job_get_wb1_registers(struct mali_pp_job *job)
{
- return job->wb1_registers;
+ return job->uargs.wb1_registers;
}
MALI_STATIC_INLINE u32* mali_pp_job_get_wb2_registers(struct mali_pp_job *job)
{
- return job->wb2_registers;
+ return job->uargs.wb2_registers;
}
MALI_STATIC_INLINE void mali_pp_job_disable_wb0(struct mali_pp_job *job)
{
- job->wb0_registers[MALI200_REG_ADDR_WB_SOURCE_SELECT] = 0;
+ job->uargs.wb0_registers[MALI200_REG_ADDR_WB_SOURCE_SELECT] = 0;
}
MALI_STATIC_INLINE void mali_pp_job_disable_wb1(struct mali_pp_job *job)
{
- job->wb1_registers[MALI200_REG_ADDR_WB_SOURCE_SELECT] = 0;
+ job->uargs.wb1_registers[MALI200_REG_ADDR_WB_SOURCE_SELECT] = 0;
}
MALI_STATIC_INLINE void mali_pp_job_disable_wb2(struct mali_pp_job *job)
{
- job->wb2_registers[MALI200_REG_ADDR_WB_SOURCE_SELECT] = 0;
+ job->uargs.wb2_registers[MALI200_REG_ADDR_WB_SOURCE_SELECT] = 0;
}
MALI_STATIC_INLINE struct mali_session_data *mali_pp_job_get_session(struct mali_pp_job *job)
@@ -152,7 +150,7 @@ MALI_STATIC_INLINE struct mali_session_data *mali_pp_job_get_session(struct mali
MALI_STATIC_INLINE mali_bool mali_pp_job_has_unstarted_sub_jobs(struct mali_pp_job *job)
{
- return (job->sub_jobs_started < job->sub_job_count) ? MALI_TRUE : MALI_FALSE;
+ return (job->sub_jobs_started < job->uargs.num_cores) ? MALI_TRUE : MALI_FALSE;
}
/* Function used when we are terminating a session with jobs. Return TRUE if it has a rendering job.
@@ -160,7 +158,7 @@ MALI_STATIC_INLINE mali_bool mali_pp_job_has_unstarted_sub_jobs(struct mali_pp_j
MALI_STATIC_INLINE mali_bool mali_pp_job_is_currently_rendering_and_if_so_abort_new_starts(struct mali_pp_job *job)
{
/* All can not be started, since then it would not be in the job queue */
- MALI_DEBUG_ASSERT( job->sub_jobs_started != job->sub_job_count );
+ MALI_DEBUG_ASSERT( job->sub_jobs_started != job->uargs.num_cores );
/* If at least one job is started */
if ( (job->sub_jobs_started > 0) )
@@ -168,7 +166,7 @@ MALI_STATIC_INLINE mali_bool mali_pp_job_is_currently_rendering_and_if_so_abort_
/* If at least one job is currently being rendered, and thus assigned to a group and core */
if (job->sub_jobs_started > job->sub_jobs_completed )
{
- u32 jobs_remaining = job->sub_job_count - job->sub_jobs_started;
+ u32 jobs_remaining = job->uargs.num_cores - job->sub_jobs_started;
job->sub_jobs_started += jobs_remaining;
job->sub_jobs_completed += jobs_remaining;
job->sub_job_errors += jobs_remaining;
@@ -182,7 +180,7 @@ MALI_STATIC_INLINE mali_bool mali_pp_job_is_currently_rendering_and_if_so_abort_
MALI_STATIC_INLINE mali_bool mali_pp_job_is_complete(struct mali_pp_job *job)
{
- return (job->sub_job_count == job->sub_jobs_completed) ? MALI_TRUE : MALI_FALSE;
+ return (job->uargs.num_cores == job->sub_jobs_completed) ? MALI_TRUE : MALI_FALSE;
}
MALI_STATIC_INLINE u32 mali_pp_job_get_first_unstarted_sub_job(struct mali_pp_job *job)
@@ -192,7 +190,7 @@ MALI_STATIC_INLINE u32 mali_pp_job_get_first_unstarted_sub_job(struct mali_pp_jo
MALI_STATIC_INLINE u32 mali_pp_job_get_sub_job_count(struct mali_pp_job *job)
{
- return job->sub_job_count;
+ return job->uargs.num_cores;
}
MALI_STATIC_INLINE void mali_pp_job_mark_sub_job_started(struct mali_pp_job *job, u32 sub_job)
@@ -202,6 +200,15 @@ MALI_STATIC_INLINE void mali_pp_job_mark_sub_job_started(struct mali_pp_job *job
job->sub_jobs_started++;
}
+MALI_STATIC_INLINE void mali_pp_job_mark_sub_job_not_stated(struct mali_pp_job *job, u32 sub_job)
+{
+ /* This is only safe on Mali-200. */
+#if !defined(USING_MALI200)
+ MALI_DEBUG_ASSERT(0);
+#endif
+ job->sub_jobs_started--;
+}
+
MALI_STATIC_INLINE void mali_pp_job_mark_sub_job_completed(struct mali_pp_job *job, mali_bool success)
{
job->sub_jobs_completed++;
@@ -222,32 +229,32 @@ MALI_STATIC_INLINE mali_bool mali_pp_job_was_success(struct mali_pp_job *job)
MALI_STATIC_INLINE mali_bool mali_pp_job_has_active_barrier(struct mali_pp_job *job)
{
- return job->active_barrier;
+ return job->uargs.flags & _MALI_PP_JOB_FLAG_BARRIER ? MALI_TRUE : MALI_FALSE;
}
MALI_STATIC_INLINE void mali_pp_job_barrier_enforced(struct mali_pp_job *job)
{
- job->active_barrier = MALI_FALSE;
+ job->uargs.flags &= ~_MALI_PP_JOB_FLAG_BARRIER;
}
MALI_STATIC_INLINE mali_bool mali_pp_job_use_no_notification(struct mali_pp_job *job)
{
- return job->no_notification;
+ return job->uargs.flags & _MALI_PP_JOB_FLAG_NO_NOTIFICATION ? MALI_TRUE : MALI_FALSE;
}
MALI_STATIC_INLINE u32 mali_pp_job_get_perf_counter_flag(struct mali_pp_job *job)
{
- return job->perf_counter_flag;
+ return job->uargs.perf_counter_flag;
}
MALI_STATIC_INLINE u32 mali_pp_job_get_perf_counter_src0(struct mali_pp_job *job)
{
- return job->perf_counter_src0;
+ return job->uargs.perf_counter_src0;
}
MALI_STATIC_INLINE u32 mali_pp_job_get_perf_counter_src1(struct mali_pp_job *job)
{
- return job->perf_counter_src1;
+ return job->uargs.perf_counter_src1;
}
MALI_STATIC_INLINE u32 mali_pp_job_get_perf_counter_value0(struct mali_pp_job *job, u32 sub_job)
diff --git a/driver/src/devicedrv/mali/common/mali_pp_scheduler.c b/driver/src/devicedrv/mali/common/mali_pp_scheduler.c
index a944055..eedf661 100644
--- a/driver/src/devicedrv/mali/common/mali_pp_scheduler.c
+++ b/driver/src/devicedrv/mali/common/mali_pp_scheduler.c
@@ -17,6 +17,8 @@
#include "mali_pp_job.h"
#include "mali_group.h"
#include "mali_cluster.h"
+#include "mali_osk_profiling.h"
+
/* Maximum of 8 PP cores (a group can only have maximum of 1 PP core) */
#define MALI_MAX_NUMBER_OF_PP_GROUPS 8
@@ -39,10 +41,14 @@ struct mali_pp_slot
*/
enum mali_pp_slot_state state;
struct mali_session_data *session;
+ struct mali_pp_job *job;
+ u32 subjob;
};
static u32 pp_version = 0;
static _MALI_OSK_LIST_HEAD(job_queue); /* List of jobs with some unscheduled work */
+static u32 job_queue_depth;
+
static struct mali_pp_slot slots[MALI_MAX_NUMBER_OF_PP_GROUPS];
static u32 num_slots = 0;
static u32 num_slots_idle = 0;
@@ -61,7 +67,7 @@ _mali_osk_errcode_t mali_pp_scheduler_initialize(void)
_MALI_OSK_INIT_LIST_HEAD(&job_queue);
- pp_scheduler_lock = _mali_osk_lock_init(_MALI_OSK_LOCKFLAG_ORDERED |_MALI_OSK_LOCKFLAG_NONINTERRUPTABLE, 0, _MALI_OSK_LOCK_ORDER_SCHEDULER);
+ pp_scheduler_lock = _mali_osk_lock_init(_MALI_OSK_LOCKFLAG_ORDERED | _MALI_OSK_LOCKFLAG_SPINLOCK_IRQ |_MALI_OSK_LOCKFLAG_NONINTERRUPTABLE, 0, _MALI_OSK_LOCK_ORDER_SCHEDULER);
if (NULL == pp_scheduler_lock)
{
return _MALI_OSK_ERR_NOMEM;
@@ -154,7 +160,7 @@ static mali_bool mali_pp_scheduler_session_has_running_jobs(struct mali_session_
for (i = 0; i < num_slots; i++)
{
if (MALI_PP_SLOT_STATE_WORKING == slots[i].state)
- {
+ {
if (slots[i].session == session)
{
return MALI_TRUE;
@@ -165,131 +171,123 @@ static mali_bool mali_pp_scheduler_session_has_running_jobs(struct mali_session_
return MALI_FALSE;
}
+static mali_bool slots_available(void)
+{
+ return num_slots_idle > 0;
+}
+
static void mali_pp_scheduler_schedule(void)
{
- u32 i;
struct mali_pp_job *job;
-#if MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP_BETWEEN_APPS
- struct mali_session_data * session;
-#endif
-
- MALI_ASSERT_PP_SCHEDULER_LOCKED();
- if (0 < pause_count || 0 == num_slots_idle || _mali_osk_list_empty(&job_queue))
+ if (0 < pause_count || 0 == num_slots_idle || 0 == job_queue_depth)
{
MALI_DEBUG_PRINT(4, ("Mali PP scheduler: Nothing to schedule (paused=%u, idle slots=%u)\n",
pause_count, num_slots_idle));
return; /* Nothing to do, so early out */
}
-
-#if MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP
- if ( num_slots_idle < num_slots )
- {
- MALI_DEBUG_PRINT(4, ("Mali PP scheduler: Job not started, since only %d/%d cores are available\n", num_slots_idle,num_slots));
- return;
- }
-#endif
-
-#if MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP_BETWEEN_APPS
- /* Finding initial session for the PP cores */
- job = _MALI_OSK_LIST_ENTRY(job_queue.next, struct mali_pp_job, list);
- session = job->session;
- if ( num_slots != num_slots_idle )
- {
- for (i = 0; (i < num_slots) ; i++)
- {
- if ( slots[i].state == MALI_PP_SLOT_STATE_IDLE )
- {
- continue;
- }
- session = mali_group_get_session(slots[i].group);
- break;
- }
- }
-#endif
-
- for (i = 0; (i < num_slots) && (0 < num_slots_idle); i++)
+ while(slots_available() && 0 < job_queue_depth)
{
- u32 sub_job;
+ u32 i, slot_count;
+ struct mali_pp_slot *reserved_slots[num_slots];
+ struct mali_session_data *session;
- if (_mali_osk_list_empty(&job_queue)) /* move this check down to where we know we have started all sub jobs for this job??? */
+ mali_pp_scheduler_lock();
+ /* Get job */
+ if (_mali_osk_list_empty(&job_queue) || !slots_available())
{
+ mali_pp_scheduler_unlock();
break; /* No more jobs to schedule, so early out */
}
-
- if (MALI_PP_SLOT_STATE_IDLE != slots[i].state)
- {
- continue;
- }
-
job = _MALI_OSK_LIST_ENTRY(job_queue.next, struct mali_pp_job, list);
MALI_DEBUG_ASSERT(mali_pp_job_has_unstarted_sub_jobs(job)); /* All jobs on the job_queue should have unstarted sub jobs */
+ session = mali_pp_job_get_session(job);
if (MALI_TRUE == mali_pp_job_has_active_barrier(job))
{
if (MALI_TRUE == mali_pp_scheduler_session_has_running_jobs(mali_pp_job_get_session(job)))
{
- /* There is already a running job from this session, so we need to enforce the barrier */
+ /* There is already a running job from this
+ * session, so we need to enforce the barrier */
+ mali_pp_scheduler_unlock();
return;
}
else
{
- /* Barrier is now enforced, update job object so we don't delay execution of sub-jobs */
+ /* Barrier is now enforced, update job object
+ * so we don't delay execution of sub-jobs */
mali_pp_job_barrier_enforced(job);
}
}
- #if MALI_PP_SCHEDULER_KEEP_SUB_JOB_STARTS_ALIGNED
- if ( (0==job->sub_jobs_started) && (num_slots_idle < num_slots) && (job->sub_job_count > num_slots_idle))
+ /* Reserve slots */
+ for (i = 0, slot_count = 0; i < num_slots; i++)
{
- MALI_DEBUG_PRINT(4, ("Mali PP scheduler: Job with %d subjobs not started, since only %d/%d cores are available\n", job->sub_job_count, num_slots_idle,num_slots));
- return;
- }
- #endif
+ struct mali_pp_slot *slot = &slots[i];
- #if MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP_BETWEEN_APPS
- if ( job->session != session )
- {
- MALI_DEBUG_PRINT(4, ("Mali PP scheduler: Job not started since existing job is from another application\n"));
- return;
+ if (MALI_PP_SLOT_STATE_IDLE != slot->state) continue;
+
+ slot->state = MALI_PP_SLOT_STATE_WORKING;
+ slot->session = session;
+ slot->job = job;
+ slot->subjob = mali_pp_job_get_first_unstarted_sub_job(job);
+ mali_pp_job_mark_sub_job_started(job, slot->subjob);
+ --job_queue_depth;
+
+ --num_slots_idle;
+ reserved_slots[slot_count++] = slot;
+
+ if (!mali_pp_job_has_unstarted_sub_jobs(job))
+ {
+ _mali_osk_list_del(&job->list);
+ break;
+ }
}
- #endif
- sub_job = mali_pp_job_get_first_unstarted_sub_job(job);
+ MALI_DEBUG_ASSERT(0 < slot_count);
+
+ mali_pp_scheduler_unlock();
- MALI_DEBUG_PRINT(4, ("Mali PP scheduler: Starting job %u (0x%08X) part %u/%u\n", mali_pp_job_get_id(job), job, sub_job + 1, mali_pp_job_get_sub_job_count(job)));
- if (_MALI_OSK_ERR_OK == mali_group_start_pp_job(slots[i].group, job, sub_job))
+ /* Start (sub)job(s) on core(s) */
+ for(i = 0; i < slot_count; i++)
{
- MALI_DEBUG_PRINT(4, ("Mali PP scheduler: Job %u (0x%08X) part %u/%u started\n", mali_pp_job_get_id(job), job, sub_job + 1, mali_pp_job_get_sub_job_count(job)));
+ struct mali_pp_slot *slot = reserved_slots[i];
+ struct mali_pp_job *job;
+ u32 subjob;
- /* Mark this sub job as started */
- mali_pp_job_mark_sub_job_started(job, sub_job);
+ MALI_DEBUG_ASSERT_POINTER(slot);
+ MALI_DEBUG_ASSERT(MALI_PP_SLOT_STATE_WORKING == slot->state);
+ MALI_DEBUG_ASSERT_POINTER(slot->job);
- /* Mark slot as busy */
- slots[i].state = MALI_PP_SLOT_STATE_WORKING;
- slots[i].session = mali_pp_job_get_session(job);
- num_slots_idle--;
+ job = slot->job;
+ subjob = slot->subjob;
- if (!mali_pp_job_has_unstarted_sub_jobs(job))
+ if (_MALI_OSK_ERR_OK == mali_group_start_pp_job(slot->group, slot->job, slot->subjob))
{
- /*
- * All sub jobs have now started for this job, remove this job from the job queue.
- * The job will now only be referred to by the slots which are running it.
- * The last slot to complete will make sure it is returned to user space.
- */
- _mali_osk_list_del(&job->list);
-#if MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP
- MALI_DEBUG_PRINT(6, ("Mali PP scheduler: Skip scheduling more jobs when MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP is set.\n"));
- return;
+ MALI_DEBUG_PRINT(4, ("Mali PP scheduler: Job %u (0x%08X) part %u/%u started\n",
+ mali_pp_job_get_id(job), job, subjob + 1,
+ mali_pp_job_get_sub_job_count(job)));
+ }
+ else
+ {
+ MALI_DEBUG_PRINT(3, ("Mali PP scheduler: Failed to start PP job\n"));
+ /* This can only happen on Mali-200 */
+#if !defined(USING_MALI200)
+ MALI_DEBUG_ASSERT(0);
#endif
+ mali_pp_scheduler_lock();
+ /* Put job back on queue */
+ mali_pp_job_mark_sub_job_not_stated(job, subjob);
+ _mali_osk_list_add(&job->list, &job_queue);
+ /* Set slot idle */
+ slot->state = MALI_PP_SLOT_STATE_IDLE;
+ slot->session = NULL;
+ slot->job = NULL;
+ slot->subjob = 0;
+ mali_pp_scheduler_unlock();
}
}
- else
- {
- MALI_DEBUG_PRINT(3, ("Mali PP scheduler: Failed to start PP job\n"));
- return;
- }
}
}
@@ -335,35 +333,42 @@ static void mali_pp_scheduler_return_job_to_user(struct mali_pp_job *job)
void mali_pp_scheduler_do_schedule(void)
{
- mali_pp_scheduler_lock();
-
mali_pp_scheduler_schedule();
-
- mali_pp_scheduler_unlock();
}
void mali_pp_scheduler_job_done(struct mali_group *group, struct mali_pp_job *job, u32 sub_job, mali_bool success)
{
u32 i;
+ struct mali_pp_slot *slot = NULL;
mali_bool job_is_done;
- MALI_DEBUG_PRINT(3, ("Mali PP scheduler: Job %u (0x%08X) part %u/%u completed (%s)\n", mali_pp_job_get_id(job), job, sub_job + 1, mali_pp_job_get_sub_job_count(job), success ? "success" : "failure"));
+ MALI_DEBUG_PRINT(3, ("Mali PP scheduler: Job %u (0x%08X) part %u/%u completed (%s)\n",
+ mali_pp_job_get_id(job),
+ job, sub_job + 1,
+ mali_pp_job_get_sub_job_count(job),
+ success ? "success" : "failure"));
mali_pp_scheduler_lock();
+ mali_pp_job_mark_sub_job_completed(job, success);
+
/* Find slot which was running this job */
for (i = 0; i < num_slots; i++)
{
- if (slots[i].group == group)
- {
- MALI_DEBUG_ASSERT(MALI_PP_SLOT_STATE_WORKING == slots[i].state);
- slots[i].state = MALI_PP_SLOT_STATE_IDLE;
- slots[i].session = NULL;
- num_slots_idle++;
- mali_pp_job_mark_sub_job_completed(job, success);
- }
+ slot = &slots[i];
+ if (slot->group == group)
+ break;
}
+ MALI_DEBUG_ASSERT_POINTER(slot);
+
+ slot->state = MALI_PP_SLOT_STATE_IDLE;
+ slot->session = NULL;
+ slot->job = NULL;
+ slot->subjob = 0;
+
+ num_slots_idle++;
+
/* If paused, then this was the last job, so wake up sleeping workers */
if (pause_count > 0)
{
@@ -373,10 +378,6 @@ void mali_pp_scheduler_job_done(struct mali_group *group, struct mali_pp_job *jo
*/
_mali_osk_wait_queue_wake_up(pp_scheduler_working_wait_queue);
}
- else
- {
- mali_pp_scheduler_schedule();
- }
job_is_done = mali_pp_job_is_complete(job);
@@ -388,6 +389,8 @@ void mali_pp_scheduler_job_done(struct mali_group *group, struct mali_pp_job *jo
MALI_DEBUG_PRINT(4, ("Mali PP scheduler: All parts completed for job %u (0x%08X)\n", mali_pp_job_get_id(job), job));
mali_pp_scheduler_return_job_to_user(job);
}
+
+ mali_pp_scheduler_schedule();
}
void mali_pp_scheduler_suspend(void)
@@ -396,11 +399,7 @@ void mali_pp_scheduler_suspend(void)
pause_count++; /* Increment the pause_count so that no more jobs will be scheduled */
mali_pp_scheduler_unlock();
- /*mali_pp_scheduler_working_lock();*/
- /* We have now aquired the working lock, which means that we have successfully paused the scheduler */
- /*mali_pp_scheduler_working_unlock();*/
-
- /* go to sleep. When woken up again (in mali_pp_scheduler_job_done), the
+ /* Go to sleep. When woken up again (in mali_pp_scheduler_job_done), the
* mali_pp_scheduler_suspended() function will be called. This will return true
* iff state is idle and pause_count > 0, so if the core is active this
* will not do anything.
@@ -419,17 +418,17 @@ void mali_pp_scheduler_resume(void)
mali_pp_scheduler_unlock();
}
-_mali_osk_errcode_t _mali_ukk_pp_start_job(_mali_uk_pp_start_job_s *args)
+_mali_osk_errcode_t _mali_ukk_pp_start_job(void *ctx, _mali_uk_pp_start_job_s *uargs)
{
struct mali_session_data *session;
struct mali_pp_job *job;
- MALI_DEBUG_ASSERT_POINTER(args);
- MALI_DEBUG_ASSERT_POINTER(args->ctx);
+ MALI_DEBUG_ASSERT_POINTER(uargs);
+ MALI_DEBUG_ASSERT_POINTER(ctx);
- session = (struct mali_session_data*)args->ctx;
+ session = (struct mali_session_data*)ctx;
- job = mali_pp_job_create(session, args, mali_scheduler_get_new_id());
+ job = mali_pp_job_create(session, uargs, mali_scheduler_get_new_id());
if (NULL == job)
{
return _MALI_OSK_ERR_NOMEM;
@@ -451,14 +450,16 @@ _mali_osk_errcode_t _mali_ukk_pp_start_job(_mali_uk_pp_start_job_s *args)
mali_pp_scheduler_lock();
+ job_queue_depth += mali_pp_job_get_sub_job_count(job);
_mali_osk_list_addtail(&job->list, &job_queue);
- MALI_DEBUG_PRINT(3, ("Mali PP scheduler: Job %u (0x%08X) with %u parts queued\n", mali_pp_job_get_id(job), job, mali_pp_job_get_sub_job_count(job)));
-
- mali_pp_scheduler_schedule();
+ MALI_DEBUG_PRINT(3, ("Mali PP scheduler: Job %u (0x%08X) with %u parts queued\n",
+ mali_pp_job_get_id(job), job, mali_pp_job_get_sub_job_count(job)));
mali_pp_scheduler_unlock();
+ if (slots_available()) mali_pp_scheduler_schedule();
+
return _MALI_OSK_ERR_OK;
}
@@ -489,9 +490,8 @@ void _mali_ukk_pp_job_disable_wb(_mali_uk_pp_disable_wb_s *args)
session = (struct mali_session_data*)args->ctx;
- mali_pp_scheduler_lock();
-
/* Check queue for jobs that match */
+ mali_pp_scheduler_lock();
_MALI_OSK_LIST_FOREACHENTRY(job, tmp, &job_queue, struct mali_pp_job, list)
{
if (mali_pp_job_get_session(job) == session &&
@@ -513,7 +513,6 @@ void _mali_ukk_pp_job_disable_wb(_mali_uk_pp_disable_wb_s *args)
break;
}
}
-
mali_pp_scheduler_unlock();
}
@@ -531,6 +530,7 @@ void mali_pp_scheduler_abort_session(struct mali_session_data *session)
if (mali_pp_job_get_session(job) == session)
{
_mali_osk_list_del(&(job->list));
+ job_queue_depth -= mali_pp_job_get_sub_job_count(job) - mali_pp_job_get_first_unstarted_sub_job(job);
if ( mali_pp_job_is_currently_rendering_and_if_so_abort_new_starts(job) )
{
@@ -551,14 +551,9 @@ void mali_pp_scheduler_abort_session(struct mali_session_data *session)
{
struct mali_group *group = slots[i].group;
- MALI_DEBUG_PRINT(5, ("PP sched abort: Looking at group 0x%08x\n", group));
-
- if (MALI_PP_SLOT_STATE_WORKING == slots[i].state)
- {
- MALI_DEBUG_PRINT(4, ("Mali PP scheduler: Aborting session 0x%08x from group 0x%08x\n", session, group));
+ MALI_DEBUG_PRINT(5, ("PP sched abort: Attempting abort for session 0x%08x on group 0x%08x\n", session, group));
- mali_group_abort_session(group, session);
- }
+ mali_group_abort_session(group, session);
}
}
@@ -573,6 +568,11 @@ static mali_bool mali_pp_scheduler_is_suspended(void)
return ret;
}
+int mali_pp_scheduler_get_queue_depth(void)
+{
+ return job_queue_depth;
+}
+
#if MALI_STATE_TRACKING
u32 mali_pp_scheduler_dump_state(char *buf, u32 size)
{
diff --git a/driver/src/devicedrv/mali/common/mali_pp_scheduler.h b/driver/src/devicedrv/mali/common/mali_pp_scheduler.h
index 48eb3bd..59bf403 100644
--- a/driver/src/devicedrv/mali/common/mali_pp_scheduler.h
+++ b/driver/src/devicedrv/mali/common/mali_pp_scheduler.h
@@ -33,6 +33,7 @@ void mali_pp_scheduler_resume(void);
*/
void mali_pp_scheduler_abort_session(struct mali_session_data *session);
+int mali_pp_scheduler_get_queue_depth(void);
u32 mali_pp_scheduler_dump_state(char *buf, u32 size);
#endif /* __MALI_PP_SCHEDULER_H__ */
diff --git a/driver/src/devicedrv/mali/common/mali_ukk.h b/driver/src/devicedrv/mali/common/mali_ukk.h
index 6b018d0..6d41b6e 100644
--- a/driver/src/devicedrv/mali/common/mali_ukk.h
+++ b/driver/src/devicedrv/mali/common/mali_ukk.h
@@ -449,10 +449,11 @@ _mali_osk_errcode_t _mali_ukk_va_to_mali_pa( _mali_uk_va_to_mali_pa_s * args );
*
* Job completion can be awaited with _mali_ukk_wait_for_notification().
*
- * @param args see _mali_uk_pp_start_job_s in "mali_utgard_uk_types.h"
+ * @oaram ctx user-kernel context (mali_session)
+ * @param uargs see _mali_uk_pp_start_job_s in "mali_utgard_uk_types.h". Use _mali_osk_copy_from_user to retrieve data!
* @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
*/
-_mali_osk_errcode_t _mali_ukk_pp_start_job( _mali_uk_pp_start_job_s *args );
+_mali_osk_errcode_t _mali_ukk_pp_start_job( void *ctx, _mali_uk_pp_start_job_s *uargs );
/** @brief Returns the number of Fragment Processors in the system
*
@@ -502,10 +503,11 @@ void _mali_ukk_pp_job_disable_wb(_mali_uk_pp_disable_wb_s *args);
*
* Job completion can be awaited with _mali_ukk_wait_for_notification().
*
- * @param args see _mali_uk_gp_start_job_s in "mali_utgard_uk_types.h"
+ * @oaram ctx user-kernel context (mali_session)
+ * @param uargs see _mali_uk_gp_start_job_s in "mali_utgard_uk_types.h". Use _mali_osk_copy_from_user to retrieve data!
* @return _MALI_OSK_ERR_OK on success, otherwise a suitable _mali_osk_errcode_t on failure.
*/
-_mali_osk_errcode_t _mali_ukk_gp_start_job( _mali_uk_gp_start_job_s *args );
+_mali_osk_errcode_t _mali_ukk_gp_start_job( void *ctx, _mali_uk_gp_start_job_s *uargs );
/** @brief Returns the number of Vertex Processors in the system.
*
diff --git a/driver/src/devicedrv/mali/include/linux/mali/mali_utgard_profiling_events.h b/driver/src/devicedrv/mali/include/linux/mali/mali_utgard_profiling_events.h
index b96596e..92ca058 100644
--- a/driver/src/devicedrv/mali/include/linux/mali/mali_utgard_profiling_events.h
+++ b/driver/src/devicedrv/mali/include/linux/mali/mali_utgard_profiling_events.h
@@ -71,6 +71,7 @@ typedef enum
MALI_PROFILING_EVENT_REASON_SINGLE_SW_UMP_TRY_LOCK = 53,
MALI_PROFILING_EVENT_REASON_SINGLE_SW_UMP_LOCK = 54,
MALI_PROFILING_EVENT_REASON_SINGLE_SW_UMP_UNLOCK = 55,
+ MALI_PROFILING_EVENT_REASON_SINGLE_LOCK_CONTENDED = 56,
} cinstr_profiling_event_reason_single_sw_t;
/**
@@ -80,6 +81,7 @@ typedef enum
{
MALI_PROFILING_EVENT_REASON_START_STOP_SW_NONE = 0,
MALI_PROFILING_EVENT_REASON_START_STOP_MALI = 1,
+ MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF = 2,
} cinstr_profiling_event_reason_start_stop_sw_t;
/**
@@ -124,4 +126,26 @@ typedef enum
MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE = 1,
} cinstr_profiling_event_reason_single_gpu_t;
+/**
+ * These values are applicable for the 3rd data parameter when
+ * the type MALI_PROFILING_EVENT_TYPE_START is used from the software channel
+ * with the MALI_PROFILING_EVENT_REASON_START_STOP_BOTTOM_HALF reason.
+ */
+typedef enum
+{
+ MALI_PROFILING_EVENT_DATA_CORE_GP0 = 1,
+ MALI_PROFILING_EVENT_DATA_CORE_PP0 = 5,
+ MALI_PROFILING_EVENT_DATA_CORE_PP1 = 6,
+ MALI_PROFILING_EVENT_DATA_CORE_PP2 = 7,
+ MALI_PROFILING_EVENT_DATA_CORE_PP3 = 8,
+ MALI_PROFILING_EVENT_DATA_CORE_PP4 = 9,
+ MALI_PROFILING_EVENT_DATA_CORE_PP5 = 10,
+ MALI_PROFILING_EVENT_DATA_CORE_PP6 = 11,
+ MALI_PROFILING_EVENT_DATA_CORE_PP7 = 12,
+} cinstr_profiling_event_data_core_t;
+
+#define MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP(num) (MALI_PROFILING_EVENT_DATA_CORE_GP0 + (num))
+#define MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP(num) (MALI_PROFILING_EVENT_DATA_CORE_PP0 + (num))
+
+
#endif /*_MALI_UTGARD_PROFILING_EVENTS_H_*/
diff --git a/driver/src/devicedrv/mali/linux/mali_kernel_linux.c b/driver/src/devicedrv/mali/linux/mali_kernel_linux.c
index df5d767..8367515 100644
--- a/driver/src/devicedrv/mali/linux/mali_kernel_linux.c
+++ b/driver/src/devicedrv/mali/linux/mali_kernel_linux.c
@@ -29,6 +29,9 @@
#include "mali_platform.h"
#include "mali_kernel_license.h"
#include "mali_dma_buf.h"
+#if MALI_INTERNAL_TIMELINE_PROFILING_ENABLED
+#include "mali_profiling_internal.h"
+#endif
/* Streamline support for the Mali driver */
#if defined(CONFIG_TRACEPOINTS) && MALI_TIMELINE_PROFILING_ENABLED
@@ -126,6 +129,15 @@ int mali_driver_init(void)
ret = map_errcode(mali_initialize_subsystems());
if (0 != ret) goto initialize_subsystems_failed;
+#if MALI_INTERNAL_TIMELINE_PROFILING_ENABLED
+ ret = _mali_internal_profiling_init(mali_boot_profiling ? MALI_TRUE : MALI_FALSE);
+ if (0 != ret)
+ {
+ /* No biggie if we wheren't able to initialize the profiling */
+ MALI_PRINT_ERROR(("Failed to initialize profiling, feature will be unavailable\n"));
+ }
+#endif
+
ret = initialize_sysfs();
if (0 != ret) goto initialize_sysfs_failed;
@@ -135,6 +147,9 @@ int mali_driver_init(void)
/* Error handling */
initialize_sysfs_failed:
+#if MALI_INTERNAL_TIMELINE_PROFILING_ENABLED
+ _mali_internal_profiling_term();
+#endif
mali_terminate_subsystems();
initialize_subsystems_failed:
mali_osk_low_level_mem_term();
@@ -154,6 +169,10 @@ void mali_driver_exit(void)
/* No need to terminate sysfs, this will be done automatically along with device termination */
+#if MALI_INTERNAL_TIMELINE_PROFILING_ENABLED
+ _mali_internal_profiling_term();
+#endif
+
mali_terminate_subsystems();
mali_osk_low_level_mem_term();
diff --git a/driver/src/devicedrv/mali/linux/mali_kernel_sysfs.c b/driver/src/devicedrv/mali/linux/mali_kernel_sysfs.c
index e2dc17b..77ebc9d 100644
--- a/driver/src/devicedrv/mali/linux/mali_kernel_sysfs.c
+++ b/driver/src/devicedrv/mali/linux/mali_kernel_sysfs.c
@@ -44,6 +44,7 @@
#include "mali_kernel_core.h"
#include "mali_user_settings_db.h"
#include "mali_device_pause_resume.h"
+#include "mali_profiling_internal.h"
#define POWER_BUFFER_SIZE 3
@@ -69,6 +70,7 @@ static const char* const mali_power_events[_MALI_MAX_EVENTS] = {
static u32 virtual_power_status_register=0;
static char pwr_buf[POWER_BUFFER_SIZE];
+
static int open_copy_private_data(struct inode *inode, struct file *filp)
{
filp->private_data = inode->i_private;
@@ -790,7 +792,7 @@ static ssize_t profiling_record_read(struct file *filp, char __user *ubuf, size_
char buf[64];
int r;
- r = sprintf(buf, "%u\n", _mali_osk_profiling_is_recording() ? 1 : 0);
+ r = sprintf(buf, "%u\n", _mali_internal_profiling_is_recording() ? 1 : 0);
return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
}
@@ -823,16 +825,16 @@ static ssize_t profiling_record_write(struct file *filp, const char __user *ubuf
u32 limit = MALI_PROFILING_MAX_BUFFER_ENTRIES; /* This can be made configurable at a later stage if we need to */
/* check if we are already recording */
- if (MALI_TRUE == _mali_osk_profiling_is_recording())
+ if (MALI_TRUE == _mali_internal_profiling_is_recording())
{
MALI_DEBUG_PRINT(3, ("Recording of profiling events already in progress\n"));
return -EFAULT;
}
/* check if we need to clear out an old recording first */
- if (MALI_TRUE == _mali_osk_profiling_have_recording())
+ if (MALI_TRUE == _mali_internal_profiling_have_recording())
{
- if (_MALI_OSK_ERR_OK != _mali_osk_profiling_clear())
+ if (_MALI_OSK_ERR_OK != _mali_internal_profiling_clear())
{
MALI_DEBUG_PRINT(3, ("Failed to clear existing recording of profiling events\n"));
return -EFAULT;
@@ -840,7 +842,7 @@ static ssize_t profiling_record_write(struct file *filp, const char __user *ubuf
}
/* start recording profiling data */
- if (_MALI_OSK_ERR_OK != _mali_osk_profiling_start(&limit))
+ if (_MALI_OSK_ERR_OK != _mali_internal_profiling_start(&limit))
{
MALI_DEBUG_PRINT(3, ("Failed to start recording of profiling events\n"));
return -EFAULT;
@@ -852,7 +854,7 @@ static ssize_t profiling_record_write(struct file *filp, const char __user *ubuf
{
/* stop recording profiling data */
u32 count = 0;
- if (_MALI_OSK_ERR_OK != _mali_osk_profiling_stop(&count))
+ if (_MALI_OSK_ERR_OK != _mali_internal_profiling_stop(&count))
{
MALI_DEBUG_PRINT(2, ("Failed to stop recording of profiling events\n"));
return -EFAULT;
@@ -876,7 +878,7 @@ static void *profiling_events_start(struct seq_file *s, loff_t *pos)
loff_t *spos;
/* check if we have data avaiable */
- if (MALI_TRUE != _mali_osk_profiling_have_recording())
+ if (MALI_TRUE != _mali_internal_profiling_have_recording())
{
return NULL;
}
@@ -896,13 +898,13 @@ static void *profiling_events_next(struct seq_file *s, void *v, loff_t *pos)
loff_t *spos = v;
/* check if we have data avaiable */
- if (MALI_TRUE != _mali_osk_profiling_have_recording())
+ if (MALI_TRUE != _mali_internal_profiling_have_recording())
{
return NULL;
}
/* check if the next entry actually is avaiable */
- if (_mali_osk_profiling_get_count() <= (u32)(*spos + 1))
+ if (_mali_internal_profiling_get_count() <= (u32)(*spos + 1))
{
return NULL;
}
@@ -927,7 +929,7 @@ static int profiling_events_show(struct seq_file *seq_file, void *v)
index = (u32)*spos;
/* Retrieve all events */
- if (_MALI_OSK_ERR_OK == _mali_osk_profiling_get_event(index, &timestamp, &event_id, data))
+ if (_MALI_OSK_ERR_OK == _mali_internal_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;
diff --git a/driver/src/devicedrv/mali/linux/mali_osk_locks.c b/driver/src/devicedrv/mali/linux/mali_osk_locks.c
index ee857d5..d007d93 100644
--- a/driver/src/devicedrv/mali/linux/mali_osk_locks.c
+++ b/driver/src/devicedrv/mali/linux/mali_osk_locks.c
@@ -13,19 +13,12 @@
* Implemenation of the OS abstraction layer for the kernel device driver
*/
-/* needed to detect kernel version specific code */
-#include <linux/version.h>
-
#include <linux/spinlock.h>
#include <linux/rwsem.h>
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
-#include <linux/semaphore.h>
-#else /* pre 2.6.26 the file was in the arch specific location */
-#include <asm/semaphore.h>
-#endif
+#include <linux/mutex.h>
#include <linux/slab.h>
+
#include "mali_osk.h"
#include "mali_kernel_common.h"
@@ -34,9 +27,9 @@ typedef enum
{
_MALI_OSK_INTERNAL_LOCKTYPE_SPIN, /* Mutex, implicitly non-interruptable, use spin_lock/spin_unlock */
_MALI_OSK_INTERNAL_LOCKTYPE_SPIN_IRQ, /* Mutex, IRQ version of spinlock, use spin_lock_irqsave/spin_unlock_irqrestore */
- _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX, /* Interruptable, use up()/down_interruptable() */
- _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT, /* Non-Interruptable, use up()/down() */
- _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT_RW, /* Non-interruptable, Reader/Writer, use {up,down}{read,write}() */
+ _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX, /* Interruptable, use mutex_unlock()/down_interruptable() */
+ _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT, /* Non-Interruptable, use mutex_unlock()/down() */
+ _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT_RW, /* Non-interruptable, Reader/Writer, use {mutex_unlock,down}{read,write}() */
/* Linux supports, but we do not support:
* Non-Interruptable Reader/Writer spinlock mutexes - RW optimization will be switched off
@@ -55,7 +48,7 @@ struct _mali_osk_lock_t_struct
union
{
spinlock_t spinlock;
- struct semaphore sema;
+ struct mutex mutex;
struct rw_semaphore rw_sema;
} obj;
MALI_DEBUG_CODE(
@@ -132,7 +125,7 @@ _mali_osk_lock_t *_mali_osk_lock_init( _mali_osk_lock_flags_t flags, u32 initial
}
/* Initially unlocked */
- sema_init( &lock->obj.sema, 1 );
+ mutex_init(&lock->obj.mutex);
}
#ifdef DEBUG
@@ -194,7 +187,7 @@ _mali_osk_errcode_t _mali_osk_lock_wait( _mali_osk_lock_t *lock, _mali_osk_lock_
break;
case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX:
- if ( down_interruptible(&lock->obj.sema) )
+ if (mutex_lock_interruptible(&lock->obj.mutex))
{
MALI_PRINT_ERROR(("Can not lock mutex\n"));
err = _MALI_OSK_ERR_RESTARTSYSCALL;
@@ -202,7 +195,7 @@ _mali_osk_errcode_t _mali_osk_lock_wait( _mali_osk_lock_t *lock, _mali_osk_lock_
break;
case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT:
- down(&lock->obj.sema);
+ mutex_lock(&lock->obj.mutex);
break;
case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT_RW:
@@ -308,7 +301,7 @@ void _mali_osk_lock_signal( _mali_osk_lock_t *lock, _mali_osk_lock_mode_t mode )
case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX:
/* FALLTHROUGH */
case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT:
- up(&lock->obj.sema);
+ mutex_unlock(&lock->obj.mutex);
break;
case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT_RW:
diff --git a/driver/src/devicedrv/mali/linux/mali_osk_notification.c b/driver/src/devicedrv/mali/linux/mali_osk_notification.c
index c14c0d5..2cfb5ef 100644
--- a/driver/src/devicedrv/mali/linux/mali_osk_notification.c
+++ b/driver/src/devicedrv/mali/linux/mali_osk_notification.c
@@ -21,11 +21,7 @@
#include <linux/sched.h>
#include <linux/slab.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
-#include <linux/semaphore.h>
-#else /* pre 2.6.26 the file was in the arch specific location */
-#include <asm/semaphore.h>
-#endif
+#include <linux/spinlock.h>
/**
* Declaration of the notification queue object type
@@ -35,7 +31,7 @@
*/
struct _mali_osk_notification_queue_t_struct
{
- struct semaphore mutex; /**< Mutex protecting the list */
+ spinlock_t mutex; /**< Mutex protecting the list */
wait_queue_head_t receive_queue; /**< Threads waiting for new entries to the queue */
struct list_head head; /**< List of notifications waiting to be picked up */
};
@@ -53,7 +49,7 @@ _mali_osk_notification_queue_t *_mali_osk_notification_queue_init( void )
result = (_mali_osk_notification_queue_t *)kmalloc(sizeof(_mali_osk_notification_queue_t), GFP_KERNEL);
if (NULL == result) return NULL;
- sema_init(&result->mutex, 1);
+ spin_lock_init(&result->mutex);
init_waitqueue_head(&result->receive_queue);
INIT_LIST_HEAD(&result->head);
@@ -121,39 +117,22 @@ void _mali_osk_notification_queue_send( _mali_osk_notification_queue_t *queue, _
notification = container_of( object, _mali_osk_notification_wrapper_t, data );
/* lock queue access */
- down(&queue->mutex);
+ spin_lock(&queue->mutex);
/* add to list */
list_add_tail(&notification->list, &queue->head);
/* unlock the queue */
- up(&queue->mutex);
+ spin_unlock(&queue->mutex);
/* and wake up one possible exclusive waiter */
wake_up(&queue->receive_queue);
}
-static int _mali_notification_queue_is_empty( _mali_osk_notification_queue_t *queue )
-{
- int ret;
-
- down(&queue->mutex);
- ret = list_empty(&queue->head);
- up(&queue->mutex);
- return ret;
-}
-
-#if MALI_STATE_TRACKING
-mali_bool _mali_osk_notification_queue_is_empty( _mali_osk_notification_queue_t *queue )
-{
- return _mali_notification_queue_is_empty(queue) ? MALI_TRUE : MALI_FALSE;
-}
-#endif
-
_mali_osk_errcode_t _mali_osk_notification_queue_dequeue( _mali_osk_notification_queue_t *queue, _mali_osk_notification_t **result )
{
_mali_osk_errcode_t ret = _MALI_OSK_ERR_ITEM_NOT_FOUND;
_mali_osk_notification_wrapper_t *wrapper_object;
- down(&queue->mutex);
+ spin_lock(&queue->mutex);
if (!list_empty(&queue->head))
{
@@ -163,7 +142,7 @@ _mali_osk_errcode_t _mali_osk_notification_queue_dequeue( _mali_osk_notification
ret = _MALI_OSK_ERR_OK;
}
- up(&queue->mutex);
+ spin_unlock(&queue->mutex);
return ret;
}
@@ -177,12 +156,10 @@ _mali_osk_errcode_t _mali_osk_notification_queue_receive( _mali_osk_notification
/* default result */
*result = NULL;
- while (_MALI_OSK_ERR_OK != _mali_osk_notification_queue_dequeue(queue, result))
+ if (wait_event_interruptible(queue->receive_queue,
+ _MALI_OSK_ERR_OK == _mali_osk_notification_queue_dequeue(queue, result)))
{
- if (wait_event_interruptible(queue->receive_queue, !_mali_notification_queue_is_empty(queue)))
- {
- return _MALI_OSK_ERR_RESTARTSYSCALL;
- }
+ return _MALI_OSK_ERR_RESTARTSYSCALL;
}
return _MALI_OSK_ERR_OK; /* all ok */
diff --git a/driver/src/devicedrv/mali/linux/mali_osk_profiling_gator.c b/driver/src/devicedrv/mali/linux/mali_osk_profiling.c
index 95bee53..95bee53 100644
--- a/driver/src/devicedrv/mali/linux/mali_osk_profiling_gator.c
+++ b/driver/src/devicedrv/mali/linux/mali_osk_profiling.c
diff --git a/driver/src/devicedrv/mali/linux/mali_osk_profiling_internal.c b/driver/src/devicedrv/mali/linux/mali_osk_profiling_internal.c
deleted file mode 100644
index 2df935d..0000000
--- a/driver/src/devicedrv/mali/linux/mali_osk_profiling_internal.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * Copyright (C) 2010-2012 ARM Limited. All rights reserved.
- *
- * This program is free software and is provided to you under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
- *
- * A copy of the licence is included with the program, and can also be obtained from Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "mali_kernel_common.h"
-#include "mali_osk.h"
-#include "mali_osk_mali.h"
-#include "mali_ukk.h"
-#include "mali_timestamp.h"
-#include "mali_osk_profiling.h"
-#include "mali_user_settings_db.h"
-
-typedef struct mali_profiling_entry
-{
- u64 timestamp;
- u32 event_id;
- u32 data[5];
-} mali_profiling_entry;
-
-
-typedef enum mali_profiling_state
-{
- MALI_PROFILING_STATE_UNINITIALIZED,
- MALI_PROFILING_STATE_IDLE,
- MALI_PROFILING_STATE_RUNNING,
- MALI_PROFILING_STATE_RETURN,
-} mali_profiling_state;
-
-static _mali_osk_lock_t *lock = NULL;
-static mali_profiling_state prof_state = MALI_PROFILING_STATE_UNINITIALIZED;
-static mali_profiling_entry* profile_entries = NULL;
-static u32 profile_entry_count = 0;
-static _mali_osk_atomic_t profile_insert_index;
-static _mali_osk_atomic_t profile_entries_written;
-
-_mali_osk_errcode_t _mali_osk_profiling_init(mali_bool auto_start)
-{
- profile_entries = NULL;
- profile_entry_count = 0;
- _mali_osk_atomic_init(&profile_insert_index, 0);
- _mali_osk_atomic_init(&profile_entries_written, 0);
-
- lock = _mali_osk_lock_init(_MALI_OSK_LOCKFLAG_ORDERED | _MALI_OSK_LOCKFLAG_SPINLOCK | _MALI_OSK_LOCKFLAG_NONINTERRUPTABLE, 0, _MALI_OSK_LOCK_ORDER_PROFILING);
- if (NULL == lock)
- {
- return _MALI_OSK_ERR_FAULT;
- }
-
- prof_state = MALI_PROFILING_STATE_IDLE;
-
- if (MALI_TRUE == auto_start)
- {
- u32 limit = MALI_PROFILING_MAX_BUFFER_ENTRIES; /* Use maximum buffer size */
-
- mali_set_user_setting(_MALI_UK_USER_SETTING_SW_EVENTS_ENABLE, MALI_TRUE);
- if (_MALI_OSK_ERR_OK != _mali_osk_profiling_start(&limit))
- {
- return _MALI_OSK_ERR_FAULT;
- }
- }
-
- return _MALI_OSK_ERR_OK;
-}
-
-void _mali_osk_profiling_term(void)
-{
- prof_state = MALI_PROFILING_STATE_UNINITIALIZED;
-
- /* wait for all elements to be completely inserted into array */
- while (_mali_osk_atomic_read(&profile_insert_index) != _mali_osk_atomic_read(&profile_entries_written))
- {
- /* do nothing */;
- }
-
- if (NULL != profile_entries)
- {
- _mali_osk_vfree(profile_entries);
- profile_entries = NULL;
- }
-
- if (NULL != lock)
- {
- _mali_osk_lock_term(lock);
- lock = NULL;
- }
-}
-
-inline _mali_osk_errcode_t _mali_osk_profiling_start(u32 * limit)
-{
- _mali_osk_errcode_t ret;
-
- mali_profiling_entry *new_profile_entries = _mali_osk_valloc(*limit * sizeof(mali_profiling_entry));
-
- if(NULL == new_profile_entries)
- {
- return _MALI_OSK_ERR_NOMEM;
- }
-
- _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW);
-
- if (prof_state != MALI_PROFILING_STATE_IDLE)
- {
- _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
- _mali_osk_vfree(new_profile_entries);
- return _MALI_OSK_ERR_INVALID_ARGS; /* invalid to call this function in this state */
- }
-
- if (*limit > MALI_PROFILING_MAX_BUFFER_ENTRIES)
- {
- *limit = MALI_PROFILING_MAX_BUFFER_ENTRIES;
- }
-
- profile_entries = new_profile_entries;
- profile_entry_count = *limit;
-
- ret = _mali_timestamp_reset();
-
- if (ret == _MALI_OSK_ERR_OK)
- {
- prof_state = MALI_PROFILING_STATE_RUNNING;
- }
- else
- {
- _mali_osk_vfree(profile_entries);
- profile_entries = NULL;
- }
-
- _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
- return ret;
-}
-
-inline void _mali_osk_profiling_add_event(u32 event_id, u32 data0, u32 data1, u32 data2, u32 data3, u32 data4)
-{
- if (prof_state == MALI_PROFILING_STATE_RUNNING)
- {
- u32 cur_index = (_mali_osk_atomic_inc_return(&profile_insert_index) - 1) % profile_entry_count;
-
- profile_entries[cur_index].timestamp = _mali_timestamp_get();
- profile_entries[cur_index].event_id = event_id;
- profile_entries[cur_index].data[0] = data0;
- profile_entries[cur_index].data[1] = data1;
- profile_entries[cur_index].data[2] = data2;
- profile_entries[cur_index].data[3] = data3;
- profile_entries[cur_index].data[4] = data4;
-
- /* If event is "leave API function", add current memory usage to the event
- * as data point 4. This is used in timeline profiling to indicate how
- * much memory was used when leaving a function. */
- if (event_id == (MALI_PROFILING_EVENT_TYPE_SINGLE|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_SINGLE_SW_LEAVE_API_FUNC))
- {
- profile_entries[cur_index].data[4] = _mali_ukk_report_memory_usage();
- }
-
- _mali_osk_atomic_inc(&profile_entries_written);
- }
-}
-
-inline void _mali_osk_profiling_report_hw_counter(u32 counter_id, u32 value)
-{
- /* Not implemented */
-}
-
-void _mali_osk_profiling_report_sw_counters(u32 *counters)
-{
- /* Not implemented */
-}
-
-inline _mali_osk_errcode_t _mali_osk_profiling_stop(u32 * count)
-{
- _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW);
-
- if (prof_state != MALI_PROFILING_STATE_RUNNING)
- {
- _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
- return _MALI_OSK_ERR_INVALID_ARGS; /* invalid to call this function in this state */
- }
-
- /* go into return state (user to retreive events), no more events will be added after this */
- prof_state = MALI_PROFILING_STATE_RETURN;
-
- _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
-
- /* wait for all elements to be completely inserted into array */
- while (_mali_osk_atomic_read(&profile_insert_index) != _mali_osk_atomic_read(&profile_entries_written))
- {
- /* do nothing */;
- }
-
- *count = _mali_osk_atomic_read(&profile_insert_index);
- if(*count>profile_entry_count) *count=profile_entry_count;
-
- return _MALI_OSK_ERR_OK;
-}
-
-inline u32 _mali_osk_profiling_get_count(void)
-{
- u32 retval = 0;
-
- _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW);
- if (prof_state == MALI_PROFILING_STATE_RETURN)
- {
- retval = _mali_osk_atomic_read(&profile_entries_written);
- if(retval>profile_entry_count) retval = profile_entry_count;
- }
- _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
-
- return retval;
-}
-
-inline _mali_osk_errcode_t _mali_osk_profiling_get_event(u32 index, u64* timestamp, u32* event_id, u32 data[5])
-{
- _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW);
-
- if(index<profile_entry_count)
- {
- u32 idx = index;
- if(_mali_osk_atomic_read(&profile_insert_index)>=profile_entry_count)
- {
- idx = (index + _mali_osk_atomic_read(&profile_insert_index)) % profile_entry_count;
- }
-
- if (prof_state != MALI_PROFILING_STATE_RETURN)
- {
- _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
- return _MALI_OSK_ERR_INVALID_ARGS; /* invalid to call this function in this state */
- }
-
- if (idx >= _mali_osk_atomic_read(&profile_entries_written))
- {
- _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
- return _MALI_OSK_ERR_FAULT;
- }
-
- *timestamp = profile_entries[idx].timestamp;
- *event_id = profile_entries[idx].event_id;
- data[0] = profile_entries[idx].data[0];
- data[1] = profile_entries[idx].data[1];
- data[2] = profile_entries[idx].data[2];
- data[3] = profile_entries[idx].data[3];
- data[4] = profile_entries[idx].data[4];
- }
- else
- {
- _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
- return _MALI_OSK_ERR_FAULT;
- }
-
- _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
- return _MALI_OSK_ERR_OK;
-}
-
-inline _mali_osk_errcode_t _mali_osk_profiling_clear(void)
-{
- _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW);
-
- if (prof_state != MALI_PROFILING_STATE_RETURN)
- {
- _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
- return _MALI_OSK_ERR_INVALID_ARGS; /* invalid to call this function in this state */
- }
-
- prof_state = MALI_PROFILING_STATE_IDLE;
- profile_entry_count = 0;
- _mali_osk_atomic_init(&profile_insert_index, 0);
- _mali_osk_atomic_init(&profile_entries_written, 0);
- if (NULL != profile_entries)
- {
- _mali_osk_vfree(profile_entries);
- profile_entries = NULL;
- }
-
- _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
- return _MALI_OSK_ERR_OK;
-}
-
-mali_bool _mali_osk_profiling_is_recording(void)
-{
- return prof_state == MALI_PROFILING_STATE_RUNNING ? MALI_TRUE : MALI_FALSE;
-}
-
-mali_bool _mali_osk_profiling_have_recording(void)
-{
- return prof_state == MALI_PROFILING_STATE_RETURN ? MALI_TRUE : MALI_FALSE;
-}
-
-_mali_osk_errcode_t _mali_ukk_profiling_start(_mali_uk_profiling_start_s *args)
-{
- return _mali_osk_profiling_start(&args->limit);
-}
-
-_mali_osk_errcode_t _mali_ukk_profiling_add_event(_mali_uk_profiling_add_event_s *args)
-{
- /* Always add process and thread identificator in the first two data elements for events from user space */
- _mali_osk_profiling_add_event(args->event_id, _mali_osk_get_pid(), _mali_osk_get_tid(), args->data[2], args->data[3], args->data[4]);
- return _MALI_OSK_ERR_OK;
-}
-
-_mali_osk_errcode_t _mali_ukk_profiling_stop(_mali_uk_profiling_stop_s *args)
-{
- return _mali_osk_profiling_stop(&args->count);
-}
-
-_mali_osk_errcode_t _mali_ukk_profiling_get_event(_mali_uk_profiling_get_event_s *args)
-{
- return _mali_osk_profiling_get_event(args->index, &args->timestamp, &args->event_id, args->data);
-}
-
-_mali_osk_errcode_t _mali_ukk_profiling_clear(_mali_uk_profiling_clear_s *args)
-{
- return _mali_osk_profiling_clear();
-}
-
-_mali_osk_errcode_t _mali_ukk_sw_counters_report(_mali_uk_sw_counters_report_s *args)
-{
- _mali_osk_profiling_report_sw_counters(args->counters);
- return _MALI_OSK_ERR_OK;
-}
-
diff --git a/driver/src/devicedrv/mali/linux/mali_osk_specific.h b/driver/src/devicedrv/mali/linux/mali_osk_specific.h
index 83ee906..157368b 100644
--- a/driver/src/devicedrv/mali/linux/mali_osk_specific.h
+++ b/driver/src/devicedrv/mali/linux/mali_osk_specific.h
@@ -17,17 +17,15 @@
#ifndef __MALI_OSK_SPECIFIC_H__
#define __MALI_OSK_SPECIFIC_H__
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+#include <asm/uaccess.h>
#define MALI_STATIC_INLINE static inline
#define MALI_NON_STATIC_INLINE inline
-#ifdef __cplusplus
+MALI_STATIC_INLINE u32 _mali_osk_copy_from_user(void *to, void *from, u32 n)
+{
+ return (u32)copy_from_user(to, from, (unsigned long)n);
}
-#endif
/** The list of events supported by the Mali DDK. */
typedef enum
@@ -39,7 +37,7 @@ typedef enum
ACTIVITY_FP0,
ACTIVITY_FP1,
ACTIVITY_FP2,
- ACTIVITY_FP3,
+ ACTIVITY_FP3,
/* L2 cache counters */
COUNTER_L2_C0,
@@ -59,7 +57,7 @@ typedef enum
COUNTER_FP3_C0,
COUNTER_FP3_C1,
- /*
+ /*
* If more hardware counters are added, the _mali_osk_hw_counter_table
* below should also be updated.
*/
diff --git a/driver/src/devicedrv/mali/linux/mali_profiling_internal.c b/driver/src/devicedrv/mali/linux/mali_profiling_internal.c
new file mode 100644
index 0000000..8202497
--- /dev/null
+++ b/driver/src/devicedrv/mali/linux/mali_profiling_internal.c
@@ -0,0 +1,294 @@
+/*
+ * Copyright (C) 2010-2012 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "mali_kernel_common.h"
+#include "mali_osk.h"
+#include "mali_osk_mali.h"
+#include "mali_ukk.h"
+#include "mali_timestamp.h"
+#include "mali_osk_profiling.h"
+#include "mali_user_settings_db.h"
+#include "mali_profiling_internal.h"
+
+typedef struct mali_profiling_entry
+{
+ u64 timestamp;
+ u32 event_id;
+ u32 data[5];
+} mali_profiling_entry;
+
+
+typedef enum mali_profiling_state
+{
+ MALI_PROFILING_STATE_UNINITIALIZED,
+ MALI_PROFILING_STATE_IDLE,
+ MALI_PROFILING_STATE_RUNNING,
+ MALI_PROFILING_STATE_RETURN,
+} mali_profiling_state;
+
+static _mali_osk_lock_t *lock = NULL;
+static mali_profiling_state prof_state = MALI_PROFILING_STATE_UNINITIALIZED;
+static mali_profiling_entry* profile_entries = NULL;
+static _mali_osk_atomic_t profile_insert_index;
+static u32 profile_mask = 0;
+static inline void add_event(u32 event_id, u32 data0, u32 data1, u32 data2, u32 data3, u32 data4);
+
+void probe_mali_timeline_event(void *data, TP_PROTO(unsigned int event_id, unsigned int d0, unsigned int d1, unsigned
+ int d2, unsigned int d3, unsigned int d4))
+{
+ add_event(event_id, d0, d1, d2, d3, d4);
+}
+
+_mali_osk_errcode_t _mali_internal_profiling_init(mali_bool auto_start)
+{
+ profile_entries = NULL;
+ profile_mask = 0;
+ _mali_osk_atomic_init(&profile_insert_index, 0);
+
+ lock = _mali_osk_lock_init(_MALI_OSK_LOCKFLAG_ORDERED | _MALI_OSK_LOCKFLAG_SPINLOCK | _MALI_OSK_LOCKFLAG_NONINTERRUPTABLE, 0, _MALI_OSK_LOCK_ORDER_PROFILING);
+ if (NULL == lock)
+ {
+ return _MALI_OSK_ERR_FAULT;
+ }
+
+ prof_state = MALI_PROFILING_STATE_IDLE;
+
+ if (MALI_TRUE == auto_start)
+ {
+ u32 limit = MALI_PROFILING_MAX_BUFFER_ENTRIES; /* Use maximum buffer size */
+
+ mali_set_user_setting(_MALI_UK_USER_SETTING_SW_EVENTS_ENABLE, MALI_TRUE);
+ if (_MALI_OSK_ERR_OK != _mali_internal_profiling_start(&limit))
+ {
+ return _MALI_OSK_ERR_FAULT;
+ }
+ }
+
+ return _MALI_OSK_ERR_OK;
+}
+
+void _mali_internal_profiling_term(void)
+{
+ u32 count;
+
+ /* Ensure profiling is stopped */
+ _mali_internal_profiling_stop(&count);
+
+ prof_state = MALI_PROFILING_STATE_UNINITIALIZED;
+
+ if (NULL != profile_entries)
+ {
+ _mali_osk_vfree(profile_entries);
+ profile_entries = NULL;
+ }
+
+ if (NULL != lock)
+ {
+ _mali_osk_lock_term(lock);
+ lock = NULL;
+ }
+}
+
+_mali_osk_errcode_t _mali_internal_profiling_start(u32 * limit)
+{
+ _mali_osk_errcode_t ret;
+
+ mali_profiling_entry *new_profile_entries;
+
+ _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW);
+
+ if (MALI_PROFILING_MAX_BUFFER_ENTRIES < *limit)
+ {
+ *limit = MALI_PROFILING_MAX_BUFFER_ENTRIES;
+ }
+
+ profile_mask = 1;
+ while (profile_mask <= *limit)
+ {
+ profile_mask <<= 1;
+ }
+ profile_mask >>= 1;
+
+ *limit = profile_mask;
+
+ profile_mask--; /* turns the power of two into a mask of one less */
+
+ new_profile_entries = _mali_osk_valloc(*limit * sizeof(mali_profiling_entry));
+
+ if (NULL == new_profile_entries)
+ {
+ _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
+ return _MALI_OSK_ERR_NOMEM;
+ }
+
+ if (MALI_PROFILING_STATE_IDLE != prof_state)
+ {
+ _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
+ _mali_osk_vfree(new_profile_entries);
+ return _MALI_OSK_ERR_INVALID_ARGS; /* invalid to call this function in this state */
+ }
+
+ profile_entries = new_profile_entries;
+
+ ret = _mali_timestamp_reset();
+
+ if (_MALI_OSK_ERR_OK == ret)
+ {
+ prof_state = MALI_PROFILING_STATE_RUNNING;
+ }
+ else
+ {
+ _mali_osk_vfree(profile_entries);
+ profile_entries = NULL;
+ }
+
+ register_trace_mali_timeline_event(probe_mali_timeline_event, NULL);
+
+ _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
+ return ret;
+}
+
+static inline void add_event(u32 event_id, u32 data0, u32 data1, u32 data2, u32 data3, u32 data4)
+{
+ u32 cur_index = (_mali_osk_atomic_inc_return(&profile_insert_index) - 1) & profile_mask;
+
+ profile_entries[cur_index].timestamp = _mali_timestamp_get();
+ profile_entries[cur_index].event_id = event_id;
+ profile_entries[cur_index].data[0] = data0;
+ profile_entries[cur_index].data[1] = data1;
+ profile_entries[cur_index].data[2] = data2;
+ profile_entries[cur_index].data[3] = data3;
+ profile_entries[cur_index].data[4] = data4;
+
+ /* If event is "leave API function", add current memory usage to the event
+ * as data point 4. This is used in timeline profiling to indicate how
+ * much memory was used when leaving a function. */
+ if (event_id == (MALI_PROFILING_EVENT_TYPE_SINGLE|MALI_PROFILING_EVENT_CHANNEL_SOFTWARE|MALI_PROFILING_EVENT_REASON_SINGLE_SW_LEAVE_API_FUNC))
+ {
+ profile_entries[cur_index].data[4] = _mali_ukk_report_memory_usage();
+ }
+}
+
+_mali_osk_errcode_t _mali_internal_profiling_stop(u32 * count)
+{
+ _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW);
+
+ if (MALI_PROFILING_STATE_RUNNING != prof_state)
+ {
+ _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
+ return _MALI_OSK_ERR_INVALID_ARGS; /* invalid to call this function in this state */
+ }
+
+ /* go into return state (user to retreive events), no more events will be added after this */
+ prof_state = MALI_PROFILING_STATE_RETURN;
+
+ unregister_trace_mali_timeline_event(probe_mali_timeline_event, NULL);
+ tracepoint_synchronize_unregister();
+
+ _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
+
+ *count = _mali_osk_atomic_read(&profile_insert_index);
+ if (*count > profile_mask) *count = profile_mask;
+
+ return _MALI_OSK_ERR_OK;
+}
+
+u32 _mali_internal_profiling_get_count(void)
+{
+ u32 retval = 0;
+
+ _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW);
+ if (MALI_PROFILING_STATE_RETURN == prof_state)
+ {
+ retval = _mali_osk_atomic_read(&profile_insert_index);
+ if (retval > profile_mask) retval = profile_mask;
+ }
+ _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
+
+ return retval;
+}
+
+_mali_osk_errcode_t _mali_internal_profiling_get_event(u32 index, u64* timestamp, u32* event_id, u32 data[5])
+{
+ u32 raw_index = _mali_osk_atomic_read(&profile_insert_index);
+
+ _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW);
+
+ if (index < profile_mask)
+ {
+ if ((raw_index & ~profile_mask) != 0)
+ {
+ index += raw_index;
+ index &= profile_mask;
+ }
+
+ if (prof_state != MALI_PROFILING_STATE_RETURN)
+ {
+ _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
+ return _MALI_OSK_ERR_INVALID_ARGS; /* invalid to call this function in this state */
+ }
+
+ if(index >= raw_index)
+ {
+ _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
+ return _MALI_OSK_ERR_FAULT;
+ }
+
+ *timestamp = profile_entries[index].timestamp;
+ *event_id = profile_entries[index].event_id;
+ data[0] = profile_entries[index].data[0];
+ data[1] = profile_entries[index].data[1];
+ data[2] = profile_entries[index].data[2];
+ data[3] = profile_entries[index].data[3];
+ data[4] = profile_entries[index].data[4];
+ }
+ else
+ {
+ _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
+ return _MALI_OSK_ERR_FAULT;
+ }
+
+ _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
+ return _MALI_OSK_ERR_OK;
+}
+
+_mali_osk_errcode_t _mali_internal_profiling_clear(void)
+{
+ _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW);
+
+ if (MALI_PROFILING_STATE_RETURN != prof_state)
+ {
+ _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
+ return _MALI_OSK_ERR_INVALID_ARGS; /* invalid to call this function in this state */
+ }
+
+ prof_state = MALI_PROFILING_STATE_IDLE;
+ profile_mask = 0;
+ _mali_osk_atomic_init(&profile_insert_index, 0);
+
+ if (NULL != profile_entries)
+ {
+ _mali_osk_vfree(profile_entries);
+ profile_entries = NULL;
+ }
+
+ _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
+ return _MALI_OSK_ERR_OK;
+}
+
+mali_bool _mali_internal_profiling_is_recording(void)
+{
+ return prof_state == MALI_PROFILING_STATE_RUNNING ? MALI_TRUE : MALI_FALSE;
+}
+
+mali_bool _mali_internal_profiling_have_recording(void)
+{
+ return prof_state == MALI_PROFILING_STATE_RETURN ? MALI_TRUE : MALI_FALSE;
+}
diff --git a/driver/src/devicedrv/mali/linux/mali_profiling_internal.h b/driver/src/devicedrv/mali/linux/mali_profiling_internal.h
new file mode 100644
index 0000000..092b9b0
--- /dev/null
+++ b/driver/src/devicedrv/mali/linux/mali_profiling_internal.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2012 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __MALI_PROFILING_INTERNAL_H__
+#define __MALI_PROFILING_INTERNAL_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include "mali_osk.h"
+
+int _mali_internal_profiling_init(mali_bool auto_start);
+void _mali_internal_profiling_term(void);
+
+mali_bool _mali_internal_profiling_is_recording(void);
+mali_bool _mali_internal_profiling_have_recording(void);
+_mali_osk_errcode_t _mali_internal_profiling_clear(void);
+_mali_osk_errcode_t _mali_internal_profiling_get_event(u32 index, u64* timestamp, u32* event_id, u32 data[5]);
+u32 _mali_internal_profiling_get_count(void);
+int _mali_internal_profiling_stop(u32 * count);
+int _mali_internal_profiling_start(u32 * limit);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MALI_PROFILING_INTERNAL_H__ */
diff --git a/driver/src/devicedrv/mali/linux/mali_ukk_gp.c b/driver/src/devicedrv/mali/linux/mali_ukk_gp.c
index 7070016..4ee4a81 100644
--- a/driver/src/devicedrv/mali/linux/mali_ukk_gp.c
+++ b/driver/src/devicedrv/mali/linux/mali_ukk_gp.c
@@ -18,40 +18,15 @@
int gp_start_job_wrapper(struct mali_session_data *session_data, _mali_uk_gp_start_job_s __user *uargs)
{
- _mali_uk_gp_start_job_s kargs;
- _mali_osk_errcode_t err;
+ _mali_osk_errcode_t err;
- MALI_CHECK_NON_NULL(uargs, -EINVAL);
- MALI_CHECK_NON_NULL(session_data, -EINVAL);
+ MALI_CHECK_NON_NULL(uargs, -EINVAL);
+ MALI_CHECK_NON_NULL(session_data, -EINVAL);
- if (!access_ok(VERIFY_WRITE, uargs, sizeof(_mali_uk_gp_start_job_s)))
- {
- return -EFAULT;
- }
+ err = _mali_ukk_gp_start_job(session_data, uargs);
+ if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
- if (0 != copy_from_user(&kargs, uargs, sizeof(_mali_uk_gp_start_job_s))) return -EFAULT;
-
- kargs.ctx = session_data;
- err = _mali_ukk_gp_start_job(&kargs);
- if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
-
- kargs.ctx = NULL; /* prevent kernel address to be returned to user space */
-
- if (0 != copy_to_user(uargs, &kargs, sizeof(_mali_uk_gp_start_job_s)))
- {
- /*
- * If this happens, then user space will not know that the job was actually started,
- * and if we return a queued job, then user space will still think that one is still queued.
- * This will typically lead to a deadlock in user space.
- * This could however only happen if user space deliberately passes a user buffer which
- * passes the access_ok(VERIFY_WRITE) check, but isn't fully writable at the time of copy_to_user().
- * The official Mali driver will never attempt to do that, and kernel space should not be affected.
- * That is why we do not bother to do a complex rollback in this very very very rare case.
- */
- return -EFAULT;
- }
-
- return 0;
+ return 0;
}
int gp_get_core_version_wrapper(struct mali_session_data *session_data, _mali_uk_get_gp_core_version_s __user *uargs)
diff --git a/driver/src/devicedrv/mali/linux/mali_ukk_pp.c b/driver/src/devicedrv/mali/linux/mali_ukk_pp.c
index c11c61b..00a84f7 100644
--- a/driver/src/devicedrv/mali/linux/mali_ukk_pp.c
+++ b/driver/src/devicedrv/mali/linux/mali_ukk_pp.c
@@ -18,24 +18,15 @@
int pp_start_job_wrapper(struct mali_session_data *session_data, _mali_uk_pp_start_job_s __user *uargs)
{
- _mali_uk_pp_start_job_s kargs;
_mali_osk_errcode_t err;
MALI_CHECK_NON_NULL(uargs, -EINVAL);
MALI_CHECK_NON_NULL(session_data, -EINVAL);
- if (!access_ok(VERIFY_WRITE, uargs, sizeof(_mali_uk_pp_start_job_s)))
- {
- return -EFAULT;
- }
-
- if (0 != copy_from_user(&kargs, uargs, sizeof(_mali_uk_pp_start_job_s))) return -EFAULT;
-
- kargs.ctx = session_data;
- err = _mali_ukk_pp_start_job(&kargs);
+ err = _mali_ukk_pp_start_job(session_data, uargs);
if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
- return 0;
+ return 0;
}
int pp_get_number_of_cores_wrapper(struct mali_session_data *session_data, _mali_uk_get_pp_number_of_cores_s __user *uargs)
diff --git a/driver/src/devicedrv/mali/regs/mali_gp_regs.h b/driver/src/devicedrv/mali/regs/mali_gp_regs.h
index 21c83c0..dd259cf 100644
--- a/driver/src/devicedrv/mali/regs/mali_gp_regs.h
+++ b/driver/src/devicedrv/mali/regs/mali_gp_regs.h
@@ -145,7 +145,6 @@ typedef enum
MALIGP2_REG_VAL_IRQ_VS_END_CMD_LST | \
MALIGP2_REG_VAL_IRQ_PLBU_END_CMD_LST | \
MALIGP2_REG_VAL_IRQ_PLBU_OUT_OF_MEM | \
- MALIGP2_REG_VAL_IRQ_HANG | \
MALIGP2_REG_VAL_IRQ_FORCE_HANG | \
MALIGP2_REG_VAL_IRQ_WRITE_BOUND_ERR | \
MALIGP2_REG_VAL_IRQ_SYNC_ERROR | \
@@ -156,7 +155,6 @@ typedef enum
MALIGP2_REG_VAL_IRQ_VS_END_CMD_LST | \
MALIGP2_REG_VAL_IRQ_PLBU_END_CMD_LST | \
MALIGP2_REG_VAL_IRQ_PLBU_OUT_OF_MEM | \
- MALIGP2_REG_VAL_IRQ_HANG | \
MALIGP2_REG_VAL_IRQ_FORCE_HANG | \
MALIGP2_REG_VAL_IRQ_WRITE_BOUND_ERR | \
MALIGP2_REG_VAL_IRQ_SYNC_ERROR | \
diff --git a/driver/src/devicedrv/ump/.version b/driver/src/devicedrv/ump/.version
index 266ae67..26def88 100644
--- a/driver/src/devicedrv/ump/.version
+++ b/driver/src/devicedrv/ump/.version
@@ -1 +1 @@
-r3p1-01rel0
+r3p1-01rel1
diff --git a/driver/src/egl/x11/drm_module/mali_drm/KDIR_CONFIGURATION b/driver/src/egl/x11/drm_module/mali_drm/KDIR_CONFIGURATION
new file mode 100644
index 0000000..cf96691
--- /dev/null
+++ b/driver/src/egl/x11/drm_module/mali_drm/KDIR_CONFIGURATION
@@ -0,0 +1,9 @@
+KDIR-ct1176:=/projects/pr297/linux/eb_ct1176/current/linux
+KDIR-pb926:=/projects/pr297/linux/pb926/current/linux
+KDIR-ct11mp:=/projects/pr297/linux/eb_ct11mp/current/linux
+KDIR-pb11mp:=/projects/pr297/linux/pb11mp/current/linux
+KDIR-pba8:=/projects/pr297/linux/pba8/current/linux
+KDIR-pbxa9:=/projects/pr297/linux/pbxa9/current/linux
+KDIR-tcc8900:=/projects/pr297/linux/tcc8900/current/linux
+KDIR-au1300:=/projects/pr297/linux/rmi-db1300/current/linux
+KDIR-u8500:=/projects/pr297/linux/MOP500/current/linux
diff --git a/driver/src/egl/x11/drm_module/mali_drm/Makefile b/driver/src/egl/x11/drm_module/mali_drm/Makefile
new file mode 100644
index 0000000..403f455
--- /dev/null
+++ b/driver/src/egl/x11/drm_module/mali_drm/Makefile
@@ -0,0 +1,77 @@
+#
+# 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.
+#
+
+MALI_DRM_FILE_PREFIX =
+
+# For each arch check: CROSS_COMPILE , KDIR , CFLAGS += -DARCH
+
+ARCH ?= arm
+## @note Should allow overriding of building MALI DRM for non-debug:
+EXTRA_CFLAGS += -DDEBUG
+
+DRM_SYMVERS_FILE = ../drm/Module.symvers
+KBUILD_EXTRA_SYMBOLS = $(KBUILD_EXTMOD)/$(DRM_SYMVERS_FILE)
+
+
+# linux build system integration
+
+ifneq ($(KERNELRELEASE),)
+# Inside the kernel build system
+
+EXTRA_CFLAGS += -I$(KBUILD_EXTMOD) -I$(KBUILD_EXTMOD)/include -I$(KBUILD_EXTMOD)/../drm/include/
+
+SRC += $(MALI_DRM_FILE_PREFIX)mali/mali_drv.c \
+ $(MALI_DRM_FILE_PREFIX)mali/mali_mm.c
+
+# Selecting files to compile by parsing the config file
+
+MODULE:=mali_drm.ko
+
+obj-m := $(MODULE:.ko=.o)
+$(MODULE:.ko=-y) := $(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-
+ # default to Virtex5
+ CONFIG ?= pb-virtex5
+else
+ # Compiling for the host
+ CONFIG ?= $(shell uname -m)
+endif
+
+# default cpu to select
+CPU ?= ct11mp
+
+# 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) modules
+
+kernelrelease:
+ $(MAKE) -C $(KDIR) kernelrelease
+
+clean:
+ $(MAKE) ARCH=$(ARCH) -C $(KDIR) M=$(CURDIR) clean
+
+endif
diff --git a/driver/src/egl/x11/drm_module/mali_drm/include/Kbuild b/driver/src/egl/x11/drm_module/mali_drm/include/Kbuild
new file mode 100644
index 0000000..c921ab1
--- /dev/null
+++ b/driver/src/egl/x11/drm_module/mali_drm/include/Kbuild
@@ -0,0 +1,11 @@
+unifdef-y += drm.h drm_sarea.h
+unifdef-y += i810_drm.h
+unifdef-y += i830_drm.h
+unifdef-y += i915_drm.h
+unifdef-y += mga_drm.h
+unifdef-y += r128_drm.h
+unifdef-y += radeon_drm.h
+unifdef-y += sis_drm.h
+unifdef-y += savage_drm.h
+unifdef-y += via_drm.h
+unifdef-y += mali_drm.h
diff --git a/driver/src/egl/x11/drm_module/mali_drm/include/mali_drm.h b/driver/src/egl/x11/drm_module/mali_drm/include/mali_drm.h
new file mode 100644
index 0000000..51924de
--- /dev/null
+++ b/driver/src/egl/x11/drm_module/mali_drm/include/mali_drm.h
@@ -0,0 +1,43 @@
+/*
+ * 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_DRM_H__
+#define __MALI_DRM_H__
+
+/* Mali specific ioctls */
+#define NOT_USED_0_3
+#define DRM_MALI_FB_ALLOC 0x04
+#define DRM_MALI_FB_FREE 0x05
+#define NOT_USED_6_12
+#define DRM_MALI_MEM_INIT 0x13
+#define DRM_MALI_MEM_ALLOC 0x14
+#define DRM_MALI_MEM_FREE 0x15
+#define DRM_MALI_FB_INIT 0x16
+
+#define DRM_IOCTL_MALI_FB_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_MALI_FB_ALLOC, drm_mali_mem_t)
+#define DRM_IOCTL_MALI_FB_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_MALI_FB_FREE, drm_mali_mem_t)
+#define DRM_IOCTL_MALI_MEM_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_MALI_MEM_INIT, drm_mali_mem_t)
+#define DRM_IOCTL_MALI_MEM_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_MALI_MEM_ALLOC, drm_mali_mem_t)
+#define DRM_IOCTL_MALI_MEM_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_MALI_MEM_FREE, drm_mali_mem_t)
+#define DRM_IOCTL_MALI_FB_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_MALI_FB_INIT, drm_mali_fb_t)
+
+typedef struct
+{
+ int context;
+ unsigned int offset;
+ unsigned int size;
+ unsigned long free;
+} drm_mali_mem_t;
+
+typedef struct {
+ unsigned int offset, size;
+} drm_mali_fb_t;
+
+#endif /* __MALI_DRM_H__ */
diff --git a/driver/src/egl/x11/drm_module/mali_drm/mali/Makefile b/driver/src/egl/x11/drm_module/mali_drm/mali/Makefile
new file mode 100644
index 0000000..874368d
--- /dev/null
+++ b/driver/src/egl/x11/drm_module/mali_drm/mali/Makefile
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+#
+# Makefile for the drm device driver. This driver provides support for the
+# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
+
+ccflags-y = -Iinclude/drm
+mali_drm-y := mali_drv.o mali_mm.o
+
+obj-$(CONFIG_DRM_MALI) += mali_drm.o
+
+
diff --git a/driver/src/egl/x11/drm_module/mali_drm/mali/mali_drv.c b/driver/src/egl/x11/drm_module/mali_drm/mali/mali_drv.c
new file mode 100644
index 0000000..c9bb653
--- /dev/null
+++ b/driver/src/egl/x11/drm_module/mali_drm/mali/mali_drv.c
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2010, 2012 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <linux/vermagic.h>
+#include "drmP.h"
+#include "mali_drm.h"
+#include "mali_drv.h"
+
+static struct platform_device *pdev;
+
+static int mali_platform_drm_probe(struct platform_device *pdev)
+{
+ return 0;
+}
+
+static int mali_platform_drm_remove(struct platform_device *pdev)
+{
+ return 0;
+}
+
+static int mali_platform_drm_suspend(struct platform_device *dev, pm_message_t state)
+{
+ return 0;
+}
+
+static int mali_platform_drm_resume(struct platform_device *dev)
+{
+ return 0;
+}
+
+
+static char mali_drm_device_name[] = "mali_drm";
+static struct platform_driver platform_drm_driver = {
+ .probe = mali_platform_drm_probe,
+ .remove = mali_platform_drm_remove,
+ .suspend = mali_platform_drm_suspend,
+ .resume = mali_platform_drm_resume,
+ .driver = {
+ .name = mali_drm_device_name,
+ .owner = THIS_MODULE,
+ },
+};
+
+#if 0
+static const struct drm_device_id dock_device_ids[] = {
+ {"MALIDRM", 0},
+ {"", 0},
+};
+#endif
+
+static int mali_driver_load(struct drm_device *dev, unsigned long chipset)
+{
+ int ret;
+ unsigned long base, size;
+ drm_mali_private_t *dev_priv;
+ printk(KERN_ERR "DRM: mali_driver_load start\n");
+
+ dev_priv = drm_calloc(1, sizeof(drm_mali_private_t), DRM_MEM_DRIVER);
+ if ( dev_priv == NULL ) return -ENOMEM;
+
+ dev->dev_private = (void *)dev_priv;
+
+ if ( NULL == dev->platformdev )
+ {
+ dev->platformdev = platform_device_register_simple(mali_drm_device_name, 0, NULL, 0);
+ pdev = dev->platformdev;
+ }
+
+ #if 0
+ base = drm_get_resource_start(dev, 1 );
+ size = drm_get_resource_len(dev, 1 );
+ #endif
+ ret = drm_sman_init(&dev_priv->sman, 2, 12, 8);
+ if ( ret ) drm_free(dev_priv, sizeof(dev_priv), DRM_MEM_DRIVER);
+ //if ( ret ) kfree( dev_priv );
+
+ printk(KERN_ERR "DRM: mali_driver_load done\n");
+
+ return ret;
+}
+
+static int mali_driver_unload( struct drm_device *dev )
+{
+ drm_mali_private_t *dev_priv = dev->dev_private;
+ printk(KERN_ERR "DRM: mali_driver_unload start\n");
+
+ drm_sman_takedown(&dev_priv->sman);
+ drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
+ //kfree( dev_priv );
+ printk(KERN_ERR "DRM: mali_driver_unload done\n");
+
+ return 0;
+}
+
+static struct drm_driver driver =
+{
+ .driver_features = DRIVER_USE_PLATFORM_DEVICE,
+ .load = mali_driver_load,
+ .unload = mali_driver_unload,
+ .context_dtor = NULL,
+ .dma_quiescent = mali_idle,
+ .reclaim_buffers = NULL,
+ .reclaim_buffers_idlelocked = mali_reclaim_buffers_locked,
+ .lastclose = mali_lastclose,
+ .get_map_ofs = drm_core_get_map_ofs,
+ .get_reg_ofs = drm_core_get_reg_ofs,
+ .ioctls = mali_ioctls,
+ .fops = {
+ .owner = THIS_MODULE,
+ .open = drm_open,
+ .release = drm_release,
+ .ioctl = drm_ioctl,
+ .mmap = drm_mmap,
+ .poll = drm_poll,
+ .fasync = drm_fasync,
+ },
+ .name = DRIVER_NAME,
+ .desc = DRIVER_DESC,
+ .date = DRIVER_DATE,
+ .major = DRIVER_MAJOR,
+ .minor = DRIVER_MINOR,
+ .patchlevel = DRIVER_PATCHLEVEL,
+};
+
+static int __init mali_init(void)
+{
+ driver.num_ioctls = mali_max_ioctl;
+ return drm_init(&driver);
+}
+
+static void __exit mali_exit(void)
+{
+ platform_device_unregister( pdev );
+ drm_exit(&driver);
+}
+
+module_init(mali_init);
+module_exit(mali_exit);
+
+MODULE_INFO(vermagic, VERMAGIC_STRING);
+MODULE_AUTHOR("ARM Ltd.");
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL and additional rights");
diff --git a/driver/src/egl/x11/drm_module/mali_drm/mali/mali_drv.h b/driver/src/egl/x11/drm_module/mali_drm/mali/mali_drv.h
new file mode 100644
index 0000000..87f28ec
--- /dev/null
+++ b/driver/src/egl/x11/drm_module/mali_drm/mali/mali_drv.h
@@ -0,0 +1,39 @@
+/*
+ * 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_DRV_H_
+#define _MALI_DRV_H_
+
+#define DRIVER_AUTHOR "ARM"
+#define DRIVER_NAME "mali_drm"
+#define DRIVER_DESC "DRM module for Mali-200, Mali-400"
+#define DRIVER_DATE "20100520"
+#define DRIVER_MAJOR 0
+#define DRIVER_MINOR 1
+#define DRIVER_PATCHLEVEL 0
+
+#include "drm_sman.h"
+
+typedef struct drm_mali_private
+{
+ drm_local_map_t *mmio;
+ unsigned int idle_fault;
+ struct drm_sman sman;
+ int vram_initialized;
+ unsigned long vram_offset;
+} drm_mali_private_t;
+
+extern int mali_idle(struct drm_device *dev);
+extern void mali_reclaim_buffers_locked(struct drm_device *dev, struct drm_file *file_priv);
+extern void mali_lastclose(struct drm_device *dev);
+extern struct drm_ioctl_desc mali_ioctls[];
+extern int mali_max_ioctl;
+
+#endif /* _MALI_DRV_H_ */
diff --git a/driver/src/egl/x11/drm_module/mali_drm/mali/mali_mm.c b/driver/src/egl/x11/drm_module/mali_drm/mali/mali_mm.c
new file mode 100644
index 0000000..65108be
--- /dev/null
+++ b/driver/src/egl/x11/drm_module/mali_drm/mali/mali_mm.c
@@ -0,0 +1,265 @@
+/*
+ * Copyright (C) 2010, 2012 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
+ *
+ * A copy of the licence is included with the program, and can also be obtained from Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "drmP.h"
+#include "mali_drm.h"
+#include "mali_drv.h"
+
+#define VIDEO_TYPE 0
+#define MEM_TYPE 1
+
+#define MALI_MM_ALIGN_SHIFT 4
+#define MALI_MM_ALIGN_MASK ( (1 << MALI_MM_ALIGN_SHIFT) - 1)
+
+
+static void *mali_sman_mm_allocate( void *private, unsigned long size, unsigned alignment )
+{
+ printk(KERN_ERR "DRM: %s\n", __func__);
+ //struct mali_memreq req;
+
+ //req.size = size;
+ /* XXX _ump_ukk_allocate( _ump_uk_allocate_s *user_interaction ); */
+ //if (req.size == 0) return NULL;
+ //else return (void *)(unsigned long)~req.offset;
+ return NULL;
+}
+
+static void mali_sman_mm_free( void *private, void *ref )
+{
+ printk(KERN_ERR "DRM: %s\n", __func__);
+ /*ump_free(~((unsigned long)ref));*/
+
+}
+
+static void mali_sman_mm_destroy( void *private )
+{
+ printk(KERN_ERR "DRM: %s\n", __func__);
+}
+
+static unsigned long mali_sman_mm_offset( void *private, void *ref )
+{
+ printk(KERN_ERR "DRM: %s\n", __func__);
+ return ~((unsigned long)ref);
+}
+
+static int mali_fb_init( struct drm_device *dev, void *data, struct drm_file *file_priv )
+{
+ drm_mali_private_t *dev_priv = dev->dev_private;
+ drm_mali_fb_t *fb = data;
+ int ret;
+ printk(KERN_ERR "DRM: %s\n", __func__);
+
+ mutex_lock(&dev->struct_mutex);
+ {
+ struct drm_sman_mm sman_mm;
+ sman_mm.private = (void *)0xFFFFFFFF;
+ sman_mm.allocate = mali_sman_mm_allocate;
+ sman_mm.free = mali_sman_mm_free;
+ sman_mm.destroy = mali_sman_mm_destroy;
+ sman_mm.offset = mali_sman_mm_offset;
+ ret = drm_sman_set_manager(&dev_priv->sman, VIDEO_TYPE, &sman_mm);
+ }
+
+ if (ret) {
+ DRM_ERROR("VRAM memory manager initialisation error\n");
+ mutex_unlock(&dev->struct_mutex);
+ return ret;
+ }
+
+ dev_priv->vram_initialized = 1;
+ dev_priv->vram_offset = fb->offset;
+
+ mutex_unlock(&dev->struct_mutex);
+ DRM_DEBUG("offset = %u, size = %u\n", fb->offset, fb->size);
+
+ return 0;
+}
+
+static int mali_drm_alloc(struct drm_device *dev, struct drm_file *file_priv, void *data, int pool)
+{
+ drm_mali_private_t *dev_priv = dev->dev_private;
+ drm_mali_mem_t *mem = data;
+ int retval = 0;
+ struct drm_memblock_item *item;
+ printk(KERN_ERR "DRM: %s\n", __func__);
+
+ mutex_lock(&dev->struct_mutex);
+
+ if (0 == dev_priv->vram_initialized )
+ {
+ DRM_ERROR("Attempt to allocate from uninitialized memory manager.\n");
+ mutex_unlock(&dev->struct_mutex);
+ return -EINVAL;
+ }
+
+ mem->size = (mem->size + MALI_MM_ALIGN_MASK) >> MALI_MM_ALIGN_SHIFT;
+ item = drm_sman_alloc(&dev_priv->sman, pool, mem->size, 0,
+ (unsigned long)file_priv);
+
+ mutex_unlock(&dev->struct_mutex);
+ if (item)
+ {
+ mem->offset = dev_priv->vram_offset + (item->mm->offset(item->mm, item->mm_info) << MALI_MM_ALIGN_SHIFT);
+ mem->free = item->user_hash.key;
+ mem->size = mem->size << MALI_MM_ALIGN_SHIFT;
+ } else {
+ mem->offset = 0;
+ mem->size = 0;
+ mem->free = 0;
+ retval = -ENOMEM;
+ }
+
+ DRM_DEBUG("alloc %d, size = %d, offset = %d\n", pool, mem->size, mem->offset);
+
+ return retval;
+}
+
+static int mali_drm_free(struct drm_device *dev, void *data, struct drm_file *file_priv)
+{
+ drm_mali_private_t *dev_priv = dev->dev_private;
+ drm_mali_mem_t *mem = data;
+ int ret;
+ printk(KERN_ERR "DRM: %s\n", __func__);
+
+ mutex_lock(&dev->struct_mutex);
+ ret = drm_sman_free_key(&dev_priv->sman, mem->free);
+ mutex_unlock(&dev->struct_mutex);
+ DRM_DEBUG("free = 0x%lx\n", mem->free);
+
+ return ret;
+}
+
+static int mali_fb_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv)
+{
+ printk(KERN_ERR "DRM: %s\n", __func__);
+ return mali_drm_alloc(dev, file_priv, data, VIDEO_TYPE);
+}
+
+static int mali_ioctl_mem_init(struct drm_device *dev, void *data, struct drm_file *file_priv)
+{
+ drm_mali_private_t *dev_priv = dev->dev_private;
+ drm_mali_mem_t *mem= data;
+ int ret;
+ dev_priv = dev->dev_private;
+ printk(KERN_ERR "DRM: %s\n", __func__);
+
+ mutex_lock(&dev->struct_mutex);
+ ret = drm_sman_set_range(&dev_priv->sman, MEM_TYPE, 0, mem->size >> MALI_MM_ALIGN_SHIFT);
+
+ if (ret) {
+ DRM_ERROR("MEM memory manager initialisation error\n");
+ mutex_unlock(&dev->struct_mutex);
+ return ret;
+ }
+
+ //dev_priv->agp_initialized = 1;
+ //dev_priv->agp_offset = agp->offset;
+ mutex_unlock(&dev->struct_mutex);
+
+ //DRM_DEBUG("offset = %u, size = %u\n", agp->offset, agp->size);
+ return 0;
+}
+
+static int mali_ioctl_mem_alloc(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
+{
+
+ printk(KERN_ERR "DRM: %s\n", __func__);
+ return mali_drm_alloc(dev, file_priv, data, MEM_TYPE);
+}
+
+static drm_local_map_t *mem_reg_init(struct drm_device *dev)
+{
+ struct drm_map_list *entry;
+ drm_local_map_t *map;
+ printk(KERN_ERR "DRM: %s\n", __func__);
+
+ list_for_each_entry(entry, &dev->maplist, head) {
+ map = entry->map;
+ if (!map)
+ continue;
+ if (map->type == _DRM_REGISTERS) {
+ return map;
+ }
+ }
+ return NULL;
+}
+
+int mali_idle(struct drm_device *dev)
+{
+ drm_mali_private_t *dev_priv = dev->dev_private;
+ uint32_t idle_reg;
+ unsigned long end;
+ int i;
+ printk(KERN_ERR "DRM: %s\n", __func__);
+
+ if (dev_priv->idle_fault)
+ return 0;
+
+ #if 0
+ if (dev_priv->mmio == NULL) {
+ dev_priv->mmio = mali_reg_init(dev);
+ if (dev_priv->mmio == NULL) {
+ DRM_ERROR("Could not find register map.\n");
+ return 0;
+ }
+ }
+ #endif
+
+ return 0;
+}
+
+
+void mali_lastclose(struct drm_device *dev)
+{
+ drm_mali_private_t *dev_priv = dev->dev_private;
+ printk(KERN_ERR "DRM: %s\n", __func__);
+
+ if (!dev_priv) return;
+
+ mutex_lock(&dev->struct_mutex);
+ drm_sman_cleanup(&dev_priv->sman);
+ dev_priv->vram_initialized = 0;
+ dev_priv->mmio = NULL;
+ mutex_unlock(&dev->struct_mutex);
+}
+
+void mali_reclaim_buffers_locked(struct drm_device * dev, struct drm_file *file_priv)
+{
+ drm_mali_private_t *dev_priv = dev->dev_private;
+ printk(KERN_ERR "DRM: %s\n", __func__);
+
+ mutex_lock(&dev->struct_mutex);
+ if (drm_sman_owner_clean(&dev_priv->sman, (unsigned long)file_priv))
+ {
+ mutex_unlock(&dev->struct_mutex);
+ return;
+ }
+
+ if (dev->driver->dma_quiescent)
+ {
+ dev->driver->dma_quiescent(dev);
+ }
+
+ drm_sman_owner_cleanup(&dev_priv->sman, (unsigned long)file_priv);
+ mutex_unlock(&dev->struct_mutex);
+ return;
+}
+
+struct drm_ioctl_desc mali_ioctls[] = {
+ DRM_IOCTL_DEF(DRM_MALI_FB_ALLOC, mali_fb_alloc, DRM_AUTH),
+ DRM_IOCTL_DEF(DRM_MALI_FB_FREE, mali_drm_free, DRM_AUTH),
+ DRM_IOCTL_DEF(DRM_MALI_MEM_INIT, mali_ioctl_mem_init, DRM_AUTH | DRM_MASTER | DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_MALI_MEM_ALLOC, mali_ioctl_mem_alloc, DRM_AUTH),
+ DRM_IOCTL_DEF(DRM_MALI_MEM_FREE, mali_drm_free, DRM_AUTH),
+ DRM_IOCTL_DEF(DRM_MALI_FB_INIT, mali_fb_init, DRM_AUTH | DRM_MASTER | DRM_ROOT_ONLY),
+};
+
+int mali_max_ioctl = DRM_ARRAY_SIZE(mali_ioctls);
diff --git a/driver/src/egl/x11/drm_module/readme b/driver/src/egl/x11/drm_module/readme
new file mode 100644
index 0000000..578d725
--- /dev/null
+++ b/driver/src/egl/x11/drm_module/readme
@@ -0,0 +1,8 @@
+How to build:
+KDIR=/work/kernel-2.6.35.7 make
+
+How to install:
+insmod drm/drm.ko
+insmod mali_drm/mali_drm.ko
+insmod trunk/src/devicedrv/mali/mali.ko
+
diff --git a/driver/src/shared/essl_compiler/src/frontend/Makefile.offline b/driver/src/shared/essl_compiler/src/frontend/Makefile.offline
index fc9c79a..709a2ba 100644
--- a/driver/src/shared/essl_compiler/src/frontend/Makefile.offline
+++ b/driver/src/shared/essl_compiler/src/frontend/Makefile.offline
@@ -41,7 +41,8 @@ MALI400_FRONTEND_NOTEST_SRCS = \
$(MALI400_COMPILER_FRONTEND_DIR)/eliminate_complex_ops.c \
$(MALI400_COMPILER_FRONTEND_DIR)/ssa.c \
$(MALI400_COMPILER_FRONTEND_DIR)/ast_to_lir.c \
- $(MALI400_COMPILER_FRONTEND_DIR)/global_variable_inlining.c
+ $(MALI400_COMPILER_FRONTEND_DIR)/global_variable_inlining.c \
+ $(MALI400_COMPILER_FRONTEND_DIR)/vertex_cpu_calculations.c
MALI400_COMPILER_SRCS += $(MALI400_FRONTEND_SRCS)
TEST_SRCS += $(filter-out $(MALI400_FRONTEND_NOTEST_SRCS),$(MALI400_FRONTEND_SRCS))
diff --git a/driver/src/shared/essl_compiler/src/middle/proactive_calculations.c b/driver/src/shared/essl_compiler/src/middle/proactive_calculations.c
index 422247d..7ea9d9e 100644
--- a/driver/src/shared/essl_compiler/src/middle/proactive_calculations.c
+++ b/driver/src/shared/essl_compiler/src/middle/proactive_calculations.c
@@ -19,6 +19,8 @@
#include "common/essl_type.h"
#include "common/symbol_table.h"
#include "middle/dominator.h"
+#include "maligp2/maligp2_instruction.h"
+#include "maligp2/maligp2_target.h"
/**
* This file includes implementation of the pilot shading optimization.
@@ -390,7 +392,6 @@ static memerr add_to_hoist_points(pilot_calculations_context *ctx,
{
if(is_const)
{
- int tmp_weight;
run_time_nodes_list * prev_rt_node_elem;
if(succ == ctx->cfg->exit_block->source)
{
@@ -407,6 +408,7 @@ static memerr add_to_hoist_points(pilot_calculations_context *ctx,
(*calc_weight) += weight;
if(succ != n)
{
+ int tmp_weight = 0;
ESSL_CHECK(find_last_fully_const_succ(ctx, succ, rtc_elem, &tmp_weight));
(*calc_weight) += tmp_weight;
}
@@ -475,7 +477,7 @@ static memerr find_last_fully_const_succ(pilot_calculations_context *ctx, node *
/* loop structure: don't work with loops as it means that we should modife control flow*/
rtc_elem->orig_rt_node = NULL;
_essl_ptrset_clear(&ctx->hoist_points);
- return -1;
+ return MEM_OK;
}
is_const = ESSL_FALSE;
}else if(succ->hdr.kind == EXPR_KIND_STORE)
@@ -533,7 +535,7 @@ static memerr find_last_point_for_hoisting_out(pilot_calculations_context *ctx)
for(elem = ctx->rtc_nodes; elem != NULL; elem = elem_n)
{
/* for each rt constant candidate*/
- int tmp_weight;
+ int tmp_weight = 0;
node_succs_list *succs_list;
elem_n = elem->next;
weight = get_node_pilot_weight(elem->node);
@@ -650,7 +652,7 @@ static node * copy_rtc_node(pilot_calculations_context *ctx, node *n)
{
node *pred, *copy_pred;
pred = GET_CHILD(n, i);
- copy_pred = copy_rtc_node(ctx, pred);
+ ESSL_CHECK(copy_pred = copy_rtc_node(ctx, pred));
SET_CHILD(res, i, copy_pred);
}
ESSL_CHECK(_essl_ptrdict_insert(&ctx->copied, n, res));
@@ -704,7 +706,7 @@ static memerr move_calculations_to_pilot_shader(pilot_calculations_context *ctx,
sym->opt.pilot.proactive_uniform_num = num;
ESSL_CHECK(sym_list = LIST_NEW(ctx->pool, symbol_list));
sym_list->sym = sym;
- LIST_INSERT_BACK(ctx->tu->uniforms, sym_list);
+ LIST_INSERT_BACK(&ctx->tu->uniforms, sym_list);
/* creating a load for the pilot uniform */
ESSL_CHECK(address = _essl_new_variable_reference_expression(ctx->pool, sym));
@@ -739,7 +741,7 @@ static memerr move_calculations_to_pilot_shader(pilot_calculations_context *ctx,
sym->opt.pilot.proactive_uniform_num = num;
ESSL_CHECK(sym_list = LIST_NEW(ctx->pool, symbol_list));
sym_list->sym = sym;
- LIST_INSERT_BACK(ctx->tu->globals, sym_list);
+ LIST_INSERT_BACK(&ctx->tu->globals, sym_list);
/* creating a load for the pilot variable */
ESSL_CHECK(address = _essl_new_variable_reference_expression(ctx->pool, sym));
@@ -918,43 +920,7 @@ static memerr collect_rt_nodes(pilot_calculations_context *ctx, node *n, basic_b
rtc_elem->orig_func = ctx->func;
LIST_INSERT_FRONT(&ctx->rtc_nodes, rtc_elem);
}
- }else if(0) /* disabled because MJOLL-2516 */
- {
- ptrdict_iter it;
- ptrdict_entry *entry;
- node *nn;
- _essl_ptrdict_iter_init(&it, &ctx->rt_const_nodes);
- while((entry = _essl_ptrdict_next_entry(&it)) != NULL)
- {
-
- node_succs_list *succs_list;
- run_time_constant_node *rtc_elem;
- essl_bool has_succs;
- nn = _essl_ptrdict_get_key(entry);
- if( nn == NULL)
- {
- break;
- }
- if(is_addressing_op(nn))
- {
- continue;
- }
-
- succs_list = find_rt_const_succs(ctx, nn, &has_succs);
- if(has_succs) /* non null variant should be further optimized */
- {
- ESSL_CHECK(rtc_elem = LIST_NEW(ctx->temp_pool, run_time_constant_node));
- rtc_elem->node = nn;
- rtc_elem->orig_rt_node = nn;
- rtc_elem->orig_rt_bb = block;
- rtc_elem->orig_func = ctx->func;
- LIST_INSERT_FRONT(&ctx->rtc_nodes, rtc_elem);
- }
-
- }
-
}
-
return MEM_OK;
}
@@ -1097,6 +1063,35 @@ static memerr find_constant_input_calculations_for_func(pilot_calculations_conte
}
/**
+ * Check if we already have too many uniforms in a GP2 shader
+ */
+static essl_bool is_too_many_uniforms(translation_unit *tu)
+{
+ symbol_list *sl;
+ symbol *sym;
+ unsigned int total_size = 0;
+ for(sl = tu->globals; sl != NULL; sl = sl->next)
+ {
+ sym = sl->sym;
+ total_size +=_essl_maligp2_get_type_size(tu->desc, sym->type, sym->address_space);
+
+ }
+ for(sl = tu->uniforms; sl != NULL; sl = sl->next)
+ {
+ sym = sl->sym;
+ total_size +=_essl_maligp2_get_type_size(tu->desc, sym->type, sym->address_space);
+ }
+
+ if(total_size > (unsigned int)(tu->desc->options->n_maligp2_constant_registers - 10)*MALIGP2_NATIVE_VECTOR_SIZE)
+ {
+ return ESSL_TRUE;
+ }
+
+ return ESSL_FALSE;
+
+}
+
+/**
* Driver function for the optimization
* To be called from middle passes run.
*/
@@ -1113,6 +1108,14 @@ memerr _essl_optimise_constant_input_calculations(pass_run_context *pr_ctx, tran
ctx.rtc_nodes = NULL;
ctx.applied = ESSL_FALSE;
+ if(ctx.desc->kind == TARGET_VERTEX_SHADER)
+ {
+ if(is_too_many_uniforms(tu))
+ {
+ return MEM_OK;
+ }
+ }
+
ESSL_CHECK(_essl_ptrdict_init(&ctx.node_succs, pr_ctx->tmp_pool));
ESSL_CHECK(_essl_ptrset_init(&ctx.visited, pr_ctx->tmp_pool));
ESSL_CHECK(_essl_ptrset_init(&ctx.hoist_points, pr_ctx->tmp_pool));
diff --git a/driver/src/shared/m200_fbdump.c b/driver/src/shared/m200_fbdump.c
index dd94abf..0258367 100644
--- a/driver/src/shared/m200_fbdump.c
+++ b/driver/src/shared/m200_fbdump.c
@@ -214,11 +214,19 @@ MALI_EXPORT mali_bool _mali_fbdump_is_requested(mali_frame_builder* fbuilder)
*/
const u8 type = (fbuilder->identifier >> 24) & 0xFF;
- if (!( MALI_FRAME_BUILDER_TYPE_EGL_COMPOSITOR == type || MALI_FRAME_BUILDER_TYPE_EGL_WINDOW == type))
+#if defined(HAVE_ANDROID_OS)
+ if (MALI_FRAME_BUILDER_TYPE_EGL_COMPOSITOR != type)
{
return MALI_FALSE;
}
#else
+ if (MALI_FRAME_BUILDER_TYPE_EGL_WINDOW != type)
+ {
+ return MALI_FALSE;
+ }
+#endif
+
+#else
#error "MALI_TIMELINE_PROFILING_ENABLED must be enabled to use MALI_FRAMEBUFFER_DUMP_ENABLED."
#endif /* MALI_TIMELINE_PROFILING_ENABLED */
diff --git a/driver/src/shared/m200_plbuheap.c b/driver/src/shared/m200_plbuheap.c
deleted file mode 100644
index b8ac572..0000000
--- a/driver/src/shared/m200_plbuheap.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * This confidential and proprietary software may be used only as
- * authorized by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2011-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.
- */
-
-#include "m200_plbuheap.h"
-
-#if !defined(HARDWARE_ISSUE_3251)
-/* default heap size must be 1024 aligned as this is the maximum tile list block bytesize */
-#ifndef __SYMBIAN32__
-#define MALI_PLBUHEAP_SIZE_INIT (1024 * 192) /* The initial size of a PLBU heap */
-#define MALI_PLBUHEAP_SIZE_GROW (1024 * 256) /* The increment on a PLBU heap*/
-#else
-/* Symbian devices prefer to conserve memory, and also make less use of these heaps in practice */
-#define MALI_PLBUHEAP_SIZE_INIT (1024 * 64)
-#define MALI_PLBUHEAP_SIZE_GROW (1024 * 128)
-#endif
-#define MALI_PLBUHEAP_SIZE_MAX (1024 * 1024 *16 * 4)
-
-#else
-/* use one large static heap block */
-#define MALI_PLBUHEAP_SIZE_STATIC (1024 * 1024 * 8)
-#endif
-
-MALI_CHECK_RESULT mali_plbuheap* _mali_plbuheap_alloc( mali_base_ctx_handle base_ctx, void* owner )
-{
- u32 i;
- mali_plbuheap* heap = NULL;
-
- heap = _mali_sys_calloc(1, sizeof( mali_plbuheap ) );
- if(heap == NULL) return NULL;
-
- heap->plbu_ds_resource = mali_ds_resource_allocate( base_ctx, owner, NULL );
- if( MALI_NO_HANDLE == heap->plbu_ds_resource )
- {
- _mali_sys_free( heap );
- return NULL;
- }
-
- _mali_sys_atomic_initialize(&heap->use_count, 0);
-
-#if !defined(HARDWARE_ISSUE_3251)
- heap->init_size = (u32)_mali_sys_config_string_get_s64("MALI_FRAME_HEAP_SIZE", MALI_PLBUHEAP_SIZE_INIT, 4096, MALI_PLBUHEAP_SIZE_MAX);
- heap->plbu_heap = _mali_mem_heap_alloc( base_ctx, heap->init_size , MALI_PLBUHEAP_SIZE_MAX, MALI_PLBUHEAP_SIZE_GROW );
-#else
- heap->init_size = (u32)_mali_sys_config_string_get_s64("MALI_FRAME_HEAP_SIZE", MALI_PLBUHEAP_SIZE_STATIC, 4096, MALI_PLBUHEAP_SIZE_STATIC);
- heap->plbu_heap = _mali_mem_alloc( base_ctx, heap_size, 1024, MALI_PP_READ | MALI_GP_WRITE );
-#endif
-
- if( MALI_NO_HANDLE == heap->plbu_heap )
- {
- _mali_plbuheap_free( heap );
- return NULL;
- }
-
- return heap;
-}
-
-void _mali_plbuheap_free( mali_plbuheap* heap )
-{
- MALI_DEBUG_ASSERT_POINTER( heap );
- MALI_DEBUG_ASSERT_POINTER( heap->plbu_heap );
- MALI_DEBUG_ASSERT_HANDLE( heap->plbu_ds_resource );
- MALI_DEBUG_ASSERT( _mali_sys_atomic_get( &heap->use_count) == 0, ("Cannot free PLBU heap while it is still in use") );
-
- if(heap->plbu_heap) _mali_mem_free( heap->plbu_heap );
- if(heap->plbu_ds_resource) mali_ds_resource_release_connections( heap->plbu_ds_resource, MALI_DS_RELEASE, MALI_DS_ABORT_ALL );
- _mali_sys_free( heap );
-}
-
-void _mali_plbuheap_add_usecount(mali_plbuheap* heap)
-{
- MALI_DEBUG_ASSERT_POINTER( heap );
- MALI_DEBUG_ASSERT_HANDLE( heap->plbu_heap );
-
- _mali_sys_atomic_inc(&heap->use_count);
-}
-
-void _mali_plbuheap_dec_usecount(mali_plbuheap* heap)
-{
- MALI_DEBUG_ASSERT_POINTER( heap );
- MALI_DEBUG_ASSERT_HANDLE( heap->plbu_heap );
-
- if( _mali_sys_atomic_dec_and_return(&heap->use_count) == 0 )
- {
- #if !defined(HARDWARE_ISSUE_3251)
- if(heap->reset)
- {
- heap->reset = MALI_FALSE;
- _mali_mem_heap_reset( heap->plbu_heap );
- }
- #endif
- }
-}
-
diff --git a/driver/src/shared/m200_plbuheap.h b/driver/src/shared/m200_plbuheap.h
deleted file mode 100644
index 2d19480..0000000
--- a/driver/src/shared/m200_plbuheap.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2011-2012 ARM Limited. All rights reserved.
- *
- * This program is free software and is provided to you under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
- *
- * A copy of the licence is included with the program, and can also be obtained from Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef _M200_PLBUHEAP_H_
-#define _M200_PLBUHEAP_H_
-
-#include <mali_system.h>
-#include <base/mali_memory.h>
-#include <base/mali_dependency_system.h>
-
-/**
- * This file provides a structure holding all information about the PLBU heap.
- *
- * In its simplest form, the PLBU heap is simply a memory block.
- *
- */
-
-struct mali_plbuheap
-{
- /* ALL of these fields are READ ONLY outside of the setters provided by this file. Do not modify! */
-
- mali_mem_handle plbu_heap; /**< The actual PLBU heap memory. */
- u32 init_size;
- u32 last_used_sizes[4];
- mali_bool reset; /**< Set when a reset is needed but couldn't happen due to the PLBU heap being in use */
- mali_atomic_int use_count; /**< Count the number of times this has gone through a job. Zero after a reset */
- mali_ds_resource_handle plbu_ds_resource; /**< The DS resource associated with this memory block. Used to prevent concurrent access. */
-
-};
-
-/**
- * Allocate a new PLBU heap.
- * The heap will be allocated holding MALI_PLBUHEAP_SIZE_INIT number of bytes.
- *
- * @param base_ctx The current base context
- * @param owner for frame_builder
- * @param bHwLimitation set when it is only for the hw limitation case
- * @return A new PLBU heap object
- */
-MALI_CHECK_RESULT mali_plbuheap* _mali_plbuheap_alloc( mali_base_ctx_handle base_ctx, void* owner, mali_bool bHwLimitation );
-
-/**
- * Free an allocated PLBU heap
- * This function will assert that the usecount is 0 when freeing.
- *
- * This function will free the heap object unquestionably.
- *
- * @param heap The heap to free
- */
-void _mali_plbuheap_free( mali_plbuheap* heap );
-
-/**
- * Add the use_count when heap is in use.
- *
- * @param heap The heap used
-*/
-void _mali_plbuheap_add_usecount(mali_plbuheap* heap);
-
-/**
- * Decrease the use_count when heap is no longer in use.
- *
- * @param heap The heap used
-*/
-void _mali_plbuheap_dec_usecount(mali_plbuheap* heap);
-
-#endif /* _M200_PLBUHEAP_H_ */
-
diff --git a/driver/src/shared/m200_projob.c b/driver/src/shared/m200_projob.c
index 9c8a4ea..d56ce52 100644
--- a/driver/src/shared/m200_projob.c
+++ b/driver/src/shared/m200_projob.c
@@ -114,7 +114,7 @@ MALI_STATIC mali_err_code allocate_and_setup_pp_job(struct mali_projob* projob,
}
/* allocate new tilelist buffer. This is allocated on the fbuilder framepool.
- * Need space for PROJOB_DRAWCALL_LIMIT * 2 commands 8 bytes each, plus initialization
+ * Need space for PROJOB_DRAWCALL_LIMIT * 2 commands � 8 bytes each, plus initialization
* commands and an end command */
num_tilebuf_commands = PROJOB_DRAWCALL_LIMIT*2 + 2; /*+2 for "begin tile" and "end list" */
tilebuf = _mali_mem_pool_alloc(pool,
@@ -252,7 +252,7 @@ u32 _mali_projob_add_gp_drawcall(struct mali_frame_builder* frame_builder, u64*
u32 *streams;
mali_addr streams_mem;
u32 num_cmnds = 0;
- int num_instructions, i;
+ int num_instructions;
/* We want to set up a set of input and output streams for the pilot job, but pilot jobs doesn't use GP inputs nor outputs.
* So all streams should be disabled. Unfortunately, the HW cannot encode "0 active streams", so we need at least one
@@ -298,7 +298,12 @@ u32 _mali_projob_add_gp_drawcall(struct mali_frame_builder* frame_builder, u64*
/* shade vertices : operation mode, number_of_verts = 1 */
+#ifdef USING_MALI450
+ /* mali 450 have two GP cores, and thus need to run the pilot job on both cores to update both constant registers */
+ cmnds[num_cmnds++] = GP_VS_COMMAND_SHADE_VERTICES( GP_PLBU_OPMODE_DRAW_ELEMENTS, 2 );
+#else
cmnds[num_cmnds++] = GP_VS_COMMAND_SHADE_VERTICES( GP_PLBU_OPMODE_DRAW_ELEMENTS, 1 );
+#endif
cmnds[num_cmnds++] = GP_VS_COMMAND_FLUSH_WRITEBACK_BUF();
return num_cmnds;
@@ -368,9 +373,6 @@ void _mali_projob_reset(mali_internal_frame* frame)
projob = &frame->projob;
- /* early out? */
- if(0 == projob->num_pp_drawcalls_added_to_the_current_pp_job) return;
-
/* problem: like with flushing, freeing a HW job can cause
* a series of callbacks that call reset. Effectively we end up
* calling reset within reset. That's messy.