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

Commit e92b23ee authored by Rahul Sharma's avatar Rahul Sharma Committed by Gerrit - the friendly Code Review server
Browse files

msm: ais: Avoid deadlock for vb2 operations using separate lock



Use mutex lock for all VB2 operations, and use separatelock other
than used for stop streaming operation to avoid dead lock.

Change-Id: Ibb466f81cb2825a77073712419fd17c9759ecde4
Signed-off-by: default avatarRahul Sharma <sharah@codeaurora.org>
parent 37b0e480
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -430,6 +430,7 @@ static int msm_fd_open(struct file *file)
	ctx->vb2_q.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
	ctx->vb2_q.io_modes = VB2_USERPTR;
	ctx->vb2_q.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
	mutex_init(&ctx->lock);
	ret = vb2_queue_init(&ctx->vb2_q);
	if (ret < 0) {
		dev_err(device->dev, "Error queue init\n");
@@ -480,7 +481,9 @@ static int msm_fd_release(struct file *file)
	msm_cpp_vbif_register_error_handler((void *)ctx,
		VBIF_CLIENT_FD, NULL);

	mutex_lock(&ctx->lock);
	vb2_queue_release(&ctx->vb2_q);
	mutex_unlock(&ctx->lock);

	vfree(ctx->stats);

@@ -510,7 +513,9 @@ static unsigned int msm_fd_poll(struct file *file,
	struct fd_ctx *ctx = msm_fd_ctx_from_fh(file->private_data);
	unsigned int ret;

	mutex_lock(&ctx->lock);
	ret = vb2_poll(&ctx->vb2_q, file, wait);
	mutex_unlock(&ctx->lock);

	if (atomic_read(&ctx->subscribed_for_event)) {
		poll_wait(file, &ctx->fh.wait, wait);
@@ -748,9 +753,9 @@ static int msm_fd_reqbufs(struct file *file,
	int ret;
	struct fd_ctx *ctx = msm_fd_ctx_from_fh(fh);

	mutex_lock(&ctx->fd_device->recovery_lock);
	mutex_lock(&ctx->lock);
	ret = vb2_reqbufs(&ctx->vb2_q, req);
	mutex_unlock(&ctx->fd_device->recovery_lock);
	mutex_unlock(&ctx->lock);
	return ret;
}

@@ -766,9 +771,9 @@ static int msm_fd_qbuf(struct file *file, void *fh,
	int ret;
	struct fd_ctx *ctx = msm_fd_ctx_from_fh(fh);

	mutex_lock(&ctx->fd_device->recovery_lock);
	mutex_lock(&ctx->lock);
	ret = vb2_qbuf(&ctx->vb2_q, pb);
	mutex_unlock(&ctx->fd_device->recovery_lock);
	mutex_unlock(&ctx->lock);
	return ret;

}
@@ -785,9 +790,9 @@ static int msm_fd_dqbuf(struct file *file,
	int ret;
	struct fd_ctx *ctx = msm_fd_ctx_from_fh(fh);

	mutex_lock(&ctx->fd_device->recovery_lock);
	mutex_lock(&ctx->lock);
	ret = vb2_dqbuf(&ctx->vb2_q, pb, file->f_flags & O_NONBLOCK);
	mutex_unlock(&ctx->fd_device->recovery_lock);
	mutex_unlock(&ctx->lock);
	return ret;
}

@@ -803,7 +808,9 @@ static int msm_fd_streamon(struct file *file,
	struct fd_ctx *ctx = msm_fd_ctx_from_fh(fh);
	int ret;

	mutex_lock(&ctx->lock);
	ret = vb2_streamon(&ctx->vb2_q, buf_type);
	mutex_unlock(&ctx->lock);
	if (ret < 0)
		dev_err(ctx->fd_device->dev, "Stream on fails\n");

@@ -822,7 +829,9 @@ static int msm_fd_streamoff(struct file *file,
	struct fd_ctx *ctx = msm_fd_ctx_from_fh(fh);
	int ret;

	mutex_lock(&ctx->lock);
	ret = vb2_streamoff(&ctx->vb2_q, buf_type);
	mutex_unlock(&ctx->lock);
	if (ret < 0)
		dev_err(ctx->fd_device->dev, "Stream off fails\n");

+1 −0
Original line number Diff line number Diff line
@@ -161,6 +161,7 @@ struct fd_ctx {
	struct msm_fd_mem_pool mem_pool;
	struct msm_fd_stats *stats;
	struct msm_fd_buf_handle work_buf;
	struct mutex lock;
};

/*