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

Commit e674a5e2 authored by Nirmal Abraham's avatar Nirmal Abraham Committed by Gerrit - the friendly Code Review server
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 64f63bb2
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -860,6 +860,7 @@ static int cam_hw_cdm_arb_submit_bl(struct cam_hw_info *cdm_hw,
			"CDM hw bl write failed tag=%d",
			core->bl_fifo[fifo_idx].bl_tag -
			1);
			cam_mem_put_cpu_buf(cdm_cmd->cmd[i].bl_addr.mem_handle);
			list_del_init(&node->entry);
			kfree(node);
			return -EIO;
@@ -871,11 +872,12 @@ static int cam_hw_cdm_arb_submit_bl(struct cam_hw_info *cdm_hw,
			"CDM hw commit failed tag=%d",
			core->bl_fifo[fifo_idx].bl_tag -
			1);
			cam_mem_put_cpu_buf(cdm_cmd->cmd[i].bl_addr.mem_handle);
			list_del_init(&node->entry);
			kfree(node);
			return -EIO;
	}

	cam_mem_put_cpu_buf(cdm_cmd->cmd[i].bl_addr.mem_handle);
	return 0;
}

+3 −1
Original line number Diff line number Diff line
@@ -377,6 +377,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;

	}
@@ -492,7 +493,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--) {
@@ -506,6 +507,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
@@ -3751,6 +3751,7 @@ static int __cam_isp_ctx_config_dev_in_top_state(
		"Preprocessing Config req_id %lld successful on ctx %u",
		req->request_id, ctx->ctx_id);

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

put_ref:
@@ -3764,6 +3765,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;
}