summaryrefslogtreecommitdiff
path: root/drivers/misc/tegra-throughput.c
diff options
context:
space:
mode:
authorIlan Aelion <iaelion@nvidia.com>2012-08-05 06:56:40 -0600
committerDan Willemsen <dwillemsen@nvidia.com>2013-09-14 12:31:24 -0700
commitfb601d1336eb76d910e0734b7b236bb1e4b26ea7 (patch)
treeed2cd47c2d1af0ee9e3392d594325f08e0808acf /drivers/misc/tegra-throughput.c
parent0124d35c88d4c0de9945e52f90cae40937e72259 (diff)
misc: tegra-throughput: prevent race on init
prevent a race condition on initialization which could result in multiple notifier registrations. Bug 1027664 Change-Id: I2e7dcad159f631a7e244d43019169fdaf195bc34 (cherry picked from commit 06ad60cd85a221eec673654c73d55fba34455a3a) Reviewed-on: http://git-master/r/121143 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Tested-by: Ilan Aelion <iaelion@nvidia.com> Reviewed-by: Michael I Gold <gold@nvidia.com> Rebase-Id: Rff9950095c9fe81af180cf46beaba5220f9c194f
Diffstat (limited to 'drivers/misc/tegra-throughput.c')
-rw-r--r--drivers/misc/tegra-throughput.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/drivers/misc/tegra-throughput.c b/drivers/misc/tegra-throughput.c
index 2ab0e516c41c..47dc682795ab 100644
--- a/drivers/misc/tegra-throughput.c
+++ b/drivers/misc/tegra-throughput.c
@@ -99,19 +99,24 @@ static int notifier_initialized;
static int throughput_open(struct inode *inode, struct file *file)
{
+ int need_init = 0;
+
+ spin_lock(&lock);
+
if (!notifier_initialized) {
- tegra_dc_register_flip_notifier(&throughput_flip_nb);
notifier_initialized = 1;
+ need_init = 1;
}
- spin_lock(&lock);
-
throughput_active_app_count++;
if (throughput_active_app_count > 1)
multiple_app_disable = 1;
spin_unlock(&lock);
+ if (need_init)
+ tegra_dc_register_flip_notifier(&throughput_flip_nb);
+
pr_debug("throughput_open node %p file %p\n", inode, file);
return 0;
@@ -119,17 +124,22 @@ static int throughput_open(struct inode *inode, struct file *file)
static int throughput_release(struct inode *inode, struct file *file)
{
+ int need_deinit = 0;
+
spin_lock(&lock);
- throughput_active_app_count--;
- spin_unlock(&lock);
+ throughput_active_app_count--;
if (throughput_active_app_count == 0) {
reset_target_frame_time();
multiple_app_disable = 0;
- tegra_dc_unregister_flip_notifier(&throughput_flip_nb);
notifier_initialized = 0;
+ need_deinit = 1;
}
+ spin_unlock(&lock);
+
+ if (need_deinit)
+ tegra_dc_unregister_flip_notifier(&throughput_flip_nb);
pr_debug("throughput_release node %p file %p\n", inode, file);