diff options
| author | Krishnankutty Kolathappilly <kkolatha@codeaurora.org> | 2017-02-06 18:21:31 -0800 |
|---|---|---|
| committer | Krishnankutty Kolathappilly <kkolatha@codeaurora.org> | 2017-02-09 21:01:58 -0800 |
| commit | fb5236bbefff84bfe8503ed75df911a587ba6e7e (patch) | |
| tree | a1a3a41ef60873707f223facbdd334529bb80252 | |
| parent | 2aa89ab3ff59a788321bc6af782d639cfc8dab1f (diff) | |
msm: cpp: Call iommu detach in the error scenarios for secure case
Call iommu detach in the error scenarios for secure case.
Add check for error conditions for smmu apis.
CRs-Fixed: 2004972
Change-Id: I4a29912d9bb81103e11f7d3cf494aaf766fb8f69
Signed-off-by: Krishnankutty Kolathappilly <kkolatha@codeaurora.org>
| -rw-r--r-- | drivers/media/platform/msm/camera_v2/common/cam_smmu_api.c | 32 | ||||
| -rw-r--r-- | drivers/media/platform/msm/camera_v2/pproc/cpp/msm_cpp.c | 18 |
2 files changed, 42 insertions, 8 deletions
diff --git a/drivers/media/platform/msm/camera_v2/common/cam_smmu_api.c b/drivers/media/platform/msm/camera_v2/common/cam_smmu_api.c index 1c0a10e2fbef..a0f1d5148c94 100644 --- a/drivers/media/platform/msm/camera_v2/common/cam_smmu_api.c +++ b/drivers/media/platform/msm/camera_v2/common/cam_smmu_api.c @@ -878,6 +878,8 @@ static int cam_smmu_detach_device(int idx) static int cam_smmu_attach_sec_cpp(int idx) { + int32_t rc = 0; + /* * When switching to secure, detach CPP NS, do scm call * with CPP SID and no need of attach again, because @@ -889,8 +891,12 @@ static int cam_smmu_attach_sec_cpp(int idx) return -EINVAL; } - msm_camera_tz_set_mode(MSM_CAMERA_TZ_MODE_SECURE, + rc = msm_camera_tz_set_mode(MSM_CAMERA_TZ_MODE_SECURE, MSM_CAMERA_TZ_HW_BLOCK_CPP); + if (rc != 0) { + pr_err("fail to set secure mode for cpp, rc %d", rc); + return rc; + } iommu_cb_set.cb_info[idx].state = CAM_SMMU_ATTACH; @@ -899,8 +905,14 @@ static int cam_smmu_attach_sec_cpp(int idx) static int cam_smmu_detach_sec_cpp(int idx) { - msm_camera_tz_set_mode(MSM_CAMERA_TZ_MODE_NON_SECURE, + int32_t rc = 0; + + rc = msm_camera_tz_set_mode(MSM_CAMERA_TZ_MODE_NON_SECURE, MSM_CAMERA_TZ_HW_BLOCK_CPP); + if (rc != 0) { + pr_err("fail to switch to non secure mode for cpp, rc %d", rc); + return rc; + } iommu_cb_set.cb_info[idx].state = CAM_SMMU_DETACH; @@ -917,6 +929,8 @@ static int cam_smmu_detach_sec_cpp(int idx) static int cam_smmu_attach_sec_vfe_ns_stats(int idx) { + int32_t rc = 0; + /* *When switching to secure, for secure pixel and non-secure stats *localizing scm/attach of non-secure SID's in attach secure @@ -933,16 +947,26 @@ static int cam_smmu_attach_sec_vfe_ns_stats(int idx) } } - msm_camera_tz_set_mode(MSM_CAMERA_TZ_MODE_SECURE, + rc = msm_camera_tz_set_mode(MSM_CAMERA_TZ_MODE_SECURE, MSM_CAMERA_TZ_HW_BLOCK_ISP); + if (rc != 0) { + pr_err("fail to set secure mode for vfe, rc %d", rc); + return rc; + } return 0; } static int cam_smmu_detach_sec_vfe_ns_stats(int idx) { - msm_camera_tz_set_mode(MSM_CAMERA_TZ_MODE_NON_SECURE, + int32_t rc = 0; + + rc = msm_camera_tz_set_mode(MSM_CAMERA_TZ_MODE_NON_SECURE, MSM_CAMERA_TZ_HW_BLOCK_ISP); + if (rc != 0) { + pr_err("fail to switch to non secure mode for vfe, rc %d", rc); + return rc; + } /* *While exiting from secure mode for secure pixel and non-secure stats, diff --git a/drivers/media/platform/msm/camera_v2/pproc/cpp/msm_cpp.c b/drivers/media/platform/msm/camera_v2/pproc/cpp/msm_cpp.c index 1cf2c54aa8b8..849935144c2c 100644 --- a/drivers/media/platform/msm/camera_v2/pproc/cpp/msm_cpp.c +++ b/drivers/media/platform/msm/camera_v2/pproc/cpp/msm_cpp.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. +/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -834,8 +834,10 @@ static int cpp_init_mem(struct cpp_device *cpp_dev) else rc = cam_smmu_get_handle("cpp", &iommu_hdl); - if (rc < 0) + if (rc < 0) { + pr_err("smmu get handle failed\n"); return -ENODEV; + } cpp_dev->iommu_hdl = iommu_hdl; cam_smmu_reg_client_page_fault_handler( @@ -1466,10 +1468,16 @@ static int cpp_close_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) msm_cpp_clear_timer(cpp_dev); cpp_release_hardware(cpp_dev); if (cpp_dev->iommu_state == CPP_IOMMU_STATE_ATTACHED) { - cpp_dev->iommu_state = CPP_IOMMU_STATE_DETACHED; - rc = cam_smmu_ops(cpp_dev->iommu_hdl, CAM_SMMU_DETACH); + if (cpp_dev->security_mode == SECURE_MODE) + rc = cam_smmu_ops(cpp_dev->iommu_hdl, + CAM_SMMU_DETACH_SEC_CPP); + else + rc = cam_smmu_ops(cpp_dev->iommu_hdl, + CAM_SMMU_DETACH); + if (rc < 0) pr_err("Error: Detach fail in release\n"); + cpp_dev->iommu_state = CPP_IOMMU_STATE_DETACHED; } cam_smmu_destroy_handle(cpp_dev->iommu_hdl); msm_cpp_empty_list(processing_q, list_frame); @@ -3442,6 +3450,7 @@ STREAM_BUFF_END: rc = msm_cpp_copy_from_ioctl_ptr(&cpp_attach_info, ioctl_ptr); if (rc < 0) { + pr_err("CPP_IOMMU_ATTACH copy from user fail"); ERR_COPY_FROM_USER(); return -EINVAL; } @@ -3479,6 +3488,7 @@ STREAM_BUFF_END: rc = msm_cpp_copy_from_ioctl_ptr(&cpp_attach_info, ioctl_ptr); if (rc < 0) { + pr_err("CPP_IOMMU_DETTACH copy from user fail"); ERR_COPY_FROM_USER(); return -EINVAL; } |
