From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_SANE_1 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 B8D46C433ED for ; Wed, 5 May 2021 12:18:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 87AE461182 for ; Wed, 5 May 2021 12:18:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233160AbhEEMSz (ORCPT ); Wed, 5 May 2021 08:18:55 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:49744 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231921AbhEEMSR (ORCPT ); Wed, 5 May 2021 08:18:17 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 4058E1F42DF4 Subject: Re: [PATCH] media: rkvdec: Fix .buf_prepare To: Ezequiel Garcia , 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 References: <20210504113714.30612-1-andrzej.p@collabora.com> <2db7709801107dbacd464a919451bbafbd335748.camel@collabora.com> From: Andrzej Pietrasiewicz Message-ID: <58791717-b7a9-d057-a998-a4440fcbe783@collabora.com> Date: Wed, 5 May 2021 14:17:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <2db7709801107dbacd464a919451bbafbd335748.camel@collabora.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Hi Ezequiel, W dniu 04.05.2021 o 13:56, Ezequiel Garcia pisze: > 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? > As a matter of fact I think it is needed in all three, because later on, whenever a driver uses vb2_get_plane_payload(), without such a patch it will get an invalid number and write that to a hardware register, causing incorrect behavior. I will respond with a v2 series. Regards, Andrzej