From patchwork Fri May 31 08:54:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seung-Woo Kim X-Patchwork-Id: 17398 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f199.google.com (mail-qc0-f199.google.com [209.85.216.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4B1CC25CAB for ; Fri, 31 May 2013 14:27:28 +0000 (UTC) Received: by mail-qc0-f199.google.com with SMTP id s1sf1877916qcw.10 for ; Fri, 31 May 2013 07:27:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-beenthere:x-forwarded-to:x-forwarded-for:delivered-to:x-auditid :from:to:date:message-id:x-mailer:in-reply-to:references :x-brightmail-tracker:x-brightmail-tracker:dlp-filter:x-mtr :x-cfilter-loop:x-mailman-approved-at:cc:subject:x-beenthere :x-mailman-version:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:errors-to:sender :x-gm-message-state:x-original-sender :x-original-authentication-results:mailing-list:x-google-group-id :content-type:content-transfer-encoding; bh=9wTM7vh2Btms3UbtzjqcIfOL9+8Qlw6TxgHwRb9sAlQ=; b=Ii7DQRix0YnSzblPJ7vkeyyzN78Q7jy4uAlToUP4by2ODok/ToBWjuMy/xiBshU/EC a8Y4wG5XcHqvTq2VtUcpvUAQDdqhgIQvNw1mPmI9gK4bjznd7+qdKLvHsKJ81c7FYSTo WwhzB9dLlwvcWI+pLxhAMsdsopDlBTzQmK4oOAQhHd7S/8peDR9eE7tHmNdI5tPkQP8z d+a+kT72MZQEnXcjv0Q0mT1/39acwQEeiCez9VJxxPYROoVQOxvIC49OctJMlVa2DiwL ISHAmdjhY5UjPhSPNCDpCJu63E/uOhs8oBm4xHsOo1m3gp5roZ38m4ICHz1hXca4f/9d wGDg== X-Received: by 10.236.230.72 with SMTP id i68mr6357116yhq.23.1370010448076; Fri, 31 May 2013 07:27:28 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.119.129 with SMTP id ku1ls1001348qeb.49.gmail; Fri, 31 May 2013 07:27:27 -0700 (PDT) X-Received: by 10.220.146.83 with SMTP id g19mr10235759vcv.62.1370010447896; Fri, 31 May 2013 07:27:27 -0700 (PDT) Received: from mail-ve0-x236.google.com (mail-ve0-x236.google.com [2607:f8b0:400c:c01::236]) by mx.google.com with ESMTPS id ha8si28579586vdb.22.2013.05.31.07.27.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 May 2013 07:27:27 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::236 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::236; Received: by mail-ve0-f182.google.com with SMTP id ox1so1183682veb.27 for ; Fri, 31 May 2013 07:27:27 -0700 (PDT) X-Received: by 10.58.187.164 with SMTP id ft4mr10325829vec.5.1370010447793; Fri, 31 May 2013 07:27:27 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.229.199 with SMTP id jj7csp52386vcb; Fri, 31 May 2013 07:27:15 -0700 (PDT) X-Received: by 10.14.176.66 with SMTP id a42mr3752019eem.150.1370010433284; Fri, 31 May 2013 07:27:13 -0700 (PDT) Received: from ip-10-141-164-156.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id z48si31077959een.37.2013.05.31.07.27.12 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 31 May 2013 07:27:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-141-164-156.ec2.internal) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1UiQGj-0001uF-8c; Fri, 31 May 2013 14:25:25 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1UiL56-0000qX-DY for linaro-mm-sig@lists.linaro.org; Fri, 31 May 2013 08:53:04 +0000 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MNN002KSNF2B9B0@mailout2.samsung.com> for linaro-mm-sig@lists.linaro.org; Fri, 31 May 2013 17:54:38 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.112]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id C8.D3.08825.E4568A15; Fri, 31 May 2013 17:54:38 +0900 (KST) X-AuditID: cbfee68e-b7f276d000002279-30-51a8654ee6ce Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 17.7B.21068.E4568A15; Fri, 31 May 2013 17:54:38 +0900 (KST) Received: from localhost.localdomain ([10.90.8.56]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MNN00BWKNEZZT60@mmp2.samsung.com>; Fri, 31 May 2013 17:54:38 +0900 (KST) From: Seung-Woo Kim To: dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, sumit.semwal@linaro.org, airlied@linux.ie Date: Fri, 31 May 2013 17:54:46 +0900 Message-id: <1369990487-23510-2-git-send-email-sw0312.kim@samsung.com> X-Mailer: git-send-email 1.7.4.1 In-reply-to: <1369990487-23510-1-git-send-email-sw0312.kim@samsung.com> References: <1369990487-23510-1-git-send-email-sw0312.kim@samsung.com> X-Brightmail-Tracker: H4sIAAAA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UIBicXFSvp2mCaEhrjpWsA0Ruj6 hgTB9RgZoIGENYwZX/5qFCwTq1hz5jpTA+MSoS5GDg4JAROJpzMNuxg5gUwxiQv31rN1MXJx CAlMZ5S48/40K4TTzCQxZ38LK0gVm4COxP4lv8FsEYFeRok195hAipgFmhklHi37wwSSEBbw ktgw9wSYzSKgKvH7+hIWEJtXwE1i2eyXjBDrFCQW3HvLBmJzCrhLrO+7DFYjBFRzb9599gmM vAsYGVYxiqYWJBcUJ6XnGukVJ+YWl+al6yXn525iBMfdM+kdjKsaLA4xCnAwKvHwHkxZHijE mlhWXJl7iFGCg1lJhFc3eEWgEG9KYmVValF+fFFpTmrxIcZkoKsmMkuJJucDU0JeSbyhsYmZ kaWRuaGFkbE5acJK4rwHW60DhQTSE0tSs1NTC1KLYLYwcXBKNTDOi7vIc1LuoLelkVqF8Adj /Zu5fZt839Tu5N310TJRa/s04Ts/bvZPnn5T2zFVZseinJOcIQceNk7TkZXxPPklt3DelAlz am68+xHyL1T/qEV6UdVuSTvuJZf4DErXd8sYVV3da98t3b3iZ8CpHbvSXoTJf9scsN5w+t1z d14dyl+x+eavC0tblFiKMxINtZiLihMBcBWjZ/8CAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Mailman-Approved-At: Fri, 31 May 2013 14:25:24 +0000 Cc: inki.dae@samsung.com, kyungmin.park@samsung.com, sw0312.kim@samsung.com, linux-kernel@vger.kernel.org Subject: [Linaro-mm-sig] [RFC][PATCH 1/2] dma-buf: add importer private data to attachment X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: linaro-mm-sig-bounces@lists.linaro.org Sender: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQmQkcB2mk40fGUo8vcZ8ko64cbzE3vXbNGaxW7UwymyjhukIY1uE9aKHOGCT/PRKuenH8UZ X-Original-Sender: sw0312.kim@samsung.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::236 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 dma-buf attachment has only exporter private data, but importer private data can be useful for importer especially to re-import the same dma-buf. To use importer private data in attachment of the device, the function to search attachment in the attachment list of dma-buf is also added. Signed-off-by: Seung-Woo Kim --- drivers/base/dma-buf.c | 31 +++++++++++++++++++++++++++++++ include/linux/dma-buf.h | 4 ++++ 2 files changed, 35 insertions(+), 0 deletions(-) diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c index 08fe897..a1eaaf2 100644 --- a/drivers/base/dma-buf.c +++ b/drivers/base/dma-buf.c @@ -259,6 +259,37 @@ err_attach: EXPORT_SYMBOL_GPL(dma_buf_attach); /** + * dma_buf_get_attachment - Get attachment with the device from dma_buf's + * attachments list + * @dmabuf: [in] buffer to find device from. + * @dev: [in] device to be found. + * + * Returns struct dma_buf_attachment * attaching the device; may return + * negative error codes. + * + */ +struct dma_buf_attachment *dma_buf_get_attachment(struct dma_buf *dmabuf, + struct device *dev) +{ + struct dma_buf_attachment *attach; + + if (WARN_ON(!dmabuf || !dev)) + return ERR_PTR(-EINVAL); + + mutex_lock(&dmabuf->lock); + list_for_each_entry(attach, &dmabuf->attachments, node) { + if (attach->dev == dev) { + mutex_unlock(&dmabuf->lock); + return attach; + } + } + mutex_unlock(&dmabuf->lock); + + return ERR_PTR(-ENODEV); +} +EXPORT_SYMBOL_GPL(dma_buf_get_attachment); + +/** * dma_buf_detach - Remove the given attachment from dmabuf's attachments list; * optionally calls detach() of dma_buf_ops for device-specific detach * @dmabuf: [in] buffer to detach from. diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h index dfac5ed..09cff0f 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h @@ -136,6 +136,7 @@ struct dma_buf { * @dev: device attached to the buffer. * @node: list of dma_buf_attachment. * @priv: exporter specific attachment data. + * @importer_priv: importer specific attachment data. * * This structure holds the attachment information between the dma_buf buffer * and its user device(s). The list contains one attachment struct per device @@ -146,6 +147,7 @@ struct dma_buf_attachment { struct device *dev; struct list_head node; void *priv; + void *importer_priv; }; /** @@ -164,6 +166,8 @@ static inline void get_dma_buf(struct dma_buf *dmabuf) struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf, struct device *dev); +struct dma_buf_attachment *dma_buf_get_attachment(struct dma_buf *dmabuf, + struct device *dev); void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *dmabuf_attach);