Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a9669844 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: camera: Remove usage of put_ref API in memory manager"

parents 074b4895 0c364778
Loading
Loading
Loading
Loading
+3 −11
Original line number Diff line number Diff line
@@ -383,7 +383,7 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
		((size_t)cmd->offset >= len - sizeof(struct cam_packet))) {
		CAM_ERR(CAM_CTXT, "invalid buff length: %zu or offset", len);
		rc = -EINVAL;
		goto free_cpu_buf;
		goto free_req;
	}

	remain_len -= (size_t)cmd->offset;
@@ -395,7 +395,7 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
			"request %lld has been flushed, reject packet",
			packet->header.request_id);
		rc = -EINVAL;
		goto free_cpu_buf;
		goto free_req;
	}

	if (packet->header.request_id > ctx->last_flush_req)
@@ -422,7 +422,7 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
			"[%s][%d] Prepare config packet failed in HW layer",
			ctx->dev_name, ctx->ctx_id);
		rc = -EFAULT;
		goto free_cpu_buf;
		goto free_req;
	}
	req->num_hw_update_entries = cfg.num_hw_update_entries;
	req->num_out_map_entries = cfg.num_out_map_entries;
@@ -480,10 +480,6 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
		}
	}

	if (cam_mem_put_cpu_buf((int32_t) cmd->packet_handle))
		CAM_WARN(CAM_CTXT, "[%s][%d] Can not put packet address",
			ctx->dev_name, ctx->ctx_id);

	return rc;

put_ref:
@@ -492,10 +488,6 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
			CAM_ERR(CAM_CTXT, "Failed to put ref of fence %d",
				req->out_map_entries[i].sync_id);
	}
free_cpu_buf:
	if (cam_mem_put_cpu_buf((int32_t) cmd->packet_handle))
		CAM_WARN(CAM_CTXT, "[%s][%d] Can not put packet address",
			ctx->dev_name, ctx->ctx_id);
free_req:
	spin_lock(&ctx->lock);
	list_add_tail(&req->list, &ctx->free_req_list);
+2 −22
Original line number Diff line number Diff line
@@ -603,7 +603,7 @@ static int cam_fd_mgr_util_prepare_io_buf_info(int32_t iommu_hdl,
						io_cfg[i].direction,
						io_cfg[i].resource_type, plane,
						rc);
					goto rel_cpu_buf;
					return rc;
				}
				if (io_cfg[i].offsets[plane] >= size) {
					CAM_ERR(CAM_FD,
@@ -611,7 +611,7 @@ static int cam_fd_mgr_util_prepare_io_buf_info(int32_t iommu_hdl,
						io_cfg[i].direction,
						io_cfg[i].resource_type, plane);
					rc = -EINVAL;
					goto rel_cpu_buf;
					return rc;
				}
				cpu_addr[plane] += io_cfg[i].offsets[plane];
			}
@@ -663,31 +663,11 @@ static int cam_fd_mgr_util_prepare_io_buf_info(int32_t iommu_hdl,
			rc = -EINVAL;
			break;
		}

		for (j = 0; j < plane; j++) {
			if (need_cpu_map) {
				if (cam_mem_put_cpu_buf(
					io_cfg[i].mem_handle[j]))
					CAM_WARN(CAM_FD,
						"Invalid cpu buf %d %d %d",
						io_cfg[i].direction,
						io_cfg[i].resource_type, j);
			}
		}
	}

	prepare->num_in_map_entries  = num_in_buf;
	prepare->num_out_map_entries = num_out_buf;
	return rc;

rel_cpu_buf:
	for (j = plane - 1; j >= 0; j--) {
		if (cam_mem_put_cpu_buf(io_cfg[i].mem_handle[j]))
			CAM_WARN(CAM_FD, "Fail to put cpu buf %d %d %d",
				io_cfg[i].direction,
				io_cfg[i].resource_type, j);
	}
	return rc;
}

static int cam_fd_mgr_util_prepare_hw_update_entries(
+3 −35
Original line number Diff line number Diff line
@@ -3370,25 +3370,6 @@ static int cam_icp_mgr_pkt_validation(struct cam_packet *packet)
	return 0;
}

static int cam_icp_mgr_put_cmd_buf(struct cam_packet *packet)
{
	int i = 0;
	struct cam_cmd_buf_desc *cmd_desc = NULL;

	cmd_desc = (struct cam_cmd_buf_desc *)
		((uint32_t *) &packet->payload + packet->cmd_buf_offset/4);

	for (i = 0; i < packet->num_cmd_buf; i++) {
		if (cmd_desc[i].type == CAM_CMD_BUF_FW) {
			if (cam_mem_put_cpu_buf(cmd_desc[i].mem_handle))
				CAM_WARN(CAM_ICP, "put cmd buf failed: 0x%x",
					cmd_desc[i].mem_handle);
		}
	}

	return 0;
}

static int cam_icp_mgr_process_cmd_desc(struct cam_icp_hw_mgr *hw_mgr,
	struct cam_packet *packet, struct cam_icp_hw_ctx_data *ctx_data,
	uint32_t *fw_cmd_buf_iova_addr)
@@ -3419,7 +3400,7 @@ static int cam_icp_mgr_process_cmd_desc(struct cam_icp_hw_mgr *hw_mgr,

				if (num_cmd_buf > 0)
					num_cmd_buf--;
				goto rel_cmd_buf;
				return rc;
			}
			*fw_cmd_buf_iova_addr = addr;
			*fw_cmd_buf_iova_addr =
@@ -3433,14 +3414,14 @@ static int cam_icp_mgr_process_cmd_desc(struct cam_icp_hw_mgr *hw_mgr,

				if (num_cmd_buf > 0)
					num_cmd_buf--;
				goto rel_cmd_buf;
				return rc;
			}
			if ((len <= cmd_desc[i].offset) ||
				(cmd_desc[i].size < cmd_desc[i].length) ||
				((len - cmd_desc[i].offset) <
				cmd_desc[i].length)) {
				CAM_ERR(CAM_ICP, "Invalid offset or length");
				goto rel_cmd_buf;
				return -EINVAL;
			}
			cpu_addr = cpu_addr + cmd_desc[i].offset;
		}
@@ -3494,18 +3475,6 @@ static int cam_icp_mgr_process_cmd_desc(struct cam_icp_hw_mgr *hw_mgr,
		}
	}

	return rc;

rel_cmd_buf:
	for (i = num_cmd_buf; i >= 0; i--) {
		if (cmd_desc[i].type == CAM_CMD_BUF_FW) {
			if (cam_mem_put_cpu_buf(cmd_desc[i].mem_handle)) {
				CAM_WARN(CAM_ICP, "put cmd buf failed 0x%x",
					cmd_desc[i].mem_handle);
			}
		}
	}

	return rc;
}

@@ -4080,7 +4049,6 @@ static int cam_icp_mgr_prepare_hw_update(void *hw_mgr_priv,

	CAM_DBG(CAM_ICP, "X: req id = %lld ctx_id = %u",
		packet->header.request_id, ctx_data->ctx_id);
	cam_icp_mgr_put_cmd_buf(packet);
	mutex_unlock(&ctx_data->ctx_mutex);
	return rc;
}
+15 −31
Original line number Diff line number Diff line
@@ -123,7 +123,6 @@ static void cam_isp_ctx_dump_req(struct cam_isp_ctx_req *req_isp)
	uint32_t *buf_addr;
	uint32_t *buf_start, *buf_end;
	size_t   remain_len = 0;
	bool     need_put = false;

	for (i = 0; i < req_isp->num_cfg; i++) {
		rc = cam_packet_util_get_cmd_mem_addr(
@@ -133,25 +132,21 @@ static void cam_isp_ctx_dump_req(struct cam_isp_ctx_req *req_isp)
				"Failed to get_cmd_mem_addr, rc=%d",
				rc);
		} else {
			if (req_isp->cfg[i].offset >= len) {
				CAM_ERR(CAM_ISP, "Invalid offset");
				need_put = true;
				goto put;
			if (req_isp->cfg[i].offset >= ((uint32_t)len)) {
				CAM_ERR(CAM_ISP,
					"Invalid offset exp %u actual %u",
					req_isp->cfg[i].offset, (uint32_t)len);
				return;
			}
			remain_len = len - req_isp->cfg[i].offset;

			if (req_isp->cfg[i].len > remain_len) {
				CAM_ERR(CAM_ISP, "Invalid offset");
				need_put = true;
			}
put:
			if (need_put) {
				if (cam_mem_put_cpu_buf(req_isp->cfg[i].handle))
					CAM_WARN(CAM_ISP,
						"Failed to put cpu buf: 0x%x",
						req_isp->cfg[i].handle);
				need_put = false;
				continue;
			if (req_isp->cfg[i].len >
				((uint32_t)remain_len)) {
				CAM_ERR(CAM_ISP,
					"Invalid len exp %u remain_len %u",
					req_isp->cfg[i].len,
					(uint32_t)remain_len);
				return;
			}

			buf_start = (uint32_t *)((uint8_t *) buf_addr +
@@ -159,9 +154,6 @@ static void cam_isp_ctx_dump_req(struct cam_isp_ctx_req *req_isp)
			buf_end = (uint32_t *)((uint8_t *) buf_start +
				req_isp->cfg[i].len - 1);
			cam_cdm_util_dump_cmd_buf(buf_start, buf_end);
			if (cam_mem_put_cpu_buf(req_isp->cfg[i].handle))
				CAM_WARN(CAM_ISP, "Failed to put cpu buf: 0x%x",
					req_isp->cfg[i].handle);
		}
	}
}
@@ -2606,7 +2598,7 @@ static int __cam_isp_ctx_config_dev_in_top_state(
		((size_t)cmd->offset >= len - sizeof(struct cam_packet))) {
		CAM_ERR(CAM_ISP, "invalid buff length: %zu or offset", len);
		rc = -EINVAL;
		goto free_cpu_buf;
		goto free_req;
	}

	remain_len -= (size_t)cmd->offset;
@@ -2626,7 +2618,7 @@ static int __cam_isp_ctx_config_dev_in_top_state(
			"request %lld has been flushed, reject packet",
			packet->header.request_id);
		rc = -EINVAL;
		goto free_cpu_buf;
		goto free_req;
	}

	/* preprocess the configuration */
@@ -2650,7 +2642,7 @@ static int __cam_isp_ctx_config_dev_in_top_state(
	if (rc != 0) {
		CAM_ERR(CAM_ISP, "Prepare config packet failed in HW layer");
		rc = -EFAULT;
		goto free_cpu_buf;
		goto free_req;
	}
	req_isp->num_cfg = cfg.num_hw_update_entries;
	req_isp->num_fence_map_out = cfg.num_out_map_entries;
@@ -2711,10 +2703,6 @@ static int __cam_isp_ctx_config_dev_in_top_state(
	if (rc)
		goto put_ref;

	if (cam_mem_put_cpu_buf((int32_t) cmd->packet_handle))
		CAM_WARN(CAM_ISP, "Can not put packet address : 0x%llx",
			cmd->packet_handle);

	CAM_DBG(CAM_REQ,
		"Preprocessing Config req_id %lld successful on ctx %u",
		req->request_id, ctx->ctx_id);
@@ -2727,10 +2715,6 @@ static int __cam_isp_ctx_config_dev_in_top_state(
			CAM_ERR(CAM_CTXT, "Failed to put ref of fence %d",
				req_isp->fence_map_out[i].sync_id);
	}
free_cpu_buf:
	if (cam_mem_put_cpu_buf((int32_t) cmd->packet_handle))
		CAM_WARN(CAM_ISP, "Can not put packet address: 0x%llx",
			cmd->packet_handle);
free_req:
	spin_lock_bh(&ctx->lock);
	list_add_tail(&req->list, &ctx->free_req_list);
+7 −11
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ static int cam_isp_update_dual_config(
	uint32_t                                   *cpu_addr;
	uint32_t                                    i, j;

	CAM_DBG(CAM_UTIL, "cmd des size %d, length: %d",
	CAM_DBG(CAM_ISP, "cmd des size %d, length: %d",
		cmd_desc->size, cmd_desc->length);

	rc = cam_packet_util_get_cmd_mem_addr(
@@ -113,7 +113,7 @@ static int cam_isp_update_dual_config(
	if ((len < sizeof(struct cam_isp_dual_config)) ||
		(cmd_desc->offset >=
		(len - sizeof(struct cam_isp_dual_config)))) {
		CAM_ERR(CAM_UTIL, "not enough buffer provided");
		CAM_ERR(CAM_ISP, "not enough buffer provided");
		return -EINVAL;
	}
	remain_len = len - cmd_desc->offset;
@@ -123,17 +123,17 @@ static int cam_isp_update_dual_config(
	if ((dual_config->num_ports *
		sizeof(struct cam_isp_dual_stripe_config)) >
		(remain_len - offsetof(struct cam_isp_dual_config, stripes))) {
		CAM_ERR(CAM_UTIL, "not enough buffer for all the dual configs");
		CAM_ERR(CAM_ISP, "not enough buffer for all the dual configs");
		return -EINVAL;
	}
	for (i = 0; i < dual_config->num_ports; i++) {

		if (i >= CAM_ISP_IFE_OUT_RES_MAX) {
			CAM_ERR(CAM_UTIL,
			CAM_ERR(CAM_ISP,
				"failed update for i:%d > size_isp_out:%d",
				i, size_isp_out);
			rc = -EINVAL;
			goto put_buf;
			goto end;
		}

		hw_mgr_res = &res_list_isp_out[i];
@@ -168,15 +168,11 @@ static int cam_isp_update_dual_config(
				&dual_isp_update_args,
				sizeof(struct cam_isp_hw_dual_isp_update_args));
			if (rc)
				goto put_buf;
				goto end;
		}
	}

put_buf:
	if (cam_mem_put_cpu_buf(cmd_desc->mem_handle))
		CAM_WARN(CAM_UTIL, "Failed to put buf: 0x%x",
			cmd_desc->mem_handle);

end:
	return rc;
}

Loading