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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY 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 605F5C433ED for ; Tue, 4 May 2021 11:57:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 393F7613BA for ; Tue, 4 May 2021 11:57:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230126AbhEDL6C (ORCPT ); Tue, 4 May 2021 07:58:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230109AbhEDL6C (ORCPT ); Tue, 4 May 2021 07:58:02 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEC5BC061574 for ; Tue, 4 May 2021 04:57:07 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 1563B1F424AA Message-ID: <2db7709801107dbacd464a919451bbafbd335748.camel@collabora.com> Subject: Re: [PATCH] media: rkvdec: Fix .buf_prepare From: Ezequiel Garcia To: Andrzej Pietrasiewicz , linux-media@vger.kernel.org Cc: linux-rockchip@lists.infradead.org, devel@driverdev.osuosl.org, Mauro Carvalho Chehab , Hans Verkuil , Greg Kroah-Hartman , kernel@collabora.com, Adrian Ratiu Date: Tue, 04 May 2021 08:56:57 -0300 In-Reply-To: <20210504113714.30612-1-andrzej.p@collabora.com> References: <20210504113714.30612-1-andrzej.p@collabora.com> Organization: Collabora Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.2-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Hi Andrzej, Thanks a lot for picking this up. On Tue, 2021-05-04 at 13:37 +0200, Andrzej Pietrasiewicz wrote: > 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. > > Fixes: cd33c830448ba ("media: rkvdec: Add the rkvdec driver") > Signed-off-by: Ezequiel Garcia > Signed-off-by: Adrian Ratiu > Signed-off-by: Andrzej Pietrasiewicz > > --- > @Hans: I haven't had anyone complain about the issue. The fix is needed for > the rkvdec vp9 work, so I think 5.14 is fine. > >  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..ef2166043127 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 bytesused is written by driver for CAPTURE buffers. > +        * (if userspace passes 0 bytesused for OUTPUT buffers, v4l2-core sets > +        * it to buffer length). > +        */ > +       if (!V4L2_TYPE_IS_OUTPUT(vq->type)) Please use V4L2_TYPE_IS_CAPTURE here. Also, why is this change needed in rkvdec, but not in cedrus or hantro? Thanks! Ezequiel