From: Tomasz Stanislawski <t.stanislaws@samsung.com>
To: Sumit Semwal <sumit.semwal@ti.com>
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org,
linux-media@vger.kernel.org, arnd@arndb.de, airlied@redhat.com,
linux@arm.linux.org.uk, jesse.barker@linaro.org,
m.szyprowski@samsung.com, rob@ti.com, daniel@ffwll.ch,
patches@linaro.org, Sumit Semwal <sumit.semwal@linaro.org>
Subject: Re: [PATCH 1/3] dma-buf: Introduce dma buffer sharing mechanism
Date: Wed, 25 Jan 2012 18:02:41 +0100 [thread overview]
Message-ID: <4F2035B1.4020204@samsung.com> (raw)
In-Reply-To: <1324891397-10877-2-git-send-email-sumit.semwal@ti.com>
Hi Sumit,
On 12/26/2011 10:23 AM, Sumit Semwal wrote:
> This is the first step in defining a dma buffer sharing mechanism.
>
> A new buffer object dma_buf is added, with operations and API to allow easy
> sharing of this buffer object across devices.
>
> The framework allows:
> - creation of a buffer object, its association with a file pointer, and
> associated allocator-defined operations on that buffer. This operation is
> called the 'export' operation.
> - different devices to 'attach' themselves to this exported buffer object, to
> facilitate backing storage negotiation, using dma_buf_attach() API.
> - the exported buffer object to be shared with the other entity by asking for
> its 'file-descriptor (fd)', and sharing the fd across.
> - a received fd to get the buffer object back, where it can be accessed using
> the associated exporter-defined operations.
> - the exporter and user to share the scatterlist associated with this buffer
> object using map_dma_buf and unmap_dma_buf operations.
>
[snip]
> +/**
> + * struct dma_buf_attachment - holds device-buffer attachment data
> + * @dmabuf: buffer for this attachment.
> + * @dev: device attached to the buffer.
> + * @node: list of dma_buf_attachment.
> + * @priv: exporter 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
> + * attached to the buffer.
> + */
> +struct dma_buf_attachment {
> + struct dma_buf *dmabuf;
> + struct device *dev;
> + struct list_head node;
> + void *priv;
> +};
> +
> +#ifdef CONFIG_DMA_SHARED_BUFFER
> +struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
> + struct device *dev);
> +void dma_buf_detach(struct dma_buf *dmabuf,
> + struct dma_buf_attachment *dmabuf_attach);
> +struct dma_buf *dma_buf_export(void *priv, struct dma_buf_ops *ops,
> + size_t size, int flags);
> +int dma_buf_fd(struct dma_buf *dmabuf);
> +struct dma_buf *dma_buf_get(int fd);
> +void dma_buf_put(struct dma_buf *dmabuf);
> +
> +struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *,
> + enum dma_data_direction);
> +void dma_buf_unmap_attachment(struct dma_buf_attachment *, struct sg_table *);
I think that you should add enum dma_data_direction as an argument
unmap function. It was mentioned that the dma_buf_attachment should keep
cached and mapped sg_table for performance reasons. The field
dma_buf_attachment::priv seams to be a natural place to keep this sg_table.
To map a buffer the exporter calls dma_map_sg. It needs dma direction
as an argument. The problem is that dma_unmap_sg also needs this
argument but dma direction is not available neither in
dma_buf_unmap_attachment nor in unmap callback. Therefore the exporter
is forced to embed returned sg_table into a bigger structure where dma
direction is remembered. Refer to function vb2_dc_dmabuf_ops_map at
link below as an example:
http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/43793/focus=43797
Regards,
Tomasz Stanislawski
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-01-25 17:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-26 9:23 [PATCH 0/3] Introduce DMA " Sumit Semwal
2011-12-26 9:23 ` [PATCH 1/3] dma-buf: Introduce dma " Sumit Semwal
2011-12-28 2:27 ` InKi Dae
2012-01-20 13:23 ` [Linaro-mm-sig] " Laurent Pinchart
2012-01-25 13:56 ` Semwal, Sumit
2012-01-26 9:58 ` Laurent Pinchart
2012-01-25 17:02 ` Tomasz Stanislawski [this message]
2012-01-25 20:07 ` Daniel Vetter
2012-01-26 5:35 ` Semwal, Sumit
2011-12-26 9:23 ` [PATCH 2/3] dma-buf: Documentation for buffer sharing framework Sumit Semwal
2012-01-01 20:09 ` Sakari Ailus
2012-01-01 23:02 ` Rob Clark
2011-12-26 9:23 ` [PATCH 3/3] dma-buf: mark EXPERIMENTAL for 1st release Sumit Semwal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F2035B1.4020204@samsung.com \
--to=t.stanislaws@samsung.com \
--cc=airlied@redhat.com \
--cc=arnd@arndb.de \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=jesse.barker@linaro.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@arm.linux.org.uk \
--cc=m.szyprowski@samsung.com \
--cc=patches@linaro.org \
--cc=rob@ti.com \
--cc=sumit.semwal@linaro.org \
--cc=sumit.semwal@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox