Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp715794ybj; Tue, 5 May 2020 06:43:28 -0700 (PDT) X-Google-Smtp-Source: APiQypIcc8bYEBkEVfc6RaGmWVb/df87XEChCZOvLPq9EanwhaKGNY6KubHPqWudVpATqvHw13nw X-Received: by 2002:a05:6402:8ca:: with SMTP id d10mr2744605edz.167.1588686208399; Tue, 05 May 2020 06:43:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588686208; cv=none; d=google.com; s=arc-20160816; b=JfsdeGBYV0ozVQv0iPIQ4WD7dE+HZhv60h4ybZjme0AbCXjv5GvSKEdMrouc7GzXn8 qPT+EfXC7GihubUZLM6cN6gHRcuUsmK7eZ6/fMGvDMLLX9jx89l/CPSF8xPk5v3lCugf o42BaGO57hfdq8VDydYQ8srlbgQ/DRDMZ3HhW1D7/77BasXlFLjad3zRtJlG7iTIucf4 FvGQcJxOXGPaeiTJB2yDCw8EY0GmLGsBhXxEiQX5bgvv53h0HqiA3FgLUZCT+xFu06NZ O14jJ0spfEmZ3ixErvUlNRZtaLeemeBCMwK8e1hDoasUx3MXTNSgsSQMolifMejCuq+V qqTg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=5zdhhz7thl6yrXag0mtI/ShZGs+29Sj/MUizsq33J5Y=; b=uC4jE83SS2rkK+kFH5fpk+EPWyiyF1dGRrl8EjBYMPpHtsyQZr0ffi8MitlIyzO38R p4WVRVFoHyBq5yeOitsL5d1r5kpBy5DuYPlVnPp87Y6c8E9LuKz7bdvBUitGNh0iHbfo rEHKhL1wt8oKNWM029Sj7g/TnUppYcebfSpi+Ighp5YsxNJjU6F+GyCs+C7BzYTG3CKm 9ptLDVREBVoR2u04d8fmukj/oXddBSIqjgf4tS7F69pXITSF2KAfFP94IHPs4kaRnQO9 LfQxsQ6c0C5zLQoNSgdiYO7fqcGpe2P7Iyih5zhhlZtW05DZbjt33996l3U4ZNX579kd 5Sdw== 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 pv24si1140801ejb.244.2020.05.05.06.43.04; Tue, 05 May 2020 06:43:28 -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 S1729128AbgEENl0 (ORCPT + 99 others); Tue, 5 May 2020 09:41:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729028AbgEENl0 (ORCPT ); Tue, 5 May 2020 09:41:26 -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 DE61CC061A0F; Tue, 5 May 2020 06:41:25 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 435832A0998 From: Ezequiel Garcia To: 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, Ezequiel Garcia Subject: [PATCH v3 1/3] media: rkvdec: Fix .buf_prepare Date: Tue, 5 May 2020 10:41:08 -0300 Message-Id: <20200505134110.3435-2-ezequiel@collabora.com> X-Mailer: git-send-email 2.26.0.rc2 In-Reply-To: <20200505134110.3435-1-ezequiel@collabora.com> References: <20200505134110.3435-1-ezequiel@collabora.com> 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 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); return 0; } -- 2.26.0.rc2