Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp787808ybh; Wed, 11 Mar 2020 10:48:42 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuByYcKNNi6C054WJm/bk4zMfzg7cHxvG3TaOz/xZX6TGiOdbEVxO3i6KPSq7hzl/TL1wqH X-Received: by 2002:a05:6830:103:: with SMTP id i3mr3130723otp.270.1583948922119; Wed, 11 Mar 2020 10:48:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583948922; cv=none; d=google.com; s=arc-20160816; b=RFRTtUPXkCMXeLnf9Ep9LlhdBzSZNYa9DAq12Dxzqet0KEbdlC/P6CRmOibTw3sYTD KE06fh6qz1/sVkXcFw8oNYDhtEBAm6v1Rm65bGEFpKvpL8isCMYRK/KhnOW1p2wgFfKG LuLQQiYcwgHMlq4k60CWfRFXCH8MLyjgigOj0tioS2xrnE5nKaas74FGW/Fu7SPvIP5K uuiNE2r+ZEVPB4xLy/nvFQs3uRi28DvFPQS7Y3XvurdWv0bUIik7HEWLagZR0jajJoVg p+ht38WhBCablXKNS6PpeIcac1ABYSWpZneL0YXEa6XeWqc1NoTTwyVJ5ly5AedPlqgp MVEw== 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=VdqCOr3Y/A7NWhRyVhPrW9WroBIE6OEYxqSrLkyetui82hVsj/UIjg6a92Air8cXUh 4K/pnCiw61mN9PnLW2dhPSTu5Yfy0SS8O1L9eXJgdmCXgm4eym7UIH4rpHagNio+bcD5 +LCHDzW4pev3djVSM0/wrvuzQ+BJ1mMftwA0IzvW9JwVOg4DuxZmaCS8DdCC3vIyqG8I 6FoEaj+GkTxK2ihEaZrSnSdKln9z6CHLUET5llkIrIQHvKYaSc1+VnHt7JWGq0lcYR3J hZGeeKQ5cPcw/fyxEb7yN4YAhIsLkqtvqvqH0fp6B6CJLdJXSrjg7E7TwRmzJaqLaOLC yRTg== 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 t18si1380206otc.192.2020.03.11.10.48.29; Wed, 11 Mar 2020 10:48:42 -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 S1730703AbgCKRrX (ORCPT + 99 others); Wed, 11 Mar 2020 13:47:23 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:33080 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730645AbgCKRrW (ORCPT ); Wed, 11 Mar 2020 13:47:22 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id C9A522912DD 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 , Ezequiel Garcia Subject: [PATCH 3/6] hantro: Use v4l2_m2m_buf_done_and_job_finish Date: Wed, 11 Mar 2020 14:42:57 -0300 Message-Id: <20200311174300.19407-4-ezequiel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200311174300.19407-1-ezequiel@collabora.com> References: <20200311174300.19407-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