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

Commit f28fbd16 authored by Nirmal Abraham's avatar Nirmal Abraham
Browse files

msm: camera: mem_mgr: release buffers after usage



Call cam_mem_put_cpu_buf corresponding to
cam_mem_get_cpu_buf calls to make sure ref_cnt
is balanced and buffer is freed when all
clients are done with the buffer usage.

CRs-Fixed: 3547081
Change-Id: I9414829d6f17c368f2718fe05dbe25c71b31e674
Signed-off-by: default avatarNirmal Abraham <quic_c_nabrah@quicinc.com>
parent 561c2c5f
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -301,6 +301,7 @@ int32_t cam_context_config_dev_to_hw(
		(cmd->offset >= (len - sizeof(struct cam_packet)))) {
		CAM_ERR(CAM_CTXT, "Not enough buf, len : %zu offset = %llu",
			len, cmd->offset);
		cam_mem_put_cpu_buf((int32_t) cmd->packet_handle);
		return -EINVAL;

	}
@@ -384,6 +385,7 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
	if ((len < sizeof(struct cam_packet)) ||
		(cmd->offset >= (len - sizeof(struct cam_packet)))) {
		CAM_ERR(CAM_CTXT, "Not enough buf");
		cam_mem_put_cpu_buf((int32_t) cmd->packet_handle);
		return -EINVAL;

	}
@@ -502,7 +504,7 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
				req->in_map_entries[j].sync_id, rc);
		}
	}

	cam_mem_put_cpu_buf((int32_t) cmd->packet_handle);
	return rc;
put_ref:
	for (--i; i >= 0; i--) {
@@ -516,6 +518,7 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
	req->ctx = NULL;
	spin_unlock(&ctx->lock);

	cam_mem_put_cpu_buf((int32_t) cmd->packet_handle);
	return rc;
}

+2 −0
Original line number Diff line number Diff line
@@ -4589,6 +4589,7 @@ static int __cam_isp_ctx_config_dev_in_top_state(
		__cam_isp_ctx_schedule_apply_req_offline(ctx_isp);
	}

	cam_mem_put_cpu_buf((int32_t) cmd->packet_handle);
	return rc;

put_ref:
@@ -4602,6 +4603,7 @@ static int __cam_isp_ctx_config_dev_in_top_state(
	list_add_tail(&req->list, &ctx->free_req_list);
	spin_unlock_bh(&ctx->lock);

	cam_mem_put_cpu_buf((int32_t) cmd->packet_handle);
	return rc;
}

+2 −0
Original line number Diff line number Diff line
@@ -155,6 +155,7 @@ static int cam_jpeg_mgr_process_irq(void *priv, void *data)
		CAM_ERR(CAM_JPEG, "Invalid offset: %u cmd buf len: %zu",
			p_cfg_req->hw_cfg_args.hw_update_entries[
			CAM_JPEG_PARAM].offset, cmd_buf_len);
		cam_mem_put_cpu_buf(mem_hdl);
		return -EINVAL;
	}

@@ -181,6 +182,7 @@ static int cam_jpeg_mgr_process_irq(void *priv, void *data)
	mutex_lock(&g_jpeg_hw_mgr.hw_mgr_mutex);
	list_add_tail(&p_cfg_req->list, &hw_mgr->free_req_list);
	mutex_unlock(&g_jpeg_hw_mgr.hw_mgr_mutex);
	cam_mem_put_cpu_buf(mem_hdl);
	return rc;
}