Browse Source

Revert "msm: camera: core: Allocate memory for flush req array dynamically"

This reverts commit 018d8dae943321b3ce7138090855c94831124846.

CRs-Fixed: 2901141
Change-Id: Ida945ea1b83fdf1f60d19b072f667a133ac9b9dc
Signed-off-by: Ravikishore Pampana <[email protected]>
Ravikishore Pampana 4 years ago
parent
commit
2c30b3e2f2
2 changed files with 12 additions and 94 deletions
  1. 10 92
      drivers/cam_core/cam_context_utils.c
  2. 2 2
      drivers/cam_core/cam_hw_mgr_intf.h

+ 10 - 92
drivers/cam_core/cam_context_utils.c

@@ -705,7 +705,7 @@ int32_t cam_context_flush_ctx_to_hw(struct cam_context *ctx)
 	struct cam_hw_flush_args flush_args;
 	struct list_head temp_list;
 	struct cam_ctx_request *req;
-	uint32_t i, j;
+	uint32_t i;
 	int rc = 0;
 	bool free_req;
 
@@ -721,31 +721,15 @@ int32_t cam_context_flush_ctx_to_hw(struct cam_context *ctx)
 	INIT_LIST_HEAD(&temp_list);
 	spin_lock(&ctx->lock);
 	list_splice_init(&ctx->pending_req_list, &temp_list);
-	flush_args.num_req_pending = 0;
-	list_for_each_entry(req, &temp_list, list) {
-		flush_args.num_req_pending++;
-	}
 	spin_unlock(&ctx->lock);
 
-	flush_args.flush_req_pending = kcalloc(flush_args.num_req_pending,
-		sizeof(void *), GFP_KERNEL);
-	if (!flush_args.flush_req_pending) {
-		rc = -ENOMEM;
-		CAM_ERR(CAM_CTXT,
-			"[%s][%d] : Failed to malloc memory for flush_req_pending",
-			ctx->dev_name, ctx->ctx_id);
-		mutex_unlock(&ctx->sync_mutex);
-		goto err;
-	}
-
 	if (cam_debug_ctx_req_list & ctx->dev_id)
 		CAM_INFO(CAM_CTXT,
 			"[%s][%d] : Moving all pending requests from pending_list to temp_list",
 			ctx->dev_name, ctx->ctx_id);
 
+	flush_args.num_req_pending = 0;
 	flush_args.last_flush_req = ctx->last_flush_req;
-
-	j = 0;
 	while (true) {
 		spin_lock(&ctx->lock);
 		if (list_empty(&temp_list)) {
@@ -760,7 +744,7 @@ int32_t cam_context_flush_ctx_to_hw(struct cam_context *ctx)
 		spin_unlock(&ctx->lock);
 		req->flushed = 1;
 
-		flush_args.flush_req_pending[j++] =
+		flush_args.flush_req_pending[flush_args.num_req_pending++] =
 			req->req_priv;
 
 		free_req = false;
@@ -811,31 +795,11 @@ int32_t cam_context_flush_ctx_to_hw(struct cam_context *ctx)
 	}
 	mutex_unlock(&ctx->sync_mutex);
 
-	kfree(flush_args.flush_req_pending);
-	flush_args.flush_req_pending = NULL;
-
 	if (ctx->hw_mgr_intf->hw_flush) {
-		spin_lock(&ctx->lock);
 		flush_args.num_req_active = 0;
-		list_for_each_entry(req, &ctx->active_req_list, list) {
-			flush_args.num_req_active++;
-		}
-		spin_unlock(&ctx->lock);
-
-		flush_args.flush_req_active = kcalloc(flush_args.num_req_active,
-			sizeof(void *), GFP_KERNEL);
-		if (!flush_args.flush_req_active) {
-			rc = -ENOMEM;
-			CAM_ERR(CAM_CTXT,
-				"[%s][%d] : Failed to malloc memory for flush_req_active",
-				ctx->dev_name, ctx->ctx_id);
-			goto err;
-		}
-
 		spin_lock(&ctx->lock);
-		j = 0;
 		list_for_each_entry(req, &ctx->active_req_list, list) {
-			flush_args.flush_req_active[j++]
+			flush_args.flush_req_active[flush_args.num_req_active++]
 				= req->req_priv;
 		}
 		spin_unlock(&ctx->lock);
@@ -848,9 +812,6 @@ int32_t cam_context_flush_ctx_to_hw(struct cam_context *ctx)
 		}
 	}
 
-	kfree(flush_args.flush_req_active);
-	flush_args.flush_req_active = NULL;
-
 	INIT_LIST_HEAD(&temp_list);
 	spin_lock(&ctx->lock);
 	list_splice_init(&ctx->active_req_list, &temp_list);
@@ -904,8 +865,7 @@ int32_t cam_context_flush_ctx_to_hw(struct cam_context *ctx)
 
 	CAM_DBG(CAM_CTXT, "[%s] X: NRT flush ctx", ctx->dev_name);
 
-err:
-	return rc;
+	return 0;
 }
 
 int32_t cam_context_flush_req_to_hw(struct cam_context *ctx,
@@ -925,25 +885,6 @@ int32_t cam_context_flush_req_to_hw(struct cam_context *ctx,
 	flush_args.num_req_active = 0;
 	mutex_lock(&ctx->sync_mutex);
 	spin_lock(&ctx->lock);
-	list_for_each_entry(req, &ctx->pending_req_list, list) {
-		if (req->request_id != cmd->req_id)
-			continue;
-		flush_args.num_req_pending++;
-	}
-	spin_unlock(&ctx->lock);
-
-	flush_args.flush_req_pending = kcalloc(flush_args.num_req_pending,
-		sizeof(void *), GFP_KERNEL);
-	if (!flush_args.flush_req_pending) {
-		rc = -ENOMEM;
-		CAM_ERR(CAM_CTXT,
-			"[%s][%d] : Failed to malloc memory for flush_req_pending",
-			ctx->dev_name, ctx->ctx_id);
-		goto err;
-	}
-
-	spin_lock(&ctx->lock);
-	i = 0;
 	list_for_each_entry(req, &ctx->pending_req_list, list) {
 		if (req->request_id != cmd->req_id)
 			continue;
@@ -956,41 +897,24 @@ int32_t cam_context_flush_req_to_hw(struct cam_context *ctx,
 		list_del_init(&req->list);
 		req->flushed = 1;
 
-		flush_args.flush_req_pending[i++] =
+		flush_args.flush_req_pending[flush_args.num_req_pending++] =
 			req->req_priv;
 		break;
 	}
 	spin_unlock(&ctx->lock);
+	mutex_unlock(&ctx->sync_mutex);
 
 	if (ctx->hw_mgr_intf->hw_flush) {
 		if (!flush_args.num_req_pending) {
 			spin_lock(&ctx->lock);
-			list_for_each_entry(req, &ctx->active_req_list, list) {
-				if (req->request_id != cmd->req_id)
-					continue;
-				flush_args.num_req_active++;
-			}
-			spin_unlock(&ctx->lock);
-
-			flush_args.flush_req_active = kcalloc(flush_args.num_req_active,
-				sizeof(void *), GFP_KERNEL);
-			if (!flush_args.flush_req_pending) {
-				rc = -ENOMEM;
-				CAM_ERR(CAM_CTXT,
-					"[%s][%d] : Failed to malloc memory for flush_req_pending",
-					ctx->dev_name, ctx->ctx_id);
-				goto err;
-			}
-
-			spin_lock(&ctx->lock);
-			i = 0;
 			list_for_each_entry(req, &ctx->active_req_list, list) {
 				if (req->request_id != cmd->req_id)
 					continue;
 
 				list_del_init(&req->list);
 
-				flush_args.flush_req_active[i++] =
+				flush_args.flush_req_active[
+					flush_args.num_req_active++] =
 					req->req_priv;
 				break;
 			}
@@ -1002,10 +926,6 @@ int32_t cam_context_flush_req_to_hw(struct cam_context *ctx,
 			flush_args.flush_type = CAM_FLUSH_TYPE_REQ;
 			ctx->hw_mgr_intf->hw_flush(
 				ctx->hw_mgr_intf->hw_mgr_priv, &flush_args);
-			kfree(flush_args.flush_req_pending);
-			flush_args.flush_req_pending = NULL;
-			kfree(flush_args.flush_req_active);
-			flush_args.flush_req_active = NULL;
 		}
 	}
 
@@ -1061,9 +981,7 @@ int32_t cam_context_flush_req_to_hw(struct cam_context *ctx,
 	}
 	CAM_DBG(CAM_CTXT, "[%s] X: NRT flush req", ctx->dev_name);
 
-err:
-	mutex_unlock(&ctx->sync_mutex);
-	return rc;
+	return 0;
 }
 
 int32_t cam_context_flush_dev_to_hw(struct cam_context *ctx,

+ 2 - 2
drivers/cam_core/cam_hw_mgr_intf.h

@@ -303,9 +303,9 @@ struct cam_hw_config_args {
 struct cam_hw_flush_args {
 	void                           *ctxt_to_hw_map;
 	uint32_t                        num_req_pending;
-	void                          **flush_req_pending;
+	void                           *flush_req_pending[20];
 	uint32_t                        num_req_active;
-	void                          **flush_req_active;
+	void                           *flush_req_active[20];
 	enum flush_type_t               flush_type;
 	uint32_t                        last_flush_req;
 };