Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1002834imm; Tue, 2 Oct 2018 00:38:52 -0700 (PDT) X-Google-Smtp-Source: ACcGV62WoQQYEx6rSya1UBDkANmbmjYV6Gq1uWTE3EFFUPEe90iM1ffbKAUejQZW1hgNPNF8CKcr X-Received: by 2002:a17:902:9a98:: with SMTP id w24-v6mr15692418plp.109.1538465932879; Tue, 02 Oct 2018 00:38:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538465932; cv=none; d=google.com; s=arc-20160816; b=NBPkmFOVsf04B9La3j6uBWSSfAiQ8LMTrYszbXsGrelHM+fCIxHIcXTDxNfF1lwmCE aD3m9DJysP/UxcwW/8NjIaaXr2Mx8oDu4jMBO/AKA7rorTjfVT1i6zlSzWOzgqx9RBzX jgBX/9AHYOBVBnrsS6i72up85eRUGEkaz/y2qEGaWoNXyxhIDvLx8MQUdbgavmvf85+4 zpq2TI3VTM2bny/TB/GhUpScMpMedyvlNvANbnuPbWYJSJMkXSMH9cV0yFdh4Y9lDuqS zaPIcvrIV/yEaxRIFwpOO+d5gwlr4Z5yYS8pnwgNXrJvvtnCEiCCESSKw/O2yQ4N4LBj tdBg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=Jmb0Kej9qZVSL2rqgit8rPCWIoY9/5vCJEvSJT42v6I=; b=hoPAx/z4U6J2GZ8qPJ5T4QW93WcAGOqdzYkYNcJ2PcQfiPgMcGKvsTdJvPJ3vS4rRz MEyh2dPfRAEtYNGVPuBoDYKF7sTyGCoPp7dx3yWwLDWaX/PPLcNesPPM0TB3Ikk8zdVq VqoP4c8sBWwHcFb7HQZxpR9gD9iWouPBBV/QPpfqwJMpZrD4CFU2Mqgdx4SFOqNYEcSj fso7quM96l6rHY0wBOTIhB7PFnQMF1yLqaxl2MSVnDA0I24CGDfsC+8sAzM/BONtiQTL Cs7iJ4mAZ63Cjo+/LiXUdOYAuW6+NQqM7oLyElGVYhaZpGp4y3gdTU2iGtnYcpNRGkk1 9oJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UsTyAL6X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t138-v6si13182631pgb.640.2018.10.02.00.38.38; Tue, 02 Oct 2018 00:38:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UsTyAL6X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727005AbeJBOUP (ORCPT + 99 others); Tue, 2 Oct 2018 10:20:15 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:55108 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726935AbeJBOUO (ORCPT ); Tue, 2 Oct 2018 10:20:14 -0400 Received: by mail-wm1-f67.google.com with SMTP id r63-v6so1141836wma.4 for ; Tue, 02 Oct 2018 00:38:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Jmb0Kej9qZVSL2rqgit8rPCWIoY9/5vCJEvSJT42v6I=; b=UsTyAL6XoaR8yKLrnf/umJdfXP0wEbtleZAvBWFrOYbRhfT5ZGVET4n1ldfUZItiPV 6NsSVqNCe8VNDHckl66VRdtNtW4Qn026OV3eNrXSQBSEE0H4PO+Z6GbSIj1aZSPLnoTU mbVz/ZU3kIUOut33gdBdaX+KQDe8Ncb52YO8Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Jmb0Kej9qZVSL2rqgit8rPCWIoY9/5vCJEvSJT42v6I=; b=gwi9uz+HkOUKPl0Rbr2awkrmajCNRiwmCWR/yrxw0JcwwmHXrmr+BotCbPjyVc94C5 ULGL1CieSb1ny3tLzocEFDJqUrfuNafzsnBB/tracTplOATD2KLoJM0Q6K7Udkq/t8HR yMxZURbic1NU+Da3DmPsosazmz9YRC4ifuPqSbCqd2P4t8ShiU+rM9nE7nWOpMfp0rNE kqshBQ5V9iiDzfxQCVX/KS14DDgAyrDJXPa9jaocdecxnla3kJcs57BfKdPJUJdbgmU5 HaWr5G/bSUPXnnMlv+LAQmVPHZTKYSLW8eZe16ANx5iZhhqIdebLMQJSSuTAp7b5biGy TJ2Q== X-Gm-Message-State: ABuFfogeoDTP9OdYxEeDQfR93Wfsq6pxBYpBB8WWdSZjUQ8a9/RdA3jR iaAdPI18wm5oM9q5UjqByw72+2CNVr8= X-Received: by 2002:a1c:5d8c:: with SMTP id r134-v6mr612129wmb.147.1538465899778; Tue, 02 Oct 2018 00:38:19 -0700 (PDT) Received: from [192.168.27.209] ([37.157.136.206]) by smtp.googlemail.com with ESMTPSA id z13sm14128213wrw.19.2018.10.02.00.38.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Oct 2018 00:38:19 -0700 (PDT) Subject: Re: [PATCH] venus: vdec: fix decoded data size To: Stanimir Varbanov , Alexandre Courbot , Hans Verkuil Cc: Nicolas Dufresne , vgarodia@codeaurora.org, Linux Media Mailing List , linux-arm-msm@vger.kernel.org, LKML References: <1530517447-29296-1-git-send-email-vgarodia@codeaurora.org> <01451f8e-aea3-b276-cb01-b0666a837d62@linaro.org> <4ce55726d810e308a2cae3f84bca7140bed48c7d.camel@ndufresne.ca> <92f6f79a-02ae-d23e-1b97-fc41fd921c89@linaro.org> <33e8d8e3-138e-0031-5b75-4bef114ac75e@xs4all.nl> <36b42952-982c-9048-77fb-72ca45cc7476@linaro.org> <051af6fb-e0e8-4008-99c5-9685ac24e454@xs4all.nl> <6d65ac0d-80a0-88fe-ed19-4785f2675e36@linaro.org> From: Stanimir Varbanov Message-ID: <18c14931-15b4-190e-eb03-5cae8f8db381@linaro.org> Date: Tue, 2 Oct 2018 10:38:18 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <6d65ac0d-80a0-88fe-ed19-4785f2675e36@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 09/19/2018 06:02 PM, Stanimir Varbanov wrote: > Hi Alex, > > On 09/19/2018 01:32 PM, Alexandre Courbot wrote: >> On Mon, Sep 17, 2018 at 11:33 PM Hans Verkuil wrote: >>> >>> On 09/17/2018 04:30 PM, Stanimir Varbanov wrote: >>>> Hi Hans, >>>> >>>> On 09/17/2018 01:00 PM, Hans Verkuil wrote: >>>>> On 07/18/2018 04:37 PM, Stanimir Varbanov wrote: >>>>>> Hi, >>>>>> >>>>>> On 07/18/2018 04:26 PM, Nicolas Dufresne wrote: >>>>>>> Le mercredi 18 juillet 2018 à 14:31 +0300, Stanimir Varbanov a écrit : >>>>>>>> Hi Vikash, >>>>>>>> >>>>>>>> On 07/02/2018 10:44 AM, Vikash Garodia wrote: >>>>>>>>> Exisiting code returns the max of the decoded >>>>>>>>> size and buffer size. It turns out that buffer >>>>>>>>> size is always greater due to hardware alignment >>>>>>>>> requirement. As a result, payload size given to >>>>>>>>> client is incorrect. This change ensures that >>>>>>>>> the bytesused is assigned to actual payload size. >>>>>>>>> >>>>>>>>> Change-Id: Ie6f3429c0cb23f682544748d181fa4fa63ca2e28 >>>>>>>>> Signed-off-by: Vikash Garodia >>>>>>>>> --- >>>>>>>>> drivers/media/platform/qcom/venus/vdec.c | 2 +- >>>>>>>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>>>>>>> >>>>>>>>> diff --git a/drivers/media/platform/qcom/venus/vdec.c >>>>>>>>> b/drivers/media/platform/qcom/venus/vdec.c >>>>>>>>> index d079aeb..ada1d2f 100644 >>>>>>>>> --- a/drivers/media/platform/qcom/venus/vdec.c >>>>>>>>> +++ b/drivers/media/platform/qcom/venus/vdec.c >>>>>>>>> @@ -890,7 +890,7 @@ static void vdec_buf_done(struct venus_inst >>>>>>>>> *inst, unsigned int buf_type, >>>>>>>>> >>>>>>>>> vb = &vbuf->vb2_buf; >>>>>>>>> vb->planes[0].bytesused = >>>>>>>>> - max_t(unsigned int, opb_sz, bytesused); >>>>>>>>> + min_t(unsigned int, opb_sz, bytesused); >>>>>>>> >>>>>>>> Most probably my intension was to avoid bytesused == 0, but that is >>>>>>>> allowed from v4l2 driver -> userspace direction >>>>>>> >>>>>>> It remains bad practice since it was used by decoders to indicate the >>>>>>> last buffer. Some userspace (some GStreamer versions) will stop working >>>>>>> if you start returning 0. >>>>>> >>>>>> I think it is legal v4l2 driver to return bytesused = 0 when userspace >>>>>> issues streamoff on both queues before EOS, no? Simply because the >>>>>> capture buffers are empty. >>>>>> >>>>> >>>>> Going through some of the older pending patches I found this one: >>>>> >>>>> So is this patch right or wrong? >>>> >>>> I'm not sure either, let's not applying it for now (if Nicolas is right >>>> this will break gstreamer plugin). >>>> >>> >>> OK, I marked this as Rejected. If you change your mind it can be reposted :-) >> >> Mmm I'm not saying it has to be done in the current form, but at the >> moment the returned bytesused seems to be wrong (at least Chrome is >> not happy). We are returning the total size of the buffer instead of >> the actually useful payload. >> >> If the intent is to avoid returning bytesused == 0 except for the >> special case of the last buffer, how about the following? >> >> --- a/drivers/media/platform/qcom/venus/vdec.c >> +++ b/drivers/media/platform/qcom/venus/vdec.c >> @@ -943,8 +943,7 @@ static void vdec_buf_done(struct venus_inst *inst, >> unsigned int buf_type, >> unsigned int opb_sz = venus_helper_get_opb_size(inst); >> >> vb = &vbuf->vb2_buf; >> - vb->planes[0].bytesused = >> - max_t(unsigned int, opb_sz, bytesused); >> + vb2_set_plane_payload(vb, 0, bytesused ? : opb_sz); >> vb->planes[0].data_offset = data_offset; >> vb->timestamp = timestamp_us * NSEC_PER_USEC; >> vbuf->sequence = inst->sequence_cap++; >> >> It works fine for me, and should not return 0 more often than it did >> before (i.e. never). In practice I also never see the firmware >> reporting a payload of zero on SDM845, but maybe older chips differ? > > yes, it looks fine. Let me test it with older versions. > OK, I played a bit with vb2_set_plane_payload(vb, 0, bytesused) On v1 I see a buffer with LAST flag and bytesused == 0 (when V4L2_DEC_CMD_STOP is used), after that after session_stop (first streamoff) is called I see the rest of the capture buffers returned with bytesused == 0. So I think we can go ahead. Vikash, can you resend with such a change? -- regards, Stan