Loading drivers/staging/android/ion/ion.c +42 −29 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ * drivers/staging/android/ion/ion.c * * Copyright (C) 2011 Google, Inc. * Copyright (c) 2011-2016, The Linux Foundation. All rights reserved. * Copyright (c) 2011-2017, The Linux Foundation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and Loading Loading @@ -122,8 +122,6 @@ struct ion_handle { int id; }; static struct ion_device *ion_dev; bool ion_buffer_fault_user_mappings(struct ion_buffer *buffer) { return (buffer->flags & ION_FLAG_CACHED) && Loading Loading @@ -844,32 +842,45 @@ void ion_unmap_kernel(struct ion_client *client, struct ion_handle *handle) } EXPORT_SYMBOL(ion_unmap_kernel); static int ion_debug_client_show(struct seq_file *s, void *unused) static struct mutex debugfs_mutex; static struct rb_root *ion_root_client; static int is_client_alive(struct ion_client *client) { struct ion_client *client = s->private; struct rb_node *n, *cnode; bool found = false; struct rb_node *node; struct ion_client *tmp; struct ion_device *dev; down_write(&ion_dev->lock); node = ion_root_client->rb_node; dev = container_of(ion_root_client, struct ion_device, clients); if (!client || (client->dev != ion_dev)) { up_write(&ion_dev->lock); return -EINVAL; down_read(&dev->lock); while (node) { tmp = rb_entry(node, struct ion_client, node); if (client < tmp) { node = node->rb_left; } else if (client > tmp) { node = node->rb_right; } else { up_read(&dev->lock); return 1; } cnode = rb_first(&ion_dev->clients); for ( ; cnode; cnode = rb_next(cnode)) { struct ion_client *c = rb_entry(cnode, struct ion_client, node); if (client == c) { found = true; break; } up_read(&dev->lock); return 0; } if (!found) { up_write(&ion_dev->lock); return -EINVAL; static int ion_debug_client_show(struct seq_file *s, void *unused) { struct ion_client *client = s->private; struct rb_node *n; mutex_lock(&debugfs_mutex); if (!is_client_alive(client)) { seq_printf(s, "ion_client 0x%pK dead, can't dump its buffers\n", client); mutex_unlock(&debugfs_mutex); return 0; } seq_printf(s, "%16.16s: %16.16s : %16.16s : %12.12s\n", Loading @@ -890,7 +901,7 @@ static int ion_debug_client_show(struct seq_file *s, void *unused) seq_printf(s, "\n"); } mutex_unlock(&client->lock); up_write(&ion_dev->lock); mutex_unlock(&debugfs_mutex); return 0; } Loading Loading @@ -1021,7 +1032,7 @@ void ion_client_destroy(struct ion_client *client) struct rb_node *n; pr_debug("%s: %d\n", __func__, __LINE__); mutex_lock(&client->lock); mutex_lock(&debugfs_mutex); while ((n = rb_first(&client->handles))) { struct ion_handle *handle = rb_entry(n, struct ion_handle, node); Loading @@ -1029,7 +1040,6 @@ void ion_client_destroy(struct ion_client *client) } idr_destroy(&client->idr); mutex_unlock(&client->lock); down_write(&dev->lock); if (client->task) Loading @@ -1042,6 +1052,7 @@ void ion_client_destroy(struct ion_client *client) kfree(client->display_name); kfree(client->name); kfree(client); mutex_unlock(&debugfs_mutex); } EXPORT_SYMBOL(ion_client_destroy); Loading Loading @@ -1838,7 +1849,7 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused) seq_printf(s, "%16s %16s %16s\n", "client", "pid", "size"); seq_puts(s, "----------------------------------------------------\n"); down_read(&dev->lock); mutex_lock(&debugfs_mutex); for (n = rb_first(&dev->clients); n; n = rb_next(n)) { struct ion_client *client = rb_entry(n, struct ion_client, node); Loading @@ -1857,7 +1868,8 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused) client->pid, size); } } up_read(&dev->lock); mutex_unlock(&debugfs_mutex); seq_puts(s, "----------------------------------------------------\n"); seq_puts(s, "orphaned allocations (info is from last known client):\n"); mutex_lock(&dev->buffer_lock); Loading Loading @@ -2095,7 +2107,8 @@ debugfs_done: init_rwsem(&idev->lock); plist_head_init(&idev->heaps); idev->clients = RB_ROOT; ion_dev = idev; ion_root_client = &idev->clients; mutex_init(&debugfs_mutex); return idev; } EXPORT_SYMBOL(ion_device_create); Loading Loading
drivers/staging/android/ion/ion.c +42 −29 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ * drivers/staging/android/ion/ion.c * * Copyright (C) 2011 Google, Inc. * Copyright (c) 2011-2016, The Linux Foundation. All rights reserved. * Copyright (c) 2011-2017, The Linux Foundation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and Loading Loading @@ -122,8 +122,6 @@ struct ion_handle { int id; }; static struct ion_device *ion_dev; bool ion_buffer_fault_user_mappings(struct ion_buffer *buffer) { return (buffer->flags & ION_FLAG_CACHED) && Loading Loading @@ -844,32 +842,45 @@ void ion_unmap_kernel(struct ion_client *client, struct ion_handle *handle) } EXPORT_SYMBOL(ion_unmap_kernel); static int ion_debug_client_show(struct seq_file *s, void *unused) static struct mutex debugfs_mutex; static struct rb_root *ion_root_client; static int is_client_alive(struct ion_client *client) { struct ion_client *client = s->private; struct rb_node *n, *cnode; bool found = false; struct rb_node *node; struct ion_client *tmp; struct ion_device *dev; down_write(&ion_dev->lock); node = ion_root_client->rb_node; dev = container_of(ion_root_client, struct ion_device, clients); if (!client || (client->dev != ion_dev)) { up_write(&ion_dev->lock); return -EINVAL; down_read(&dev->lock); while (node) { tmp = rb_entry(node, struct ion_client, node); if (client < tmp) { node = node->rb_left; } else if (client > tmp) { node = node->rb_right; } else { up_read(&dev->lock); return 1; } cnode = rb_first(&ion_dev->clients); for ( ; cnode; cnode = rb_next(cnode)) { struct ion_client *c = rb_entry(cnode, struct ion_client, node); if (client == c) { found = true; break; } up_read(&dev->lock); return 0; } if (!found) { up_write(&ion_dev->lock); return -EINVAL; static int ion_debug_client_show(struct seq_file *s, void *unused) { struct ion_client *client = s->private; struct rb_node *n; mutex_lock(&debugfs_mutex); if (!is_client_alive(client)) { seq_printf(s, "ion_client 0x%pK dead, can't dump its buffers\n", client); mutex_unlock(&debugfs_mutex); return 0; } seq_printf(s, "%16.16s: %16.16s : %16.16s : %12.12s\n", Loading @@ -890,7 +901,7 @@ static int ion_debug_client_show(struct seq_file *s, void *unused) seq_printf(s, "\n"); } mutex_unlock(&client->lock); up_write(&ion_dev->lock); mutex_unlock(&debugfs_mutex); return 0; } Loading Loading @@ -1021,7 +1032,7 @@ void ion_client_destroy(struct ion_client *client) struct rb_node *n; pr_debug("%s: %d\n", __func__, __LINE__); mutex_lock(&client->lock); mutex_lock(&debugfs_mutex); while ((n = rb_first(&client->handles))) { struct ion_handle *handle = rb_entry(n, struct ion_handle, node); Loading @@ -1029,7 +1040,6 @@ void ion_client_destroy(struct ion_client *client) } idr_destroy(&client->idr); mutex_unlock(&client->lock); down_write(&dev->lock); if (client->task) Loading @@ -1042,6 +1052,7 @@ void ion_client_destroy(struct ion_client *client) kfree(client->display_name); kfree(client->name); kfree(client); mutex_unlock(&debugfs_mutex); } EXPORT_SYMBOL(ion_client_destroy); Loading Loading @@ -1838,7 +1849,7 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused) seq_printf(s, "%16s %16s %16s\n", "client", "pid", "size"); seq_puts(s, "----------------------------------------------------\n"); down_read(&dev->lock); mutex_lock(&debugfs_mutex); for (n = rb_first(&dev->clients); n; n = rb_next(n)) { struct ion_client *client = rb_entry(n, struct ion_client, node); Loading @@ -1857,7 +1868,8 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused) client->pid, size); } } up_read(&dev->lock); mutex_unlock(&debugfs_mutex); seq_puts(s, "----------------------------------------------------\n"); seq_puts(s, "orphaned allocations (info is from last known client):\n"); mutex_lock(&dev->buffer_lock); Loading Loading @@ -2095,7 +2107,8 @@ debugfs_done: init_rwsem(&idev->lock); plist_head_init(&idev->heaps); idev->clients = RB_ROOT; ion_dev = idev; ion_root_client = &idev->clients; mutex_init(&debugfs_mutex); return idev; } EXPORT_SYMBOL(ion_device_create); Loading