From 8a370a3b55ee8750167174238ce316900409f558 Mon Sep 17 00:00:00 2001 From: Bibek Basu Date: Wed, 30 Jul 2014 11:57:09 +0530 Subject: 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 Reviewed-on: http://git-master/r/448701 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Venkat Moganty Reviewed-by: Matthew Pedro --- drivers/video/tegra/host/nvhost_acm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'drivers/video/tegra') 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); } -- cgit v1.2.3