How create an ION buffer to be accessible by kernel

488 views
Skip to first unread message

michael s

unread,
Jan 25, 2014, 2:49:57 AM1/25/14
to android-...@googlegroups.com
Hi,

In my user space application, I allocate a buffer using
ion_alloc() and ion_map().

I am able to pass the map_fd (file descriptor return from ion_map() to my driver.
And in my driver, I get a dma_buf using dma_buf_get().
 struct dma_buf *dbuf = dma_buf_get(fd);

My question is how can I map this dma_buf to my kernel address space so that my driver code can access (read/write) this buffer?
I think I need to use dma_buf_kmap. But what should I pass to the 2nd parameter of dma_buf_kmap, the api specified the 2nd parameter is (the page in PAGE_SIZE units to map) dma_buf_kmap?
https://www.kernel.org/doc/htmldocs/device-drivers/API-dma-buf-kmap.html
 

I want the whole dma_buf to be accessible.


alexandre bailon

unread,
Jan 27, 2014, 9:19:14 AM1/27/14
to android-...@googlegroups.com
Hi,

I haven't good knowledge about dma_buf but I don't think you can use ion file descriptor to get a dma_buf.
To access map an ION buffer allocated from user space, you should use:
struct ion_handle *ion_import_fd(struct ion_client *client, int fd) and
void *ion_map_kernel(struct ion_client *client, struct ion_handle *handle)

The first function will convert the ion fd in in struct ion_handle. The second function will use the ion_handle to map the buffer.

Regards

m silverstri

unread,
Jan 27, 2014, 6:05:02 PM1/27/14
to android-...@googlegroups.com
Thanks.

Do you know how to answer my original question:

But what should I pass to the 2nd parameter of dma_buf_kmap, the api
specified the 2nd parameter is (the page in
PAGE_SIZE units to map) dma_buf_kmap?

https://www.kernel.org/doc/htmldocs/device-drivers/API-dma-buf-kmap.html

Thank you.
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "android-platform" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/android-platform/VES-0P1IWqo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> android-platfo...@googlegroups.com.
> To post to this group, send email to android-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/android-platform.
> For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages