QCamera3: avoid race condition in getEaselFwVersion
Moved firmware version extraction to onOpened after easel is
booted and the firmware version is guaranteed to be correct.
This way a possible race condition for the mutex lock over
gHdrPlusClientLock from consecutive frame captures is averted.
Bug: 65458066
Change-Id: Ie7124ad008e1513cba5f60942df087e6d81396f3
Signed-off-by: Arnd Geis <arndg@google.com>
diff --git a/msm8998/QCamera2/HAL3/QCamera3HWI.cpp b/msm8998/QCamera2/HAL3/QCamera3HWI.cpp
index 1f082b6..d35c65e 100644
--- a/msm8998/QCamera2/HAL3/QCamera3HWI.cpp
+++ b/msm8998/QCamera2/HAL3/QCamera3HWI.cpp
@@ -569,6 +569,7 @@
memset(mLdafCalib, 0, sizeof(mLdafCalib));
memset(mEaselFwVersion, 0, sizeof(mEaselFwVersion));
+ mEaselFwUpdated = false;
memset(prop, 0, sizeof(prop));
property_get("persist.camera.tnr.preview", prop, "0");
@@ -900,6 +901,7 @@
ALOGE("%s: Resuming Easel failed: %s (%d)", __FUNCTION__, strerror(-rc), rc);
return rc;
}
+ mEaselFwUpdated = false;
}
}
@@ -14094,22 +14096,15 @@
* PARAMETERS : None
*
* RETURN : string describing Firmware version
-* "\0" if Easel manager client is not open
+* "\0" if version is not up to date
*==========================================================================*/
const char *QCamera3HardwareInterface::getEaselFwVersion()
{
- int rc = NO_ERROR;
-
- std::unique_lock<std::mutex> l(gHdrPlusClientLock);
- ALOGD("%s: Querying Easel firmware version", __FUNCTION__);
- if (EaselManagerClientOpened) {
- rc = gEaselManagerClient->getFwVersion(mEaselFwVersion);
- if (rc != OK)
- ALOGD("%s: Failed to query Easel firmware version", __FUNCTION__);
- else
- return (const char *)&mEaselFwVersion[0];
+ if (mEaselFwUpdated) {
+ return (const char *)&mEaselFwVersion[0];
+ } else {
+ return NULL;
}
- return NULL;
}
/*===========================================================================
@@ -15203,6 +15198,8 @@
void QCamera3HardwareInterface::onOpened(std::unique_ptr<HdrPlusClient> client)
{
+ int rc = NO_ERROR;
+
if (client == nullptr) {
ALOGE("%s: Opened client is null.", __FUNCTION__);
return;
@@ -15236,6 +15233,16 @@
if (res != OK) {
LOGE("%s: Failed to configure HDR+ streams.", __FUNCTION__);
}
+
+ // Get Easel firmware version
+ if (EaselManagerClientOpened) {
+ rc = gEaselManagerClient->getFwVersion(mEaselFwVersion);
+ if (rc != OK) {
+ ALOGD("%s: Failed to query Easel firmware version", __FUNCTION__);
+ } else {
+ mEaselFwUpdated = true;
+ }
+ }
}
void QCamera3HardwareInterface::onOpenFailed(status_t err)