From a5cc4b45aaa4691cdf0b6c634d8166f689e78ab0 Mon Sep 17 00:00:00 2001 From: Chunsang Jeong Date: Wed, 19 Oct 2011 09:27:07 +0900 Subject: Added /proc/mali for getting profiling information from driver. Signed-off-by: Chunsang Jeong --- drivers/gpu/arm/mali/Makefile | 1 + drivers/gpu/arm/mali/common/mali_kernel_GP2.c | 11 +++ drivers/gpu/arm/mali/common/mali_kernel_MALI200.c | 11 +++ drivers/gpu/arm/mali/common/mali_kernel_core.c | 17 ++++ .../gpu/arm/mali/common/mali_kernel_rendercore.c | 102 +++++++++++++++++++++ .../gpu/arm/mali/common/mali_kernel_rendercore.h | 4 + .../gpu/arm/mali/common/mali_kernel_subsystem.h | 8 ++ drivers/gpu/arm/mali/common/pmm/mali_pmm.h | 4 + drivers/gpu/arm/mali/linux/mali_kernel_linux.c | 43 ++++++++- drivers/gpu/arm/mali/linux/mali_kernel_pm.c | 7 ++ drivers/gpu/arm/mali/linux/mali_kernel_sysfs.c | 4 +- 11 files changed, 208 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/gpu/arm/mali/Makefile b/drivers/gpu/arm/mali/Makefile index 1f955dd7219f..d4f009aee84c 100755 --- a/drivers/gpu/arm/mali/Makefile +++ b/drivers/gpu/arm/mali/Makefile @@ -88,6 +88,7 @@ DEFINES += -DMALI_PMM_RUNTIME_JOB_CONTROL_ON=$(USING_MALI_RUN_TIME_PM) # MALI_STATE_TRACKING is only supported on Linux kernels from version 2.6.32. DEFINES += -DMALI_STATE_TRACKING=1 +DEFINES += -DMALI_STATE_TRACKING_USING_PROC=1 DEFINES += -DMALI_OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB=$(OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB) ifneq ($(call submodule_enabled, $M, PMU),0) diff --git a/drivers/gpu/arm/mali/common/mali_kernel_GP2.c b/drivers/gpu/arm/mali/common/mali_kernel_GP2.c index 552b57efcb4e..cb8531491790 100755 --- a/drivers/gpu/arm/mali/common/mali_kernel_GP2.c +++ b/drivers/gpu/arm/mali/common/mali_kernel_GP2.c @@ -102,8 +102,12 @@ static _mali_osk_errcode_t maligp_renderunit_create(_mali_osk_resource_t * resou static void maligp_subsystem_broadcast_notification(mali_core_notification_message message, u32 data); #endif #if MALI_STATE_TRACKING +#if MALI_STATE_TRACKING_USING_PROC +void maligp_subsystem_dump_state(void); +#else u32 maligp_subsystem_dump_state(char *buf, u32 size); #endif +#endif /* Internal support functions */ static _mali_osk_errcode_t maligp_core_version_legal( mali_core_renderunit *core ); @@ -1441,8 +1445,15 @@ _mali_osk_errcode_t maligp_signal_power_down( mali_bool immediate_only ) #endif #if MALI_STATE_TRACKING +#if MALI_STATE_TRACKING_USING_PROC +void maligp_subsystem_dump_state(void) +{ + return mali_core_renderunit_dump_state(&subsystem_maligp); +} +#else u32 maligp_subsystem_dump_state(char *buf, u32 size) { return mali_core_renderunit_dump_state(&subsystem_maligp, buf, size); } #endif +#endif diff --git a/drivers/gpu/arm/mali/common/mali_kernel_MALI200.c b/drivers/gpu/arm/mali/common/mali_kernel_MALI200.c index 75e6af78978e..ca06f2a820d1 100755 --- a/drivers/gpu/arm/mali/common/mali_kernel_MALI200.c +++ b/drivers/gpu/arm/mali/common/mali_kernel_MALI200.c @@ -94,8 +94,12 @@ static _mali_osk_errcode_t mali200_renderunit_create(_mali_osk_resource_t * reso static void mali200_subsystem_broadcast_notification(mali_core_notification_message message, u32 data); #endif #if MALI_STATE_TRACKING +#if MALI_STATE_TRACKING_USING_PROC +void mali200_subsystem_dump_state(void); +#else u32 mali200_subsystem_dump_state(char *buf, u32 size); #endif +#endif /* Internal support functions */ static _mali_osk_errcode_t mali200_core_version_legal( mali_core_renderunit *core ); @@ -1208,8 +1212,15 @@ _mali_osk_errcode_t malipp_signal_power_down( u32 core_num, mali_bool immediate_ #endif #if MALI_STATE_TRACKING +#if MALI_STATE_TRACKING_USING_PROC +void mali200_subsystem_dump_state(void) +{ + mali_core_renderunit_dump_state(&subsystem_mali200); +} +#else u32 mali200_subsystem_dump_state(char *buf, u32 size) { return mali_core_renderunit_dump_state(&subsystem_mali200, buf, size); } #endif +#endif diff --git a/drivers/gpu/arm/mali/common/mali_kernel_core.c b/drivers/gpu/arm/mali/common/mali_kernel_core.c index d4d0f5013fb4..5add804d5bb8 100755 --- a/drivers/gpu/arm/mali/common/mali_kernel_core.c +++ b/drivers/gpu/arm/mali/common/mali_kernel_core.c @@ -884,6 +884,22 @@ _mali_osk_errcode_t mali_core_signal_power_down( mali_pmm_core_id core, mali_boo #if MALI_STATE_TRACKING +#if MALI_STATE_TRACKING_USING_PROC +void _mali_kernel_core_dump_state(void) +{ + int i; + for (i = 0; i < SUBSYSTEMS_COUNT; ++i) + { + if (NULL != subsystems[i]->dump_state) + { + subsystems[i]->dump_state(); + } + } +#if USING_MALI_PMM + mali_pmm_dump_os_thread_state(); +#endif +} +#else u32 _mali_kernel_core_dump_state(char* buf, u32 size) { int i, n; @@ -906,3 +922,4 @@ u32 _mali_kernel_core_dump_state(char* buf, u32 size) return (u32)(buf - original_buf); } #endif +#endif diff --git a/drivers/gpu/arm/mali/common/mali_kernel_rendercore.c b/drivers/gpu/arm/mali/common/mali_kernel_rendercore.c index 5ff681b32d3f..23623879f982 100755 --- a/drivers/gpu/arm/mali/common/mali_kernel_rendercore.c +++ b/drivers/gpu/arm/mali/common/mali_kernel_rendercore.c @@ -1953,6 +1953,107 @@ _mali_osk_errcode_t mali_core_subsystem_signal_power_up(mali_core_subsystem *sub #endif /* USING_MALI_PMM */ #if MALI_STATE_TRACKING +#if MALI_STATE_TRACKING_USING_PROC +void mali_core_renderunit_dump_state(mali_core_subsystem* subsystem) +{ + u32 i; + mali_core_renderunit *core; + mali_core_renderunit *tmp_core; + + mali_core_session* session; + mali_core_session* tmp_session; + + MALI_CORE_SUBSYSTEM_MUTEX_GRAB( subsystem ); + MALI_PRINT(("Subsystem;\n")); + MALI_PRINT((" Name: %s\n", subsystem->name)); + + for (i = 0; i < subsystem->number_of_cores; i++) + { + MALI_PRINT((" Core: #%u\n", subsystem->mali_core_array[i]->core_number)); + MALI_PRINT((" Description: %s\n", subsystem->mali_core_array[i]->description)); + switch(subsystem->mali_core_array[i]->state) + { + case CORE_IDLE: + MALI_PRINT((" State: CORE_IDLE\n")); + break; + case CORE_WORKING: + MALI_PRINT((" State: CORE_WORKING\n")); + break; + case CORE_WATCHDOG_TIMEOUT: + MALI_PRINT((" State: CORE_WATCHDOG_TIMEOUT\n")); + break; + case CORE_POLL: + MALI_PRINT((" State: CORE_POLL\n")); + break; + case CORE_HANG_CHECK_TIMEOUT: + MALI_PRINT((" State: CORE_HANG_CHECK_TIMEOUT\n")); + break; + case CORE_OFF: + MALI_PRINT((" State: CORE_OFF\n")); + break; + default: + MALI_PRINT((" State: Unknown (0x%X)\n", subsystem->mali_core_array[i]->state)); + break; + } + if (subsystem->mali_core_array[i]->state!=CORE_OFF) + { + /* Temporary debug code. Use reset framework to print registers in log.. */ + subsystem->reset_core( subsystem->mali_core_array[i], 0xcafebabe ); + } + MALI_PRINT((" Current job: 0x%X\n", (u32)(subsystem->mali_core_array[i]->current_job))); + if (subsystem->mali_core_array[i]->current_job) + { + MALI_PRINT((" Current job session: 0x%X\n", subsystem->mali_core_array[i]->current_job->session)); + MALI_PRINT((" Current job number: %d\n", subsystem->mali_core_array[i]->current_job->job_nr)); + MALI_PRINT((" Current job render_time jiffies: %d\n", _mali_osk_time_tickcount()-subsystem->mali_core_array[i]->current_job->start_time_jiffies)); + } + MALI_PRINT((" Core version: 0x%X\n", subsystem->mali_core_array[i]->core_version)); +#if USING_MALI_PMM + MALI_PRINT((" PMM id: 0x%X\n", subsystem->mali_core_array[i]->pmm_id)); + MALI_PRINT((" Power down requested: %s\n", subsystem->mali_core_array[i]->pend_power_down ? "TRUE" : "FALSE")); +#endif + } + + MALI_PRINT((" Cores on idle list:\n")); + _MALI_OSK_LIST_FOREACHENTRY(core, tmp_core, &subsystem->renderunit_idle_head, mali_core_renderunit, list) + { + MALI_PRINT((" Core #%u\n", core->core_number)); + } + + MALI_PRINT((" Cores on off list:\n")); + _MALI_OSK_LIST_FOREACHENTRY(core, tmp_core, &subsystem->renderunit_off_head, mali_core_renderunit, list) + { + MALI_PRINT((" Core #%u\n", core->core_number)); + } + + MALI_PRINT((" Connected sessions:\n")); + _MALI_OSK_LIST_FOREACHENTRY(session, tmp_session, &subsystem->all_sessions_head, mali_core_session, all_sessions_list) + { + MALI_PRINT((" Session 0x%X:\n", (u32)session)); + MALI_PRINT((" Waiting job: 0x%X\n", (u32)session->job_waiting_to_run)); + MALI_PRINT((" Notification queue: %s\n", _mali_osk_notification_queue_is_empty(session->notification_queue) ? "EMPTY" : "NON-EMPTY")); + MALI_PRINT((" Jobs received:%4d\n", _mali_osk_atomic_read(&session->jobs_received))); + MALI_PRINT((" Jobs started :%4d\n", _mali_osk_atomic_read(&session->jobs_started))); + MALI_PRINT((" Jobs ended :%4d\n", _mali_osk_atomic_read(&session->jobs_ended))); + MALI_PRINT((" Jobs returned:%4d\n", _mali_osk_atomic_read(&session->jobs_returned))); + MALI_PRINT((" PID: %d\n", session->pid)); + } + + MALI_PRINT((" Waiting sessions sum all priorities: %u\n", subsystem->awaiting_sessions_sum_all_priorities)); + for (i = 0; i < PRIORITY_LEVELS; i++) + { + MALI_PRINT((" Waiting sessions with priority %u:\n", i)); + _MALI_OSK_LIST_FOREACHENTRY(session, tmp_session, &subsystem->awaiting_sessions_head[i], mali_core_session, awaiting_sessions_list) + { + MALI_PRINT((" Session 0x%X:\n", (u32)session)); + MALI_PRINT((" Waiting job: 0x%X\n", (u32)session->job_waiting_to_run)); + MALI_PRINT((" Notification queue: %s\n", _mali_osk_notification_queue_is_empty(session->notification_queue) ? "EMPTY" : "NON-EMPTY")); + } + } + + MALI_CORE_SUBSYSTEM_MUTEX_RELEASE( subsystem ); +} +#else u32 mali_core_renderunit_dump_state(mali_core_subsystem* subsystem, char *buf, u32 size) { u32 i, len = 0; @@ -2076,3 +2177,4 @@ u32 mali_core_renderunit_dump_state(mali_core_subsystem* subsystem, char *buf, u return len; } #endif +#endif diff --git a/drivers/gpu/arm/mali/common/mali_kernel_rendercore.h b/drivers/gpu/arm/mali/common/mali_kernel_rendercore.h index b72d467a0c3c..566dab2ad790 100755 --- a/drivers/gpu/arm/mali/common/mali_kernel_rendercore.h +++ b/drivers/gpu/arm/mali/common/mali_kernel_rendercore.h @@ -357,7 +357,11 @@ _mali_osk_errcode_t mali_core_subsystem_signal_power_up(mali_core_subsystem *sub #endif #if MALI_STATE_TRACKING +#if MALI_STATE_TRACKING_USING_PROC +void mali_core_renderunit_dump_state(mali_core_subsystem* subsystem); +#else u32 mali_core_renderunit_dump_state(mali_core_subsystem* subsystem, char *buf, u32 size); #endif +#endif #endif /* __MALI_RENDERCORE_H__ */ diff --git a/drivers/gpu/arm/mali/common/mali_kernel_subsystem.h b/drivers/gpu/arm/mali/common/mali_kernel_subsystem.h index 9efba566bd9d..e8593543974e 100755 --- a/drivers/gpu/arm/mali/common/mali_kernel_subsystem.h +++ b/drivers/gpu/arm/mali/common/mali_kernel_subsystem.h @@ -74,8 +74,12 @@ typedef struct mali_kernel_subsystem #if MALI_STATE_TRACKING /** Dump the current state of the subsystem */ +#if MALI_STATE_TRACKING_USING_PROC + void (*dump_state)(void); +#else u32 (*dump_state)(char *buf, u32 size); #endif +#endif } mali_kernel_subsystem; /* functions used by the subsystems to interact with the core */ @@ -100,8 +104,12 @@ void _mali_kernel_core_broadcast_subsystem_message(mali_core_notification_messag /** * Tell all subsystems to dump their current state */ +#if MALI_STATE_TRACKING_USING_PROC +void _mali_kernel_core_dump_state(void); +#else u32 _mali_kernel_core_dump_state(char *buf, u32 size); #endif +#endif #endif /* __MALI_KERNEL_SUBSYSTEM_H__ */ diff --git a/drivers/gpu/arm/mali/common/pmm/mali_pmm.h b/drivers/gpu/arm/mali/common/pmm/mali_pmm.h index 7b45fd36eea6..e977acbc081a 100755 --- a/drivers/gpu/arm/mali/common/pmm/mali_pmm.h +++ b/drivers/gpu/arm/mali/common/pmm/mali_pmm.h @@ -323,7 +323,11 @@ void _mali_pmm_trace_event_message( mali_pmm_message_t *event, mali_bool receive /** @brief Dumps the current state of OS PMM thread */ #if MALI_STATE_TRACKING +#if MALI_STATE_TRACKING_USING_PROC +void mali_pmm_dump_os_thread_state( void ); +#else u32 mali_pmm_dump_os_thread_state( char *buf, u32 size ); +#endif #endif /* MALI_STATE_TRACKING */ /** @} */ /* end group pmmapi */ diff --git a/drivers/gpu/arm/mali/linux/mali_kernel_linux.c b/drivers/gpu/arm/mali/linux/mali_kernel_linux.c index 382be6802b2d..ba8b9fa6183e 100755 --- a/drivers/gpu/arm/mali/linux/mali_kernel_linux.c +++ b/drivers/gpu/arm/mali/linux/mali_kernel_linux.c @@ -17,7 +17,9 @@ #include /* character device definitions */ #include /* memory mananger definitions */ #include - +#if MALI_STATE_TRACKING_USING_PROC +#include +#endif /* the mali kernel subsystem types */ #include "mali_kernel_subsystem.h" @@ -44,7 +46,7 @@ module_param(mali_debug_level, int, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP | S_IR MODULE_PARM_DESC(mali_debug_level, "Higher number, more dmesg output"); /* By default the module uses any available major, but it's possible to set it at load time to a specific number */ -int mali_major = 0; +int mali_major = 244; module_param(mali_major, int, S_IRUGO); /* r--r--r-- */ MODULE_PARM_DESC(mali_major, "Device major number"); @@ -71,6 +73,10 @@ static char mali_dev_name[] = "mali"; /* should be const, but the functions we c /* the mali device */ static struct mali_dev device; +#if MALI_STATE_TRACKING_USING_PROC +static struct proc_dir_entry *proc_entry; +static int mali_proc_read(char *page, char **start, off_t off, int count, int *eof, void *data); +#endif static int mali_open(struct inode *inode, struct file *filp); static int mali_release(struct inode *inode, struct file *filp); @@ -185,6 +191,14 @@ int initialize_kernel_device(void) goto init_cdev_err; } +#if MALI_STATE_TRACKING_USING_PROC + proc_entry = create_proc_entry(mali_dev_name, 0644, NULL); + if (proc_entry != NULL) + { + proc_entry->read_proc = mali_proc_read; + } +#endif + err = mali_sysfs_register(&device, dev, mali_dev_name); if (err) { @@ -199,6 +213,9 @@ init_sysfs_err: init_cdev_err: unregister_chrdev_region(dev, 1/*count*/); init_chrdev_err: +#if MALI_STATE_TRACKING_USING_PROC + remove_proc_entry(mali_dev_name, NULL); +#endif return err; } @@ -209,6 +226,10 @@ void terminate_kernel_device(void) mali_sysfs_unregister(&device, dev, mali_dev_name); +#if MALI_STATE_TRACKING_USING_PROC + remove_proc_entry(mali_dev_name, NULL); +#endif + /* unregister char device */ cdev_del(&device.cdev); /* free major */ @@ -464,6 +485,24 @@ static int mali_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, return err; } +#if MALI_STATE_TRACKING_USING_PROC +static int mali_proc_read(char *page, char **start, off_t off, int count, int *eof, void *data) +{ + + MALI_DEBUG_PRINT(0,("\n***in the mali_proc_read\n")); //zepplin + MALI_DEBUG_PRINT(1, ("mali_proc_read(page=%p, start=%p, off=%u, count=%d, eof=%p, data=%p\n", page, start, off, count, eof, data)); + + /* + * A more elegant solution would be to gather information from all subsystems and + * then report it all in the /proc/mali file, but this would require a bit more work. + * Use MALI_PRINT for now so we get the information in the dmesg log at least. + */ + _mali_kernel_core_dump_state(); + + return 0; +} +#endif + module_init(mali_driver_init); module_exit(mali_driver_exit); diff --git a/drivers/gpu/arm/mali/linux/mali_kernel_pm.c b/drivers/gpu/arm/mali/linux/mali_kernel_pm.c index 3969466f39ef..f323592f5112 100755 --- a/drivers/gpu/arm/mali/linux/mali_kernel_pm.c +++ b/drivers/gpu/arm/mali/linux/mali_kernel_pm.c @@ -641,9 +641,16 @@ int mali_get_ospmm_thread_state(void) #endif /* CONFIG_PM */ #if MALI_STATE_TRACKING +#if MALI_STATE_TRACKING_USING_PROC +void mali_pmm_dump_os_thread_state( void ) +{ + MALI_PRINTF(("\nOSPMM: OS PMM thread is waiting: %s\n", is_os_pmm_thread_waiting ? "true" : "false")); +} +#else u32 mali_pmm_dump_os_thread_state( char *buf, u32 size ) { return snprintf(buf, size, "OSPMM: OS PMM thread is waiting: %s\n", is_os_pmm_thread_waiting ? "true" : "false"); } +#endif #endif /* MALI_STATE_TRACKING */ #endif /* USING_MALI_PMM */ diff --git a/drivers/gpu/arm/mali/linux/mali_kernel_sysfs.c b/drivers/gpu/arm/mali/linux/mali_kernel_sysfs.c index 62c7fba8791e..c03e9f2efbb1 100644 --- a/drivers/gpu/arm/mali/linux/mali_kernel_sysfs.c +++ b/drivers/gpu/arm/mali/linux/mali_kernel_sysfs.c @@ -37,7 +37,7 @@ static int mali_seq_internal_state_show(struct seq_file *seq_file, void *v) u32 len = 0; u32 size; char *buf; - +#if (MALI_STATE_TRACKING_USING_PROC==0) size = seq_get_buf(seq_file, &buf); if(!size) @@ -52,7 +52,7 @@ static int mali_seq_internal_state_show(struct seq_file *seq_file, void *v) len += _mali_kernel_core_dump_state(buf + len, size - len); seq_commit(seq_file, len); - +#endif return 0; } -- cgit v1.2.3