Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp847488ybi; Fri, 12 Jul 2019 05:38:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+D1L2OjZ07BYXKy6RcUlGMsC0zV3dig5wvl6TDlOAqwTHHMnWZ71f1lTyvi2CYF16FTDD X-Received: by 2002:a17:90a:3548:: with SMTP id q66mr11696437pjb.17.1562935114138; Fri, 12 Jul 2019 05:38:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562935114; cv=none; d=google.com; s=arc-20160816; b=fw2u6bT471qVxn1xlLWCa4NiD+R8o2iKqvVjiVMogcnXFJkMz+nmuNSn+OYK4IbG5I /gzReQh7Ph04DpW4Yipt0lLvSnu5IDKeYVVwlTQTtoRm/oCFKRvahKX6tuozodC9fEGG IKYik1/flRzOJpfQzZC8wYnElY/QQNPQ2ib7V7H8w/e7JfahlLsIQeyrPinhziB7z81g kp/rcqfUKxWEMfG59XyQhxgj0UBqLhpTwqtGpyYxjDtmGc5uXT4YW5IW+2FtoEVnw8/t efQOzgJJWPFv4ATRtCbIZ4EtbEQUmBf9QzkWRv++Z4f8j1pKArpi1oc1TsYVOZQmHyEF aiOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EbZCoMwg/1skyeXWQiGk/q64iy9ydgNTJTkZhKtmEKo=; b=ZSBwM62QdWJjRNEik+Mp2rhD908+YqVY2NMULcXpC/Zqy93EGUm15x1HpgH7NN4lKP AKGdbwYOKpgmSK3mrKC1WdKPeRl+/rx+7Um1hdTBNJdam/YYv4w+6vLAiioBiBakeJBJ ZEkkDXmWjhrQqKVFqmYw3Hal2LahC0UNuN81YlOP8fBUg+CYs8x4z8pLoXjP3nRigSbV BbwsbQPfZWotEQssI37ZrAXUY0u1arChklqhoC3e2+gYccgNRMbh8wWdc6Y9sMNcMdxv MDGXEa7vD9ikQdHn59d1rkj38XGDked8odZopcjiEwVDvdqxMJdb0gl/SWbJ5Z+h9W4R FKQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rOmVg4wp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t62si7851901pgd.175.2019.07.12.05.38.18; Fri, 12 Jul 2019 05:38:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rOmVg4wp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729122AbfGLMba (ORCPT + 99 others); Fri, 12 Jul 2019 08:31:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:48174 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728938AbfGLMb1 (ORCPT ); Fri, 12 Jul 2019 08:31:27 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0B09D21670; Fri, 12 Jul 2019 12:31:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934686; bh=olJftJlAQ6DDBMLKiEdImLF1HG2V6dQWw8Atvy841GQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rOmVg4wprhb40w/pj6cIHur78P3BrJjxeLNUNP7chPar38CeNtr0a0QEfMvSTzTG7 x1/QC5CAAJwqY3MQ1DUbGT+jwQna0KqaWt/WplMk6yRsTbGLgxqk/EQbM8w4LdOOIR SHuP1lp+dKfXqEoxGFD816pjo/1wB4thAHgR2kN0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dave Stevenson , Stefan Wahren , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 5.1 137/138] staging: bcm2835-camera: Handle empty EOS buffers whilst streaming Date: Fri, 12 Jul 2019 14:20:01 +0200 Message-Id: <20190712121633.965683307@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121628.731888964@linuxfoundation.org> References: <20190712121628.731888964@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Stevenson commit a26be06d6d96c10a9ab005e99d93fbb5d3babd98 upstream. The change to mapping V4L2 to MMAL buffers 1:1 didn't handle the condition we get with raw pixel buffers (eg YUV and RGB) direct from the camera's stills port. That sends the pixel buffer and then an empty buffer with the EOS flag set. The EOS buffer wasn't handled and returned an error up the stack. Handle the condition correctly by returning it to the component if streaming, or returning with an error if stopping streaming. Fixes: 938416707071 ("staging: bcm2835-camera: Remove V4L2/MMAL buffer remapping") Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 21 +++++----- drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 5 +- 2 files changed, 15 insertions(+), 11 deletions(-) --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -337,16 +337,13 @@ static void buffer_cb(struct vchiq_mmal_ return; } else if (length == 0) { /* stream ended */ - if (buf) { - /* this should only ever happen if the port is - * disabled and there are buffers still queued + if (dev->capture.frame_count) { + /* empty buffer whilst capturing - expected to be an + * EOS, so grab another frame */ - vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); - pr_debug("Empty buffer"); - } else if (dev->capture.frame_count) { - /* grab another frame */ if (is_capturing(dev)) { - pr_debug("Grab another frame"); + v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, + "Grab another frame"); vchiq_mmal_port_parameter_set( instance, dev->capture.camera_port, @@ -354,8 +351,14 @@ static void buffer_cb(struct vchiq_mmal_ &dev->capture.frame_count, sizeof(dev->capture.frame_count)); } + if (vchiq_mmal_submit_buffer(instance, port, buf)) + v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, + "Failed to return EOS buffer"); } else { - /* signal frame completion */ + /* stopping streaming. + * return buffer, and signal frame completion + */ + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); complete(&dev->capture.frame_cmplt); } } else { --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -290,8 +290,6 @@ static int bulk_receive(struct vchiq_mma /* store length */ msg_context->u.bulk.buffer_used = rd_len; - msg_context->u.bulk.mmal_flags = - msg->u.buffer_from_host.buffer_header.flags; msg_context->u.bulk.dts = msg->u.buffer_from_host.buffer_header.dts; msg_context->u.bulk.pts = msg->u.buffer_from_host.buffer_header.pts; @@ -452,6 +450,9 @@ static void buffer_to_host_cb(struct vch return; } + msg_context->u.bulk.mmal_flags = + msg->u.buffer_from_host.buffer_header.flags; + if (msg->h.status != MMAL_MSG_STATUS_SUCCESS) { /* message reception had an error */ pr_warn("error %d in reply\n", msg->h.status);