Loading drivers/staging/android/ion/ion-ioctl.c +3 −3 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { int fd; fd = ion_alloc_priv(data.allocation.len, fd = ion_alloc_fd(data.allocation.len, data.allocation.heap_id_mask, data.allocation.flags); if (fd < 0) Loading drivers/staging/android/ion/ion.c +53 −41 Original line number Diff line number Diff line Loading @@ -509,90 +509,102 @@ static const struct dma_buf_ops dma_buf_ops = { .unmap = ion_dma_buf_kunmap, }; int ion_alloc(size_t len, unsigned int heap_id_mask, unsigned int flags) struct dma_buf *ion_alloc_dmabuf(size_t len, unsigned int heap_id_mask, unsigned int flags) { struct ion_device *dev = internal_dev; struct ion_buffer *buffer = NULL; struct ion_heap *heap; bool type_valid = false; DEFINE_DMA_BUF_EXPORT_INFO(exp_info); struct dma_buf *dmabuf; pr_debug("%s: len %zu heap_id_mask %u flags %x\n", __func__, len, heap_id_mask, flags); /* * traverse the list of heaps available in this system in priority * order. Check the heap type is supported. * order. If the heap type is supported by the client, and matches the * request of the caller allocate from it. Repeat until allocate has * succeeded or all heaps have been tried */ len = PAGE_ALIGN(len); if (!len) return ERR_PTR(-EINVAL); down_read(&dev->lock); plist_for_each_entry(heap, &dev->heaps, node) { /* if the caller didn't specify this heap id */ if (!((1 << heap->id) & heap_id_mask)) continue; if (heap->type == ION_HEAP_TYPE_SYSTEM || heap->type == (enum ion_heap_type)ION_HEAP_TYPE_SYSTEM_SECURE) { type_valid = true; } else { pr_warn("ion_alloc heap type not supported, type:%d\n", heap->type); } buffer = ion_buffer_create(heap, dev, len, flags); if (!IS_ERR(buffer)) break; } up_read(&dev->lock); if (!type_valid) return -EINVAL; if (!buffer) return ERR_PTR(-ENODEV); return ion_alloc_priv(len, heap_id_mask, flags); if (IS_ERR(buffer)) return ERR_CAST(buffer); exp_info.ops = &dma_buf_ops; exp_info.size = buffer->size; exp_info.flags = O_RDWR; exp_info.priv = buffer; dmabuf = dma_buf_export(&exp_info); if (IS_ERR(dmabuf)) _ion_buffer_destroy(buffer); return dmabuf; } EXPORT_SYMBOL(ion_alloc); int ion_alloc_priv(size_t len, unsigned int heap_id_mask, unsigned int flags) struct dma_buf *ion_alloc(size_t len, unsigned int heap_id_mask, unsigned int flags) { struct ion_device *dev = internal_dev; struct ion_buffer *buffer = NULL; struct ion_heap *heap; DEFINE_DMA_BUF_EXPORT_INFO(exp_info); int fd; struct dma_buf *dmabuf; bool type_valid = false; pr_debug("%s: len %zu heap_id_mask %u flags %x\n", __func__, len, heap_id_mask, flags); /* * traverse the list of heaps available in this system in priority * order. If the heap type is supported by the client, and matches the * request of the caller allocate from it. Repeat until allocate has * succeeded or all heaps have been tried * order. Check the heap type is supported. */ len = PAGE_ALIGN(len); if (!len) return -EINVAL; down_read(&dev->lock); plist_for_each_entry(heap, &dev->heaps, node) { /* if the caller didn't specify this heap id */ if (!((1 << heap->id) & heap_id_mask)) continue; buffer = ion_buffer_create(heap, dev, len, flags); if (!IS_ERR(buffer)) if (heap->type == ION_HEAP_TYPE_SYSTEM || heap->type == (enum ion_heap_type)ION_HEAP_TYPE_SYSTEM_SECURE) { type_valid = true; } else { pr_warn("%s: heap type not supported, type:%d\n", __func__, heap->type); } break; } up_read(&dev->lock); if (buffer == NULL) return -ENODEV; if (!type_valid) return ERR_PTR(-EINVAL); if (IS_ERR(buffer)) return PTR_ERR(buffer); return ion_alloc_dmabuf(len, heap_id_mask, flags); } EXPORT_SYMBOL(ion_alloc); exp_info.ops = &dma_buf_ops; exp_info.size = buffer->size; exp_info.flags = O_RDWR; exp_info.priv = buffer; int ion_alloc_fd(size_t len, unsigned int heap_id_mask, unsigned int flags) { int fd; struct dma_buf *dmabuf; dmabuf = dma_buf_export(&exp_info); dmabuf = ion_alloc_dmabuf(len, heap_id_mask, flags); if (IS_ERR(dmabuf)) { _ion_buffer_destroy(buffer); return PTR_ERR(dmabuf); } Loading drivers/staging/android/ion/ion.h +1 −1 Original line number Diff line number Diff line Loading @@ -312,7 +312,7 @@ int ion_heap_map_user(struct ion_heap *heap, struct ion_buffer *buffer, int ion_heap_buffer_zero(struct ion_buffer *buffer); int ion_heap_pages_zero(struct page *page, size_t size, pgprot_t pgprot); int ion_alloc_priv(size_t len, unsigned int heap_id_mask, unsigned int flags); int ion_alloc_fd(size_t len, unsigned int heap_id_mask, unsigned int flags); /** * ion_heap_init_shrinker Loading drivers/staging/android/ion/ion_kernel.h +9 −3 Original line number Diff line number Diff line Loading @@ -13,15 +13,21 @@ #ifndef _ION_KERNEL_H #define _ION_KERNEL_H #include <linux/dma-buf.h> #include "../uapi/ion.h" #ifdef CONFIG_ION int ion_alloc(size_t len, unsigned int heap_id_mask, unsigned int flags); /* * Allocates an ion buffer. * Use IS_ERR on returned pointer to check for success. */ struct dma_buf *ion_alloc(size_t len, unsigned int heap_id_mask, unsigned int flags); #else static inline int ion_alloc(size_t len, unsigned int heap_id_mask, static inline struct dma_buf *ion_alloc(size_t len, unsigned int heap_id_mask, unsigned int flags) { return -ENOMEM; Loading Loading
drivers/staging/android/ion/ion-ioctl.c +3 −3 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { int fd; fd = ion_alloc_priv(data.allocation.len, fd = ion_alloc_fd(data.allocation.len, data.allocation.heap_id_mask, data.allocation.flags); if (fd < 0) Loading
drivers/staging/android/ion/ion.c +53 −41 Original line number Diff line number Diff line Loading @@ -509,90 +509,102 @@ static const struct dma_buf_ops dma_buf_ops = { .unmap = ion_dma_buf_kunmap, }; int ion_alloc(size_t len, unsigned int heap_id_mask, unsigned int flags) struct dma_buf *ion_alloc_dmabuf(size_t len, unsigned int heap_id_mask, unsigned int flags) { struct ion_device *dev = internal_dev; struct ion_buffer *buffer = NULL; struct ion_heap *heap; bool type_valid = false; DEFINE_DMA_BUF_EXPORT_INFO(exp_info); struct dma_buf *dmabuf; pr_debug("%s: len %zu heap_id_mask %u flags %x\n", __func__, len, heap_id_mask, flags); /* * traverse the list of heaps available in this system in priority * order. Check the heap type is supported. * order. If the heap type is supported by the client, and matches the * request of the caller allocate from it. Repeat until allocate has * succeeded or all heaps have been tried */ len = PAGE_ALIGN(len); if (!len) return ERR_PTR(-EINVAL); down_read(&dev->lock); plist_for_each_entry(heap, &dev->heaps, node) { /* if the caller didn't specify this heap id */ if (!((1 << heap->id) & heap_id_mask)) continue; if (heap->type == ION_HEAP_TYPE_SYSTEM || heap->type == (enum ion_heap_type)ION_HEAP_TYPE_SYSTEM_SECURE) { type_valid = true; } else { pr_warn("ion_alloc heap type not supported, type:%d\n", heap->type); } buffer = ion_buffer_create(heap, dev, len, flags); if (!IS_ERR(buffer)) break; } up_read(&dev->lock); if (!type_valid) return -EINVAL; if (!buffer) return ERR_PTR(-ENODEV); return ion_alloc_priv(len, heap_id_mask, flags); if (IS_ERR(buffer)) return ERR_CAST(buffer); exp_info.ops = &dma_buf_ops; exp_info.size = buffer->size; exp_info.flags = O_RDWR; exp_info.priv = buffer; dmabuf = dma_buf_export(&exp_info); if (IS_ERR(dmabuf)) _ion_buffer_destroy(buffer); return dmabuf; } EXPORT_SYMBOL(ion_alloc); int ion_alloc_priv(size_t len, unsigned int heap_id_mask, unsigned int flags) struct dma_buf *ion_alloc(size_t len, unsigned int heap_id_mask, unsigned int flags) { struct ion_device *dev = internal_dev; struct ion_buffer *buffer = NULL; struct ion_heap *heap; DEFINE_DMA_BUF_EXPORT_INFO(exp_info); int fd; struct dma_buf *dmabuf; bool type_valid = false; pr_debug("%s: len %zu heap_id_mask %u flags %x\n", __func__, len, heap_id_mask, flags); /* * traverse the list of heaps available in this system in priority * order. If the heap type is supported by the client, and matches the * request of the caller allocate from it. Repeat until allocate has * succeeded or all heaps have been tried * order. Check the heap type is supported. */ len = PAGE_ALIGN(len); if (!len) return -EINVAL; down_read(&dev->lock); plist_for_each_entry(heap, &dev->heaps, node) { /* if the caller didn't specify this heap id */ if (!((1 << heap->id) & heap_id_mask)) continue; buffer = ion_buffer_create(heap, dev, len, flags); if (!IS_ERR(buffer)) if (heap->type == ION_HEAP_TYPE_SYSTEM || heap->type == (enum ion_heap_type)ION_HEAP_TYPE_SYSTEM_SECURE) { type_valid = true; } else { pr_warn("%s: heap type not supported, type:%d\n", __func__, heap->type); } break; } up_read(&dev->lock); if (buffer == NULL) return -ENODEV; if (!type_valid) return ERR_PTR(-EINVAL); if (IS_ERR(buffer)) return PTR_ERR(buffer); return ion_alloc_dmabuf(len, heap_id_mask, flags); } EXPORT_SYMBOL(ion_alloc); exp_info.ops = &dma_buf_ops; exp_info.size = buffer->size; exp_info.flags = O_RDWR; exp_info.priv = buffer; int ion_alloc_fd(size_t len, unsigned int heap_id_mask, unsigned int flags) { int fd; struct dma_buf *dmabuf; dmabuf = dma_buf_export(&exp_info); dmabuf = ion_alloc_dmabuf(len, heap_id_mask, flags); if (IS_ERR(dmabuf)) { _ion_buffer_destroy(buffer); return PTR_ERR(dmabuf); } Loading
drivers/staging/android/ion/ion.h +1 −1 Original line number Diff line number Diff line Loading @@ -312,7 +312,7 @@ int ion_heap_map_user(struct ion_heap *heap, struct ion_buffer *buffer, int ion_heap_buffer_zero(struct ion_buffer *buffer); int ion_heap_pages_zero(struct page *page, size_t size, pgprot_t pgprot); int ion_alloc_priv(size_t len, unsigned int heap_id_mask, unsigned int flags); int ion_alloc_fd(size_t len, unsigned int heap_id_mask, unsigned int flags); /** * ion_heap_init_shrinker Loading
drivers/staging/android/ion/ion_kernel.h +9 −3 Original line number Diff line number Diff line Loading @@ -13,15 +13,21 @@ #ifndef _ION_KERNEL_H #define _ION_KERNEL_H #include <linux/dma-buf.h> #include "../uapi/ion.h" #ifdef CONFIG_ION int ion_alloc(size_t len, unsigned int heap_id_mask, unsigned int flags); /* * Allocates an ion buffer. * Use IS_ERR on returned pointer to check for success. */ struct dma_buf *ion_alloc(size_t len, unsigned int heap_id_mask, unsigned int flags); #else static inline int ion_alloc(size_t len, unsigned int heap_id_mask, static inline struct dma_buf *ion_alloc(size_t len, unsigned int heap_id_mask, unsigned int flags) { return -ENOMEM; Loading