aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrishansh Bhardwaj <tbhardwa@codeaurora.org>2019-01-18 18:40:25 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2019-05-13 04:39:41 -0700
commitf95c225ba6f72aa217ad9b8602586033ce2e91c3 (patch)
tree82c927f12a201745fada350db046fa8fdf5378c6
parent5df92ede01c7e14a744377219a543e8b456cc428 (diff)
msm: camera: Adds state variable in mem managerLA.UM.6.3.r7-01700-sdm845.0
Add state variable for camera mem manager to show initialization status. Ensure that all operations are rejected before initialization. Change-Id: I1ddbaaf6fbed59e4804476562c97f6895d99e916 Signed-off-by: Trishansh Bhardwaj <tbhardwa@codeaurora.org>
-rw-r--r--drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.c54
-rw-r--r--drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.h8
2 files changed, 60 insertions, 2 deletions
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.c b/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.c
index f2c243e8c7a9..66142dbf3f74 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.c
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016-2019, 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
@@ -23,6 +23,7 @@
#include "cam_debug_util.h"
static struct cam_mem_table tbl;
+static atomic_t cam_mem_mgr_state = ATOMIC_INIT(CAM_MEM_MGR_UNINITIALIZED);
static int cam_mem_util_map_cpu_va(struct ion_handle *hdl,
uintptr_t *vaddr,
@@ -108,6 +109,7 @@ int cam_mem_mgr_init(void)
tbl.bufq[i].buf_handle = -1;
}
mutex_init(&tbl.m_lock);
+ atomic_set(&cam_mem_mgr_state, CAM_MEM_MGR_INITIALIZED);
return rc;
bitmap_fail:
@@ -151,6 +153,11 @@ int cam_mem_get_io_buf(int32_t buf_handle, int32_t mmu_handle,
{
int rc = 0, idx;
+ if (!atomic_read(&cam_mem_mgr_state)) {
+ CAM_ERR(CAM_CRM, "failed. mem_mgr not initialized");
+ return -EINVAL;
+ }
+
idx = CAM_MEM_MGR_GET_HDL_IDX(buf_handle);
if (idx >= CAM_MEM_BUFQ_MAX || idx <= 0)
return -EINVAL;
@@ -191,6 +198,10 @@ int cam_mem_get_cpu_buf(int32_t buf_handle, uintptr_t *vaddr_ptr, size_t *len)
uintptr_t kvaddr = 0;
size_t klen = 0;
+ if (!atomic_read(&cam_mem_mgr_state)) {
+ CAM_ERR(CAM_CRM, "failed. mem_mgr not initialized");
+ return -EINVAL;
+ }
if (!buf_handle || !vaddr_ptr || !len)
return -EINVAL;
@@ -242,6 +253,11 @@ int cam_mem_mgr_cache_ops(struct cam_mem_cache_ops_cmd *cmd)
uint32_t ion_cache_ops;
unsigned long ion_flag = 0;
+ if (!atomic_read(&cam_mem_mgr_state)) {
+ CAM_ERR(CAM_CRM, "failed. mem_mgr not initialized");
+ return -EINVAL;
+ }
+
if (!cmd)
return -EINVAL;
@@ -518,6 +534,11 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd)
dma_addr_t hw_vaddr = 0;
size_t len;
+ if (!atomic_read(&cam_mem_mgr_state)) {
+ CAM_ERR(CAM_CRM, "failed. mem_mgr not initialized");
+ return -EINVAL;
+ }
+
if (!cmd) {
CAM_ERR(CAM_MEM, " Invalid argument");
return -EINVAL;
@@ -616,6 +637,11 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd)
dma_addr_t hw_vaddr = 0;
size_t len = 0;
+ if (!atomic_read(&cam_mem_mgr_state)) {
+ CAM_ERR(CAM_CRM, "failed. mem_mgr not initialized");
+ return -EINVAL;
+ }
+
if (!cmd || (cmd->fd < 0)) {
CAM_ERR(CAM_MEM, "Invalid argument");
return -EINVAL;
@@ -801,6 +827,7 @@ static int cam_mem_mgr_cleanup_table(void)
void cam_mem_mgr_deinit(void)
{
+ atomic_set(&cam_mem_mgr_state, CAM_MEM_MGR_UNINITIALIZED);
cam_mem_mgr_cleanup_table();
mutex_lock(&tbl.m_lock);
bitmap_zero(tbl.bitmap, tbl.bits);
@@ -889,6 +916,11 @@ int cam_mem_mgr_release(struct cam_mem_mgr_release_cmd *cmd)
int idx;
int rc;
+ if (!atomic_read(&cam_mem_mgr_state)) {
+ CAM_ERR(CAM_CRM, "failed. mem_mgr not initialized");
+ return -EINVAL;
+ }
+
if (!cmd) {
CAM_ERR(CAM_MEM, "Invalid argument");
return -EINVAL;
@@ -936,6 +968,11 @@ int cam_mem_mgr_request_mem(struct cam_mem_mgr_request_desc *inp,
enum cam_smmu_region_id region = CAM_SMMU_REGION_SHARED;
+ if (!atomic_read(&cam_mem_mgr_state)) {
+ CAM_ERR(CAM_CRM, "failed. mem_mgr not initialized");
+ return -EINVAL;
+ }
+
if (!inp || !out) {
CAM_ERR(CAM_MEM, "Invalid params");
return -EINVAL;
@@ -1054,6 +1091,11 @@ int cam_mem_mgr_release_mem(struct cam_mem_mgr_memory_desc *inp)
int32_t idx;
int rc;
+ if (!atomic_read(&cam_mem_mgr_state)) {
+ CAM_ERR(CAM_CRM, "failed. mem_mgr not initialized");
+ return -EINVAL;
+ }
+
if (!inp) {
CAM_ERR(CAM_MEM, "Invalid argument");
return -EINVAL;
@@ -1103,6 +1145,11 @@ int cam_mem_mgr_reserve_memory_region(struct cam_mem_mgr_request_desc *inp,
int32_t smmu_hdl = 0;
int32_t num_hdl = 0;
+ if (!atomic_read(&cam_mem_mgr_state)) {
+ CAM_ERR(CAM_CRM, "failed. mem_mgr not initialized");
+ return -EINVAL;
+ }
+
if (!inp || !out) {
CAM_ERR(CAM_MEM, "Invalid param(s)");
return -EINVAL;
@@ -1195,6 +1242,11 @@ int cam_mem_mgr_free_memory_region(struct cam_mem_mgr_memory_desc *inp)
int rc;
int32_t smmu_hdl;
+ if (!atomic_read(&cam_mem_mgr_state)) {
+ CAM_ERR(CAM_CRM, "failed. mem_mgr not initialized");
+ return -EINVAL;
+ }
+
if (!inp) {
CAM_ERR(CAM_MEM, "Invalid argument");
return -EINVAL;
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.h b/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.h
index 92c366d723f9..73f0eb3d3425 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.h
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016-2019, 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
@@ -20,6 +20,12 @@
#define CAM_MEM_BUFQ_MAX 1024
+/* Enum for possible mem mgr states */
+enum cam_mem_mgr_state {
+ CAM_MEM_MGR_UNINITIALIZED,
+ CAM_MEM_MGR_INITIALIZED,
+};
+
/*Enum for possible SMMU operations */
enum cam_smmu_mapping_client {
CAM_SMMU_MAPPING_USER,