msm: camera: csiphy: Fix misc seccam integration issues

The current secure camera implementation suffers with a few
issues in terms of typecasting, error handling and in
populating the information in the right data structures when
the new SCM API is used on the targets without domain ID support.
In addition, we needed to be explicit in failing to acquire
if dual IFE is required in secure camera use cases as it is
not a supported feature as of now.

CRs-Fixed: 3317248
Change-Id: Idb762158b0ff0e0a0d6d51de4770fc3d9d9072c8
Signed-off-by: Vijay Kumar Tumati <quic_vtumati@quicinc.com>
This commit is contained in:
Vijay Kumar Tumati
2023-01-18 19:17:47 -08:00
committed by Camera Software Integration
parent 0c5599492f
commit bae0381f76
7 changed files with 24 additions and 10 deletions

View File

@@ -5350,6 +5350,13 @@ static int cam_ife_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args)
} }
} }
if (in_port[i].usage_type && in_port[i].secure_mode) {
CAM_ERR(CAM_ISP,
"Dual IFE mode is not supported in secure camera usecases");
rc = -EINVAL;
goto free_mem;
}
cam_ife_hw_mgr_preprocess_port(ife_ctx, &in_port[i]); cam_ife_hw_mgr_preprocess_port(ife_ctx, &in_port[i]);
total_pix_port += in_port[i].ipp_count + total_pix_port += in_port[i].ipp_count +
in_port[i].ife_rd_count + in_port[i].ife_rd_count +

View File

@@ -26,6 +26,7 @@
#include "cam_cdm_util.h" #include "cam_cdm_util.h"
#include "cam_common_util.h" #include "cam_common_util.h"
#include "cam_subdev.h" #include "cam_subdev.h"
#include "cam_compat.h"
/* CSIPHY TPG VC/DT values */ /* CSIPHY TPG VC/DT values */
#define CAM_IFE_CPHY_TPG_VC_VAL 0x0 #define CAM_IFE_CPHY_TPG_VC_VAL 0x0
@@ -4720,9 +4721,6 @@ static void cam_ife_csid_ver2_send_secure_info(
secure_info.vc_mask = 0; secure_info.vc_mask = 0;
secure_info.csid_hw_idx_mask = BIT(csid_hw->hw_intf->hw_idx); secure_info.csid_hw_idx_mask = BIT(csid_hw->hw_intf->hw_idx);
if (csid_hw->sync_mode == CAM_ISP_HW_SYNC_MASTER)
secure_info.csid_hw_idx_mask |= BIT(csid_hw->dual_core_idx);
CAM_DBG(CAM_ISP, CAM_DBG(CAM_ISP,
"PHY secure info for CSID[%u], lane_cfg: 0x%x, ife: 0x%x, cdm: 0x%x, vc_mask: 0x%llx", "PHY secure info for CSID[%u], lane_cfg: 0x%x, ife: 0x%x, cdm: 0x%x, vc_mask: 0x%llx",
csid_hw->hw_intf->hw_idx, csid_hw->hw_intf->hw_idx,
@@ -4877,7 +4875,7 @@ int cam_ife_csid_ver2_start(void *hw_priv, void *args,
*/ */
if ((csid_hw->sync_mode != CAM_ISP_HW_SYNC_SLAVE) && if ((csid_hw->sync_mode != CAM_ISP_HW_SYNC_SLAVE) &&
start_args->is_secure && start_args->is_secure &&
csid_hw->flags.domain_id_security) cam_is_mink_api_available())
cam_ife_csid_ver2_send_secure_info(start_args, csid_hw); cam_ife_csid_ver2_send_secure_info(start_args, csid_hw);
/* /*

View File

@@ -552,7 +552,7 @@ struct cam_ife_csid_ver2_common_reg_info {
struct cam_ife_csid_secure_info { struct cam_ife_csid_secure_info {
uint32_t phy_sel; uint32_t phy_sel;
uint32_t lane_cfg; uint32_t lane_cfg;
uint32_t vc_mask; uint64_t vc_mask;
uint32_t csid_hw_idx_mask; uint32_t csid_hw_idx_mask;
uint32_t cdm_hw_idx_mask; uint32_t cdm_hw_idx_mask;
}; };

View File

@@ -482,8 +482,8 @@ static int cam_csiphy_update_secure_info(struct csiphy_device *csiphy_dev, int32
uint32_t cpas_version; uint32_t cpas_version;
int rc; int rc;
if (csiphy_dev->domain_id_security) { if (cam_is_mink_api_available()) {
CAM_DBG(CAM_CSIPHY, "Domain ID scheme for CSIPHY [%u], skipping legacy update", CAM_DBG(CAM_CSIPHY, "Using MINK API for CSIPHY [%u], skipping legacy update",
csiphy_dev->soc_info.index); csiphy_dev->soc_info.index);
return 0; return 0;
@@ -2502,7 +2502,7 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
rc = cam_csiphy_program_secure_mode(csiphy_dev, rc = cam_csiphy_program_secure_mode(csiphy_dev,
CAM_SECURE_MODE_SECURE, offset); CAM_SECURE_MODE_SECURE, offset);
if (rc < 0) { if (rc) {
csiphy_dev->csiphy_info[offset] csiphy_dev->csiphy_info[offset]
.secure_mode = .secure_mode =
CAM_SECURE_MODE_NON_SECURE; CAM_SECURE_MODE_NON_SECURE;
@@ -2570,7 +2570,7 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
rc = cam_csiphy_program_secure_mode( rc = cam_csiphy_program_secure_mode(
csiphy_dev, csiphy_dev,
CAM_SECURE_MODE_SECURE, offset); CAM_SECURE_MODE_SECURE, offset);
if (rc < 0) { if (rc) {
csiphy_dev->csiphy_info[offset].secure_mode = csiphy_dev->csiphy_info[offset].secure_mode =
CAM_SECURE_MODE_NON_SECURE; CAM_SECURE_MODE_NON_SECURE;
goto cpas_stop; goto cpas_stop;

View File

@@ -118,7 +118,7 @@ enum cam_csiphy_common_reg_program {
struct cam_csiphy_secure_info { struct cam_csiphy_secure_info {
uint32_t phy_lane_sel_mask; uint32_t phy_lane_sel_mask;
uint32_t lane_assign; uint32_t lane_assign;
uint32_t vc_mask; uint64_t vc_mask;
uint32_t csid_hw_idx_mask; uint32_t csid_hw_idx_mask;
uint32_t cdm_hw_idx_mask; uint32_t cdm_hw_idx_mask;
}; };

View File

@@ -272,6 +272,14 @@ void cam_free_clear(const void * ptr)
} }
#endif #endif
bool cam_is_mink_api_available(void)
{
#if KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE
return true;
#else
return false;
#endif
}
#if KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE #if KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE
int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev, int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev,
bool protect, int32_t offset) bool protect, int32_t offset)

View File

@@ -60,6 +60,7 @@ int camera_component_match_add_drivers(struct device *master_dev,
struct component_match **match_list); struct component_match **match_list);
int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev, int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev,
bool protect, int32_t offset); bool protect, int32_t offset);
bool cam_is_mink_api_available(void);
void cam_free_clear(const void *); void cam_free_clear(const void *);
void cam_check_iommu_faults(struct iommu_domain *domain, void cam_check_iommu_faults(struct iommu_domain *domain,
struct cam_smmu_pf_info *pf_info); struct cam_smmu_pf_info *pf_info);