From patchwork Wed May 5 12:23:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 12239869 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D3C3C433ED for ; Wed, 5 May 2021 12:25:54 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3D876613BA for ; Wed, 5 May 2021 12:25:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D876613BA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gFfdn3KH6IawGHpvjWAQG/2WbFfEgek9tn2lPnSkKqU=; b=jqscOa8X6iJxryUvXu+RCVJ3Pj ufhfa1WkZHTZ9geiOVTo7v9C2CsbPognmLYERUXARNy6NGPEXM08PxJ3xUERrNFvd8z0dT7GEoMBw hWYSf6htmAqosjdpU5fRedXc4x9edgvWJKqSZophXGIVTMKRhxLRmxv3Qic65mT90F8/rqINsCDJi 5fhefiOSyIYxQs09an2sw6Gr1XaX2c8yKkxy74xBcgjE8gVT5ywz4Bl+KHq3Bh9RsNUotQteP8WH0 qP6qv6Y5uOvdxPof0PxZWhrL7xLcs0094efjWRb37ti/K5zSDHvGsyVJakgGdbNi3F9ftxNR2Pl4u ggMXx+rw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leGZm-001B7H-Fm; Wed, 05 May 2021 12:24:26 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leGZU-001B4U-2a; Wed, 05 May 2021 12:24:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=A1AUtStBeVfRKl6345Sk3B1Dh43/R8MYy4TatQe7EEI=; b=oTZViZMcYq8CtBswRlKQ+fRaSd YKooosv36ER29bk99lEboERpGbqHcC2rbnvHM5I0g1Ip/2tI/7kiwhmw6Llg5zHAyYnKSTs9IvV+f EN+ll5/KzBDnMGzBKeJYXk5ubxkPtyAxp8qHfZ9brU12TaEldFk9GR9MKE/2Vj5GTdVgs2Ymh6eNQ YwaE63d4Nj6tDzOSFAG0ZWnn26bp5pF9A1CmrHtot1wEQ9iRXCLjBGJYFwzWv5vXjtHaSBEnmImqU vX1O4vznYZemhSfyR3ibBR6tuh3Vq63w56pE7sq50xK7phdxX7f488sWS9PHI8DRzAF+cOuINapB9 PVREtUXg==; Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leGZR-004jpT-II; Wed, 05 May 2021 12:24:06 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id E26BE1F42E69 From: Andrzej Pietrasiewicz To: linux-media@vger.kernel.org Cc: linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, devel@driverdev.osuosl.org, Mauro Carvalho Chehab , Hans Verkuil , Ezequiel Garcia , Philipp Zabel , Maxime Ripard , Paul Kocialkowski , Chen-Yu Tsai , Jernej Skrabec , Greg Kroah-Hartman , Andrzej Pietrasiewicz , kernel@collabora.com, Adrian Ratiu Subject: [PATCHv2 1/3] media: rkvdec: Fix .buf_prepare Date: Wed, 5 May 2021 14:23:45 +0200 Message-Id: <20210505122347.7576-2-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210505122347.7576-1-andrzej.p@collabora.com> References: <58791717-b7a9-d057-a998-a4440fcbe783@collabora.com> <20210505122347.7576-1-andrzej.p@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210505_052405_757836_7F51D047 X-CRM114-Status: GOOD ( 13.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Ezequiel Garcia The driver should only set the payload on .buf_prepare if the buffer is CAPTURE type. If an OUTPUT buffer has a zero bytesused set by userspace then v4l2-core will set it to buffer length. If we overwrite bytesused for OUTPUT buffers, too, then vb2_get_plane_payload() will return incorrect value which might be then written to hw registers by the driver in rkvdec-h264.c. Fixes: cd33c830448ba ("media: rkvdec: Add the rkvdec driver") Signed-off-by: Ezequiel Garcia Signed-off-by: Adrian Ratiu [Changed the comment and used V4L2_TYPE_IS_CAPTURE macro] Signed-off-by: Andrzej Pietrasiewicz --- drivers/staging/media/rkvdec/rkvdec.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c index d821661d30f3..cd65ad2af8d4 100644 --- a/drivers/staging/media/rkvdec/rkvdec.c +++ b/drivers/staging/media/rkvdec/rkvdec.c @@ -481,7 +481,15 @@ static int rkvdec_buf_prepare(struct vb2_buffer *vb) if (vb2_plane_size(vb, i) < sizeimage) return -EINVAL; } - vb2_set_plane_payload(vb, 0, f->fmt.pix_mp.plane_fmt[0].sizeimage); + + /* + * Buffer's bytesused must be written by driver for CAPTURE buffers. + * (for OUTPUT buffers, if userspace passes 0 bytesused, v4l2-core sets + * it to buffer length). + */ + if (V4L2_TYPE_IS_CAPTURE(vq->type)) + vb2_set_plane_payload(vb, 0, f->fmt.pix_mp.plane_fmt[0].sizeimage); + return 0; } From patchwork Wed May 5 12:23:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 12239871 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AD5CC433ED for ; Wed, 5 May 2021 12:26:15 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C5EF2613B3 for ; Wed, 5 May 2021 12:26:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C5EF2613B3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6utFPdRlIHmxVayzple0ymsbgb4p+z48Mb605KtapXo=; b=kbrIcB8jsiO4ZGysydnt8GX9bw lrqmwP75TPg8Et8PTpLwhk0fFJPVfiKAdYa7XQSGeYw4roZP7Kxj2SWJxQVK3CR0gcqvaUNd3z+Zc O/b+3/A5kMo6svv57PUupH86VO37QUZgYQPtAnqiMB+Ao9QW83yxdlZXHSfDMX+qS7QlD9rFkh767 XAxi0h3wxTEmqksB82eVrujQGgZh/PHvOZStUeN79prF8UkKjjKUySPQL4qSI6YOgRPquh9xF4uLO 9C7I8YlZMtDqlyf3Ek+f/lrviesaV7+qrKnky3L1yuSwcQglLU7w6lBQ7g2YMz0ArX9ZtEIBdlCRE YdrFrE5w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leGa3-001BAx-Kj; Wed, 05 May 2021 12:24:43 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leGZV-001B50-3s; Wed, 05 May 2021 12:24:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=H2lFn0WJrpaiqmtJkzKYEZgqDCMjCr4r6tB5ZbxpZMc=; b=cnAIWsekRGBxAArYV8S0IrDPmP o2FN52vCY9r1HxRt+5rGimqstoqLpzD3lLwf7Y961qsVuiU0KvDyjnxqzV35edQR1rS/W1b2+yEz3 EK2zrTpAmUKgoTaLkMaAybl0ZUMg6L72tuHqQIbPXZbza+aj4v8GTJnbacGd2fL7ywKnSejIpgQge SHcPEYmS9HezPCKsUCnAasdFbst2w1Z2Zto5eLrMRWoyEYnPoqKkVT1bYAp7IpPeOPdA3xuaixEMa 8DPl2BbN//BH7X4AsBKpkM7v6a7OIv+RkNHHthtnrjjVN0I7GovVWWyB4qO8lnJhMmuznUsmBLW0D mkZ4U+nw==; Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leGZS-004jpU-8D; Wed, 05 May 2021 12:24:07 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 7B69C1F42E6E From: Andrzej Pietrasiewicz To: linux-media@vger.kernel.org Cc: linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, devel@driverdev.osuosl.org, Mauro Carvalho Chehab , Hans Verkuil , Ezequiel Garcia , Philipp Zabel , Maxime Ripard , Paul Kocialkowski , Chen-Yu Tsai , Jernej Skrabec , Greg Kroah-Hartman , Andrzej Pietrasiewicz , kernel@collabora.com Subject: [PATCHv2 2/3] media: hantro: Fix .buf_prepare Date: Wed, 5 May 2021 14:23:46 +0200 Message-Id: <20210505122347.7576-3-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210505122347.7576-1-andrzej.p@collabora.com> References: <58791717-b7a9-d057-a998-a4440fcbe783@collabora.com> <20210505122347.7576-1-andrzej.p@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210505_052406_438516_DC72F8F2 X-CRM114-Status: GOOD ( 12.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The driver should only set the payload on .buf_prepare if the buffer is CAPTURE type. If an OUTPUT buffer has a zero bytesused set by userspace then v4l2-core will set it to buffer length. If we overwrite bytesused for OUTPUT buffers, too, then vb2_get_plane_payload() will return incorrect value which might be then written to hw registers by the driver in hantro_g1_h264_dec.c. Signed-off-by: Andrzej Pietrasiewicz --- drivers/staging/media/hantro/hantro_v4l2.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/hantro/hantro_v4l2.c b/drivers/staging/media/hantro/hantro_v4l2.c index 1bc118e375a1..7ccc6405036a 100644 --- a/drivers/staging/media/hantro/hantro_v4l2.c +++ b/drivers/staging/media/hantro/hantro_v4l2.c @@ -639,7 +639,14 @@ static int hantro_buf_prepare(struct vb2_buffer *vb) ret = hantro_buf_plane_check(vb, pix_fmt); if (ret) return ret; - vb2_set_plane_payload(vb, 0, pix_fmt->plane_fmt[0].sizeimage); + /* + * Buffer's bytesused must be written by driver for CAPTURE buffers. + * (for OUTPUT buffers, if userspace passes 0 bytesused, v4l2-core sets + * it to buffer length). + */ + if (V4L2_TYPE_IS_CAPTURE(vq->type)) + vb2_set_plane_payload(vb, 0, pix_fmt->plane_fmt[0].sizeimage); + return 0; } From patchwork Wed May 5 12:23:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 12239873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FA14C433B4 for ; Wed, 5 May 2021 12:26:25 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 347D7613BC for ; Wed, 5 May 2021 12:26:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 347D7613BC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3etrp8SyObSqyQx1QIXfYUJ5UbaWdbZ+NA9NoIwLkKA=; b=g6931eZPUEsJefQtc6memtceNG 7f1WSMIu06RweJV4/KXgIIhwYrADg4gtMN+0olKCf6xt/kpnhqqPixxzeHWaiMB3orIDJAULnRzOX HNPfqqpRYXE52DiHZwInN/OmpD331T674LkW4AZf5nW6Iy/wjk3PK4KGfKA6pm1/osm3HvHAZnyrV 2T3eHmsXX/emH6Jd3kxj4avDNA9psYXvd8GDazBW0vum2NMpQBLHSVjho9e3WzjZXC+L8iF6lve1r wXkCRiVh+uMrNxrITtWvdpU+sTMj8m1l1Djc2s+6IUMJXOjAGSwy/sy+/P2oY9grw4yPHoCG++x5u Vmj6CvvQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leGaF-001BE9-Qg; Wed, 05 May 2021 12:24:57 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leGZV-001B55-EU; Wed, 05 May 2021 12:24:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=XB8w0x746nuVa5cRMFzfUM6hn9Fg9EwljrdPuav5PuA=; b=LD3/ZZON2Jl346Ru0KC6wCFKRm ubw8Jit6hYaZ9cMjFctnsSpv32IJ/CIyE/aDEDLWhwZQkaCE2KhmzxwHRte4U3+yyryL9hELqx/rx Lwfhjz9ET2FNSzV4tlQLSpw/viBaNA3rWQ7xrWqbP8UVxj0+VlwqdZ4vSzqEpFu3OvEeR2CuZV7oV 2gEXNL9+GPyiww+s98xq8ltWls3IWUahWcQvccUcqZIsjUt/3oCdLaJjK0W0RrSDa+4BvYkZHXWzg y/fEOfn/EX8RJmgMF706fEjzhQVznbScezNApPy8P7M0bPkNA0rnkDkpItXnkBbp1pxusTczc0GFW LeShb86A==; Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leGZS-004jpt-OF; Wed, 05 May 2021 12:24:08 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 0B0F01F42E72 From: Andrzej Pietrasiewicz To: linux-media@vger.kernel.org Cc: linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, devel@driverdev.osuosl.org, Mauro Carvalho Chehab , Hans Verkuil , Ezequiel Garcia , Philipp Zabel , Maxime Ripard , Paul Kocialkowski , Chen-Yu Tsai , Jernej Skrabec , Greg Kroah-Hartman , Andrzej Pietrasiewicz , kernel@collabora.com Subject: [PATCHv2 3/3] media: cedrus: Fix .buf_prepare Date: Wed, 5 May 2021 14:23:47 +0200 Message-Id: <20210505122347.7576-4-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210505122347.7576-1-andrzej.p@collabora.com> References: <58791717-b7a9-d057-a998-a4440fcbe783@collabora.com> <20210505122347.7576-1-andrzej.p@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210505_052406_952840_BEE6F0BB X-CRM114-Status: GOOD ( 12.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The driver should only set the payload on .buf_prepare if the buffer is CAPTURE type. If an OUTPUT buffer has a zero bytesused set by userspace then v4l2-core will set it to buffer length. If we overwrite bytesused for OUTPUT buffers, too, then vb2_get_plane_payload() will return incorrect value which might be then written to hw registers by the driver in cedrus_h264.c or cedrus_vp8.c. Signed-off-by: Andrzej Pietrasiewicz --- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index b62eb8e84057..bf731caf2ed5 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -457,7 +457,13 @@ static int cedrus_buf_prepare(struct vb2_buffer *vb) if (vb2_plane_size(vb, 0) < pix_fmt->sizeimage) return -EINVAL; - vb2_set_plane_payload(vb, 0, pix_fmt->sizeimage); + /* + * Buffer's bytesused must be written by driver for CAPTURE buffers. + * (for OUTPUT buffers, if userspace passes 0 bytesused, v4l2-core sets + * it to buffer length). + */ + if (V4L2_TYPE_IS_CAPTURE(vq->type)) + vb2_set_plane_payload(vb, 0, pix_fmt->sizeimage); return 0; }