[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1476229810-26570-7-git-send-email-kandoiruchi@google.com>
Date: Tue, 11 Oct 2016 16:50:10 -0700
From: Ruchi Kandoi <kandoiruchi@...gle.com>
To: kandoiruchi@...gle.com, gregkh@...uxfoundation.org,
arve@...roid.com, riandrews@...roid.com, sumit.semwal@...aro.org,
arnd@...db.de, labbott@...hat.com, viro@...iv.linux.org.uk,
jlayton@...chiereds.net, bfields@...ldses.org, mingo@...hat.com,
peterz@...radead.org, akpm@...ux-foundation.org,
keescook@...omium.org, mhocko@...e.com, oleg@...hat.com,
john.stultz@...aro.org, mguzik@...hat.com, jdanis@...gle.com,
adobriyan@...il.com, ghackmann@...gle.com,
kirill.shutemov@...ux.intel.com, vbabka@...e.cz,
dave.hansen@...ux.intel.com, dan.j.williams@...el.com,
hannes@...xchg.org, iamjoonsoo.kim@....com, luto@...nel.org,
tj@...nel.org, vdavydov.dev@...il.com, ebiederm@...ssion.com,
linux-kernel@...r.kernel.org, devel@...verdev.osuosl.org,
linux-media@...r.kernel.org, dri-devel@...ts.freedesktop.org,
linaro-mm-sig@...ts.linaro.org, linux-fsdevel@...r.kernel.org,
linux-mm@...ck.org
Subject: [RFC 6/6] drivers: staging: ion: add ION_IOC_TAG ioctl
From: Greg Hackmann <ghackmann@...gle.com>
ION_IOC_TAG provides a userspace interface for tagging buffers with
their memtrack usage after allocation.
Signed-off-by: Ruchi Kandoi <kandoiruchi@...gle.com>
---
drivers/staging/android/ion/ion-ioctl.c | 17 +++++++++++++++++
drivers/staging/android/uapi/ion.h | 25 +++++++++++++++++++++++++
2 files changed, 42 insertions(+)
diff --git a/drivers/staging/android/ion/ion-ioctl.c b/drivers/staging/android/ion/ion-ioctl.c
index 7e7431d..8745a85 100644
--- a/drivers/staging/android/ion/ion-ioctl.c
+++ b/drivers/staging/android/ion/ion-ioctl.c
@@ -28,6 +28,7 @@ union ion_ioctl_arg {
struct ion_handle_data handle;
struct ion_custom_data custom;
struct ion_heap_query query;
+ struct ion_tag_data tag;
};
static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg *arg)
@@ -162,6 +163,22 @@ long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
case ION_IOC_HEAP_QUERY:
ret = ion_query_heaps(client, &data.query);
break;
+ case ION_IOC_TAG:
+ {
+#ifdef CONFIG_MEMTRACK
+ struct ion_handle *handle;
+
+ handle = ion_handle_get_by_id(client, data.tag.handle);
+ if (IS_ERR(handle))
+ return PTR_ERR(handle);
+ data.tag.tag[sizeof(data.tag.tag) - 1] = 0;
+ memtrack_buffer_set_tag(&handle->buffer->memtrack_buffer,
+ data.tag.tag);
+#else
+ ret = -ENOTTY;
+#endif
+ break;
+ }
default:
return -ENOTTY;
}
diff --git a/drivers/staging/android/uapi/ion.h b/drivers/staging/android/uapi/ion.h
index 14cd873..4c26196 100644
--- a/drivers/staging/android/uapi/ion.h
+++ b/drivers/staging/android/uapi/ion.h
@@ -115,6 +115,22 @@ struct ion_handle_data {
ion_user_handle_t handle;
};
+#define ION_MAX_TAG_LEN 32
+
+/**
+ * struct ion_fd_data - metadata passed from userspace for a handle
+ * @handle: a handle
+ * @tag: a string describing the buffer
+ *
+ * For ION_IOC_TAG userspace populates the handle field with
+ * the handle returned from ion alloc and type contains the memtrack_type which
+ * accurately describes the usage for the memory.
+ */
+struct ion_tag_data {
+ ion_user_handle_t handle;
+ char tag[ION_MAX_TAG_LEN];
+};
+
/**
* struct ion_custom_data - metadata passed to/from userspace for a custom ioctl
* @cmd: the custom ioctl function to call
@@ -217,6 +233,15 @@ struct ion_heap_query {
#define ION_IOC_SYNC _IOWR(ION_IOC_MAGIC, 7, struct ion_fd_data)
/**
+ * DOC: ION_IOC_TAG - adds a memtrack descriptor tag to memory
+ *
+ * Takes an ion_tag_data struct with the type field populated with a
+ * memtrack_type and handle populated with a valid opaque handle. The
+ * memtrack_type should accurately define the usage for the memory.
+ */
+#define ION_IOC_TAG _IOWR(ION_IOC_MAGIC, 8, struct ion_tag_data)
+
+/**
* DOC: ION_IOC_CUSTOM - call architecture specific ion ioctl
*
* Takes the argument of the architecture specific ioctl to call and
--
2.8.0.rc3.226.g39d4020
Powered by blists - more mailing lists