From: Laura Abbott <lauraa@codeaurora.org>
To: Sumit Semwal <sumit.semwal@linaro.org>, linux-kernel@vger.kernel.org
Cc: linaro-kernel@lists.linaro.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org,
linux-media@vger.kernel.org
Subject: Re: [Linaro-mm-sig] [RFC 2/4] cenalloc: Constraint-Enabled Allocation helpers for dma-buf
Date: Mon, 13 Oct 2014 01:35:30 -0700 [thread overview]
Message-ID: <543B8ED2.4000207@codeaurora.org> (raw)
In-Reply-To: <1412971678-4457-3-git-send-email-sumit.semwal@linaro.org>
On 10/10/2014 1:07 PM, Sumit Semwal wrote:
> Devices sharing buffers using dma-buf could benefit from sharing their
> constraints via struct device, and dma-buf framework would manage the
> common constraints for all attached devices per buffer.
>
> With that information, we could have a 'generic' allocator helper in
> the form of a central dma-buf exporter, which can create dma-bufs, and
> allocate backing storage at the time of first call to
> dma_buf_map_attachment.
>
> This allocation would utilise the constraint-mask by matching it to
> the right allocator from a pool of allocators, and then allocating
> buffer backing storage from this allocator.
>
> The pool of allocators could be platform-dependent, allowing for
> platforms to hide the specifics of these allocators from the devices
> that access the dma-buf buffers.
>
> A sample sequence could be:
> - get handle to cenalloc_device,
> - create a dmabuf using cenalloc_buffer_create;
> - use this dmabuf to attach each device, which has its constraints
> set in the constraints mask (dev->dma_params->access_constraints_mask)
> - at each dma_buf_attach() call, dma-buf will check to see if the constraint
> mask for the device requesting attachment is compatible with the constraints
> of devices already attached to the dma-buf; returns an error if it isn't.
> - after all devices have attached, the first call to dma_buf_map_attachment()
> will allocate the backing storage for the buffer.
> - follow the dma-buf api for map / unmap etc usage.
> - detach all attachments,
> - call cenalloc_buffer_free to free the buffer if refcount reaches zero;
>
> ** IMPORTANT**
> This mechanism of delayed allocation based on constraint-enablement will work
> *ONLY IF* the first map_attachment() call is made AFTER all attach() calls are
> done.
>
My first instinct is 'I wonder which drivers will call map_attachment at
the wrong time and screw things up'. Are there any plans for
synchronization and/or debugging output to catch drivers violating this
requirement?
[...]
> +int cenalloc_phys(struct dma_buf *dmabuf,
> + phys_addr_t *addr, size_t *len)
> +{
> + struct cenalloc_buffer *buffer;
> + int ret;
> +
> + if (is_cenalloc_buffer(dmabuf))
> + buffer = (struct cenalloc_buffer *)dmabuf->priv;
> + else
> + return -EINVAL;
> +
> + if (!buffer->allocator->ops->phys) {
> + pr_err("%s: cenalloc_phys is not implemented by this allocator.\n",
> + __func__);
> + return -ENODEV;
> + }
> + mutex_lock(&buffer->lock);
> + ret = buffer->allocator->ops->phys(buffer->allocator, buffer, addr,
> + len);
> + mutex_lock(&buffer->lock);
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(cenalloc_phys);
> +
The .phys operation makes it difficult to have drivers which can
handle both contiguous and non contiguous memory (too much special
casing). Any chance we could drop this API and just have drivers
treat an sg_table with 1 entry as contiguous memory?
Thanks,
Laura
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
next prev parent reply other threads:[~2014-10-13 8:35 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-10 20:07 [RFC 0/4] dma-buf Constraints-Enabled Allocation helpers Sumit Semwal
2014-10-10 20:07 ` [RFC 1/4] dma-buf: Add constraints sharing information Sumit Semwal
2014-10-11 18:55 ` Daniel Vetter
2014-10-13 8:14 ` [Linaro-mm-sig] " Laura Abbott
2014-10-13 9:32 ` Daniel Vetter
2014-12-10 13:31 ` Sumit Semwal
2014-12-10 13:47 ` Daniel Vetter
2015-01-08 14:14 ` [Linaro-mm-sig] " Benjamin Gaignard
2014-10-10 20:07 ` [RFC 2/4] cenalloc: Constraint-Enabled Allocation helpers for dma-buf Sumit Semwal
2014-10-10 23:09 ` Greg Kroah-Hartman
2014-10-11 18:40 ` Daniel Vetter
2014-10-14 14:03 ` Sumit Semwal
2014-10-13 8:35 ` Laura Abbott [this message]
2014-10-14 14:11 ` [Linaro-mm-sig] " Sumit Semwal
2014-10-10 20:07 ` [RFC 3/4] cenalloc: Build files for constraint-enabled allocation helpers Sumit Semwal
2014-10-10 20:07 ` [RFC 4/4] cenalloc: a sample allocator for contiguous page allocation Sumit Semwal
2014-10-13 8:12 ` [Linaro-mm-sig] [RFC 0/4] dma-buf Constraints-Enabled Allocation helpers Laura Abbott
2014-10-14 14:00 ` 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=543B8ED2.4000207@codeaurora.org \
--to=lauraa@codeaurora.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=linaro-kernel@lists.linaro.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=sumit.semwal@linaro.org \
/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;
as well as URLs for NNTP newsgroup(s).