From patchwork Thu Jan 24 09:51:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10778631 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 A12131390 for ; Thu, 24 Jan 2019 09:53:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 932CB2E80D for ; Thu, 24 Jan 2019 09:53:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 919732E817; Thu, 24 Jan 2019 09:53:08 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 308202E80D for ; Thu, 24 Jan 2019 09:53:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726080AbfAXJw5 (ORCPT ); Thu, 24 Jan 2019 04:52:57 -0500 Received: from mail.bootlin.com ([62.4.15.54]:59119 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725287AbfAXJw5 (ORCPT ); Thu, 24 Jan 2019 04:52:57 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id CD6DC2084E; Thu, 24 Jan 2019 10:52:54 +0100 (CET) Received: from localhost.localdomain (aaubervilliers-681-1-87-206.w90-88.abo.wanadoo.fr [90.88.29.206]) by mail.bootlin.com (Postfix) with ESMTPSA id 5C68520654; Thu, 24 Jan 2019 10:52:44 +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 Cc: Pawel Osciak , Mauro Carvalho Chehab , Maxime Ripard , Paul Kocialkowski , Thomas Petazzoni , Hans Verkuil , Ezequiel Garcia , Tomasz Figa , Laurent Pinchart , Sakari Ailus , Pawel Osciak Subject: [PATCH 1/2] media: vb2: Keep dma-buf buffers mapped until they are freed Date: Thu, 24 Jan 2019 10:51:55 +0100 Message-Id: <20190124095156.21898-1-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Pawel Osciak When using vb2 for video decoding, dequeued capture buffers may still be accessed by the hardware: this is the case when they are used as reference frames for decoding subsequent frames. When the buffer is imported with dma-buf, it needs to be mapped before access. Until now, it was mapped when queuing and unmapped when dequeuing, which doesn't work for access as a reference frames. One way to solve this would be to map the buffer again when it is needed as a reference, but the mapping/unmapping operations can seriously impact performance. As a result, map the buffer once (when it is first needed when queued) and keep it mapped until it is freed. Signed-off-by: Pawel Osciak Reviewed-on: https://chromium-review.googlesource.com/334103 Signed-off-by: Paul Kocialkowski [Paul: Updated for mainline and changed commit message] --- drivers/media/common/videobuf2/videobuf2-core.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 70e8c3366f9c..ce9294a635cc 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -1196,6 +1196,9 @@ static int __prepare_dmabuf(struct vb2_buffer *vb) * userspace knows sooner rather than later if the dma-buf map fails. */ 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", @@ -1758,14 +1761,6 @@ static void __vb2_dqbuf(struct vb2_buffer *vb) vb->state = VB2_BUF_STATE_DEQUEUED; - /* unmap DMABUF buffer */ - if (q->memory == VB2_MEMORY_DMABUF) - for (i = 0; i < vb->num_planes; ++i) { - if (!vb->planes[i].dbuf_mapped) - continue; - call_void_memop(vb, unmap_dmabuf, vb->planes[i].mem_priv); - vb->planes[i].dbuf_mapped = 0; - } call_void_bufop(q, init_buffer, vb); } From patchwork Thu Jan 24 09:51:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10778627 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 9024413BF for ; Thu, 24 Jan 2019 09:53:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 822892E804 for ; Thu, 24 Jan 2019 09:53:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75FB42E79C; Thu, 24 Jan 2019 09:53:05 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 565FB2E803 for ; Thu, 24 Jan 2019 09:53:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727454AbfAXJw6 (ORCPT ); Thu, 24 Jan 2019 04:52:58 -0500 Received: from mail.bootlin.com ([62.4.15.54]:59128 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbfAXJw5 (ORCPT ); Thu, 24 Jan 2019 04:52:57 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 1EE0F207B0; Thu, 24 Jan 2019 10:52:55 +0100 (CET) Received: from localhost.localdomain (aaubervilliers-681-1-87-206.w90-88.abo.wanadoo.fr [90.88.29.206]) by mail.bootlin.com (Postfix) with ESMTPSA id AF6A920798; Thu, 24 Jan 2019 10:52:44 +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 Cc: Pawel Osciak , Mauro Carvalho Chehab , Maxime Ripard , Paul Kocialkowski , Thomas Petazzoni , Hans Verkuil , Ezequiel Garcia , Tomasz Figa , Laurent Pinchart , Sakari Ailus Subject: [PATCH 2/2] media: cedrus: Remove completed item from TODO list (dma-buf references) Date: Thu, 24 Jan 2019 10:51:56 +0100 Message-Id: <20190124095156.21898-2-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190124095156.21898-1-paul.kocialkowski@bootlin.com> References: <20190124095156.21898-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.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.