Loading drivers/staging/android/ion/ion-ioctl.c +28 −0 Original line number Original line Diff line number Diff line Loading @@ -19,10 +19,12 @@ #include <linux/uaccess.h> #include <linux/uaccess.h> #include "ion.h" #include "ion.h" #include "ion_system_secure_heap.h" union ion_ioctl_arg { union ion_ioctl_arg { struct ion_allocation_data allocation; struct ion_allocation_data allocation; struct ion_heap_query query; struct ion_heap_query query; struct ion_prefetch_data prefetch_data; }; }; static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg *arg) static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg *arg) Loading Loading @@ -95,7 +97,33 @@ long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) case ION_IOC_HEAP_QUERY: case ION_IOC_HEAP_QUERY: ret = ion_query_heaps(&data.query); ret = ion_query_heaps(&data.query); break; break; case ION_IOC_PREFETCH: { int ret; ret = ion_walk_heaps(data.prefetch_data.heap_id, (enum ion_heap_type) ION_HEAP_TYPE_SYSTEM_SECURE, (void *)&data.prefetch_data, ion_system_secure_heap_prefetch); if (ret) return ret; break; } case ION_IOC_DRAIN: { int ret; ret = ion_walk_heaps(data.prefetch_data.heap_id, (enum ion_heap_type) ION_HEAP_TYPE_SYSTEM_SECURE, (void *)&data.prefetch_data, ion_system_secure_heap_drain); if (ret) return ret; break; } default: default: return -ENOTTY; return -ENOTTY; } } Loading drivers/staging/android/ion/ion_system_heap.h +2 −2 Original line number Original line Diff line number Diff line /* Copyright (c) 2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * * This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * it under the terms of the GNU General Public License version 2 and Loading @@ -9,7 +9,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * GNU General Public License for more details. */ */ #include <soc/qcom/secure_buffer.h> #include "ion.h" #include "ion.h" #ifndef _ION_SYSTEM_HEAP_H #ifndef _ION_SYSTEM_HEAP_H Loading drivers/staging/android/ion/ion_system_secure_heap.c +5 −4 Original line number Original line Diff line number Diff line /* /* * * * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved. * Copyright (c) 2014-2018, The Linux Foundation. All rights reserved. * * * This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * it under the terms of the GNU General Public License version 2 and Loading @@ -17,6 +17,7 @@ #include <soc/qcom/secure_buffer.h> #include <soc/qcom/secure_buffer.h> #include <linux/workqueue.h> #include <linux/workqueue.h> #include <linux/uaccess.h> #include <linux/uaccess.h> #include <linux/kernel.h> #include "ion_system_secure_heap.h" #include "ion_system_secure_heap.h" #include "ion_system_heap.h" #include "ion_system_heap.h" Loading @@ -37,7 +38,7 @@ struct ion_system_secure_heap { struct prefetch_info { struct prefetch_info { struct list_head list; struct list_head list; int vmid; int vmid; size_t size; u64 size; bool shrink; bool shrink; }; }; Loading Loading @@ -171,7 +172,7 @@ static void process_one_shrink(struct ion_heap *sys_heap, pool_size = ion_system_secure_heap_page_pool_total(sys_heap, pool_size = ion_system_secure_heap_page_pool_total(sys_heap, info->vmid); info->vmid); size = min(pool_size, info->size); size = min_t(size_t, pool_size, info->size); ret = sys_heap->ops->allocate(sys_heap, &buffer, size, buffer.flags); ret = sys_heap->ops->allocate(sys_heap, &buffer, size, buffer.flags); if (ret) { if (ret) { pr_debug("%s: Failed to shrink 0x%zx, ret = %d\n", pr_debug("%s: Failed to shrink 0x%zx, ret = %d\n", Loading Loading @@ -214,7 +215,7 @@ static int alloc_prefetch_info( bool shrink, struct list_head *items) bool shrink, struct list_head *items) { { struct prefetch_info *info; struct prefetch_info *info; size_t __user *user_sizes; u64 __user *user_sizes; int err; int err; unsigned int nr_sizes, vmid, i; unsigned int nr_sizes, vmid, i; Loading drivers/staging/android/ion/ion_system_secure_heap.h +1 −14 Original line number Original line Diff line number Diff line /* Copyright (c) 2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * * This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * it under the terms of the GNU General Public License version 2 and Loading @@ -15,19 +15,6 @@ #ifndef _ION_SYSTEM_SECURE_HEAP_H #ifndef _ION_SYSTEM_SECURE_HEAP_H #define _ION_SYSTEM_SECURE_HEAP_H #define _ION_SYSTEM_SECURE_HEAP_H struct ion_prefetch_regions { unsigned int vmid; size_t __user *sizes; unsigned int nr_sizes; }; struct ion_prefetch_data { int heap_id; unsigned long len; struct ion_prefetch_regions __user *regions; unsigned int nr_regions; }; int ion_system_secure_heap_prefetch(struct ion_heap *heap, void *data); int ion_system_secure_heap_prefetch(struct ion_heap *heap, void *data); int ion_system_secure_heap_drain(struct ion_heap *heap, void *data); int ion_system_secure_heap_drain(struct ion_heap *heap, void *data); Loading drivers/staging/android/uapi/msm_ion.h +23 −0 Original line number Original line Diff line number Diff line #ifndef _UAPI_LINUX_MSM_ION_H #ifndef _UAPI_LINUX_MSM_ION_H #define _UAPI_LINUX_MSM_ION_H #define _UAPI_LINUX_MSM_ION_H #include <linux/types.h> #define ION_BIT(nr) (1U << (nr)) #define ION_BIT(nr) (1U << (nr)) /** /** Loading Loading @@ -80,4 +82,25 @@ enum ion_heap_ids { */ */ #define ION_HEAP(bit) ION_BIT(bit) #define ION_HEAP(bit) ION_BIT(bit) #define ION_IOC_MSM_MAGIC 'M' struct ion_prefetch_regions { __u32 vmid; __u64 __user *sizes; __u32 nr_sizes; }; struct ion_prefetch_data { __u32 heap_id; __u64 len; struct ion_prefetch_regions __user *regions; __u32 nr_regions; }; #define ION_IOC_PREFETCH _IOWR(ION_IOC_MSM_MAGIC, 3, \ struct ion_prefetch_data) #define ION_IOC_DRAIN _IOWR(ION_IOC_MSM_MAGIC, 4, \ struct ion_prefetch_data) #endif /* _UAPI_LINUX_MSM_ION_H */ #endif /* _UAPI_LINUX_MSM_ION_H */ Loading
drivers/staging/android/ion/ion-ioctl.c +28 −0 Original line number Original line Diff line number Diff line Loading @@ -19,10 +19,12 @@ #include <linux/uaccess.h> #include <linux/uaccess.h> #include "ion.h" #include "ion.h" #include "ion_system_secure_heap.h" union ion_ioctl_arg { union ion_ioctl_arg { struct ion_allocation_data allocation; struct ion_allocation_data allocation; struct ion_heap_query query; struct ion_heap_query query; struct ion_prefetch_data prefetch_data; }; }; static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg *arg) static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg *arg) Loading Loading @@ -95,7 +97,33 @@ long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) case ION_IOC_HEAP_QUERY: case ION_IOC_HEAP_QUERY: ret = ion_query_heaps(&data.query); ret = ion_query_heaps(&data.query); break; break; case ION_IOC_PREFETCH: { int ret; ret = ion_walk_heaps(data.prefetch_data.heap_id, (enum ion_heap_type) ION_HEAP_TYPE_SYSTEM_SECURE, (void *)&data.prefetch_data, ion_system_secure_heap_prefetch); if (ret) return ret; break; } case ION_IOC_DRAIN: { int ret; ret = ion_walk_heaps(data.prefetch_data.heap_id, (enum ion_heap_type) ION_HEAP_TYPE_SYSTEM_SECURE, (void *)&data.prefetch_data, ion_system_secure_heap_drain); if (ret) return ret; break; } default: default: return -ENOTTY; return -ENOTTY; } } Loading
drivers/staging/android/ion/ion_system_heap.h +2 −2 Original line number Original line Diff line number Diff line /* Copyright (c) 2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * * This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * it under the terms of the GNU General Public License version 2 and Loading @@ -9,7 +9,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * GNU General Public License for more details. */ */ #include <soc/qcom/secure_buffer.h> #include "ion.h" #include "ion.h" #ifndef _ION_SYSTEM_HEAP_H #ifndef _ION_SYSTEM_HEAP_H Loading
drivers/staging/android/ion/ion_system_secure_heap.c +5 −4 Original line number Original line Diff line number Diff line /* /* * * * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved. * Copyright (c) 2014-2018, The Linux Foundation. All rights reserved. * * * This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * it under the terms of the GNU General Public License version 2 and Loading @@ -17,6 +17,7 @@ #include <soc/qcom/secure_buffer.h> #include <soc/qcom/secure_buffer.h> #include <linux/workqueue.h> #include <linux/workqueue.h> #include <linux/uaccess.h> #include <linux/uaccess.h> #include <linux/kernel.h> #include "ion_system_secure_heap.h" #include "ion_system_secure_heap.h" #include "ion_system_heap.h" #include "ion_system_heap.h" Loading @@ -37,7 +38,7 @@ struct ion_system_secure_heap { struct prefetch_info { struct prefetch_info { struct list_head list; struct list_head list; int vmid; int vmid; size_t size; u64 size; bool shrink; bool shrink; }; }; Loading Loading @@ -171,7 +172,7 @@ static void process_one_shrink(struct ion_heap *sys_heap, pool_size = ion_system_secure_heap_page_pool_total(sys_heap, pool_size = ion_system_secure_heap_page_pool_total(sys_heap, info->vmid); info->vmid); size = min(pool_size, info->size); size = min_t(size_t, pool_size, info->size); ret = sys_heap->ops->allocate(sys_heap, &buffer, size, buffer.flags); ret = sys_heap->ops->allocate(sys_heap, &buffer, size, buffer.flags); if (ret) { if (ret) { pr_debug("%s: Failed to shrink 0x%zx, ret = %d\n", pr_debug("%s: Failed to shrink 0x%zx, ret = %d\n", Loading Loading @@ -214,7 +215,7 @@ static int alloc_prefetch_info( bool shrink, struct list_head *items) bool shrink, struct list_head *items) { { struct prefetch_info *info; struct prefetch_info *info; size_t __user *user_sizes; u64 __user *user_sizes; int err; int err; unsigned int nr_sizes, vmid, i; unsigned int nr_sizes, vmid, i; Loading
drivers/staging/android/ion/ion_system_secure_heap.h +1 −14 Original line number Original line Diff line number Diff line /* Copyright (c) 2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * * This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * it under the terms of the GNU General Public License version 2 and Loading @@ -15,19 +15,6 @@ #ifndef _ION_SYSTEM_SECURE_HEAP_H #ifndef _ION_SYSTEM_SECURE_HEAP_H #define _ION_SYSTEM_SECURE_HEAP_H #define _ION_SYSTEM_SECURE_HEAP_H struct ion_prefetch_regions { unsigned int vmid; size_t __user *sizes; unsigned int nr_sizes; }; struct ion_prefetch_data { int heap_id; unsigned long len; struct ion_prefetch_regions __user *regions; unsigned int nr_regions; }; int ion_system_secure_heap_prefetch(struct ion_heap *heap, void *data); int ion_system_secure_heap_prefetch(struct ion_heap *heap, void *data); int ion_system_secure_heap_drain(struct ion_heap *heap, void *data); int ion_system_secure_heap_drain(struct ion_heap *heap, void *data); Loading
drivers/staging/android/uapi/msm_ion.h +23 −0 Original line number Original line Diff line number Diff line #ifndef _UAPI_LINUX_MSM_ION_H #ifndef _UAPI_LINUX_MSM_ION_H #define _UAPI_LINUX_MSM_ION_H #define _UAPI_LINUX_MSM_ION_H #include <linux/types.h> #define ION_BIT(nr) (1U << (nr)) #define ION_BIT(nr) (1U << (nr)) /** /** Loading Loading @@ -80,4 +82,25 @@ enum ion_heap_ids { */ */ #define ION_HEAP(bit) ION_BIT(bit) #define ION_HEAP(bit) ION_BIT(bit) #define ION_IOC_MSM_MAGIC 'M' struct ion_prefetch_regions { __u32 vmid; __u64 __user *sizes; __u32 nr_sizes; }; struct ion_prefetch_data { __u32 heap_id; __u64 len; struct ion_prefetch_regions __user *regions; __u32 nr_regions; }; #define ION_IOC_PREFETCH _IOWR(ION_IOC_MSM_MAGIC, 3, \ struct ion_prefetch_data) #define ION_IOC_DRAIN _IOWR(ION_IOC_MSM_MAGIC, 4, \ struct ion_prefetch_data) #endif /* _UAPI_LINUX_MSM_ION_H */ #endif /* _UAPI_LINUX_MSM_ION_H */