From patchwork Fri Mar 16 20:02:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 7336 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 3EECC23E29 for ; Fri, 16 Mar 2012 20:02:28 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id EB463A18345 for ; Fri, 16 Mar 2012 20:02:27 +0000 (UTC) Received: by iage36 with SMTP id e36so7810969iag.11 for ; Fri, 16 Mar 2012 13:02:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :dkim-signature:sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=23APqqP7glE5nLN1LGNH1WshauX/N9bGw2z7cN8xneU=; b=O8bDFHYqbQa0Fmk4FWQaUYtkKuymBJxzZ2ZIDueYn+YDP7MfwXeoIsWAbcahjMSsnE f0xxi4nXaWBdlCDVmuoc9HVLumVLm3EQCUTsing7uDGtCY9RCAZe+7Ii4NC0dAMD8ixC dHgWcA5u7Ad1CD1Pi1ha/VIvwJhicvNVFkIC1x6DVyO3bTPGwzXjx30mVmfEU/YVDox9 yFOIkvQN8iI2VK6oKkGnM/7tjbaGOlag3eus/bxATK8jIIq2Hzbqs7Qos4k65MIlcBZz 7UAbaVptyHHMOeYBi/edwRTpyeLx0nSsTZvLu1Xqw8wZxih58NKtLBTKOgvp3u4tYEpR RKbw== Received: by 10.50.197.132 with SMTP id iu4mr370381igc.74.1331928147308; Fri, 16 Mar 2012 13:02:27 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.53.18 with SMTP id k18csp15846ibg; Fri, 16 Mar 2012 13:02:26 -0700 (PDT) Received: by 10.236.182.232 with SMTP id o68mr3969782yhm.58.1331928146199; Fri, 16 Mar 2012 13:02:26 -0700 (PDT) Received: from mail-gy0-f178.google.com (mail-gy0-f178.google.com [209.85.160.178]) by mx.google.com with ESMTPS id d28si5894967yhl.144.2012.03.16.13.02.25 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Mar 2012 13:02:26 -0700 (PDT) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.160.178 as permitted sender) client-ip=209.85.160.178; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.160.178 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass header.i=@gmail.com Received: by ghbf1 with SMTP id f1so5661297ghb.37 for ; Fri, 16 Mar 2012 13:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer; bh=23APqqP7glE5nLN1LGNH1WshauX/N9bGw2z7cN8xneU=; b=VgUw+E9CkTUz6Nonmp0JfnXWDopfrwMbAcMtGlkCx2ZFX7+aETkL2M/NZyGt3lT+40 PIYN93xpnUu+ngfQofd8Ap+/HN2ms8ApaiuBi8GRsbM3wQmaGSjjGtgBQzp8TgPdOmvP 6ils/XcqO5p+UZWbc3pXhEpUFRAKRL7TzOdANoObcZj8Wc0tK3jJycPsnn4ApbPyoCO9 MN7SSYQKFz20vqa1qXPEVvwA3seItyivCqBmMtQr1EOZz00/E9WvXd2Pn15c3BBggj1H 6fkDtM1U/s81VaNf7Jpm/eapYUQLKdBBygWYi258uNp1YkgLNp7OU4h8iM8vNwK7lEIe pMVQ== Received: by 10.182.75.103 with SMTP id b7mr3707159obw.54.1331928145176; Fri, 16 Mar 2012 13:02:25 -0700 (PDT) Received: from localhost (ppp-70-129-134-19.dsl.rcsntx.swbell.net. [70.129.134.19]) by mx.google.com with ESMTPS id m3sm2300623oem.7.2012.03.16.13.02.23 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Mar 2012 13:02:24 -0700 (PDT) Sender: Rob Clark From: Rob Clark To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org Cc: patches@linaro.org, sumit.semwal@linaro.org, daniel@ffwll.ch, airlied@redhat.com, Rob Clark Subject: [PATCH] dma-buf: add get_dma_buf() Date: Fri, 16 Mar 2012 15:02:24 -0500 Message-Id: <1331928144-30628-1-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.5.4 X-Gm-Message-State: ALoCoQl97AvGvhltFTHEJGuE/cLybg+rWXkx0R4RHKCf48HA8YlMkZDLiVBusLxbNvC2uI0Ir6ln From: Rob Clark Works in a similar way to get_file(), and is needed in cases such as when the exporter needs to also keep a reference to the dmabuf (that is later released with a dma_buf_put()), and possibly other similar cases. Signed-off-by: Rob Clark Reviewed-by: Kyungmin Park --- Minor update on original to add a missing #include include/linux/dma-buf.h | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h index 891457a..bc4203dc 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h @@ -30,6 +30,7 @@ #include #include #include +#include struct dma_buf; struct dma_buf_attachment; @@ -110,6 +111,20 @@ struct dma_buf_attachment { void *priv; }; +/** + * get_dma_buf - convenience wrapper for get_file. + * @dmabuf: [in] pointer to dma_buf + * + * Increments the reference count on the dma-buf, needed in case of drivers + * that either need to create additional references to the dmabuf on the + * kernel side. For example, an exporter that needs to keep a dmabuf ptr + * so that subsequent exports don't create a new dmabuf. + */ +static inline void get_dma_buf(struct dma_buf *dmabuf) +{ + get_file(dmabuf->file); +} + #ifdef CONFIG_DMA_SHARED_BUFFER struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf, struct device *dev);