From: kfx Date: Mon, 19 Mar 2012 08:02:18 +0000 (+0800) Subject: ion drivers: add 'query client infomation' interface for vpu X-Git-Tag: firefly_0821_release~9600^2~4 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=bbe02462c15d40dc7118df6fb0a950b285da5e7c;p=firefly-linux-kernel-4.4.55.git ion drivers: add 'query client infomation' interface for vpu --- diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c index 378e6b1feef3..f5074c0348d4 100755 --- a/drivers/gpu/ion/ion.c +++ b/drivers/gpu/ion/ion.c @@ -1111,6 +1111,40 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) return err; break; } + case ION_GET_CLIENT: + { + struct ion_handle *handle; + struct ion_client_data data; + struct rb_node *n; + + if (copy_from_user(&data, (void __user *)arg, + sizeof(struct ion_client_data))) + return -EFAULT; + + mutex_lock(&client->lock); + switch (data.type) { + case ION_TYPE_GET_TOTAL_SIZE: + data.total_size = 0; + for (n = rb_first(&client->handles); n; n = rb_next(n)) { + handle = rb_entry(n, struct ion_handle, node); + data.total_size += handle->buffer->size; + } + break; + case ION_TYPE_SIZE_GET_COUNT: + data.count = 0; + for (n = rb_first(&client->handles); n; n = rb_next(n)) { + handle = rb_entry(n, struct ion_handle, node); + if(handle->buffer->size == data.size) + data.count++; + } + break; + } + mutex_unlock(&client->lock); + if (copy_to_user((void __user *)arg, &data, + sizeof(struct ion_client_data))) + return -EFAULT; + break; + } default: return -ENOTTY; } diff --git a/include/linux/ion.h b/include/linux/ion.h index 202766b7d0e5..1063072b28fb 100755 --- a/include/linux/ion.h +++ b/include/linux/ion.h @@ -312,6 +312,16 @@ struct ion_flush_data { void *virt; size_t size; }; +struct ion_client_data { +#define ION_TYPE_GET_TOTAL_SIZE 0 +#define ION_TYPE_SIZE_GET_COUNT 1 + unsigned int type; + union { + size_t size; + size_t total_size; + }; + unsigned int count; +}; #define ION_IOC_MAGIC 'I' /** @@ -371,4 +381,5 @@ struct ion_flush_data { #define ION_CACHE_CLEAN _IOWR(ION_IOC_MAGIC, 8, struct ion_flush_data) #define ION_CACHE_INVALID _IOWR(ION_IOC_MAGIC, 9, struct ion_flush_data) #define ION_GET_PHYS _IOWR(ION_IOC_MAGIC, 10, unsigned long) +#define ION_GET_CLIENT _IOWR(ION_IOC_MAGIC, 11, struct ion_client_data) #endif /* _LINUX_ION_H */