Increment the DMA counter if gralloc_alloc completes successfully am: 047d270064
am: 959d5e35ba

Change-Id: Id29ce93ca2bdb698af3b85c1294a3d9fbed93755
diff --git a/system/gralloc/gralloc.cpp b/system/gralloc/gralloc.cpp
index ff2c744..57a9e9e 100644
--- a/system/gralloc/gralloc.cpp
+++ b/system/gralloc/gralloc.cpp
@@ -709,15 +709,6 @@
         }
 
         cb->setFd(fd);
-
-        hostCon->lock();
-
-        if (rcEnc->getDmaVersion() > 0) {
-            D("%s: creating goldfish dma region of size %lu (cb fd %d)\n", __FUNCTION__, ashmem_size, cb->fd);
-            init_gralloc_dmaregion();
-            get_gralloc_dmaregion();
-        }
-        hostCon->unlock();
     }
 
     if (needHostCb) {
@@ -776,6 +767,14 @@
         *pStride = stride;
         break;
     }
+
+    hostCon->lock();
+    if (rcEnc->getDmaVersion() > 0) {
+        init_gralloc_dmaregion();
+        get_gralloc_dmaregion();
+    }
+    hostCon->unlock();
+
     return 0;
 }