summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBibek Basu <bbasu@nvidia.com>2014-07-30 11:57:09 +0530
committerMatthew Pedro <mapedro@nvidia.com>2014-07-31 10:36:21 -0700
commit8a370a3b55ee8750167174238ce316900409f558 (patch)
treeca3df3f43daa8f59fa938fd65114f286bd5f0240
parent30f8d578556191ac90ca5d1ec4cba5f05cd690ce (diff)
video: tegra: host: power module before access
There could be race in refcount update leading to access of module registers without enabling the clock and power.This patch tries to catch such instances and enables power. Bug 1478467 Change-Id: Ia32da44bfcd7838e312815b6261ccadf4470a761 Signed-off-by: Bibek Basu <bbasu@nvidia.com> Reviewed-on: http://git-master/r/448701 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Venkat Moganty <vmoganty@nvidia.com> Reviewed-by: Matthew Pedro <mapedro@nvidia.com>
-rw-r--r--drivers/video/tegra/host/nvhost_acm.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/video/tegra/host/nvhost_acm.c b/drivers/video/tegra/host/nvhost_acm.c
index 5bde55ad2ff5..fcedb5c1a2c8 100644
--- a/drivers/video/tegra/host/nvhost_acm.c
+++ b/drivers/video/tegra/host/nvhost_acm.c
@@ -3,7 +3,7 @@
*
* Tegra Graphics Host Automatic Clock Management
*
- * Copyright (c) 2010-2012, NVIDIA Corporation. All rights reserved.
+ * Copyright (c) 2010-2014, NVIDIA Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -219,8 +219,11 @@ void nvhost_module_busy(struct nvhost_device *dev)
cancel_delayed_work(&dev->powerstate_down);
dev->refcount++;
- if (dev->refcount > 0 && !nvhost_module_powered(dev))
+ if (unlikely(dev->refcount <= 0))
+ pr_err("unbalanced refcount %d\n", dev->refcount);
+ if (!nvhost_module_powered(dev))
to_state_running_locked(dev);
+
mutex_unlock(&dev->lock);
}