Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp630402ybh; Wed, 18 Mar 2020 06:22:48 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuGye0yzb8VA4TsXr3A7O6Xr6KcopKsGnKSMf31Ht7R3pw0CJSxcVAEB2pQa+pogaEklP+5 X-Received: by 2002:aca:a883:: with SMTP id r125mr2981043oie.10.1584537768714; Wed, 18 Mar 2020 06:22:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584537768; cv=none; d=google.com; s=arc-20160816; b=FyhuSXcfmWW7gFvbUp3oI0zF5CjnI9TvvNM2DVNpsWa0SL75qHzgnPQPacpwJpGNm2 w6Axe3hCqrB005AEbJXEn9N7ihyscOsJZwuzZi20hXK9Ld7grhpv1Hftna+lg0uqD8bJ gGJdHbqmtBSRhYRxvZofV1TgLg3V/xPpl6eS62kmTPWXNFtwK6dHDeIMVMhCm3KYTAE0 YEdndA1paFndJwHA36BNLtZSoGfgCyc2W033kry4CiFPKYRVxaTn4xD82lU5w+UMaAtq uJW4mBvms8UAUo9srUkkr8qnPAkYdqRW1tmTKI3/I53uDl2+OtIwEIonTIA/kVXlKgrv lE1g== 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=dLkrTDafy2dt9g873SBuxg18KESS8mvPLO+DgrntCVQ=; b=UDcUYLlXlhGqT9+3LNmFbqVIkzPtAnX/uw2APC2lHENCqYCUyCK/p3yaFfV1A/Yl68 JwhQO2cLtietlK3EdZ7YJgRcdzYH8qwXlnZvHoMryN45F7QGZSXyECrRXNnL0j13QX58 efQnElJNSnvLgNvMyT1Aw+Dp1eWO394dvn0KQAlXPAQNYkdLSr2MeKuUj4WraMhkK8+M otYcgGa3qAMrVLm9YB0AxdaeaCk4gMcJr+6I20QpA9xVas2kxUmdJPzAOwO9CxbLEGJV QAsT7DocM+Gp2JIo8gngCr//DTUYuFlMXb2nfYjIr+p1UIeDPS/G3fsyOlrsKlnegVS2 DITg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d5si3300901otc.161.2020.03.18.06.22.36; Wed, 18 Mar 2020 06:22:48 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727104AbgCRNWD (ORCPT + 99 others); Wed, 18 Mar 2020 09:22:03 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:44488 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726842AbgCRNWC (ORCPT ); Wed, 18 Mar 2020 09:22:02 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 1330629661A From: Ezequiel Garcia To: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Tomasz Figa , Nicolas Dufresne , kernel@collabora.com, Jonas Karlman , Heiko Stuebner , Hans Verkuil , Alexandre Courbot , Jeffrey Kardatzke , Rob Herring , Ezequiel Garcia Subject: [PATCH v2 3/8] hantro: Use v4l2_m2m_buf_done_and_job_finish Date: Wed, 18 Mar 2020 10:21:03 -0300 Message-Id: <20200318132108.21873-4-ezequiel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200318132108.21873-1-ezequiel@collabora.com> References: <20200318132108.21873-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 Let the core sort out the nuances of returning buffers to userspace, by using the v4l2_m2m_buf_done_and_job_finish helper. This change also removes usage of buffer sequence fields, which shouldn't have any meaning for stateless decoders. Signed-off-by: Ezequiel Garcia --- drivers/staging/media/hantro/hantro_drv.c | 27 ++++++++--------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c index 0b1200fc0e1a..ec889d755cd6 100644 --- a/drivers/staging/media/hantro/hantro_drv.c +++ b/drivers/staging/media/hantro/hantro_drv.c @@ -94,32 +94,23 @@ static void hantro_job_finish(struct hantro_dev *vpu, unsigned int bytesused, enum vb2_buffer_state result) { - struct vb2_v4l2_buffer *src, *dst; int ret; pm_runtime_mark_last_busy(vpu->dev); pm_runtime_put_autosuspend(vpu->dev); clk_bulk_disable(vpu->variant->num_clocks, vpu->clocks); - src = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); - dst = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); - - if (WARN_ON(!src)) - return; - if (WARN_ON(!dst)) - return; - - src->sequence = ctx->sequence_out++; - dst->sequence = ctx->sequence_cap++; - - ret = ctx->buf_finish(ctx, &dst->vb2_buf, bytesused); - if (ret) - result = VB2_BUF_STATE_ERROR; + if (ctx->buf_finish) { + struct vb2_v4l2_buffer *dst; - v4l2_m2m_buf_done(src, result); - v4l2_m2m_buf_done(dst, result); + dst = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); + ret = ctx->buf_finish(ctx, &dst->vb2_buf, bytesused); + if (ret) + result = VB2_BUF_STATE_ERROR; + } - v4l2_m2m_job_finish(vpu->m2m_dev, ctx->fh.m2m_ctx); + v4l2_m2m_buf_done_and_job_finish(ctx->dev->m2m_dev, ctx->fh.m2m_ctx, + result); } void hantro_irq_done(struct hantro_dev *vpu, unsigned int bytesused, -- 2.25.0