Optimize mapper unlock()

- copying to dma from dma: skip if ptr is same
- Always go down the DMA path for unlock() via never
  doing sub-region updates
- skip unlock write if we didnt lock for write

Bug: 189960317
Test: ./cts-tradefed run cts -m CtsViewTestCases -t
android.view.cts.ASurfaceControlBackPressureTest#testSurfaceTransaction_setEnableBackPressure
fails fewer frames
Test: ./cts-tradefed run cts -m CtsNativeHardwareTestCases 100%

Change-Id: I96fa3637c3b03d4177aa9edd2d1ff94845fc7a7b
diff --git a/system/OpenglSystemCommon/HostConnection.h b/system/OpenglSystemCommon/HostConnection.h
index 880bfc1..0f7c351 100644
--- a/system/OpenglSystemCommon/HostConnection.h
+++ b/system/OpenglSystemCommon/HostConnection.h
@@ -85,7 +85,9 @@
     }
     virtual uint64_t lockAndWriteDma(void* data, uint32_t size) {
         if (m_dmaPtr && m_dmaPhysAddr) {
-            memcpy(m_dmaPtr, data, size);
+            if (data != m_dmaPtr) {
+                memcpy(m_dmaPtr, data, size);
+            }
             return m_dmaPhysAddr;
         } else if (m_dmaCxt) {
             return writeGoldfishDma(data, size, m_dmaCxt);