X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=arch%2Farm%2Foprofile%2Fcommon.c;h=0a5cf3a6438be268f792ae0cb1ec9d7c6a66692c;hb=7b5dea12346f98b0624e00ef585246bfec8b0959;hp=6f8bc1f0e6a11a9eae95968f7356ed5a2b895a78;hpb=0b1fc9b86f49e1e73e473e06a16556ca0dce53ae;p=linux-2.6-omap-h63xx.git diff --git a/arch/arm/oprofile/common.c b/arch/arm/oprofile/common.c index 6f8bc1f0e6a..0a5cf3a6438 100644 --- a/arch/arm/oprofile/common.c +++ b/arch/arm/oprofile/common.c @@ -10,17 +10,18 @@ #include #include #include +#include #include -#include +#include #include "op_counter.h" #include "op_arm_model.h" static struct op_arm_model_spec *op_arm_model; static int op_arm_enabled; -static struct semaphore op_arm_sem; +static DEFINE_MUTEX(op_arm_mutex); -struct op_counter_config counter_config[OP_MAX_COUNTER]; +struct op_counter_config *counter_config; static int op_arm_create_files(struct super_block *sb, struct dentry *root) { @@ -28,7 +29,7 @@ static int op_arm_create_files(struct super_block *sb, struct dentry *root) for (i = 0; i < op_arm_model->num_counters; i++) { struct dentry *dir; - char buf[2]; + char buf[4]; snprintf(buf, sizeof buf, "%d", i); dir = oprofilefs_mkdir(sb, root, buf); @@ -57,45 +58,45 @@ static int op_arm_start(void) { int ret = -EBUSY; - down(&op_arm_sem); + mutex_lock(&op_arm_mutex); if (!op_arm_enabled) { ret = op_arm_model->start(); op_arm_enabled = !ret; } - up(&op_arm_sem); + mutex_unlock(&op_arm_mutex); return ret; } static void op_arm_stop(void) { - down(&op_arm_sem); + mutex_lock(&op_arm_mutex); if (op_arm_enabled) op_arm_model->stop(); op_arm_enabled = 0; - up(&op_arm_sem); + mutex_unlock(&op_arm_mutex); } #ifdef CONFIG_PM static int op_arm_suspend(struct sys_device *dev, pm_message_t state) { - down(&op_arm_sem); + mutex_lock(&op_arm_mutex); if (op_arm_enabled) op_arm_model->stop(); - up(&op_arm_sem); + mutex_unlock(&op_arm_mutex); return 0; } static int op_arm_resume(struct sys_device *dev) { - down(&op_arm_sem); + mutex_lock(&op_arm_mutex); if (op_arm_enabled && op_arm_model->start()) op_arm_enabled = 0; - up(&op_arm_sem); + mutex_unlock(&op_arm_mutex); return 0; } static struct sysdev_class oprofile_sysclass = { - set_kset_name("oprofile"), + .name = "oprofile", .resume = op_arm_resume, .suspend = op_arm_suspend, }; @@ -130,17 +131,30 @@ int __init oprofile_arch_init(struct oprofile_operations *ops) struct op_arm_model_spec *spec = NULL; int ret = -ENODEV; + ops->backtrace = arm_backtrace; + #ifdef CONFIG_CPU_XSCALE spec = &op_xscale_spec; #endif - if (spec) { - init_MUTEX(&op_arm_sem); +#ifdef CONFIG_OPROFILE_ARMV6 + spec = &op_armv6_spec; +#endif + +#ifdef CONFIG_OPROFILE_MPCORE + spec = &op_mpcore_spec; +#endif + if (spec) { ret = spec->init(); if (ret < 0) return ret; + counter_config = kcalloc(spec->num_counters, sizeof(struct op_counter_config), + GFP_KERNEL); + if (!counter_config) + return -ENOMEM; + op_arm_model = spec; init_driverfs(); ops->create_files = op_arm_create_files; @@ -149,7 +163,6 @@ int __init oprofile_arch_init(struct oprofile_operations *ops) ops->start = op_arm_start; ops->stop = op_arm_stop; ops->cpu_type = op_arm_model->name; - ops->backtrace = arm_backtrace; printk(KERN_INFO "oprofile: using %s\n", spec->name); } @@ -162,5 +175,5 @@ void oprofile_arch_exit(void) exit_driverfs(); op_arm_model = NULL; } + kfree(counter_config); } -