From d6f2fbcca5e1915f4862b41f84d08f019d70f72a Mon Sep 17 00:00:00 2001 From: Azam Sadiq Pasha Kapatrala Syed Date: Sun, 22 Jan 2017 20:42:26 -0800 Subject: [PATCH] msm: camera: Find and return mapped fd's from the list Change to iterate the mapped buffer list and use the secure buffer info structure instead of dma buffer info to return the secure mapped fd's pertaining to the corresponding session. Change-Id: I6dbfef3741d7ae0b24a4e101eebbf8dc62da630a Signed-off-by: Azam Sadiq Pasha Kapatrala Syed --- .../msm/camera_v2/common/cam_smmu_api.c | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 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 54c0aa39cdd3..1c0a10e2fbef 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 @@ -1,4 +1,4 @@ -/* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved. +/* Copyright (c) 2014-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 @@ -1212,6 +1212,25 @@ static enum cam_smmu_buf_state cam_smmu_check_fd_in_list(int idx, return CAM_SMMU_BUFF_NOT_EXIST; } +static enum cam_smmu_buf_state cam_smmu_check_secure_fd_in_list(int idx, + int ion_fd, dma_addr_t *paddr_ptr, + size_t *len_ptr) +{ + struct cam_sec_buff_info *mapping; + + list_for_each_entry(mapping, + &iommu_cb_set.cb_info[idx].smmu_buf_list, + list) { + if (mapping->ion_fd == ion_fd) { + mapping->ref_count++; + *paddr_ptr = mapping->paddr; + *len_ptr = mapping->len; + return CAM_SMMU_BUFF_EXIST; + } + } + return CAM_SMMU_BUFF_NOT_EXIST; +} + int cam_smmu_get_handle(char *identifier, int *handle_ptr) { int ret = 0; @@ -1935,7 +1954,8 @@ int cam_smmu_get_stage2_phy_addr(int handle, goto get_addr_end; } - buf_state = cam_smmu_check_fd_in_list(idx, ion_fd, paddr_ptr, len_ptr); + buf_state = cam_smmu_check_secure_fd_in_list(idx, ion_fd, paddr_ptr, + len_ptr); if (buf_state == CAM_SMMU_BUFF_EXIST) { CDBG("ion_fd:%d already in the list, give same addr back", ion_fd);