Revert "msm: camera: csiphy: Integrate mink call for secure camera"

External dependency has been reverted, change not ready.
This reverts commit b76d66be06cb035886ddebbf7671e02c93fdd1af.

CRs-Fixed: 3317248
Change-Id: If82504f1eb22b1c908d08d256f3b4c4cbad60bc9
Signed-off-by: Li Sha Lim <quic_lishlim@quicinc.com>
This commit is contained in:
Li Sha Lim
2022-12-20 10:12:02 -08:00
committed by Vepuri Vinay Kumar
parent d65382f14f
commit aabbfaffeb
7 changed files with 107 additions and 177 deletions

View File

@ -19,9 +19,6 @@ MMRM_BOARDS := taro parrot kalama pineapple
# List of board platforms for which Synx V2 vendor driver API should be enabled
SYNX_VENDOR_BOARDS := pineapple
# List of board platforms for which SMCINVOKE_DLKM driver API should be enabled
SMCINVOKE_DLKM_BOARDS := pineapple
CAMERA_SRC_FILES := \
$(addprefix $(LOCAL_PATH)/, $(call all-named-files-under,*.h,drivers dt-bindings include))\
$(addprefix $(LOCAL_PATH)/, $(call all-named-files-under,*.mk,config))\

View File

@ -9,7 +9,7 @@ ifeq ($(call is-board-platform-in-list, $(MMRM_BOARDS)),true)
CAM_MMRM_EXTRA_SYMBOLS ?= $(realpath $(TOP))/$(call intermediates-dir-for,DLKM,mmrm-module-symvers)/Module.symvers
$(info camera-kernel: Found msm-mmrm driver, adding symbol dependency! $(CAM_MMRM_EXTRA_SYMBOLS))
ifneq ($(TARGET_BOARD_PLATFORM), pineapple)
LOCAL_REQUIRED_MODULES := mmrm-module-symvers
LOCAL_REQUIRED_MODULES := mmrm-module-symvers
endif # End of check lanai
CAM_MMRM_EXTRA_CONFIGS ?= $(realpath $(TOP))/vendor/qcom/opensource/mmrm-driver/config/waipiommrm.conf
LOCAL_ADDITIONAL_DEPENDENCIES := $(call intermediates-dir-for,DLKM,mmrm-module-symvers)/Module.symvers
@ -34,18 +34,5 @@ endif # End of check for board platform SYNX_VENDOR_BOARDS
endif # End of find synx driver
# Check if this board's product.mk finds smcinvoke_dlkm.ko driver
ifeq ($(findstring smcinvoke_dlkm.ko, $(BOARD_VENDOR_KERNEL_MODULES)), smcinvoke_dlkm.ko)
ifeq ($(call is-board-platform-in-list, $(SMCINVOKE_DLKM_BOARDS)),true)
SMCINVOKE_EXTRA_SYMBOLS ?= $(realpath $(TOP))/$(call intermediates-dir-for,DLKM,smcinvoke_dlkm.ko)/Module.symvers
$(info camera-kernel: Found smcinvoke driver, adding symbol dependency! $(SMCINVOKE_EXTRA_SYMBOLS))
LOCAL_REQUIRED_MODULES += smcinvoke_dlkm.ko
LOCAL_ADDITIONAL_DEPENDENCIES += $(call intermediates-dir-for,DLKM,smcinvoke_dlkm.ko)/Module.symvers
endif # End of check for board platform SMCINVOKE_DLKM_BOARDS
endif # End of find smcinvoke_dlkm driver
KBUILD_OPTIONS += KBUILD_EXTRA_SYMBOLS=$(CAM_MMRM_EXTRA_SYMBOLS) KBUILD_EXTRA_SYMBOLS+=$(CAM_SYNX_EXTRA_SYMBOLS) $(SMCINVOKE_EXTRA_SYMBOLS)
KBUILD_OPTIONS += KBUILD_EXTRA_SYMBOLS=$(CAM_MMRM_EXTRA_SYMBOLS) KBUILD_EXTRA_SYMBOLS+=$(CAM_SYNX_EXTRA_SYMBOLS)
KBUILD_OPTIONS += KBUILD_EXTRA_CONFIGS=$(CAM_MMRM_EXTRA_CONFIGS) KBUILD_EXTRA_CONFIGS+=$(CAM_SYNX_EXTRA_CONFIGS)

View File

@ -482,13 +482,6 @@ static int cam_csiphy_update_secure_info(struct csiphy_device *csiphy_dev, int32
uint32_t cpas_version;
int rc;
if (csiphy_dev->domain_id_security) {
CAM_DBG(CAM_CSIPHY, "Domain ID scheme for CSIPHY [%u], skipping legacy update",
csiphy_dev->soc_info.index);
return 0;
}
lane_assign = csiphy_dev->csiphy_info[index].lane_assign;
lane_cnt = csiphy_dev->csiphy_info[index].lane_cnt;
@ -1233,26 +1226,22 @@ static int cam_csiphy_program_secure_mode(struct csiphy_device *csiphy_dev,
{
int rc = 0;
if (csiphy_dev->domain_id_security && protect) {
if (!csiphy_dev->csiphy_info[offset].secure_info_updated) {
CAM_ERR(CAM_CSIPHY,
"PHY[%u] domain id info not updated, aborting secure call",
csiphy_dev->soc_info.index);
if (!csiphy_dev->domain_id_security)
rc = cam_csiphy_notify_secure_mode(csiphy_dev, protect, offset);
/* Else a new scm call here */
else {
if (protect && !csiphy_dev->csiphy_info[offset].secure_info_updated) {
CAM_ERR(CAM_CSIPHY, "Secure info not updated prior to stream on");
return -EINVAL;
}
rc = cam_cpas_enable_clks_for_domain_id(true);
if (rc)
return rc;
}
csiphy_dev->csiphy_info[offset].secure_info.protect = protect;
CAM_DBG(CAM_CSIPHY, "To call new scm, protect: %d, offset: %d",
protect, offset);
rc = cam_csiphy_notify_secure_mode(csiphy_dev, protect, offset);
if (csiphy_dev->domain_id_security && !protect) {
cam_cpas_enable_clks_for_domain_id(false);
csiphy_dev->csiphy_info[offset].secure_info_updated = false;
if (!protect)
csiphy_dev->csiphy_info[offset].secure_info_updated = false;
}
return rc;

View File

@ -28,13 +28,27 @@ static inline void cam_csiphy_trigger_reg_dump(struct csiphy_device *csiphy_dev)
}
}
static int cam_csiphy_format_secure_phy_lane_info(
struct csiphy_device *csiphy_dev, int offset, uint64_t *mask)
int cam_csiphy_format_secure_phy_lane_info(
struct csiphy_device *csiphy_dev, int offset)
{
struct cam_csiphy_tz_secure_info *tz_secure_info;
struct cam_csiphy_param *param;
uint64_t phy_lane_sel_mask = 0;
if (!csiphy_dev) {
CAM_ERR(CAM_CSIPHY, "Invalid param, csiphy_dev: %s",
CAM_IS_NULL_TO_STR(csiphy_dev));
return -EINVAL;
}
if (offset >= CSIPHY_MAX_INSTANCES_PER_PHY) {
CAM_ERR(CAM_CSIPHY, "Invalid CSIPHY param offset: %d",
offset);
return -EINVAL;
}
param = &csiphy_dev->csiphy_info[offset];
tz_secure_info = &param->secure_info;
if (param->csiphy_3phase) {
if (param->lane_enable & CPHY_LANE_0)
@ -60,12 +74,12 @@ static int cam_csiphy_format_secure_phy_lane_info(
csiphy_dev->soc_info.index);
return -EINVAL;
}
phy_lane_sel_mask |= BIT(csiphy_dev->soc_info.index);
*mask = phy_lane_sel_mask;
tz_secure_info->phy_lane_sel_mask |= phy_lane_sel_mask;
CAM_DBG(CAM_CSIPHY, "Formatted PHY[%u] phy_lane_sel_mask: 0x%llx",
csiphy_dev->soc_info.index, *mask);
csiphy_dev->soc_info.index,
tz_secure_info->phy_lane_sel_mask);
return 0;
@ -94,34 +108,35 @@ static void cam_csiphy_populate_secure_info(
struct cam_csiphy_secure_info *secure_info =
(struct cam_csiphy_secure_info *)data;
struct cam_csiphy_param *param;
struct cam_csiphy_tz_secure_info *tz_secure_info;
for (i = 0; i < CSIPHY_MAX_INSTANCES_PER_PHY; i++) {
param = &csiphy_dev->csiphy_info[i];
if (param->secure_mode &&
param->lane_assign == secure_info->lane_assign) {
tz_secure_info = &param->secure_info;
param->secure_info.cdm_hw_idx_mask = secure_info->cdm_hw_idx_mask;
param->secure_info.csid_hw_idx_mask = secure_info->csid_hw_idx_mask;
param->secure_info.vc_mask = secure_info->vc_mask;
param->secure_info.phy_lane_sel_mask = 0;
tz_secure_info->cdm_hw_idx_mask = secure_info->cdm_hw_idx_mask;
tz_secure_info->csid_hw_idx_mask = secure_info->csid_hw_idx_mask;
tz_secure_info->vc_mask = secure_info->vc_mask;
tz_secure_info->phy_lane_sel_mask = 0;
if (!cam_csiphy_format_secure_phy_lane_info(csiphy_dev, i,
&param->csiphy_phy_lane_sel_mask)) {
if (!cam_csiphy_format_secure_phy_lane_info(csiphy_dev, i)) {
param->secure_info_updated = true;
CAM_DBG(CAM_CSIPHY,
"PHY[%d] secure info, phy_lane_mask: 0x%llx, ife: 0x%x, cdm: 0x%x, vc_mask: 0x%llx",
csiphy_dev->soc_info.index,
param->csiphy_phy_lane_sel_mask,
param->secure_info.csid_hw_idx_mask,
param->secure_info.cdm_hw_idx_mask,
param->secure_info.vc_mask);
tz_secure_info->phy_lane_sel_mask,
tz_secure_info->csid_hw_idx_mask,
tz_secure_info->cdm_hw_idx_mask,
tz_secure_info->vc_mask);
} else
CAM_ERR(CAM_CSIPHY,
"Error in formatting PHY[%u] phy_lane_sel_mask: 0x%llx",
csiphy_dev->soc_info.index,
param->csiphy_phy_lane_sel_mask);
tz_secure_info->phy_lane_sel_mask);
break;
}

View File

@ -123,6 +123,28 @@ struct cam_csiphy_secure_info {
uint32_t cdm_hw_idx_mask;
};
/**
* struct cam_csiphy_tz_secure_info
*
* This is the struct containing all the necessary values
* for scm programming of domain id
*
* @phy_lane_sel_mask: This value to be filled completely by csiphy
* @csid_hw_idx_mask: Bit position denoting CSID(s) in use for secure
* session
* @cdm_hw_idx_mask: Bit position denoting CDM in use for secure
* session
* @vc_mask: VC mask (unused in mobile case)
* @protect: To protect or reset previously protected lanes
*/
struct cam_csiphy_tz_secure_info {
uint64_t phy_lane_sel_mask;
uint32_t csid_hw_idx_mask;
uint32_t cdm_hw_idx_mask;
uint32_t vc_mask;
uint32_t protect;
};
/**
* struct cam_csiphy_aon_sel_params_t
* @aon_cam_sel_offset : AON Cam Select Register offset in cpas top
@ -307,10 +329,9 @@ struct csiphy_ctrl_t {
* @csiphy_3phase : To identify DPHY or CPHY
* @mipi_flags : MIPI phy flags
* @csiphy_cpas_cp_reg_mask : CP reg mask for phy instance
* @csiphy_phy_lane_sel_mask : Generic format for CP information for PHY and lane
* @hdl_data : CSIPHY handle table
* @secure_info : All domain-id security related information packed in proper
* format for mink call
* format for scm call
* @secure_info_updated : If all information in the secure_info struct above
* is passed and formatted properly from CSID driver
* @conn_csid_idx : Connected CSID core idx (Primary csid in case of dual ife)
@ -327,9 +348,8 @@ struct cam_csiphy_param {
int csiphy_3phase;
uint16_t mipi_flags;
uint64_t csiphy_cpas_cp_reg_mask;
uint64_t csiphy_phy_lane_sel_mask;
struct csiphy_hdl_tbl hdl_data;
struct cam_csiphy_secure_info secure_info;
struct cam_csiphy_tz_secure_info secure_info;
bool secure_info_updated;
int32_t conn_csid_idx;
bool use_hw_client_voting;

View File

@ -173,6 +173,23 @@ int cam_ife_notify_safe_lut_scm(bool safe_trigger)
return rc;
}
int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev,
bool protect, int32_t offset)
{
int rc = 0;
if (offset >= CSIPHY_MAX_INSTANCES_PER_PHY) {
CAM_ERR(CAM_CSIPHY, "Invalid CSIPHY offset");
rc = -EINVAL;
} else if (qcom_scm_camera_protect_phy_lanes(protect,
csiphy_dev->csiphy_info[offset].csiphy_cpas_cp_reg_mask)) {
CAM_ERR(CAM_CSIPHY, "SCM call to hypervisor failed");
rc = -EINVAL;
}
return rc;
}
void cam_cpastop_scm_write(struct cam_cpas_hw_errata_wa *errata_wa)
{
int reg_val;
@ -240,6 +257,28 @@ int cam_ife_notify_safe_lut_scm(bool safe_trigger)
return rc;
}
int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev,
bool protect, int32_t offset)
{
int rc = 0;
struct scm_desc description = {
.arginfo = SCM_ARGS(2, SCM_VAL, SCM_VAL),
.args[0] = protect,
.args[1] = csiphy_dev->csiphy_info[offset]
.csiphy_cpas_cp_reg_mask,
};
if (offset >= CSIPHY_MAX_INSTANCES_PER_PHY) {
CAM_ERR(CAM_CSIPHY, "Invalid CSIPHY offset");
rc = -EINVAL;
} else if (scm_call2(SCM_SIP_FNID(0x18, 0x7), &description)) {
CAM_ERR(CAM_CSIPHY, "SCM call to hypervisor failed");
rc = -EINVAL;
}
return rc;
}
void cam_cpastop_scm_write(struct cam_cpas_hw_errata_wa *errata_wa)
{
int reg_val;
@ -272,116 +311,6 @@ void cam_free_clear(const void * ptr)
}
#endif
#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)
{
int rc = 0;
struct Object client_env, sc_object;
ITCDriverSensorInfo params = {0};
struct cam_csiphy_secure_info *secure_info;
if (offset >= CSIPHY_MAX_INSTANCES_PER_PHY) {
CAM_ERR(CAM_CSIPHY, "Invalid CSIPHY offset");
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;
}
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;
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;
}
return 0;
}
#elif KERNEL_VERSION(5, 4, 0) <= LINUX_VERSION_CODE
int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev,
bool protect, int32_t offset)
{
int rc = 0;
/**
* A check here is made if the target is using
* an older version of the kernel driver (< 6.0)
* with domain id feature present. In this case,
* we are to fail this call, as the new mink call
* is only supported on kernel driver versions 6.0
* and above, and the new domain id scheme is not
* backwards compatible with the older scheme.
*/
if (csiphy_dev->domain_id_security) {
CAM_ERR(CAM_CSIPHY,
"Domain id support not present on current kernel driver: %d",
LINUX_VERSION_CODE);
return -EINVAL;
}
if (offset >= CSIPHY_MAX_INSTANCES_PER_PHY) {
CAM_ERR(CAM_CSIPHY, "Invalid CSIPHY offset");
rc = -EINVAL;
} else if (qcom_scm_camera_protect_phy_lanes(protect,
csiphy_dev->csiphy_info[offset].csiphy_cpas_cp_reg_mask)) {
CAM_ERR(CAM_CSIPHY, "SCM call to hypervisor failed");
rc = -EINVAL;
}
return rc;
}
#else
int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev,
bool protect, int32_t offset)
{
int rc = 0;
struct scm_desc description = {
.arginfo = SCM_ARGS(2, SCM_VAL, SCM_VAL),
.args[0] = protect,
.args[1] = csiphy_dev->csiphy_info[offset]
.csiphy_cpas_cp_reg_mask,
};
if (offset >= CSIPHY_MAX_INSTANCES_PER_PHY) {
CAM_ERR(CAM_CSIPHY, "Invalid CSIPHY offset");
rc = -EINVAL;
} else if (scm_call2(SCM_SIP_FNID(0x18, 0x7), &description)) {
CAM_ERR(CAM_CSIPHY, "SCM call to hypervisor failed");
rc = -EINVAL;
}
return rc;
}
#endif
/* Callback to compare device from match list before adding as component */
static inline int camera_component_compare_dev(struct device *dev, void *data)
{

View File

@ -39,13 +39,6 @@
MODULE_IMPORT_NS(DMA_BUF);
#endif
#if KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE
#include <linux/smcinvoke.h>
#include <linux/IClientEnv.h>
#include <linux/ITrustedCameraDriver.h>
#include <linux/CTrustedCameraDriver.h>
#endif
struct cam_fw_alloc_info {
struct device *fw_dev;
void *fw_kva;