From patchwork Fri May 6 22:11:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 9036951 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 27D939F1D3 for ; Fri, 6 May 2016 22:14:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 35CC4202BE for ; Fri, 6 May 2016 22:14:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 36CC120219 for ; Fri, 6 May 2016 22:14:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aynyj-00015T-Uh; Fri, 06 May 2016 22:12:09 +0000 Received: from lists.s-osg.org ([54.187.51.154]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aynyg-00014H-9L for linux-arm-kernel@lists.infradead.org; Fri, 06 May 2016 22:12:07 +0000 Received: from minerva.localdomain (host-45.58.217.201.copaco.com.py [201.217.58.45]) by lists.s-osg.org (Postfix) with ESMTPSA id 20E3CE27CF; Fri, 6 May 2016 15:11:47 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [RESEND PATCH] [media] s5p-mfc: don't close instance after free OUTPUT buffers Date: Fri, 6 May 2016 18:11:22 -0400 Message-Id: <1462572682-5195-1-git-send-email-javier@osg.samsung.com> X-Mailer: git-send-email 2.5.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160506_151206_369937_AD80016C X-CRM114-Status: GOOD ( 12.60 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kamil Debski , linux-media@vger.kernel.org, Mauro Carvalho Chehab , ayaka , Shuah Khan , Jeongtae Park , Javier Martinez Canillas , Kyungmin Park , Nicolas Dufresne , linux-arm-kernel@lists.infradead.org, Marek Szyprowski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: ayaka User-space applications can use the VIDIOC_REQBUFS ioctl to determine if a memory mapped, user pointer or DMABUF based I/O is supported by the driver. So a set of VIDIOC_REQBUFS ioctl calls will be made with count 0 and then the real VIDIOC_REQBUFS call with count == n. But for count 0, the driver not only frees the buffer but also closes the MFC instance and s5p_mfc_ctx state is set to MFCINST_FREE. The VIDIOC_REQBUFS handler for the output device checks if the s5p_mfc_ctx state is set to MFCINST_INIT (which happens on an VIDIOC_S_FMT) and fails otherwise. So after a VIDIOC_REQBUFS(n), future VIDIOC_REQBUFS(n) calls will fails unless a VIDIOC_S_FMT ioctl calls happens before the reqbufs. But applications may first set the format and then attempt to determine the I/O methods supported by the driver (for example Gstramer does it) so the state won't be set to MFCINST_INIT again and VIDIOC_REQBUFS will fail. To avoid this issue, only free the buffers on VIDIOC_REQBUFS(0) but don't close the MFC instance to allow future VIDIOC_REQBUFS(n) calls to succeed. Signed-off-by: ayaka [javier: Rewrote changelog to explain the problem more detailed] Signed-off-by: Javier Martinez Canillas Acked-by: Nicolas Dufresne Tested-by: Marek Szyprowski --- Hello, This is a resend of a patch posted by Ayaka some time ago [0]. Without $SUBJECT, trying to decode a video using Gstramer fails on an Exynos5422 Odroid XU4 board with following error message: $ gst-launch-1.0 filesrc location=test.mov ! qtdemux ! h264parse ! v4l2video0dec ! videoconvert ! autovideosink Setting pipeline to PAUSED ... Pipeline is PREROLLING ... [ 3947.114756] vidioc_reqbufs:576: Only V4L2_MEMORY_MAP is supported [ 3947.114771] vidioc_reqbufs:576: Only V4L2_MEMORY_MAP is supported [ 3947.114903] reqbufs_output:484: Reqbufs called in an invalid state [ 3947.114913] reqbufs_output:510: Failed allocating buffers for OUTPUT queue ERROR: from element /GstPipeline:pipeline0/v4l2video0dec:v4l2video0dec0: Failed to allocate required memory. Additional debug info: gstv4l2videodec.c(575): gst_v4l2_video_dec_handle_frame (): /GstPipeline:pipeline0/v4l2video0dec:v4l2video0dec0: Buffer pool activation failed ERROR: pipeline doesn't want to preroll. Setting pipeline to NULL ... Freeing pipeline ... [0]: https://patchwork.linuxtv.org/patch/32794/ Best regards, Javier drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c index f2d6376ce618..8b9467de2d6a 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c @@ -474,7 +474,6 @@ static int reqbufs_output(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx, ret = vb2_reqbufs(&ctx->vq_src, reqbufs); if (ret) goto out; - s5p_mfc_close_mfc_inst(dev, ctx); ctx->src_bufs_cnt = 0; ctx->output_state = QUEUE_FREE; } else if (ctx->output_state == QUEUE_FREE) {