diff options
author | Igor Nabirushkin <inabirushkin@nvidia.com> | 2014-01-26 20:37:31 +0400 |
---|---|---|
committer | Gabby Lee <galee@nvidia.com> | 2014-02-12 20:45:58 -0800 |
commit | d0510cca51cc2dc764c5838736bf1841bedfb558 (patch) | |
tree | f1421c86e0e208fce4de46b062211870c95a0fde /drivers | |
parent | 48c34477a883e3b7a7872ab9f3de725f9542060a (diff) |
misc: tegra-profiler: add start/stop locks
Locks for ability to use loadable module
to override the built-in driver on rooted devices
Bug 1447640
Change-Id: If20605597d77a0cf76206fbe2f474c8853696a9b
Signed-off-by: Igor Nabirushkin <inabirushkin@nvidia.com>
Reviewed-on: http://git-master/r/365854
Reviewed-by: Automatic_Commit_Validation_User
Tested-by: Daniel Horowitz <dhorowitz@nvidia.com>
Reviewed-by: Gabby Lee <galee@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/misc/tegra-profiler/main.c | 34 | ||||
-rw-r--r-- | drivers/misc/tegra-profiler/quadd.h | 1 | ||||
-rw-r--r-- | drivers/misc/tegra-profiler/version.h | 2 |
3 files changed, 32 insertions, 5 deletions
diff --git a/drivers/misc/tegra-profiler/main.c b/drivers/misc/tegra-profiler/main.c index 7186e3529602..ef692473d76a 100644 --- a/drivers/misc/tegra-profiler/main.c +++ b/drivers/misc/tegra-profiler/main.c @@ -54,16 +54,33 @@ static int get_default_properties(void) return 0; } +int tegra_profiler_try_lock(void) +{ + return atomic_cmpxchg(&ctx.tegra_profiler_lock, 0, 1); +} +EXPORT_SYMBOL_GPL(tegra_profiler_try_lock); + +void tegra_profiler_unlock(void) +{ + atomic_set(&ctx.tegra_profiler_lock, 0); +} +EXPORT_SYMBOL_GPL(tegra_profiler_unlock); + static int start(void) { int err; + if (tegra_profiler_try_lock()) { + pr_err("Error: tegra_profiler lock\n"); + return -EBUSY; + } + if (!atomic_cmpxchg(&ctx.started, 0, 1)) { if (ctx.pmu) { err = ctx.pmu->enable(); if (err) { pr_err("error: pmu enable\n"); - return err; + goto errout; } } @@ -71,7 +88,7 @@ static int start(void) err = ctx.pl310->enable(); if (err) { pr_err("error: pl310 enable\n"); - return err; + goto errout; } } @@ -81,17 +98,22 @@ static int start(void) err = quadd_power_clk_start(); if (err < 0) { pr_err("error: power_clk start\n"); - return err; + goto errout; } err = quadd_hrt_start(); if (err) { pr_err("error: hrt start\n"); - return err; + goto errout; } } return 0; + +errout: + atomic_set(&ctx.started, 0); + tegra_profiler_unlock(); + return err; } static void stop(void) @@ -109,6 +131,8 @@ static void stop(void) if (ctx.pl310) ctx.pl310->disable(); + + tegra_profiler_unlock(); } } @@ -407,7 +431,9 @@ static int __init quadd_module_init(void) #ifdef QM_DEBUG_SAMPLES_ENABLE pr_info("############## DEBUG VERSION! ##############\n"); #endif + atomic_set(&ctx.started, 0); + atomic_set(&ctx.tegra_profiler_lock, 0); get_default_properties(); diff --git a/drivers/misc/tegra-profiler/quadd.h b/drivers/misc/tegra-profiler/quadd.h index 3815f616eaec..8e4d591f8cac 100644 --- a/drivers/misc/tegra-profiler/quadd.h +++ b/drivers/misc/tegra-profiler/quadd.h @@ -60,6 +60,7 @@ struct quadd_ctx { struct quadd_mmap_ctx *mmap; atomic_t started; + atomic_t tegra_profiler_lock; int collect_kernel_ips; }; diff --git a/drivers/misc/tegra-profiler/version.h b/drivers/misc/tegra-profiler/version.h index b6b9a9c9a57f..090ff1bf3d6f 100644 --- a/drivers/misc/tegra-profiler/version.h +++ b/drivers/misc/tegra-profiler/version.h @@ -18,7 +18,7 @@ #ifndef __QUADD_VERSION_H #define __QUADD_VERSION_H -#define QUADD_MODULE_VERSION "1.41" +#define QUADD_MODULE_VERSION "1.42" #define QUADD_MODULE_BRANCH "Dev" #endif /* __QUADD_VERSION_H */ |