gpu: ion: Add support for flushing via fd

Userspace clients pass fds around, not handles. Support flushing
via fd.

Change-Id: Ic22d9327e9fa72cb604c3010a2a6f798be8dfdb1
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
This commit is contained in:
Laura Abbott
2011-11-18 18:36:47 -08:00
committed by Stephen Boyd
parent 878705f82d
commit 5769ad8032
2 changed files with 22 additions and 2 deletions

View File

@@ -1020,6 +1020,8 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
struct ion_flush_data data;
unsigned long start, end;
struct ion_handle *handle = NULL;
int ret;
if (copy_from_user(&data, (void __user *)arg,
sizeof(struct ion_flush_data)))
@@ -1034,8 +1036,24 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
return -EINVAL;
}
return ion_do_cache_op(client, data.handle, data.vaddr,
data.offset, data.length, cmd);
if (!data.handle) {
handle = ion_import_dma_buf(client, data.fd);
if (IS_ERR(handle)) {
pr_info("%s: Could not import handle: %d\n",
__func__, (int)handle);
return -EINVAL;
}
}
ret = ion_do_cache_op(client,
data.handle ? data.handle : handle,
data.vaddr, data.offset, data.length,
cmd);
if (!data.handle)
ion_free(client, handle);
break;
}
case ION_IOC_GET_FLAGS:

View File

@@ -411,6 +411,7 @@ struct ion_custom_data {
/* struct ion_flush_data - data passed to ion for flushing caches
*
* @handle: handle with data to flush
* @fd: fd to flush
* @vaddr: userspace virtual address mapped with mmap
* @offset: offset into the handle to flush
* @length: length of handle to flush
@@ -421,6 +422,7 @@ struct ion_custom_data {
*/
struct ion_flush_data {
struct ion_handle *handle;
int fd;
void *vaddr;
unsigned int offset;
unsigned int length;