msm: camera: csiphy: Handle process shutdown during secure camera

Use SCM 7 call during the process shutdown. This is to
workaround a race condition between the close of camera FD
and the invoke driver FD that leads to a device crash.
Additionally, keep the Domain ID clocks on only during
protect or unprotect operations.

CRs-Fixed: 3509086
Change-Id: Ic091aa737df10bb2b41190c2f850c31fd17af9b2
Signed-off-by: Vijay Kumar Tumati <quic_vtumati@quicinc.com>
This commit is contained in:
Vijay Kumar Tumati
2023-05-17 15:39:12 -07:00
committed by Camera Software Integration
parent ebaa2a7356
commit 16be1306ef
3 changed files with 58 additions and 45 deletions

View File

@@ -327,7 +327,7 @@ bool cam_is_mink_api_available(void)
}
#if KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE
int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev,
bool protect, int32_t offset)
bool protect, int32_t offset, bool is_shutdown)
{
int rc = 0;
struct Object client_env, sc_object;
@@ -339,41 +339,54 @@ int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev,
return -EINVAL;
}
rc = get_client_env_object(&client_env);
if (rc) {
CAM_ERR(CAM_CSIPHY, "Failed getting mink env object, rc: %d", rc);
return rc;
}
if (!is_shutdown) {
rc = get_client_env_object(&client_env);
if (rc) {
CAM_ERR(CAM_CSIPHY, "Failed getting mink env object, rc: %d", rc);
return rc;
}
rc = IClientEnv_open(client_env, CTrustedCameraDriver_UID, &sc_object);
if (rc) {
CAM_ERR(CAM_CSIPHY, "Failed getting mink sc_object, rc: %d", rc);
return rc;
}
rc = IClientEnv_open(client_env, CTrustedCameraDriver_UID, &sc_object);
if (rc) {
CAM_ERR(CAM_CSIPHY, "Failed getting mink sc_object, rc: %d", rc);
return rc;
}
secure_info = &csiphy_dev->csiphy_info[offset].secure_info;
params.csid_hw_idx_mask = secure_info->csid_hw_idx_mask;
params.cdm_hw_idx_mask = secure_info->cdm_hw_idx_mask;
params.vc_mask = secure_info->vc_mask;
params.phy_lane_sel_mask =
csiphy_dev->csiphy_info[offset].csiphy_phy_lane_sel_mask;
params.protect = protect ? 1 : 0;
secure_info = &csiphy_dev->csiphy_info[offset].secure_info;
params.csid_hw_idx_mask = secure_info->csid_hw_idx_mask;
params.cdm_hw_idx_mask = secure_info->cdm_hw_idx_mask;
params.vc_mask = secure_info->vc_mask;
params.phy_lane_sel_mask =
csiphy_dev->csiphy_info[offset].csiphy_phy_lane_sel_mask;
params.protect = protect ? 1 : 0;
rc = ITrustedCameraDriver_dynamicProtectSensor(sc_object, &params);
if (rc) {
CAM_ERR(CAM_CSIPHY, "Mink secure call failed, rc: %d", rc);
return rc;
}
rc = ITrustedCameraDriver_dynamicProtectSensor(sc_object, &params);
if (rc) {
CAM_ERR(CAM_CSIPHY, "Mink secure call failed, rc: %d", rc);
return rc;
}
rc = Object_release(sc_object);
if (rc) {
CAM_ERR(CAM_CSIPHY, "Failed releasing secure camera object, rc: %d", rc);
return rc;
}
rc = Object_release(client_env);
if (rc) {
CAM_ERR(CAM_CSIPHY, "Failed releasing mink env object, rc: %d", rc);
return rc;
rc = Object_release(sc_object);
if (rc) {
CAM_ERR(CAM_CSIPHY, "Failed releasing secure camera object, rc: %d", rc);
return rc;
}
rc = Object_release(client_env);
if (rc) {
CAM_ERR(CAM_CSIPHY, "Failed releasing mink env object, rc: %d", rc);
return rc;
}
} else {
/* This is a temporary work around until the SMC Invoke driver is
* refactored to avoid the dependency on FDs, which was causing issues
* during process shutdown.
*/
rc = qcom_scm_camera_protect_phy_lanes(protect, 0);
if (rc) {
CAM_ERR(CAM_CSIPHY, "SCM call to hypervisor failed");
return rc;
}
}
return 0;