From patchwork Mon Jan 14 13:38:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10762565 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5CF8D1580 for ; Mon, 14 Jan 2019 13:39:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49FEF2868C for ; Mon, 14 Jan 2019 13:39:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3CF6328864; Mon, 14 Jan 2019 13:39:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E04422868C for ; Mon, 14 Jan 2019 13:39:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xJUqO1uqF5U42UeEr1+2EPvKBWTL/7IOyoVa6MpL+D8=; b=BzLGsBQsakS9z9 71krW8xj9bIQvvaBtPIpuw6lj/oubuUO2PXO99yBaKRQ/0l6ZLNYWEeqHVM0K6QHia1ekTHxkLvno B/dAr8FjfFhD8vXjUHGSJ+hiJqI1mlO3cfLVThxJjsCzpUKo8p2JZUf9oIhvu6DATPQP/VeoY3H+H 5CinuHak6KTmcAorEXMICaaaWhPzIxVwG+qTDQV9HpOl3IbqBYS24jUXlZSiec6QTU3KD3tCPS7v0 Sim3c047y86jMlSQ1X1lAVlqKVp1eJYtg+zxf6crQm7Q0P53l5xhbI4/4MQtAjV+6euVd/LGKonLm opGjoEnEx3N0uO8IVPIw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gj2Su-0003fC-6i; Mon, 14 Jan 2019 13:39:44 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gj2SI-000369-FJ for linux-arm-kernel@lists.infradead.org; Mon, 14 Jan 2019 13:39:09 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id E27AA20955; Mon, 14 Jan 2019 14:39:00 +0100 (CET) Received: from localhost.localdomain (aaubervilliers-681-1-45-241.w90-88.abo.wanadoo.fr [90.88.163.241]) by mail.bootlin.com (Postfix) with ESMTPSA id 6D91620728; Mon, 14 Jan 2019 14:39:00 +0100 (CET) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com Subject: [PATCH RFC 1/4] media: vb2: Add helpers to access unselected buffers Date: Mon, 14 Jan 2019 14:38:36 +0100 Message-Id: <20190114133839.29967-2-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114133839.29967-1-paul.kocialkowski@bootlin.com> References: <20190114133839.29967-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190114_053906_817052_819F5CF5 X-CRM114-Status: GOOD ( 12.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hans Verkuil , Alexandre Courbot , Pawel Osciak , Maxime Ripard , Randy Li , Thomas Petazzoni , Tomasz Figa , Paul Kocialkowski , Kyungmin Park , Laurent Pinchart , Philipp Zabel , Sakari Ailus , Mauro Carvalho Chehab , Ezequiel Garcia , Marek Szyprowski Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce helpers to request and release access to buffers that are not currently selected as current output or capture buffers. This is useful to ensure proper access to buffers imported via dma-buf that are used as reference and thus require associated map/unmap calls before access. Signed-off-by: Paul Kocialkowski --- .../media/common/videobuf2/videobuf2-core.c | 46 +++++++++++++++++++ include/media/videobuf2-core.h | 15 ++++++ 2 files changed, 61 insertions(+) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 70e8c3366f9c..2a0c5de4d683 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -986,6 +986,52 @@ void vb2_discard_done(struct vb2_queue *q) } EXPORT_SYMBOL_GPL(vb2_discard_done); +int vb2_buffer_access_request(struct vb2_buffer *vb) +{ + struct vb2_queue *q = vb->vb2_queue; + unsigned int plane; + int ret; + + /* Only dmabuf-imported buffers need to be mapped before access. */ + if (q->memory != VB2_MEMORY_DMABUF) + return -EINVAL; + + for (plane = 0; plane < vb->num_planes; ++plane) { + if (vb->planes[plane].dbuf_mapped) + continue; + + ret = call_memop(vb, map_dmabuf, vb->planes[plane].mem_priv); + if (ret) { + dprintk(1, "failed to map dmabuf for plane %d\n", + plane); + return ret; + } + vb->planes[plane].dbuf_mapped = 1; + } + + return 0; +} +EXPORT_SYMBOL_GPL(vb2_buffer_access_request); + +void vb2_buffer_access_release(struct vb2_buffer *vb) +{ + struct vb2_queue *q = vb->vb2_queue; + unsigned int plane; + + /* Only dmabuf-imported buffers need to be unmapped after access. */ + if (q->memory != VB2_MEMORY_DMABUF) + return; + + for (plane = 0; plane < vb->num_planes; ++plane) { + if (!vb->planes[plane].dbuf_mapped) + continue; + + call_void_memop(vb, unmap_dmabuf, vb->planes[plane].mem_priv); + vb->planes[plane].dbuf_mapped = 0; + } +} +EXPORT_SYMBOL_GPL(vb2_buffer_access_release); + /* * __prepare_mmap() - prepare an MMAP buffer */ diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 4a737b2c610b..bf378c1e718b 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -1199,4 +1199,19 @@ bool vb2_request_object_is_buffer(struct media_request_object *obj); */ unsigned int vb2_request_buffer_cnt(struct media_request *req); +/** + * vb2_buffer_access_request() - request out-of-band data access to a buffer + * + * @vb: buffer to request data access for + */ +int vb2_buffer_access_request(struct vb2_buffer *vb); + + +/** + * vb2_buffer_access_release() - release out-of-band data access to a buffer + * + * @vb: buffer to release data access for + */ +void vb2_buffer_access_release(struct vb2_buffer *vb); + #endif /* _MEDIA_VIDEOBUF2_CORE_H */ From patchwork Mon Jan 14 13:38:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10762567 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F17714E5 for ; Mon, 14 Jan 2019 13:40:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEEF32868C for ; Mon, 14 Jan 2019 13:40:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF2B528864; Mon, 14 Jan 2019 13:40:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8526C2868C for ; Mon, 14 Jan 2019 13:40:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HGbw6G8zme880r63SGdLLIxheXoWvpOdOCLtjLxV7o4=; b=p7CWhPFO8T1DqY LjNkuHN1ytGPw5+0f7IVZDdzfSdRFeoBkznyTP6NAtJ5GkReXqXwFNmAnEXIiKpu/hImV4Gi6EEpK gVkXZclxReYLpbZaBvgMgtUyr6S81oum0au8HHSnewWaNovibOgcY5rdUVvht7JFVh4o2qzS0+nnX zWI+dsxcZT5bXCvE0odIk2f64UJ8BKWR/3+D5AZ2v/8h4v9XwXNbC63EoWvWjYwn2iV+4t1shbIQG ejfVaxFjh4o8A+12nwsyKCHt3/LoqT6F18qwnidM0OB99DTsfLM9H+RtymFslwgRyWrmr+qV1mqHl FU9IXUYBy3KU0eTP1sbw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gj2T6-0003s6-PO; Mon, 14 Jan 2019 13:39:56 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gj2SI-000368-FH for linux-arm-kernel@lists.infradead.org; Mon, 14 Jan 2019 13:39:10 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 4C011209D7; Mon, 14 Jan 2019 14:39:01 +0100 (CET) Received: from localhost.localdomain (aaubervilliers-681-1-45-241.w90-88.abo.wanadoo.fr [90.88.163.241]) by mail.bootlin.com (Postfix) with ESMTPSA id CFB9F206F9; Mon, 14 Jan 2019 14:39:00 +0100 (CET) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com Subject: [PATCH RFC 2/4] media: v4l2-mem2mem: Add an optional job_done operation Date: Mon, 14 Jan 2019 14:38:37 +0100 Message-Id: <20190114133839.29967-3-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114133839.29967-1-paul.kocialkowski@bootlin.com> References: <20190114133839.29967-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190114_053906_827249_08FB463E X-CRM114-Status: GOOD ( 16.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hans Verkuil , Alexandre Courbot , Pawel Osciak , Maxime Ripard , Randy Li , Thomas Petazzoni , Tomasz Figa , Paul Kocialkowski , Kyungmin Park , Laurent Pinchart , Philipp Zabel , Sakari Ailus , Mauro Carvalho Chehab , Ezequiel Garcia , Marek Szyprowski Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce a new optional job_done operation, which allows calling back to the driver when a job is done. Since the job might be completed from interrupt context where some operations are not available, having a callback from non-atomic context allows performing these operations upon completion of a job. This is particularly useful for releasing access to a reference buffer, which cannot be done in atomic context. Use the already existing v4l2_m2m_device_run_work work queue for that and clear the M2M device current context after calling job_done in the worker thread, so that the private data can be passed to the operation. Delaying the current context clearing should not be a problem since the next call to v4l2_m2m_try_run happens right after that. Signed-off-by: Paul Kocialkowski --- drivers/media/v4l2-core/v4l2-mem2mem.c | 8 ++++++-- include/media/v4l2-mem2mem.h | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c index 631f4e2aa942..d5bccb0192f9 100644 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c @@ -376,6 +376,11 @@ static void v4l2_m2m_device_run_work(struct work_struct *work) struct v4l2_m2m_dev *m2m_dev = container_of(work, struct v4l2_m2m_dev, job_work); + if (m2m_dev->m2m_ops->job_done && m2m_dev->curr_ctx) + m2m_dev->m2m_ops->job_done(m2m_dev->curr_ctx->priv); + + m2m_dev->curr_ctx = NULL; + v4l2_m2m_try_run(m2m_dev); } @@ -431,8 +436,7 @@ void v4l2_m2m_job_finish(struct v4l2_m2m_dev *m2m_dev, list_del(&m2m_dev->curr_ctx->queue); m2m_dev->curr_ctx->job_flags &= ~(TRANS_QUEUED | TRANS_RUNNING); wake_up(&m2m_dev->curr_ctx->finished); - m2m_dev->curr_ctx = NULL; - + /* The current context pointer is cleared after the job_done step. */ spin_unlock_irqrestore(&m2m_dev->job_spinlock, flags); /* This instance might have more buffers ready, but since we do not diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h index 43e447dcf69d..261bcd661b2d 100644 --- a/include/media/v4l2-mem2mem.h +++ b/include/media/v4l2-mem2mem.h @@ -40,11 +40,15 @@ * v4l2_m2m_job_finish() (as if the transaction ended normally). * This function does not have to (and will usually not) wait * until the device enters a state when it can be stopped. + * @job_done: optional. Informs the driver that the current job was completed. + * This can be useful to release access to extra buffers that were + * required for the job, such as reference buffers for decoding. */ struct v4l2_m2m_ops { void (*device_run)(void *priv); int (*job_ready)(void *priv); void (*job_abort)(void *priv); + void (*job_done)(void *priv); }; struct video_device; From patchwork Mon Jan 14 13:38:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10762569 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B49421580 for ; Mon, 14 Jan 2019 13:40:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3559289CA for ; Mon, 14 Jan 2019 13:40:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97AA028BAA; Mon, 14 Jan 2019 13:40:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 350AB289CA for ; Mon, 14 Jan 2019 13:40:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Z6BU97wAu+z0tYyARh7koHoLHaODGLAqTsjJdWgVC2o=; b=i0IQ545/VhASQC S6UFhRurgx2eGCB5F24fjQEqX3Q5fNlInXoCC2okvLJyZyjI3vAVu8bTS83NYYw6bKdEm21uV9G9O 0x4A2sGuaVvWCc4ya73Hue0KSedQ3/tuN+6RSz46T2uPVV9578q35IEmMrTgVeQEex1kFTP4xaD/Y W5jSnbAqOyNXg0SJfFfORvY+NLrK7Rtvu1Ni6UmFKsB2RpKrqBZyf0wxHqQ26mfd23xYLdtnB/08K BbX5afu47r8XXPCNG+k3IRD+PfmUY+wZl8i9tUEw2R8lsot1pAMKIflWOS8ibRH+RN/qfo1xB313J 6OnOpxM+AnJO/h0axqGg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gj2TN-0004iA-Ny; Mon, 14 Jan 2019 13:40:13 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gj2SI-000366-F0 for linux-arm-kernel@lists.infradead.org; Mon, 14 Jan 2019 13:39:10 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id A9B9D20A0F; Mon, 14 Jan 2019 14:39:01 +0100 (CET) Received: from localhost.localdomain (aaubervilliers-681-1-45-241.w90-88.abo.wanadoo.fr [90.88.163.241]) by mail.bootlin.com (Postfix) with ESMTPSA id 3D02E20728; Mon, 14 Jan 2019 14:39:01 +0100 (CET) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com Subject: [PATCH RFC 3/4] media: cedrus: Request access to reference buffers when decoding Date: Mon, 14 Jan 2019 14:38:38 +0100 Message-Id: <20190114133839.29967-4-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114133839.29967-1-paul.kocialkowski@bootlin.com> References: <20190114133839.29967-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190114_053906_811764_08B9B301 X-CRM114-Status: GOOD ( 13.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hans Verkuil , Alexandre Courbot , Pawel Osciak , Maxime Ripard , Randy Li , Thomas Petazzoni , Tomasz Figa , Paul Kocialkowski , Kyungmin Park , Laurent Pinchart , Philipp Zabel , Sakari Ailus , Mauro Carvalho Chehab , Ezequiel Garcia , Marek Szyprowski Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Because we need to request and release access to reference buffers that are backed by a dma-buf import, keep track of the buffers used as reference and add the appropriate calls in the device_run and job_done m2m callbacks. The latter is introduced for this purpose. Signed-off-by: Paul Kocialkowski --- drivers/staging/media/sunxi/cedrus/cedrus.c | 1 + drivers/staging/media/sunxi/cedrus/cedrus.h | 1 + .../staging/media/sunxi/cedrus/cedrus_dec.c | 18 ++++++++++++++++++ .../staging/media/sunxi/cedrus/cedrus_dec.h | 1 + .../staging/media/sunxi/cedrus/cedrus_mpeg2.c | 8 ++++++++ 5 files changed, 29 insertions(+) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index ff11cbeba205..a2c75eb01c2c 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -250,6 +250,7 @@ static const struct video_device cedrus_video_device = { static const struct v4l2_m2m_ops cedrus_m2m_ops = { .device_run = cedrus_device_run, + .job_done = cedrus_job_done, }; static const struct media_device_ops cedrus_m2m_media_ops = { diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index 4aedd24a9848..c1ce3c4ae2a1 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -77,6 +77,7 @@ struct cedrus_ctx { struct v4l2_ctrl **ctrls; struct vb2_buffer *dst_bufs[VIDEO_MAX_FRAME]; + bool reference_bufs[VIDEO_MAX_FRAME]; }; struct cedrus_dec_ops { diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c index 2c295286766c..90bf51e71f4f 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c @@ -41,6 +41,7 @@ void cedrus_device_run(void *priv) struct cedrus_dev *dev = ctx->dev; struct cedrus_run run = {}; struct media_request *src_req; + unsigned int i; run.src = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); run.dst = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); @@ -63,10 +64,17 @@ void cedrus_device_run(void *priv) break; } + for (i = 0; i < VIDEO_MAX_FRAME; i++) + ctx->reference_bufs[i] = false; + v4l2_m2m_buf_copy_data(run.src, run.dst, true); dev->dec_ops[ctx->current_codec]->setup(ctx, &run); + for (i = 0; i < VIDEO_MAX_FRAME; i++) + if (ctx->reference_bufs[i] && ctx->dst_bufs[i]) + vb2_buffer_access_request(ctx->dst_bufs[i]); + /* Complete request(s) controls if needed. */ if (src_req) @@ -74,3 +82,13 @@ void cedrus_device_run(void *priv) dev->dec_ops[ctx->current_codec]->trigger(ctx); } + +void cedrus_job_done(void *priv) +{ + struct cedrus_ctx *ctx = priv; + unsigned int i; + + for (i = 0; i < VIDEO_MAX_FRAME; i++) + if (ctx->reference_bufs[i] && ctx->dst_bufs[i]) + vb2_buffer_access_release(ctx->dst_bufs[i]); +} diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.h b/drivers/staging/media/sunxi/cedrus/cedrus_dec.h index 8d0fc248220f..9265f28e6dbe 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.h @@ -19,5 +19,6 @@ int cedrus_reference_index_find(struct vb2_queue *queue, struct vb2_buffer *vb2_buf, u64 timestamp); void cedrus_device_run(void *priv); +void cedrus_job_done(void *priv); #endif diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c index 81c66a8aa1ac..2e7deded17aa 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c @@ -162,6 +162,10 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) /* Forward and backward prediction reference buffers. */ forward_idx = cedrus_reference_index_find(cap_q, &run->dst->vb2_buf, slice_params->forward_ref_ts); + if (forward_idx < 0) + return; + + ctx->reference_bufs[forward_idx] = true; fwd_luma_addr = cedrus_dst_buf_addr(ctx, forward_idx, 0); fwd_chroma_addr = cedrus_dst_buf_addr(ctx, forward_idx, 1); @@ -171,6 +175,10 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) backward_idx = cedrus_reference_index_find(cap_q, &run->dst->vb2_buf, slice_params->backward_ref_ts); + if (forward_idx < 0) + return; + + ctx->reference_bufs[backward_idx] = true; bwd_luma_addr = cedrus_dst_buf_addr(ctx, backward_idx, 0); bwd_chroma_addr = cedrus_dst_buf_addr(ctx, backward_idx, 1); From patchwork Mon Jan 14 13:38:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10762553 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D38214E5 for ; Mon, 14 Jan 2019 13:39:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C972822AFC for ; Mon, 14 Jan 2019 13:39:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDB3522BF1; Mon, 14 Jan 2019 13:39:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6BCFF22AFC for ; Mon, 14 Jan 2019 13:39:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rJKnc0pih+/iFMMxO0A/1yLzNACRZSbyaD7XKq5gDAs=; b=qqJ4n2uWo00bYS zOyF38FrY7DMalJ3pc1q2greobxZj4QwaViyP2mBiZr9I8d/C5uMFeqsK46RdKWET1+geAubPnEmN zUKXRKVIZ11I24LpR2OZfMEe3yZOs5Y3Zv2r4PBVewopF+APndaXt/cUu+SnLf0F/IrTw4ftmoBec EdjmHbHmy1O+l/TQ3WEOCk/3zrrnllO/DTUS3VpExT0MzhdolMU2VV6VrbJp5V62FJskgqs+A3s/I r0aHXDXqcWSQAPPDNnJJu2FfQ7eqTgE5ZHKenfrcez9srqJ3b30dqJfMbcyVYXJyF3osmmo+SACfM o2laDCO8OF5phUxAdP9w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gj2SM-00039B-Ae; Mon, 14 Jan 2019 13:39:10 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gj2SI-00036A-Ex for linux-arm-kernel@lists.infradead.org; Mon, 14 Jan 2019 13:39:08 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 12B4220A2A; Mon, 14 Jan 2019 14:39:02 +0100 (CET) Received: from localhost.localdomain (aaubervilliers-681-1-45-241.w90-88.abo.wanadoo.fr [90.88.163.241]) by mail.bootlin.com (Postfix) with ESMTPSA id 9C361206F9; Mon, 14 Jan 2019 14:39:01 +0100 (CET) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com Subject: [PATCH RFC 4/4] media: cedrus: Remove completed item from TODO list (dma-buf references) Date: Mon, 14 Jan 2019 14:38:39 +0100 Message-Id: <20190114133839.29967-5-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114133839.29967-1-paul.kocialkowski@bootlin.com> References: <20190114133839.29967-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190114_053906_640987_F33C2CCD X-CRM114-Status: GOOD ( 10.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hans Verkuil , Alexandre Courbot , Pawel Osciak , Maxime Ripard , Randy Li , Thomas Petazzoni , Tomasz Figa , Paul Kocialkowski , Kyungmin Park , Laurent Pinchart , Philipp Zabel , Sakari Ailus , Mauro Carvalho Chehab , Ezequiel Garcia , Marek Szyprowski Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Access to reference frames that were imported from dma-buf was taken care of and is no longer a pending item on the driver's TODO list. Signed-off-by: Paul Kocialkowski --- drivers/staging/media/sunxi/cedrus/TODO | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/TODO b/drivers/staging/media/sunxi/cedrus/TODO index a951b3fd1ea1..ec277ece47af 100644 --- a/drivers/staging/media/sunxi/cedrus/TODO +++ b/drivers/staging/media/sunxi/cedrus/TODO @@ -5,8 +5,3 @@ Before this stateless decoder driver can leave the staging area: * Userspace support for the Request API needs to be reviewed; * Another stateless decoder driver should be submitted; * At least one stateless encoder driver should be submitted. -* When queueing a request containing references to I frames, the - refcount of the memory for those I frames needs to be incremented - and decremented when the request is completed. This will likely - require some help from vb2. The driver should fail the request - if the memory/buffer is gone.