Merge "gralloc: layercount validation check"
diff --git a/gralloc/gr_adreno_info.cpp b/gralloc/gr_adreno_info.cpp
index 31e1199..03aacff 100644
--- a/gralloc/gr_adreno_info.cpp
+++ b/gralloc/gr_adreno_info.cpp
@@ -81,11 +81,6 @@
     gfx_ubwc_disable_ = true;
   }
 
-  if ((property_get(MAP_FB_MEMORY_PROP, property, NULL) > 0) &&
-      (!strncmp(property, "1", PROPERTY_VALUE_MAX) ||
-       (!strncasecmp(property, "true", PROPERTY_VALUE_MAX)))) {
-    map_fb_ = true;
-  }
 }
 
 AdrenoMemInfo::~AdrenoMemInfo() {
@@ -99,12 +94,6 @@
   *aligned_w = (unsigned int)ALIGN(width, 32);
   *aligned_h = (unsigned int)ALIGN(height, 32);
 
-  // Don't add any additional padding if debug.gralloc.map_fb_memory
-  // is enabled
-  if (map_fb_) {
-    return;
-  }
-
   int bpp = 4;
   switch (format) {
     case HAL_PIXEL_FORMAT_RGB_888:
diff --git a/gralloc/gr_adreno_info.h b/gralloc/gr_adreno_info.h
index a454d15..b85e7c1 100644
--- a/gralloc/gr_adreno_info.h
+++ b/gralloc/gr_adreno_info.h
@@ -143,7 +143,6 @@
   unsigned int (*LINK_adreno_get_gpu_pixel_alignment)() = NULL;
 
   bool gfx_ubwc_disable_ = false;
-  bool map_fb_ = false;
   void *libadreno_utils_ = NULL;
 
   static AdrenoMemInfo *s_instance;
diff --git a/gralloc/gr_allocator.cpp b/gralloc/gr_allocator.cpp
index 34a5c03..912ada0 100644
--- a/gralloc/gr_allocator.cpp
+++ b/gralloc/gr_allocator.cpp
@@ -236,12 +236,13 @@
   }
 
   // CPU read rarely
-  if ((usage & BufferUsage::CPU_READ_RARELY) && !(usage & BufferUsage::CPU_READ_OFTEN)) {
+  if ((usage & BufferUsage::CPU_READ_MASK) == static_cast<uint64_t>(BufferUsage::CPU_READ_RARELY)) {
     return true;
   }
 
   // CPU  write rarely
-  if ((usage & BufferUsage::CPU_WRITE_RARELY) && !(usage & BufferUsage::CPU_WRITE_OFTEN)) {
+  if ((usage & BufferUsage::CPU_WRITE_MASK) ==
+      static_cast<uint64_t>(BufferUsage::CPU_WRITE_RARELY)) {
     return true;
   }
 
diff --git a/gralloc/gr_buf_mgr.cpp b/gralloc/gr_buf_mgr.cpp
index 91d9011..687f3c1 100644
--- a/gralloc/gr_buf_mgr.cpp
+++ b/gralloc/gr_buf_mgr.cpp
@@ -39,15 +39,6 @@
 }
 
 BufferManager::BufferManager() : next_id_(0) {
-  char property[PROPERTY_VALUE_MAX];
-
-  // Map framebuffer memory
-  if ((property_get(MAP_FB_MEMORY_PROP, property, NULL) > 0) &&
-      (!strncmp(property, "1", PROPERTY_VALUE_MAX) ||
-       (!strncasecmp(property, "true", PROPERTY_VALUE_MAX)))) {
-    map_fb_mem_ = true;
-  }
-
   handles_map_.clear();
   allocator_ = new Allocator();
   allocator_->Init();
@@ -382,6 +373,7 @@
 }
 
 Error BufferManager::Dump(std::ostringstream *os) {
+  std::lock_guard<std::mutex> buffer_lock(buffer_lock_);
   for (auto it : handles_map_) {
     auto buf = it.second;
     auto hnd = buf->handle;
diff --git a/gralloc/gr_buf_mgr.h b/gralloc/gr_buf_mgr.h
index 24b4c23..258be2b 100644
--- a/gralloc/gr_buf_mgr.h
+++ b/gralloc/gr_buf_mgr.h
@@ -85,8 +85,6 @@
 
   // Get the wrapper Buffer object from the handle, returns nullptr if handle is not found
   std::shared_ptr<Buffer> GetBufferFromHandleLocked(const private_handle_t *hnd);
-
-  bool map_fb_mem_ = false;
   Allocator *allocator_ = NULL;
   std::mutex buffer_lock_;
   std::unordered_map<const private_handle_t *, std::shared_ptr<Buffer>> handles_map_ = {};
diff --git a/sdm/include/utils/locker.h b/sdm/include/utils/locker.h
index dabeb11..e0d91cb 100755
--- a/sdm/include/utils/locker.h
+++ b/sdm/include/utils/locker.h
@@ -127,15 +127,15 @@
 
   Locker() : sequence_wait_(0) {
     pthread_mutex_init(&mutex_, 0);
-    pthread_condattr_init(&cond_attr);
-    pthread_condattr_setclock(&cond_attr, CLOCK_MONOTONIC);
-    pthread_cond_init(&condition_, &cond_attr);
+    pthread_condattr_init(&cond_attr_);
+    pthread_condattr_setclock(&cond_attr_, CLOCK_MONOTONIC);
+    pthread_cond_init(&condition_, &cond_attr_);
   }
 
   ~Locker() {
     pthread_mutex_destroy(&mutex_);
     pthread_cond_destroy(&condition_);
-    pthread_condattr_destroy(&cond_attr);
+    pthread_condattr_destroy(&cond_attr_);
   }
 
   void Lock() { pthread_mutex_lock(&mutex_); }
@@ -157,7 +157,7 @@
  private:
   pthread_mutex_t mutex_;
   pthread_cond_t condition_;
-  pthread_condattr_t cond_attr;
+  pthread_condattr_t cond_attr_;
   int sequence_wait_;   // This flag is set to 1 on sequence entry, 0 on exit, and -1 on cancel.
                         // Some routines will wait for sequence of function calls to finish
                         // so that capturing a transitionary snapshot of context is prevented.
diff --git a/sdm/libs/core/color_manager.cpp b/sdm/libs/core/color_manager.cpp
index f348eca..04af820 100644
--- a/sdm/libs/core/color_manager.cpp
+++ b/sdm/libs/core/color_manager.cpp
@@ -128,7 +128,7 @@
       DLOGW("Fail to get DSPP feature versions");
     } else {
       hw_attr.Set(hw_res_info_, panel_info, attribute, versions);
-      DLOGW("PAV2 version is versions = %d, version = %d ",
+      DLOGI("PAV2 version is versions = %d, version = %d ",
             hw_attr.version.version[kGlobalColorFeaturePaV2],
             versions.version[kGlobalColorFeaturePaV2]);
     }
diff --git a/sdm/libs/hwc2/hwc_session.cpp b/sdm/libs/hwc2/hwc_session.cpp
index f7b7896..aaceb39 100644
--- a/sdm/libs/hwc2/hwc_session.cpp
+++ b/sdm/libs/hwc2/hwc_session.cpp
@@ -200,15 +200,6 @@
   }
 
   is_composer_up_ = true;
-  struct rlimit fd_limit = {};
-  getrlimit(RLIMIT_NOFILE, &fd_limit);
-  fd_limit.rlim_cur = fd_limit.rlim_cur * 2;
-  if (fd_limit.rlim_cur < fd_limit.rlim_max) {
-    auto err = setrlimit(RLIMIT_NOFILE, &fd_limit);
-    if (err) {
-      DLOGW("Unable to increase fd limit -  err:%d, %s", errno, strerror(errno));
-    }
-  }
 
   return 0;
 }