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

Commit 2ddca85a authored by Terence Ho's avatar Terence Ho
Browse files

msm: Address warnings and review comments for ais



Fix the error path cleanup of mapping info structure.
Remove unnecessary WARN_ON usages in camera code.
This patch also fixes buffer enqueue memory leak.

Change-Id: I2ab5861c9f96a454fd03b36b69814cd8af0cebfd
Signed-off-by: default avatarTerence Ho <terenceh@codeaurora.org>
parent c3d5931b
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -621,7 +621,9 @@ static int camera_v4l2_open(struct file *filep)
	struct msm_video_device *pvdev = video_drvdata(filep);
	unsigned int opn_idx, idx;

	BUG_ON(!pvdev);
	if (WARN_ON(!pvdev))
		return -EIO;

	rc = camera_v4l2_fh_open(filep);
	if (rc < 0) {
		pr_err("%s : camera_v4l2_fh_open failed Line %d rc %d\n",
@@ -733,7 +735,9 @@ static int camera_v4l2_close(struct file *filep)
	unsigned int opn_idx, mask;
	struct msm_session *session;

	BUG_ON(!pvdev);
	if (WARN_ON(!pvdev))
		return -EIO;

	session = msm_session_find(pvdev->vdev->num);
	if (WARN_ON(!session))
		return -EIO;
@@ -861,19 +865,19 @@ int camera_init_v4l2(struct device *dev, unsigned int *session)

	pvdev = kzalloc(sizeof(struct msm_video_device),
		GFP_KERNEL);
	if (WARN_ON(!pvdev)) {
	if (!pvdev) {
		rc = -ENOMEM;
		goto init_end;
	}

	pvdev->vdev = video_device_alloc();
	if (WARN_ON(!pvdev->vdev)) {
	if (!pvdev->vdev) {
		rc = -ENOMEM;
		goto video_fail;
	}

	v4l2_dev = kzalloc(sizeof(struct v4l2_device), GFP_KERNEL);
	if (WARN_ON(!v4l2_dev)) {
	if (!v4l2_dev) {
		rc = -ENOMEM;
		goto v4l2_fail;
	}
+9 −7
Original line number Diff line number Diff line
@@ -771,12 +771,18 @@ static int cam_smmu_map_buffer_and_add_to_list(int idx, int ion_fd,
		goto err_out;
	}

	mapping_info = kzalloc(sizeof(struct cam_dma_buff_info), GFP_KERNEL);
	if (!mapping_info) {
		rc = -ENOSPC;
		goto err_out;
	}

	/* allocate memory for each buffer information */
	buf = dma_buf_get(ion_fd);
	if (IS_ERR_OR_NULL(buf)) {
		rc = PTR_ERR(buf);
		pr_err("Error: dma get buf failed. fd = %d\n", ion_fd);
		goto err_out;
		goto err_alloc;
	}

	attach = dma_buf_attach(buf, iommu_cb_set.cb_info[idx].dev);
@@ -816,11 +822,6 @@ static int cam_smmu_map_buffer_and_add_to_list(int idx, int ion_fd,
	}

	/* fill up mapping_info */
	mapping_info = kzalloc(sizeof(struct cam_dma_buff_info), GFP_KERNEL);
	if (!mapping_info) {
		rc = -ENOSPC;
		goto err_unmap_sg;
	}
	mapping_info->ion_fd = ion_fd;
	mapping_info->buf = buf;
	mapping_info->attach = attach;
@@ -849,11 +850,12 @@ static int cam_smmu_map_buffer_and_add_to_list(int idx, int ion_fd,

err_unmap_sg:
	dma_buf_unmap_attachment(attach, table, dma_dir);
	kfree(mapping_info);
err_detach:
	dma_buf_detach(buf, attach);
err_put:
	dma_buf_put(buf);
err_alloc:
	kfree(mapping_info);
err_out:
	return rc;
}
+16 −9
Original line number Diff line number Diff line
@@ -399,7 +399,6 @@ int msm_isp_flush_queue(struct msm_isp_buf_mgr *buf_mgr,
	uint32_t rc = 0;
	int i = 0;
	struct msm_isp_bufq *bufq = NULL;
	struct msm_isp_buffer *temp_buf_info = NULL;

	bufq = msm_isp_get_bufq(buf_mgr, bufq_handle);
	if (!bufq) {
@@ -407,16 +406,24 @@ int msm_isp_flush_queue(struct msm_isp_buf_mgr *buf_mgr,
		return rc;
	}

	for (i = 0; i < bufq->num_bufs; i++) {
		temp_buf_info = &bufq->bufs[i];
		temp_buf_info->state = MSM_ISP_BUFFER_STATE_INITIALIZED;
		temp_buf_info->buf_debug.put_state_last = 0;
		temp_buf_info->buf_idx = i;
		INIT_LIST_HEAD(&temp_buf_info->list);
	}
	rc = msm_isp_buf_unprepare_all(buf_mgr, bufq_handle);

	for (i = 0; i < ISP_NUM_BUF_MASK; i++)
		bufq->put_buf_mask[i] = 0;
	INIT_LIST_HEAD(&bufq->head);
	rc = msm_isp_buf_unprepare_all(buf_mgr, bufq_handle);

	memset(bufq->bufs, 0x0, bufq->num_bufs*sizeof(bufq->bufs[0]));
	for (i = 0; i < bufq->num_bufs; i++) {
		bufq->bufs[i].state = MSM_ISP_BUFFER_STATE_INITIALIZED;
		bufq->bufs[i].buf_debug.put_state[0] =
				MSM_ISP_BUFFER_STATE_PUT_PREPARED;
		bufq->bufs[i].buf_debug.put_state[1] =
				MSM_ISP_BUFFER_STATE_PUT_PREPARED;
		bufq->bufs[i].buf_debug.put_state_last = 0;
		bufq->bufs[i].bufq_handle = bufq->bufq_handle;
		bufq->bufs[i].buf_idx = i;
		INIT_LIST_HEAD(&bufq->bufs[i].list);
	}

	return rc;

+1 −1
Original line number Diff line number Diff line
@@ -545,7 +545,7 @@ static void msm_isp_cfg_framedrop_reg(struct vfe_device *vfe_dev,
		stream_info->stream_handle, framedrop_pattern,
		framedrop_period);

	BUG_ON(0 == framedrop_period);
	WARN_ON(0 == framedrop_period);
	if (DUAL_VFE_AND_VFE1(stream_info, vfe_dev)) {
		vfe0_stream_info = msm_isp_vfe_get_stream(
					vfe_dev->common_data->dual_vfe_res,
+12 −9
Original line number Diff line number Diff line
@@ -164,7 +164,8 @@ typedef int (*msm_queue_find_func)(void *d1, void *d2);

static void msm_init_queue(struct msm_queue_head *qhead)
{
	BUG_ON(!qhead);
	if (WARN_ON(!qhead))
		return;

	INIT_LIST_HEAD(&qhead->list);
	spin_lock_init(&qhead->lock);
@@ -812,7 +813,8 @@ static unsigned int msm_poll(struct file *f,
	int rc = 0;
	struct v4l2_fh *eventq = f->private_data;

	BUG_ON(!eventq);
	if (WARN_ON(!eventq))
		return 0;

	poll_wait(f, &eventq->wait, pll_table);

@@ -998,7 +1000,8 @@ static int msm_open(struct file *filep)
	unsigned long flags;
	struct msm_video_device *pvdev = video_drvdata(filep);

	BUG_ON(!pvdev);
	if (WARN_ON(!pvdev))
		return -EIO;

	/* !!! only ONE open is allowed !!! */
	if (atomic_read(&pvdev->opened))
@@ -1136,8 +1139,8 @@ static void msm_sd_notify(struct v4l2_subdev *sd,
	int rc = 0;
	struct v4l2_subdev *subdev = NULL;

	BUG_ON(!sd);
	BUG_ON(!arg);
	if (WARN_ON(!sd) || WARN_ON(!arg))
		return;

	/* Check if subdev exists before processing*/
	if (!msm_sd_find(sd->name))
@@ -1203,20 +1206,20 @@ static int msm_probe(struct platform_device *pdev)

	msm_v4l2_dev = kzalloc(sizeof(*msm_v4l2_dev),
		GFP_KERNEL);
	if (WARN_ON(!msm_v4l2_dev)) {
	if (!msm_v4l2_dev) {
		rc = -ENOMEM;
		goto probe_end;
	}

	pvdev = kzalloc(sizeof(struct msm_video_device),
		GFP_KERNEL);
	if (WARN_ON(!pvdev)) {
	if (!pvdev) {
		rc = -ENOMEM;
		goto pvdev_fail;
	}

	pvdev->vdev = video_device_alloc();
	if (WARN_ON(!pvdev->vdev)) {
	if (!pvdev->vdev) {
		rc = -ENOMEM;
		goto video_fail;
	}
@@ -1272,7 +1275,7 @@ static int msm_probe(struct platform_device *pdev)
	video_set_drvdata(pvdev->vdev, pvdev);

	msm_session_q = kzalloc(sizeof(*msm_session_q), GFP_KERNEL);
	if (WARN_ON(!msm_session_q))
	if (!msm_session_q)
		goto v4l2_fail;

	msm_init_queue(msm_session_q);
Loading