From patchwork Fri Mar 16 16:04:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 7334 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 08A1923E00 for ; Fri, 16 Mar 2012 16:04:54 +0000 (UTC) Received: from mail-ee0-f52.google.com (mail-ee0-f52.google.com [74.125.83.52]) by fiordland.canonical.com (Postfix) with ESMTP id E3B92A18863 for ; Fri, 16 Mar 2012 16:04:53 +0000 (UTC) Received: by eekd4 with SMTP id d4so2558146eek.11 for ; Fri, 16 Mar 2012 09:04:53 -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=ppVZz8hU4kruT8aF8CkUxNtay3nrWuh5XvLrpW+tOfk=; b=XnrWgfR8CRoFwoGbeludgIJWU/wCHi65ivxIS4U/etOV2BZsDHAOFd3Yzi3I5pBCoH Y5fEwFLZATiPD8Du2v45cXELw0igPbzXDYtKblOMeEUYM+ZcOv+NKg83IotHLK5ocUVC pnZg/Xrs8EZxeRDJzRlhgm+SZVA8RNWd/qtREBoq+2OclgNWkMH8z29RHHdm9Jgs2f1B zafpKp0RWBwv8qO8V6Y5HG3vP7ZB8Skxf2QwovULSBPxp/Y7yLB3NZawCbzWWvBRAB+o IqmX6NJevtckSu0DcNvfEDuG5rS8aCuOqZFc3ZiVAgdFWE6I0oHbeIELIErvBy8CEM6C a/qw== Received: by 10.50.197.132 with SMTP id iu4mr2862174igc.74.1331913893233; Fri, 16 Mar 2012 09:04:53 -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 k18csp11347ibg; Fri, 16 Mar 2012 09:04:52 -0700 (PDT) Received: by 10.236.139.132 with SMTP id c4mr2859561yhj.48.1331913892257; Fri, 16 Mar 2012 09:04:52 -0700 (PDT) Received: from mail-yw0-f50.google.com (mail-yw0-f50.google.com [209.85.213.50]) by mx.google.com with ESMTPS id b5si5117672yhe.60.2012.03.16.09.04.51 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Mar 2012 09:04:52 -0700 (PDT) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.213.50 as permitted sender) client-ip=209.85.213.50; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.213.50 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass header.i=@gmail.com Received: by yhjj63 with SMTP id j63so5349708yhj.37 for ; Fri, 16 Mar 2012 09:04:51 -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=ppVZz8hU4kruT8aF8CkUxNtay3nrWuh5XvLrpW+tOfk=; b=H1fTj0Mf0/MjV97FT2tRe9qhdRGC4nFfxJsuGd18gunRsbcTAe+OHDyDroB27/DBAF bCfJAEMcDetfJR9p/mf9qApNsKb4xgO7buzSjSxS/I5DPRa6QakeFIxW/ZAkMPfV/IWa 6BmZ+4j7l9UxeIcL/1o51KNtDyfZ9KwfNnnh60D4Xd1y+MLwUIafhVtGmPiJtbhTOQyu Y66gzgKYwizCJfCkL/rciNOWqTrcqEfVTpSHKHwGio9rcCoUJ8JWHJLkibpYPeu4v2Jj bALj9kd8SHQ87ipVxoFn/UnogiTgytz+/fR+xkJvAPCtFb98K7GQfWYI9ssCXbbF+5jx tbNw== Received: by 10.60.30.66 with SMTP id q2mr3643828oeh.25.1331913891064; Fri, 16 Mar 2012 09:04:51 -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 s2sm4000119oea.2.2012.03.16.09.04.44 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Mar 2012 09:04:44 -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 11:04:41 -0500 Message-Id: <1331913881-13105-1-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.5.4 X-Gm-Message-State: ALoCoQm+9bPLlE+yJcOQ34H9PFTkkX5SLxNMjB+AfUjYfAPVpPhOo5kBR4eh/qnAwoJeg+0joViQ 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: Dave Airlie --- include/linux/dma-buf.h | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h index cbdff81..25eb287 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h @@ -132,6 +132,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);