nvmap: fix test condition to avoid infinite loop daily-2014.08.04.3_l4t/l4t-r16 tegra-l4t-r16-er-2014-08-01
Bibek Basu [Fri, 1 Aug 2014 05:59:19 +0000 (10:59 +0530)]
Make sure that we dont enter infinite loop due to
negative value of pins in some cases. Also remove
debugging check for refcount.

Bug 1478467

Change-Id: I7df8efa5b3cf8927a0c18363add4f031aca48e48
Signed-off-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-on: http://git-master/r/450209
Reviewed-by: Matthew Pedro <mapedro@nvidia.com>
Tested-by: Matthew Pedro <mapedro@nvidia.com>

drivers/video/tegra/host/nvhost_acm.c
drivers/video/tegra/nvmap/nvmap_handle.c

index fcedb5c..edf9286 100644 (file)
@@ -219,9 +219,7 @@ void nvhost_module_busy(struct nvhost_device *dev)
        cancel_delayed_work(&dev->powerstate_down);
 
        dev->refcount++;
-       if (unlikely(dev->refcount <= 0))
-               pr_err("unbalanced refcount %d\n", dev->refcount);
-       if (!nvhost_module_powered(dev))
+       if (dev->refcount > 0 && !nvhost_module_powered(dev))
                to_state_running_locked(dev);
 
        mutex_unlock(&dev->lock);
index 1c5e61c..1a6aec5 100644 (file)
@@ -904,7 +904,7 @@ void nvmap_free_handle_id(struct nvmap_client *client, unsigned long id)
                nvmap_err(client, "%s freeing pinned handle %p\n",
                          current->group_leader->comm, h);
 
-       while (pins--)
+       while (pins-- > 0)
                nvmap_unpin_handles(client, &ref->handle, 1);
 
        if (h->owner == client)