OSDN Git Service

BACKPORT: staging: android: ion: Pull out ion ioctls to a separate file
authorLaura Abbott <labbott@redhat.com>
Wed, 7 Sep 2016 18:49:58 +0000 (11:49 -0700)
committerArian <arian.kulmer@web.de>
Tue, 19 Nov 2019 15:24:39 +0000 (16:24 +0100)
commit b1fa6d8acb50c8e90f50fb262e5d4b7d478592bf upstream.

The number of Ion ioctls may continue to grow along with necessary
validation. Pull it out into a separate file for easier management
and review.

Change-Id: I0889f08eff35d2cd149ce0f958ef05515eaaee04
Signed-off-by: Laura Abbott <labbott@redhat.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[nc: Partial backport, only needed for the next commit]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
drivers/staging/android/ion/ion.c
drivers/staging/android/ion/ion_priv.h

index 9a0b73b..5998c08 100644 (file)
 #include "ion_priv.h"
 #include "compat_ion.h"
 
-/**
- * struct ion_device - the metadata of the ion device node
- * @dev:               the actual misc device
- * @buffers:           an rb tree of all the existing buffers
- * @buffer_lock:       lock protecting the tree of buffers
- * @lock:              rwsem protecting the tree of heaps and clients
- * @heaps:             list of all the heaps in the system
- * @user_clients:      list of all the clients created from userspace
- */
-struct ion_device {
-       struct miscdevice dev;
-       struct rb_root buffers;
-       struct mutex buffer_lock;
-       struct rw_semaphore lock;
-       struct plist_head heaps;
-       long (*custom_ioctl)(struct ion_client *client, unsigned int cmd,
-                            unsigned long arg);
-       struct rb_root clients;
-       struct dentry *debug_root;
-       struct dentry *heaps_debug_root;
-       struct dentry *clients_debug_root;
-};
-
-/**
- * struct ion_client - a process/hw block local address space
- * @node:              node in the tree of all clients
- * @dev:               backpointer to ion device
- * @handles:           an rb tree of all the handles in this client
- * @idr:               an idr space for allocating handle ids
- * @lock:              lock protecting the tree of handles
- * @name:              used for debugging
- * @display_name:      used for debugging (unique version of @name)
- * @display_serial:    used for debugging (to make display_name unique)
- * @task:              used for debugging
- *
- * A client represents a list of buffers this client may access.
- * The mutex stored here is used to protect both handles tree
- * as well as the handles themselves, and should be held while modifying either.
- */
-struct ion_client {
-       struct rb_node node;
-       struct ion_device *dev;
-       struct rb_root handles;
-       struct idr idr;
-       struct mutex lock;
-       char *name;
-       char *display_name;
-       int display_serial;
-       struct task_struct *task;
-       pid_t pid;
-       struct dentry *debug_root;
-};
-
-/**
- * ion_handle - a client local reference to a buffer
- * @ref:               reference count
- * @client:            back pointer to the client the buffer resides in
- * @buffer:            pointer to the buffer
- * @node:              node in the client's handle rbtree
- * @kmap_cnt:          count of times this client has mapped to kernel
- * @id:                        client-unique id allocated by client->idr
- *
- * Modifications to node, map_cnt or mapping should be protected by the
- * lock in the client.  Other fields are never changed after initialization.
- */
-struct ion_handle {
-       struct kref ref;
-       unsigned int user_ref_count;
-       struct ion_client *client;
-       struct ion_buffer *buffer;
-       struct rb_node node;
-       unsigned int kmap_cnt;
-       int id;
-};
-
 bool ion_buffer_fault_user_mappings(struct ion_buffer *buffer)
 {
        return (buffer->flags & ION_FLAG_CACHED) &&
index 77bd0f8..a4b847c 100644 (file)
@@ -34,6 +34,7 @@
 #include <asm/cacheflush.h>
 #endif
 #include <linux/device.h>
+#include <linux/miscdevice.h>
 
 #include "ion.h"
 
@@ -98,6 +99,81 @@ struct ion_buffer {
 void ion_buffer_destroy(struct ion_buffer *buffer);
 
 /**
+ * struct ion_device - the metadata of the ion device node
+ * @dev:               the actual misc device
+ * @buffers:           an rb tree of all the existing buffers
+ * @buffer_lock:       lock protecting the tree of buffers
+ * @lock:              rwsem protecting the tree of heaps and clients
+ * @heaps:             list of all the heaps in the system
+ * @user_clients:      list of all the clients created from userspace
+ */
+struct ion_device {
+       struct miscdevice dev;
+       struct rb_root buffers;
+       struct mutex buffer_lock;
+       struct rw_semaphore lock;
+       struct plist_head heaps;
+       long (*custom_ioctl)(struct ion_client *client, unsigned int cmd,
+                            unsigned long arg);
+       struct rb_root clients;
+       struct dentry *debug_root;
+       struct dentry *heaps_debug_root;
+       struct dentry *clients_debug_root;
+};
+
+/**
+ * struct ion_client - a process/hw block local address space
+ * @node:              node in the tree of all clients
+ * @dev:               backpointer to ion device
+ * @handles:           an rb tree of all the handles in this client
+ * @idr:               an idr space for allocating handle ids
+ * @lock:              lock protecting the tree of handles
+ * @name:              used for debugging
+ * @display_name:      used for debugging (unique version of @name)
+ * @display_serial:    used for debugging (to make display_name unique)
+ * @task:              used for debugging
+ *
+ * A client represents a list of buffers this client may access.
+ * The mutex stored here is used to protect both handles tree
+ * as well as the handles themselves, and should be held while modifying either.
+ */
+struct ion_client {
+       struct rb_node node;
+       struct ion_device *dev;
+       struct rb_root handles;
+       struct idr idr;
+       struct mutex lock;
+       char *name;
+       char *display_name;
+       int display_serial;
+       struct task_struct *task;
+       pid_t pid;
+       struct dentry *debug_root;
+};
+
+/**
+ * ion_handle - a client local reference to a buffer
+ * @ref:               reference count
+ * @client:            back pointer to the client the buffer resides in
+ * @buffer:            pointer to the buffer
+ * @node:              node in the client's handle rbtree
+ * @kmap_cnt:          count of times this client has mapped to kernel
+ * @id:                        client-unique id allocated by client->idr
+ *
+ * Modifications to node, map_cnt or mapping should be protected by the
+ * lock in the client.  Other fields are never changed after initialization.
+ */
+struct ion_handle {
+       struct kref ref;
+       unsigned int user_ref_count;
+       struct ion_client *client;
+       struct ion_buffer *buffer;
+       struct rb_node node;
+       unsigned int kmap_cnt;
+       int id;
+};
+
+/**
  * struct ion_heap_ops - ops to operate on a given heap
  * @allocate:          allocate memory
  * @free:              free memory. Will be called with