From patchwork Mon Jan 14 13:38:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10762559 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 6EAD01580 for ; Mon, 14 Jan 2019 13:39:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5DC492868C for ; Mon, 14 Jan 2019 13:39:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51C862887D; Mon, 14 Jan 2019 13:39:24 +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 E67422868C for ; Mon, 14 Jan 2019 13:39:23 +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: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:In-Reply-To:References: List-Owner; bh=hY7lmBB2ANnif9DtMBwz4Rd7+3rwdokpLl7nJyriiy4=; b=BFv2ISEbeqhHgy pGtHOZww4X7x+z2somxQHPh4qCsKA+RyRdu4ZaPJpWKF0ZButzNC+EvZSHgm1g92/TvH6PzekKZQ3 Vz7LPVCzMd1cKxYyORe0tlI0lS3uksnAMaY7KiDnb0+Vdtls0KV2pk8U719g1ikhytcy6K/e1Xs/1 fT96JCysb+Y7cqTz9luKEURthUw4I/KPzB8FjK8WGa74ty+AGJZ+5Mvv/FKOAmMw3Trk87beF8lJV gpzvmqv6Hk33sNeSYsfhcnB7O2Oj8zUgo0O5JJlUzD22g2+w6b9ogRf5DY8J0sj79bCBChjoLLt2n QOqZQtixgUckj8zneBuw==; 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 1gj2SV-0003Hd-8V; Mon, 14 Jan 2019 13:39:19 +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-000367-FG 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 7934F20742; 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 08D0B206F9; 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 0/3] media: Ensure access to dma-buf-imported reference buffers Date: Mon, 14 Jan 2019 14:38:35 +0100 Message-Id: <20190114133839.29967-1-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190114_053906_640881_70796905 X-CRM114-Status: GOOD ( 14.20 ) 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 This is a first attempt at implementing proper access to buffers imported with dma-buf and used as reference frames for decoding subsequent frames. The main concern associated with this scenario was that memory could be liberated while the buffer is not in a queued state. After careful checking, it appears that this is not the case as the refcount is always increased when importing the buffer. It is only decreased when the same buffer is queued with a different dma-buf fd or when all buffers are liberated. In the meantime (when decoding using the frame as a reference happens), the buffer is thus guaranteed to stay alive. However, buffers imported with dma-buf require calls to dma-buf-specific map/unmap memops before they are accessed. This introduces the plumbing for allowing that. One major issue is that it cannot be done in atomic context, where the job is marked as completed. To solve this, a new m2m operation (job_done) is introduced which allows releasing access to the reference buffers from the m2m worker thread. Since this series touches the core of vb2 and m2m and may not be the best way to implement this, it is marked as RFC. This series is based on the series starting with: media: cedrus: Cleanup duplicate declarations from cedrus_dec header Paul Kocialkowski (4): media: vb2: Add helpers to access unselected buffers media: v4l2-mem2mem: Add an optional job_done operation media: cedrus: Request access to reference buffers when decoding media: cedrus: Remove completed item from TODO list (dma-buf references) .../media/common/videobuf2/videobuf2-core.c | 46 +++++++++++++++++++ drivers/media/v4l2-core/v4l2-mem2mem.c | 8 +++- drivers/staging/media/sunxi/cedrus/TODO | 5 -- 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 ++++ include/media/v4l2-mem2mem.h | 4 ++ include/media/videobuf2-core.h | 15 ++++++ 10 files changed, 100 insertions(+), 7 deletions(-)