From patchwork Fri Oct 8 08:50:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 240881 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o988oxEm005116 for ; Fri, 8 Oct 2010 08:51:00 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756240Ab0JHIu6 (ORCPT ); Fri, 8 Oct 2010 04:50:58 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:44212 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753504Ab0JHIuy (ORCPT ); Fri, 8 Oct 2010 04:50:54 -0400 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: TEXT/PLAIN Received: from eu_spt1 ([210.118.77.14]) by mailout4.w1.samsung.com (Sun Java(tm) System Messaging Server 6.3-8.04 (built Jul 29 2009; 32bit)) with ESMTP id <0L9Y00LTQR8S9S10@mailout4.w1.samsung.com>; Fri, 08 Oct 2010 09:50:52 +0100 (BST) Received: from linux.samsung.com ([106.116.38.10]) by spt1.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0L9Y00IDSR8R97@spt1.w1.samsung.com>; Fri, 08 Oct 2010 09:50:52 +0100 (BST) Received: from mcdsrvbld02.digital.local (unknown [106.116.37.23]) by linux.samsung.com (Postfix) with ESMTP id 5475B270094; Fri, 08 Oct 2010 10:46:24 +0200 (CEST) Date: Fri, 08 Oct 2010 10:50:36 +0200 From: Sylwester Nawrocki Subject: [PATCH 4/5 v4] V4L/DVB: s5p-fimc: Do not lock both buffer queues in s_fmt In-reply-to: <1286527837-4980-1-git-send-email-s.nawrocki@samsung.com> To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: m.szyprowski@samsung.com, kyungmin.park@samsung.com, s.nawrocki@samsung.com Message-id: <1286527837-4980-5-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.1 References: <1286527837-4980-1-git-send-email-s.nawrocki@samsung.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 08 Oct 2010 08:51:00 +0000 (UTC) diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c index 27379a6..23cc054 100644 --- a/drivers/media/video/s5p-fimc/fimc-core.c +++ b/drivers/media/video/s5p-fimc/fimc-core.c @@ -742,8 +742,9 @@ static int fimc_m2m_try_fmt(struct file *file, void *priv, static int fimc_m2m_s_fmt(struct file *file, void *priv, struct v4l2_format *f) { struct fimc_ctx *ctx = priv; - struct v4l2_device *v4l2_dev = &ctx->fimc_dev->m2m.v4l2_dev; - struct videobuf_queue *src_vq, *dst_vq; + struct fimc_dev *fimc = ctx->fimc_dev; + struct v4l2_device *v4l2_dev = &fimc->m2m.v4l2_dev; + struct videobuf_queue *vq; struct fimc_frame *frame; struct v4l2_pix_format *pix; unsigned long flags; @@ -755,69 +756,61 @@ static int fimc_m2m_s_fmt(struct file *file, void *priv, struct v4l2_format *f) if (ret) return ret; - mutex_lock(&ctx->fimc_dev->lock); + if (mutex_lock_interruptible(&fimc->lock)) + return -ERESTARTSYS; - src_vq = v4l2_m2m_get_src_vq(ctx->m2m_ctx); - dst_vq = v4l2_m2m_get_dst_vq(ctx->m2m_ctx); + vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type); + mutex_lock(&vq->vb_lock); - mutex_lock(&src_vq->vb_lock); - mutex_lock(&dst_vq->vb_lock); + if (videobuf_queue_is_busy(vq)) { + v4l2_err(v4l2_dev, "%s: queue (%d) busy\n", __func__, f->type); + ret = -EBUSY; + goto sf_out; + } + spin_lock_irqsave(&ctx->slock, flags); if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { - if (videobuf_queue_is_busy(src_vq)) { - v4l2_err(v4l2_dev, "%s queue busy\n", __func__); - ret = -EBUSY; - goto s_fmt_out; - } frame = &ctx->s_frame; - spin_lock_irqsave(&ctx->slock, flags); ctx->state |= FIMC_SRC_FMT; - spin_unlock_irqrestore(&ctx->slock, flags); - } else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { - if (videobuf_queue_is_busy(dst_vq)) { - v4l2_err(v4l2_dev, "%s queue busy\n", __func__); - ret = -EBUSY; - goto s_fmt_out; - } frame = &ctx->d_frame; - spin_lock_irqsave(&ctx->slock, flags); ctx->state |= FIMC_DST_FMT; - spin_unlock_irqrestore(&ctx->slock, flags); } else { + spin_unlock_irqrestore(&ctx->slock, flags); v4l2_err(&ctx->fimc_dev->m2m.v4l2_dev, "Wrong buffer/video queue type (%d)\n", f->type); ret = -EINVAL; - goto s_fmt_out; + goto sf_out; } + spin_unlock_irqrestore(&ctx->slock, flags); pix = &f->fmt.pix; frame->fmt = find_format(f); if (!frame->fmt) { ret = -EINVAL; - goto s_fmt_out; + goto sf_out; } - frame->f_width = pix->bytesperline * 8 / frame->fmt->depth; - frame->f_height = pix->sizeimage/pix->bytesperline; - frame->width = pix->width; - frame->height = pix->height; - frame->o_width = pix->width; + frame->f_width = pix->bytesperline * 8 / frame->fmt->depth; + frame->f_height = pix->height; + frame->width = pix->width; + frame->height = pix->height; + frame->o_width = pix->width; frame->o_height = pix->height; - frame->offs_h = 0; - frame->offs_v = 0; - frame->size = (pix->width * pix->height * frame->fmt->depth) >> 3; - src_vq->field = dst_vq->field = pix->field; + frame->offs_h = 0; + frame->offs_v = 0; + frame->size = (pix->width * pix->height * frame->fmt->depth) >> 3; + vq->field = pix->field; + spin_lock_irqsave(&ctx->slock, flags); ctx->state |= FIMC_PARAMS; spin_unlock_irqrestore(&ctx->slock, flags); - dbg("f_width= %d, f_height= %d", frame->f_width, frame->f_height); + dbg("f_w: %d, f_h: %d", frame->f_width, frame->f_height); -s_fmt_out: - mutex_unlock(&dst_vq->vb_lock); - mutex_unlock(&src_vq->vb_lock); - mutex_unlock(&ctx->fimc_dev->lock); +sf_out: + mutex_unlock(&vq->vb_lock); + mutex_unlock(&fimc->lock); return ret; }