Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1390393ybk; Thu, 14 May 2020 07:53:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYdXvmtQSIK50wyMqNbf1ippqOGaTZ5AVxn2At4MX8pbxvZ7aUKqG+MOtP0erNGvaADsMI X-Received: by 2002:a17:906:add7:: with SMTP id lb23mr4374641ejb.6.1589467983728; Thu, 14 May 2020 07:53:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589467983; cv=none; d=google.com; s=arc-20160816; b=W9BnSvzd5xC+7VBmLgRdzeeO2SqlOoKPRtKoh1DIrYoM9FngFBkzIbDR4vwlaS/Ds5 pK2GDhVXKz3QynzOWlVFg/VFwF7y/BPnp51IuCdmqhmc2ruS++FjSVfJeBm+O/KBnZqy pStYpoGvjz5jhj9FaGlhaKPOM6lNjp05BKYUIIF8fZYWpCFJGK+hTAyzPruZcpi+9AiS npZZMQJ9e36b5B+26YY6xS0fybpg5v68Ayr1fPSku/6uMmsuCdG3h+2LP6MBs3Mq6VeB GBDGerADC4lVJ7vhBOGWWasLp8PIBGRXLSAkoJJfYj1xCWThL2YGttzN0VfsfMIFXWF1 ILxA== 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:date:cc:to:from:subject :message-id; bh=+Q4AICoZIuOP20QCNv0oslPwn2gOBxcruYrqXKak4yA=; b=lhR6zlE8qx77gtShpEciU/YK+Icarwk1jcwRR/Recay38oZS4IOU+QryMo5iKo9Ela symvvaX3npB6Adj+xIdptWEtIQ2Ib9MwZHvwNFedLCotQTZADk0DvoTm+Z8GVM1LHb3Y guPmJ0PwsxvH+a9FYvl8SEoxFUVYFsZKSAar4v6mI/zrSlVrVa7y3YGCUM/0bRmEazln P8cV4VMn+WHOdyKfOQC6YrINUd1I7faWscHAqbHaYkwTP14N7S45GoP9KwSeCXu9tMCY 0HLmjZ8z5cSgir95n/qCqorrd8ZGbJ645L9bijxUVG65iL/fFsoK2fMM2iXRuI5khoaJ 8zVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c17si1990462ejn.336.2020.05.14.07.52.40; Thu, 14 May 2020 07:53:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726051AbgENOvI (ORCPT + 99 others); Thu, 14 May 2020 10:51:08 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:60952 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726176AbgENOvH (ORCPT ); Thu, 14 May 2020 10:51:07 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: nicolas) with ESMTPSA id AA0282A2B4B Message-ID: <7cd2e6ba4da315ba61878db9e80a10cda8daeb12.camel@collabora.com> Subject: Re: [PATCH v3 1/3] media: rkvdec: Fix .buf_prepare From: Nicolas Dufresne To: Ezequiel Garcia , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Tomasz Figa , kernel@collabora.com, Jonas Karlman , Heiko Stuebner , Hans Verkuil , Alexandre Courbot , Jeffrey Kardatzke , gustavo.padovan@collabora.com Date: Thu, 14 May 2020 10:50:53 -0400 In-Reply-To: <20200505134110.3435-2-ezequiel@collabora.com> References: <20200505134110.3435-1-ezequiel@collabora.com> <20200505134110.3435-2-ezequiel@collabora.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.1 (3.36.1-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le mardi 05 mai 2020 à 10:41 -0300, Ezequiel Garcia a écrit : > The driver should only set the payload on .buf_prepare > if the buffer is CAPTURE type, or if an OUTPUT buffer > has a zeroed payload. > > Fix it. > > Fixes: cd33c830448ba ("media: rkvdec: Add the rkvdec driver") > Signed-off-by: Ezequiel Garcia > --- > 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 225eeca73356..4df2a248ab96 100644 > --- a/drivers/staging/media/rkvdec/rkvdec.c > +++ b/drivers/staging/media/rkvdec/rkvdec.c > @@ -456,7 +456,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 is written by the driver for CAPTURE buffers, > + * or if the application passed zero bytesused on an OUTPUT buffer. > + */ > + if (!V4L2_TYPE_IS_OUTPUT(vq->type) || > + (V4L2_TYPE_IS_OUTPUT(vq->type) && !vb2_get_plane_payload(vb, 0))) > + vb2_set_plane_payload(vb, 0, > + f->fmt.pix_mp.plane_fmt[0].sizeimage); I believe the spec lacks a bit of a clarification. Converting from 0 to sizeimage should only be allowed for RAW images. So I would like to suggest to change this fix into: - vb2_set_plane_payload(vb, 0, f->fmt.pix_mp.plane_fmt[0].sizeimage); + + /* Buffer's bytesused is written by the driver for CAPTURE buffers */ + if (!V4L2_TYPE_IS_OUTPUT(vq->type)) + vb2_set_plane_payload(vb, 0, + f->fmt.pix_mp.plane_fmt[0].sizeimage); And then we can fix the spec accordingly. Note that neighter FFMPEG or GStreamer will pass empty (zero sized) payload at the moment, and if it did, it would be a bug, and the payload should instead be ignored. > return 0; > } > > -- > 2.26.0.rc2 > >