]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
misc: tegra-profiler: add start/stop locks
authorIgor Nabirushkin <inabirushkin@nvidia.com>
Sun, 26 Jan 2014 16:37:31 +0000 (20:37 +0400)
committerBharat Nihalani <bnihalani@nvidia.com>
Fri, 7 Feb 2014 13:20:24 +0000 (05:20 -0800)
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/360134
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>
drivers/misc/tegra-profiler/main.c
drivers/misc/tegra-profiler/quadd.h
drivers/misc/tegra-profiler/version.h
include/linux/tegra_profiler.h

index 3829d8cc9a43bd643d3dfd48415e28ccf4a97dd5..493cc7f0a405b61c8e1be282657dc6378b1ee9be 100644 (file)
@@ -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();
 
index 3815f616eaec33f78f9b9dcea40b0f64440fc6dc..8e4d591f8cac50ceb1010d2adffa7a2fd6d36b99 100644 (file)
@@ -60,6 +60,7 @@ struct quadd_ctx {
        struct quadd_mmap_ctx *mmap;
 
        atomic_t started;
+       atomic_t tegra_profiler_lock;
 
        int collect_kernel_ips;
 };
index b6b9a9c9a57f7d315770c0e619f3592bb2863f3e..090ff1bf3d6fbfaa2359cd1f0205df0069683af6 100644 (file)
@@ -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 */
index e3f90a2688c4975902a357ba04d6e777f737120e..277fc93241e415c671ae6d67e95e0a56b12d493c 100644 (file)
@@ -37,6 +37,9 @@
 #define QUADD_DEVICE_NAME      "quadd"
 #define QUADD_AUTH_DEVICE_NAME "quadd_auth"
 
+#define QUADD_MOD_DEVICE_NAME          "quadd_mod"
+#define QUADD_MOD_AUTH_DEVICE_NAME     "quadd_mod_auth"
+
 #define QUADD_IOCTL    100
 
 /*