diff options
author | José Pekkarinen <jose.pekkarinen@nokia.com> | 2016-04-11 10:41:07 +0300 |
---|---|---|
committer | José Pekkarinen <jose.pekkarinen@nokia.com> | 2016-04-13 08:17:18 +0300 |
commit | e09b41010ba33a20a87472ee821fa407a5b8da36 (patch) | |
tree | d10dc367189862e7ca5c592f033dc3726e1df4e3 /kernel/drivers/staging/android | |
parent | f93b97fd65072de626c074dbe099a1fff05ce060 (diff) |
These changes are the raw update to linux-4.4.6-rt14. Kernel sources
are taken from kernel.org, and rt patch from the rt wiki download page.
During the rebasing, the following patch collided:
Force tick interrupt and get rid of softirq magic(I70131fb85).
Collisions have been removed because its logic was found on the
source already.
Change-Id: I7f57a4081d9deaa0d9ccfc41a6c8daccdee3b769
Signed-off-by: José Pekkarinen <jose.pekkarinen@nokia.com>
Diffstat (limited to 'kernel/drivers/staging/android')
21 files changed, 210 insertions, 180 deletions
diff --git a/kernel/drivers/staging/android/Kconfig b/kernel/drivers/staging/android/Kconfig index 8feb9048e..42b15126a 100644 --- a/kernel/drivers/staging/android/Kconfig +++ b/kernel/drivers/staging/android/Kconfig @@ -20,13 +20,23 @@ config ANDROID_TIMED_OUTPUT config ANDROID_TIMED_GPIO tristate "Android timed gpio driver" - depends on GPIOLIB && ANDROID_TIMED_OUTPUT + depends on GPIOLIB || COMPILE_TEST + depends on ANDROID_TIMED_OUTPUT default n + ---help--- + Unlike generic gpio is to allow programs to access and manipulate gpio + registers from user space, timed output/gpio is a system to allow changing + a gpio pin and restore it automatically after a specified timeout. config ANDROID_LOW_MEMORY_KILLER bool "Android Low Memory Killer" ---help--- - Registers processes to be killed when memory is low + Registers processes to be killed when low memory conditions, this is useful + as there is no particular swap space on android. + + The registered process will kills according to the priorities in android init + scripts (/init.rc), and it defines priority values with minimum free memory size + for each priority. config SYNC bool "Synchronization framework" @@ -44,7 +54,7 @@ config SW_SYNC depends on SYNC ---help--- A sync object driver that uses a 32bit counter to coordinate - syncrhronization. Useful when there is no hardware primitive backing + synchronization. Useful when there is no hardware primitive backing the synchronization. config SW_SYNC_USER diff --git a/kernel/drivers/staging/android/TODO b/kernel/drivers/staging/android/TODO index 06954cdf3..8f3ac37bf 100644 --- a/kernel/drivers/staging/android/TODO +++ b/kernel/drivers/staging/android/TODO @@ -2,16 +2,28 @@ TODO: - checkpatch.pl cleanups - sparse fixes - rename files to be not so "generic" - - make sure things build as modules properly - add proper arch dependencies as needed - audit userspace interfaces to make sure they are sane - - kuid_t should never be exposed to user space as it is - kernel internal type. Data structure for this kuid_t is: - typedef struct { - uid_t val; - } kuid_t; - - This bug is introduced by Xiong Zhou in the patch bd471258f2e09 - - ("staging: android: logger: use kuid_t instead of uid_t") + + +ion/ + - Remove ION_IOC_SYNC: Flushing for devices should be purely a kernel internal + interface on top of dma-buf. flush_for_device needs to be added to dma-buf + first. + - Remove ION_IOC_CUSTOM: Atm used for cache flushing for cpu access in some + vendor trees. Should be replaced with an ioctl on the dma-buf to expose the + begin/end_cpu_access hooks to userspace. + - Clarify the tricks ion plays with explicitly managing coherency behind the + dma api's back (this is absolutely needed for high-perf gpu drivers): Add an + explicit coherency management mode to flush_for_device to be used by drivers + which want to manage caches themselves and which indicates whether cpu caches + need flushing. + - With those removed there's probably no use for ION_IOC_IMPORT anymore either + since ion would just be the central allocator for shared buffers. + - Add dt-binding to expose cma regions as ion heaps, with the rule that any + such cma regions must already be used by some device for dma. I.e. ion only + exposes existing cma regions and doesn't reserve unecessarily memory when + booting a system which doesn't use ion. Please send patches to Greg Kroah-Hartman <greg@kroah.com> and Cc: -Brian Swetland <swetland@google.com> +Arve Hjønnevåg <arve@android.com> and Riley Andrews <riandrews@android.com> diff --git a/kernel/drivers/staging/android/ashmem.c b/kernel/drivers/staging/android/ashmem.c index c5c037ccf..3f2a3d611 100644 --- a/kernel/drivers/staging/android/ashmem.c +++ b/kernel/drivers/staging/android/ashmem.c @@ -18,7 +18,8 @@ #define pr_fmt(fmt) "ashmem: " fmt -#include <linux/module.h> +#include <linux/init.h> +#include <linux/export.h> #include <linux/file.h> #include <linux/fs.h> #include <linux/falloc.h> @@ -43,7 +44,7 @@ * @unpinned_list: The list of all ashmem areas * @file: The shmem-based backing file * @size: The size of the mapping, in bytes - * @prot_masks: The allowed protection bits, as vm_flags + * @prot_mask: The allowed protection bits, as vm_flags * * The lifecycle of this structure is from our parent file's open() until * its release(). It is also protected by 'ashmem_mutex' @@ -82,14 +83,14 @@ struct ashmem_range { /* LRU list of unpinned pages, protected by ashmem_mutex */ static LIST_HEAD(ashmem_lru_list); -/** +/* * long lru_count - The count of pages on our LRU list. * * This is protected by ashmem_mutex. */ static unsigned long lru_count; -/** +/* * ashmem_mutex - protects the list of and each individual ashmem_area * * Lock Ordering: ashmex_mutex -> i_mutex -> i_alloc_sem @@ -311,10 +312,9 @@ static ssize_t ashmem_read(struct file *file, char __user *buf, * ashmem_release is called. */ ret = __vfs_read(asma->file, buf, len, pos); - if (ret >= 0) { + if (ret >= 0) /** Update backing file pos, since f_ops->read() doesn't */ asma->file->f_pos = *pos; - } return ret; out_unlock: @@ -388,7 +388,7 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) /* ... and allocate the backing shmem file */ vmfile = shmem_file_setup(name, asma->size, vma->vm_flags); - if (unlikely(IS_ERR(vmfile))) { + if (IS_ERR(vmfile)) { ret = PTR_ERR(vmfile); goto out; } @@ -618,7 +618,8 @@ static int ashmem_pin(struct ashmem_area *asma, size_t pgstart, size_t pgend) /* Case #3: We overlap from the rear, so adjust it */ if (range->pgend <= pgend) { - range_shrink(range, range->pgstart, pgstart-1); + range_shrink(range, range->pgstart, + pgstart - 1); continue; } @@ -660,7 +661,7 @@ restart: if (page_range_subsumed_by_range(range, pgstart, pgend)) return 0; if (page_range_in_range(range, pgstart, pgend)) { - pgstart = min_t(size_t, range->pgstart, pgstart), + pgstart = min_t(size_t, range->pgstart, pgstart); pgend = max_t(size_t, range->pgend, pgend); purged |= range->purged; range_del(range); @@ -715,7 +716,7 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, unsigned long cmd, if (unlikely((pin.offset | pin.len) & ~PAGE_MASK)) return -EINVAL; - if (unlikely(((__u32) -1) - pin.offset < pin.len)) + if (unlikely(((__u32)-1) - pin.offset < pin.len)) return -EINVAL; if (unlikely(PAGE_ALIGN(asma->size) < pin.offset + pin.len)) @@ -759,7 +760,7 @@ static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ret = -EINVAL; if (!asma->file) { ret = 0; - asma->size = (size_t) arg; + asma->size = (size_t)arg; } break; case ASHMEM_GET_SIZE: @@ -833,16 +834,16 @@ static int __init ashmem_init(void) int ret; ashmem_area_cachep = kmem_cache_create("ashmem_area_cache", - sizeof(struct ashmem_area), - 0, 0, NULL); + sizeof(struct ashmem_area), + 0, 0, NULL); if (unlikely(!ashmem_area_cachep)) { pr_err("failed to create slab cache\n"); return -ENOMEM; } ashmem_range_cachep = kmem_cache_create("ashmem_range_cache", - sizeof(struct ashmem_range), - 0, 0, NULL); + sizeof(struct ashmem_range), + 0, 0, NULL); if (unlikely(!ashmem_range_cachep)) { pr_err("failed to create slab cache\n"); return -ENOMEM; @@ -860,24 +861,4 @@ static int __init ashmem_init(void) return 0; } - -static void __exit ashmem_exit(void) -{ - int ret; - - unregister_shrinker(&ashmem_shrinker); - - ret = misc_deregister(&ashmem_misc); - if (unlikely(ret)) - pr_err("failed to unregister misc device!\n"); - - kmem_cache_destroy(ashmem_range_cachep); - kmem_cache_destroy(ashmem_area_cachep); - - pr_info("unloaded\n"); -} - -module_init(ashmem_init); -module_exit(ashmem_exit); - -MODULE_LICENSE("GPL"); +device_initcall(ashmem_init); diff --git a/kernel/drivers/staging/android/ion/compat_ion.h b/kernel/drivers/staging/android/ion/compat_ion.h index c2ad5893d..9da8f9176 100644 --- a/kernel/drivers/staging/android/ion/compat_ion.h +++ b/kernel/drivers/staging/android/ion/compat_ion.h @@ -1,5 +1,4 @@ /* - * drivers/staging/android/ion/compat_ion.h * * Copyright (C) 2013 Google, Inc. diff --git a/kernel/drivers/staging/android/ion/ion.c b/kernel/drivers/staging/android/ion/ion.c index b0b96ab31..e237e9f33 100644 --- a/kernel/drivers/staging/android/ion/ion.c +++ b/kernel/drivers/staging/android/ion/ion.c @@ -1,5 +1,5 @@ /* - + * * drivers/staging/android/ion/ion.c * * Copyright (C) 2011 Google, Inc. @@ -213,10 +213,10 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap, "heap->ops->map_dma should return ERR_PTR on error")) table = ERR_PTR(-EINVAL); if (IS_ERR(table)) { - heap->ops->free(buffer); - kfree(buffer); - return ERR_CAST(table); + ret = -EINVAL; + goto err1; } + buffer->sg_table = table; if (ion_buffer_fault_user_mappings(buffer)) { int num_pages = PAGE_ALIGN(buffer->size) / PAGE_SIZE; @@ -226,7 +226,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap, buffer->pages = vmalloc(sizeof(struct page *) * num_pages); if (!buffer->pages) { ret = -ENOMEM; - goto err1; + goto err; } for_each_sg(table->sgl, sg, table->nents, i) { @@ -235,23 +235,22 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap, for (j = 0; j < sg->length / PAGE_SIZE; j++) buffer->pages[k++] = page++; } - - if (ret) - goto err; } buffer->dev = dev; buffer->size = len; INIT_LIST_HEAD(&buffer->vmas); mutex_init(&buffer->lock); - /* this will set up dma addresses for the sglist -- it is not - technically correct as per the dma api -- a specific - device isn't really taking ownership here. However, in practice on - our systems the only dma_address space is physical addresses. - Additionally, we can't afford the overhead of invalidating every - allocation via dma_map_sg. The implicit contract here is that - memory coming from the heaps is ready for dma, ie if it has a - cached mapping that mapping has been invalidated */ + /* + * this will set up dma addresses for the sglist -- it is not + * technically correct as per the dma api -- a specific + * device isn't really taking ownership here. However, in practice on + * our systems the only dma_address space is physical addresses. + * Additionally, we can't afford the overhead of invalidating every + * allocation via dma_map_sg. The implicit contract here is that + * memory coming from the heaps is ready for dma, ie if it has a + * cached mapping that mapping has been invalidated + */ for_each_sg(buffer->sg_table->sgl, sg, buffer->sg_table->nents, i) sg_dma_address(sg) = sg_phys(sg); mutex_lock(&dev->buffer_lock); @@ -261,9 +260,8 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap, err: heap->ops->unmap_dma(heap, buffer); - heap->ops->free(buffer); err1: - vfree(buffer->pages); + heap->ops->free(buffer); err2: kfree(buffer); return ERR_PTR(ret); @@ -753,8 +751,10 @@ struct ion_client *ion_client_create(struct ion_device *dev, get_task_struct(current->group_leader); task_lock(current->group_leader); pid = task_pid_nr(current->group_leader); - /* don't bother to store task struct for kernel threads, - they can't be killed anyway */ + /* + * don't bother to store task struct for kernel threads, + * they can't be killed anyway + */ if (current->group_leader->flags & PF_KTHREAD) { put_task_struct(current->group_leader); task = NULL; @@ -997,7 +997,7 @@ static void ion_vm_close(struct vm_area_struct *vma) mutex_unlock(&buffer->lock); } -static struct vm_operations_struct ion_vma_ops = { +static const struct vm_operations_struct ion_vma_ops = { .open = ion_vm_open, .close = ion_vm_close, .fault = ion_vm_fault, @@ -1103,10 +1103,10 @@ static struct dma_buf_ops dma_buf_ops = { struct dma_buf *ion_share_dma_buf(struct ion_client *client, struct ion_handle *handle) { + DEFINE_DMA_BUF_EXPORT_INFO(exp_info); struct ion_buffer *buffer; struct dma_buf *dmabuf; bool valid_handle; - DEFINE_DMA_BUF_EXPORT_INFO(exp_info); mutex_lock(&client->lock); valid_handle = ion_handle_validate(client, handle); @@ -1179,13 +1179,13 @@ struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd) mutex_unlock(&client->lock); goto end; } - mutex_unlock(&client->lock); handle = ion_handle_create(client, buffer); - if (IS_ERR(handle)) + if (IS_ERR(handle)) { + mutex_unlock(&client->lock); goto end; + } - mutex_lock(&client->lock); ret = ion_handle_add(client, handle); mutex_unlock(&client->lock); if (ret) { @@ -1466,7 +1466,6 @@ static const struct file_operations debug_heap_fops = { .release = single_release, }; -#ifdef DEBUG_HEAP_SHRINKER static int debug_shrink_set(void *data, u64 val) { struct ion_heap *heap = data; @@ -1474,15 +1473,14 @@ static int debug_shrink_set(void *data, u64 val) int objs; sc.gfp_mask = -1; - sc.nr_to_scan = 0; - - if (!val) - return 0; + sc.nr_to_scan = val; - objs = heap->shrinker.shrink(&heap->shrinker, &sc); - sc.nr_to_scan = objs; + if (!val) { + objs = heap->shrinker.count_objects(&heap->shrinker, &sc); + sc.nr_to_scan = objs; + } - heap->shrinker.shrink(&heap->shrinker, &sc); + heap->shrinker.scan_objects(&heap->shrinker, &sc); return 0; } @@ -1495,14 +1493,13 @@ static int debug_shrink_get(void *data, u64 *val) sc.gfp_mask = -1; sc.nr_to_scan = 0; - objs = heap->shrinker.shrink(&heap->shrinker, &sc); + objs = heap->shrinker.count_objects(&heap->shrinker, &sc); *val = objs; return 0; } DEFINE_SIMPLE_ATTRIBUTE(debug_shrink_fops, debug_shrink_get, debug_shrink_set, "%llu\n"); -#endif void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap) { @@ -1524,8 +1521,10 @@ void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap) heap->dev = dev; down_write(&dev->lock); - /* use negative heap->id to reverse the priority -- when traversing - the list later attempt higher id numbers first */ + /* + * use negative heap->id to reverse the priority -- when traversing + * the list later attempt higher id numbers first + */ plist_node_init(&heap->node, -heap->id); plist_add(&heap->node, &dev->heaps); debug_file = debugfs_create_file(heap->name, 0664, @@ -1540,8 +1539,7 @@ void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap) path, heap->name); } -#ifdef DEBUG_HEAP_SHRINKER - if (heap->shrinker.shrink) { + if (heap->shrinker.count_objects && heap->shrinker.scan_objects) { char debug_name[64]; snprintf(debug_name, 64, "%s_shrink", heap->name); @@ -1556,9 +1554,10 @@ void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap) path, debug_name); } } -#endif + up_write(&dev->lock); } +EXPORT_SYMBOL(ion_device_add_heap); struct ion_device *ion_device_create(long (*custom_ioctl) (struct ion_client *client, @@ -1579,6 +1578,7 @@ struct ion_device *ion_device_create(long (*custom_ioctl) ret = misc_register(&idev->dev); if (ret) { pr_err("ion: failed to register misc device.\n"); + kfree(idev); return ERR_PTR(ret); } @@ -1607,6 +1607,7 @@ debugfs_done: idev->clients = RB_ROOT; return idev; } +EXPORT_SYMBOL(ion_device_create); void ion_device_destroy(struct ion_device *dev) { @@ -1615,6 +1616,7 @@ void ion_device_destroy(struct ion_device *dev) /* XXX need to free the heaps and clients ? */ kfree(dev); } +EXPORT_SYMBOL(ion_device_destroy); void __init ion_reserve(struct ion_platform_data *data) { diff --git a/kernel/drivers/staging/android/ion/ion.h b/kernel/drivers/staging/android/ion/ion.h index 443db8459..b860c5f57 100644 --- a/kernel/drivers/staging/android/ion/ion.h +++ b/kernel/drivers/staging/android/ion/ion.h @@ -28,10 +28,12 @@ struct ion_mapper; struct ion_client; struct ion_buffer; -/* This should be removed some day when phys_addr_t's are fully - plumbed in the kernel, and all instances of ion_phys_addr_t should - be converted to phys_addr_t. For the time being many kernel interfaces - do not accept phys_addr_t's that would have to */ +/* + * This should be removed some day when phys_addr_t's are fully + * plumbed in the kernel, and all instances of ion_phys_addr_t should + * be converted to phys_addr_t. For the time being many kernel interfaces + * do not accept phys_addr_t's that would have to + */ #define ion_phys_addr_t unsigned long /** diff --git a/kernel/drivers/staging/android/ion/ion_chunk_heap.c b/kernel/drivers/staging/android/ion/ion_chunk_heap.c index 3e6ec2ee6..0813163f9 100644 --- a/kernel/drivers/staging/android/ion/ion_chunk_heap.c +++ b/kernel/drivers/staging/android/ion/ion_chunk_heap.c @@ -173,8 +173,8 @@ struct ion_heap *ion_chunk_heap_create(struct ion_platform_heap *heap_data) chunk_heap->heap.ops = &chunk_heap_ops; chunk_heap->heap.type = ION_HEAP_TYPE_CHUNK; chunk_heap->heap.flags = ION_HEAP_FLAG_DEFER_FREE; - pr_info("%s: base %lu size %zu align %ld\n", __func__, chunk_heap->base, - heap_data->size, heap_data->align); + pr_debug("%s: base %lu size %zu align %ld\n", __func__, + chunk_heap->base, heap_data->size, heap_data->align); return &chunk_heap->heap; diff --git a/kernel/drivers/staging/android/ion/ion_cma_heap.c b/kernel/drivers/staging/android/ion/ion_cma_heap.c index f4211f1be..a3446da4f 100644 --- a/kernel/drivers/staging/android/ion/ion_cma_heap.c +++ b/kernel/drivers/staging/android/ion/ion_cma_heap.c @@ -73,8 +73,8 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, if (!info->table) goto free_mem; - if (dma_common_get_sgtable - (dev, info->table, info->cpu_addr, info->handle, len)) + if (dma_get_sgtable(dev, info->table, info->cpu_addr, info->handle, + len)) goto free_table; /* keep this for memory release */ buffer->priv_virt = info; @@ -180,8 +180,10 @@ struct ion_heap *ion_cma_heap_create(struct ion_platform_heap *data) return ERR_PTR(-ENOMEM); cma_heap->heap.ops = &ion_cma_ops; - /* get device from private heaps data, later it will be - * used to make the link with reserved CMA memory */ + /* + * get device from private heaps data, later it will be + * used to make the link with reserved CMA memory + */ cma_heap->dev = data->priv; cma_heap->heap.type = ION_HEAP_TYPE_DMA; return &cma_heap->heap; diff --git a/kernel/drivers/staging/android/ion/ion_heap.c b/kernel/drivers/staging/android/ion/ion_heap.c index fd13d05b5..ca15a87f6 100644 --- a/kernel/drivers/staging/android/ion/ion_heap.c +++ b/kernel/drivers/staging/android/ion/ion_heap.c @@ -56,7 +56,7 @@ void *ion_heap_map_kernel(struct ion_heap *heap, vaddr = vmap(pages, npages, VM_MAP, pgprot); vfree(pages); - if (vaddr == NULL) + if (!vaddr) return ERR_PTR(-ENOMEM); return vaddr; @@ -352,6 +352,7 @@ struct ion_heap *ion_heap_create(struct ion_platform_heap *heap_data) heap->id = heap_data->id; return heap; } +EXPORT_SYMBOL(ion_heap_create); void ion_heap_destroy(struct ion_heap *heap) { @@ -379,3 +380,4 @@ void ion_heap_destroy(struct ion_heap *heap) heap->type); } } +EXPORT_SYMBOL(ion_heap_destroy); diff --git a/kernel/drivers/staging/android/ion/ion_page_pool.c b/kernel/drivers/staging/android/ion/ion_page_pool.c index 4b88f11e5..fd7e23e0c 100644 --- a/kernel/drivers/staging/android/ion/ion_page_pool.c +++ b/kernel/drivers/staging/android/ion/ion_page_pool.c @@ -19,7 +19,7 @@ #include <linux/err.h> #include <linux/fs.h> #include <linux/list.h> -#include <linux/module.h> +#include <linux/init.h> #include <linux/slab.h> #include <linux/swap.h> #include "ion_priv.h" @@ -116,7 +116,7 @@ static int ion_page_pool_total(struct ion_page_pool *pool, bool high) int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, int nr_to_scan) { - int freed; + int freed = 0; bool high; if (current_is_kswapd()) @@ -127,7 +127,7 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, if (nr_to_scan == 0) return ion_page_pool_total(pool, high); - for (freed = 0; freed < nr_to_scan; freed++) { + while (freed < nr_to_scan) { struct page *page; mutex_lock(&pool->mutex); @@ -141,6 +141,7 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, } mutex_unlock(&pool->mutex); ion_page_pool_free_pages(pool, page); + freed += (1 << pool->order); } return freed; @@ -173,10 +174,4 @@ static int __init ion_page_pool_init(void) { return 0; } - -static void __exit ion_page_pool_exit(void) -{ -} - -module_init(ion_page_pool_init); -module_exit(ion_page_pool_exit); +device_initcall(ion_page_pool_init); diff --git a/kernel/drivers/staging/android/ion/ion_priv.h b/kernel/drivers/staging/android/ion/ion_priv.h index 18a5f93e1..0239883bf 100644 --- a/kernel/drivers/staging/android/ion/ion_priv.h +++ b/kernel/drivers/staging/android/ion/ion_priv.h @@ -33,7 +33,7 @@ struct ion_buffer *ion_handle_buffer(struct ion_handle *handle); /** * struct ion_buffer - metadata for a particular buffer - * @ref: refernce count + * @ref: reference count * @node: node in the ion_device buffers tree * @dev: back pointer to the ion_device * @heap: back pointer to the heap the buffer came from @@ -46,7 +46,7 @@ struct ion_buffer *ion_handle_buffer(struct ion_handle *handle); * an ion_phys_addr_t (and someday a phys_addr_t) * @lock: protects the buffers cnt fields * @kmap_cnt: number of times the buffer is mapped to the kernel - * @vaddr: the kenrel mapping if kmap_cnt is not zero + * @vaddr: the kernel mapping if kmap_cnt is not zero * @dmap_cnt: number of times the buffer is mapped for dma * @sg_table: the sg table for the buffer if dmap_cnt is not zero * @pages: flat array of pages in the buffer -- used by fault @@ -266,7 +266,7 @@ void ion_heap_freelist_add(struct ion_heap *heap, struct ion_buffer *buffer); /** * ion_heap_freelist_drain - drain the deferred free list * @heap: the heap - * @size: ammount of memory to drain in bytes + * @size: amount of memory to drain in bytes * * Drains the indicated amount of memory from the deferred freelist immediately. * Returns the total amount freed. The total freed may be higher depending @@ -346,7 +346,8 @@ void ion_carveout_free(struct ion_heap *heap, ion_phys_addr_t addr, * to keep a pool of pre allocated memory to use from your heap. Keeping * a pool of memory that is ready for dma, ie any cached mapping have been * invalidated from the cache, provides a significant performance benefit on - * many systems */ + * many systems + */ /** * struct ion_page_pool - pagepool struct diff --git a/kernel/drivers/staging/android/ion/ion_system_heap.c b/kernel/drivers/staging/android/ion/ion_system_heap.c index da2a63c0a..d4c3e5512 100644 --- a/kernel/drivers/staging/android/ion/ion_system_heap.c +++ b/kernel/drivers/staging/android/ion/ion_system_heap.c @@ -27,7 +27,7 @@ #include "ion_priv.h" static gfp_t high_order_gfp_flags = (GFP_HIGHUSER | __GFP_ZERO | __GFP_NOWARN | - __GFP_NORETRY) & ~__GFP_WAIT; + __GFP_NORETRY) & ~__GFP_DIRECT_RECLAIM; static gfp_t low_order_gfp_flags = (GFP_HIGHUSER | __GFP_ZERO | __GFP_NOWARN); static const unsigned int orders[] = {8, 4, 0}; static const int num_orders = ARRAY_SIZE(orders); @@ -185,8 +185,11 @@ static void ion_system_heap_free(struct ion_buffer *buffer) struct scatterlist *sg; int i; - /* uncached pages come from the page pools, zero them before returning - for security purposes (other allocations are zerod at alloc time */ + /* + * uncached pages come from the page pools, zero them before returning + * for security purposes (other allocations are zerod at + * alloc time + */ if (!cached && !(buffer->private_flags & ION_PRIV_FLAG_SHRINKER_FREE)) ion_heap_buffer_zero(buffer); @@ -212,14 +215,26 @@ static int ion_system_heap_shrink(struct ion_heap *heap, gfp_t gfp_mask, { struct ion_system_heap *sys_heap; int nr_total = 0; - int i; + int i, nr_freed; + int only_scan = 0; sys_heap = container_of(heap, struct ion_system_heap, heap); + if (!nr_to_scan) + only_scan = 1; + for (i = 0; i < num_orders; i++) { struct ion_page_pool *pool = sys_heap->pools[i]; - nr_total += ion_page_pool_shrink(pool, gfp_mask, nr_to_scan); + nr_freed = ion_page_pool_shrink(pool, gfp_mask, nr_to_scan); + nr_total += nr_freed; + + if (!only_scan) { + nr_to_scan -= nr_freed; + /* shrink completed */ + if (nr_to_scan <= 0) + break; + } } return nr_total; diff --git a/kernel/drivers/staging/android/ion/ion_test.c b/kernel/drivers/staging/android/ion/ion_test.c index 3bc461cbb..b8dcf5a26 100644 --- a/kernel/drivers/staging/android/ion/ion_test.c +++ b/kernel/drivers/staging/android/ion/ion_test.c @@ -261,7 +261,21 @@ static int __init ion_test_probe(struct platform_device *pdev) return 0; } +static int ion_test_remove(struct platform_device *pdev) +{ + struct ion_test_device *testdev; + + testdev = platform_get_drvdata(pdev); + if (!testdev) + return -ENODATA; + + misc_deregister(&testdev->misc); + return 0; +} + +static struct platform_device *ion_test_pdev; static struct platform_driver ion_test_platform_driver = { + .remove = ion_test_remove, .driver = { .name = "ion-test", }, @@ -269,13 +283,18 @@ static struct platform_driver ion_test_platform_driver = { static int __init ion_test_init(void) { - platform_device_register_simple("ion-test", -1, NULL, 0); + ion_test_pdev = platform_device_register_simple("ion-test", + -1, NULL, 0); + if (!ion_test_pdev) + return -ENODEV; + return platform_driver_probe(&ion_test_platform_driver, ion_test_probe); } static void __exit ion_test_exit(void) { platform_driver_unregister(&ion_test_platform_driver); + platform_device_unregister(ion_test_pdev); } module_init(ion_test_init); diff --git a/kernel/drivers/staging/android/ion/tegra/Makefile b/kernel/drivers/staging/android/ion/tegra/Makefile index 11cd003fb..808f1f53f 100644 --- a/kernel/drivers/staging/android/ion/tegra/Makefile +++ b/kernel/drivers/staging/android/ion/tegra/Makefile @@ -1 +1 @@ -obj-y += tegra_ion.o +obj-$(CONFIG_ION_TEGRA) += tegra_ion.o diff --git a/kernel/drivers/staging/android/ion/tegra/tegra_ion.c b/kernel/drivers/staging/android/ion/tegra/tegra_ion.c index 5b8ef0e66..4d3c516cc 100644 --- a/kernel/drivers/staging/android/ion/tegra/tegra_ion.c +++ b/kernel/drivers/staging/android/ion/tegra/tegra_ion.c @@ -15,6 +15,7 @@ */ #include <linux/err.h> +#include <linux/module.h> #include <linux/platform_device.h> #include <linux/slab.h> #include "../ion.h" diff --git a/kernel/drivers/staging/android/lowmemorykiller.c b/kernel/drivers/staging/android/lowmemorykiller.c index feafa172b..e679d8432 100644 --- a/kernel/drivers/staging/android/lowmemorykiller.c +++ b/kernel/drivers/staging/android/lowmemorykiller.c @@ -32,7 +32,8 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include <linux/module.h> +#include <linux/init.h> +#include <linux/moduleparam.h> #include <linux/kernel.h> #include <linux/mm.h> #include <linux/oom.h> @@ -156,17 +157,20 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc) p->pid, p->comm, oom_score_adj, tasksize); } if (selected) { - lowmem_print(1, "send sigkill to %d (%s), adj %hd, size %d\n", - selected->pid, selected->comm, - selected_oom_score_adj, selected_tasksize); - lowmem_deathpending_timeout = jiffies + HZ; + task_lock(selected); + send_sig(SIGKILL, selected, 0); /* * FIXME: lowmemorykiller shouldn't abuse global OOM killer * infrastructure. There is no real reason why the selected * task should have access to the memory reserves. */ - mark_tsk_oom_victim(selected); - send_sig(SIGKILL, selected, 0); + if (selected->mm) + mark_oom_victim(selected); + task_unlock(selected); + lowmem_print(1, "send sigkill to %d (%s), adj %hd, size %d\n", + selected->pid, selected->comm, + selected_oom_score_adj, selected_tasksize); + lowmem_deathpending_timeout = jiffies + HZ; rem += selected_tasksize; } @@ -187,12 +191,12 @@ static int __init lowmem_init(void) register_shrinker(&lowmem_shrinker); return 0; } +device_initcall(lowmem_init); -static void __exit lowmem_exit(void) -{ - unregister_shrinker(&lowmem_shrinker); -} - +/* + * not really modular, but the easiest way to keep compat with existing + * bootargs behaviour is to continue using module_param here. + */ module_param_named(cost, lowmem_shrinker.seeks, int, S_IRUGO | S_IWUSR); module_param_array_named(adj, lowmem_adj, short, &lowmem_adj_size, S_IRUGO | S_IWUSR); @@ -200,8 +204,3 @@ module_param_array_named(minfree, lowmem_minfree, uint, &lowmem_minfree_size, S_IRUGO | S_IWUSR); module_param_named(debug_level, lowmem_debug_level, uint, S_IRUGO | S_IWUSR); -module_init(lowmem_init); -module_exit(lowmem_exit); - -MODULE_LICENSE("GPL"); - diff --git a/kernel/drivers/staging/android/sw_sync.c b/kernel/drivers/staging/android/sw_sync.c index c90838d36..c4ff1679e 100644 --- a/kernel/drivers/staging/android/sw_sync.c +++ b/kernel/drivers/staging/android/sw_sync.c @@ -15,11 +15,11 @@ */ #include <linux/kernel.h> +#include <linux/init.h> #include <linux/export.h> #include <linux/file.h> #include <linux/fs.h> #include <linux/miscdevice.h> -#include <linux/module.h> #include <linux/syscalls.h> #include <linux/uaccess.h> @@ -145,7 +145,7 @@ static int sw_sync_open(struct inode *inode, struct file *file) get_task_comm(task_comm, current); obj = sw_sync_timeline_create(task_comm); - if (obj == NULL) + if (!obj) return -ENOMEM; file->private_data = obj; @@ -179,14 +179,14 @@ static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj, } pt = sw_sync_pt_create(obj, data.value); - if (pt == NULL) { + if (!pt) { err = -ENOMEM; goto err; } data.name[sizeof(data.name) - 1] = '\0'; fence = sync_fence_create(data.name, pt); - if (fence == NULL) { + if (!fence) { sync_pt_free(pt); err = -ENOMEM; goto err; @@ -255,13 +255,6 @@ static int __init sw_sync_device_init(void) { return misc_register(&sw_sync_dev); } - -static void __exit sw_sync_device_remove(void) -{ - misc_deregister(&sw_sync_dev); -} - -module_init(sw_sync_device_init); -module_exit(sw_sync_device_remove); +device_initcall(sw_sync_device_init); #endif /* CONFIG_SW_SYNC_USER */ diff --git a/kernel/drivers/staging/android/sync.h b/kernel/drivers/staging/android/sync.h index a21b79fb4..61f8a3aed 100644 --- a/kernel/drivers/staging/android/sync.h +++ b/kernel/drivers/staging/android/sync.h @@ -337,11 +337,11 @@ int sync_fence_wait(struct sync_fence *fence, long timeout); #ifdef CONFIG_DEBUG_FS -extern void sync_timeline_debug_add(struct sync_timeline *obj); -extern void sync_timeline_debug_remove(struct sync_timeline *obj); -extern void sync_fence_debug_add(struct sync_fence *fence); -extern void sync_fence_debug_remove(struct sync_fence *fence); -extern void sync_dump(void); +void sync_timeline_debug_add(struct sync_timeline *obj); +void sync_timeline_debug_remove(struct sync_timeline *obj); +void sync_fence_debug_add(struct sync_fence *fence); +void sync_fence_debug_remove(struct sync_fence *fence); +void sync_dump(void); #else # define sync_timeline_debug_add(obj) diff --git a/kernel/drivers/staging/android/timed_gpio.c b/kernel/drivers/staging/android/timed_gpio.c index 938a35cd9..ce11726f1 100644 --- a/kernel/drivers/staging/android/timed_gpio.c +++ b/kernel/drivers/staging/android/timed_gpio.c @@ -61,9 +61,9 @@ static int gpio_get_time(struct timed_output_dev *dev) static void gpio_enable(struct timed_output_dev *dev, int value) { - struct timed_gpio_data *data = + struct timed_gpio_data *data = container_of(dev, struct timed_gpio_data, dev); - unsigned long flags; + unsigned long flags; spin_lock_irqsave(&data->lock, flags); diff --git a/kernel/drivers/staging/android/timed_output.c b/kernel/drivers/staging/android/timed_output.c index b41429f37..aff9cdb00 100644 --- a/kernel/drivers/staging/android/timed_output.c +++ b/kernel/drivers/staging/android/timed_output.c @@ -16,7 +16,8 @@ #define pr_fmt(fmt) "timed_output: " fmt -#include <linux/module.h> +#include <linux/init.h> +#include <linux/export.h> #include <linux/types.h> #include <linux/device.h> #include <linux/fs.h> @@ -106,15 +107,4 @@ static int __init timed_output_init(void) { return create_timed_output_class(); } - -static void __exit timed_output_exit(void) -{ - class_destroy(timed_output_class); -} - -module_init(timed_output_init); -module_exit(timed_output_exit); - -MODULE_AUTHOR("Mike Lockwood <lockwood@android.com>"); -MODULE_DESCRIPTION("timed output class driver"); -MODULE_LICENSE("GPL"); +device_initcall(timed_output_init); diff --git a/kernel/drivers/staging/android/uapi/ion.h b/kernel/drivers/staging/android/uapi/ion.h index 6aa495673..0a8e40f92 100644 --- a/kernel/drivers/staging/android/uapi/ion.h +++ b/kernel/drivers/staging/android/uapi/ion.h @@ -40,8 +40,10 @@ enum ion_heap_type { ION_HEAP_TYPE_CARVEOUT, ION_HEAP_TYPE_CHUNK, ION_HEAP_TYPE_DMA, - ION_HEAP_TYPE_CUSTOM, /* must be last so device specific heaps always - are at the end of this enum */ + ION_HEAP_TYPE_CUSTOM, /* + * must be last so device specific heaps always + * are at the end of this enum + */ ION_NUM_HEAPS = 16, }; @@ -56,13 +58,18 @@ enum ion_heap_type { * allocation flags - the lower 16 bits are used by core ion, the upper 16 * bits are reserved for use by the heaps themselves. */ -#define ION_FLAG_CACHED 1 /* mappings of this buffer should be - cached, ion will do cache - maintenance when the buffer is - mapped for dma */ -#define ION_FLAG_CACHED_NEEDS_SYNC 2 /* mappings of this buffer will created - at mmap time, if this is set - caches must be managed manually */ +#define ION_FLAG_CACHED 1 /* + * mappings of this buffer should be + * cached, ion will do cache + * maintenance when the buffer is + * mapped for dma + */ +#define ION_FLAG_CACHED_NEEDS_SYNC 2 /* + * mappings of this buffer will created + * at mmap time, if this is set + * caches must be managed + * manually + */ /** * DOC: Ion Userspace API @@ -179,7 +186,7 @@ struct ion_custom_data { * DOC: ION_IOC_SYNC - syncs a shared file descriptors to memory * * Deprecated in favor of using the dma_buf api's correctly (syncing - * will happend automatically when the buffer is mapped to a device). + * will happen automatically when the buffer is mapped to a device). * If necessary should be used after touching a cached buffer from the cpu, * this will make the buffer in memory coherent. */ |