Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp844942ybi; Fri, 12 Jul 2019 05:36:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqw9jAExJrTGD3wZDdNwjWikjPPE26WrhMzze53RbAor7hQhN19pnQumiUS4/xcRjN1/aP9y X-Received: by 2002:a63:1310:: with SMTP id i16mr10465071pgl.187.1562934960978; Fri, 12 Jul 2019 05:36:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562934960; cv=none; d=google.com; s=arc-20160816; b=FnD8sHXGLXV4UWAV7+np1AetYhcTOFPSg5NqykD0xdj8xag1EIGmNIzZnn90woHLKy gLqpDygVvH47yPRh4zU0QlMFvh9tJrVBPzmQSo8/u4+TIrnzpAbt8uViGH0YNCFfgi5d EyINAo/zu/BZjdqcZVjChp4rq+Cc13xGgGlPpW19Epocd671iJUxOSe/8RrHB8hfmucz t/sqjlVriRqwCxmNCc6UU2AZUcNv1DMduSlcxdkpgOiFz7wKx/9ysDCY04tqodsDMxFY qssbBYThM6YtiY49xHHavLQ29d+JtETC9CTS6+HbnHeNVDlxw34qfJPsfSeDBKLWP8KI xqdg== 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=PpzbcHmdINzfrPlbgSyk0G3t/quM56A8bWKp2r6sEB8=; b=EAhRFse2lpG2Lsjdm9BlLNxXETudwhlSdIbQwqp3FSaf2k+Yr3GPxG3wyUmBZhNHTi oYNl1n7I/cWRmGrrZBZaXwgW1YvMibPDFSKp2klcyF9jka+u13ctzG/3UJcgFRmnpOMI 21afm3Nszs76ZJr95/o6hvT69wFe9y9Dzf12BSnP1YtDzemlYyBgiCjYqPN3otgl9b2b SDiJvcFSZRCGTBnnfjtXguCj/S6x33QIyvCBLfwGBI9pedf4/D1M8vV2U1yocaEgYQfL GM+qRMkkkJD9iY0iSY8VR2zYMXeLodkHxJKtRd+CjLEwKAI7NoPPWZLJ7h11EcOUTQfk 6Gdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cOZubTGm; 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 g9si7792993plm.207.2019.07.12.05.35.45; Fri, 12 Jul 2019 05:36:00 -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=cOZubTGm; 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 S1729768AbfGLMej (ORCPT + 99 others); Fri, 12 Jul 2019 08:34:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:54592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729011AbfGLMeh (ORCPT ); Fri, 12 Jul 2019 08:34:37 -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 CBC642166E; Fri, 12 Jul 2019 12:34:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934876; bh=2K/uD0r3A09Hh2lPcxtdPbp6h7drV/rkobpYhe7gJ6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cOZubTGmJNhZLSOTWcAwk95nHxWwUFyxXAg+gxYJO+eleBjyqqoN0Z7R5n3SLXIhx ZRgrR6cpuq5n2tiLrPDfBpGGPZO+6iJyxBq911dcUrBdz2C8i/9bkoQ7sKiQibNKFU 2WWpR50lIzJUE8ykvrkrzJamnJjz44x4mZO2bG0s= 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.2 60/61] staging: bcm2835-camera: Handle empty EOS buffers whilst streaming Date: Fri, 12 Jul 2019 14:20:13 +0200 Message-Id: <20190712121624.073045625@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121620.632595223@linuxfoundation.org> References: <20190712121620.632595223@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 @@ -336,16 +336,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, @@ -353,8 +350,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);