#include "ion_priv.h"
#include "compat_ion.h"
+#define CREATE_TRACE_POINTS
+#include "../trace/ion.h"
+
/**
* struct ion_device - the metadata of the ion device node
* @dev: the actual misc device
void ion_buffer_destroy(struct ion_buffer *buffer)
{
+ trace_ion_buffer_destroy("", (unsigned int)buffer, buffer->size);
+
if (WARN_ON(buffer->kmap_cnt > 0))
buffer->heap->ops->unmap_kernel(buffer->heap, buffer);
buffer->heap->ops->unmap_dma(buffer->heap, buffer);
handle = ERR_PTR(ret);
}
+ trace_ion_buffer_alloc(client->display_name, (unsigned int)buffer,
+ buffer->size);
+
return handle;
}
EXPORT_SYMBOL(ion_alloc);
return;
}
mutex_unlock(&client->lock);
+ trace_ion_buffer_free(client->display_name, (unsigned int)handle->buffer,
+ handle->buffer->size);
ion_handle_put(handle);
}
EXPORT_SYMBOL(ion_free);
vaddr = ion_handle_kmap_get(handle);
mutex_unlock(&buffer->lock);
mutex_unlock(&client->lock);
+ trace_ion_kernel_map(client->display_name, (unsigned int)buffer,
+ buffer->size, (unsigned int)vaddr);
return vaddr;
}
EXPORT_SYMBOL(ion_map_kernel);
mutex_lock(&client->lock);
buffer = handle->buffer;
mutex_lock(&buffer->lock);
+ trace_ion_kernel_unmap(client->display_name, (unsigned int)buffer,
+ buffer->size);
ion_handle_kmap_put(handle);
mutex_unlock(&buffer->lock);
mutex_unlock(&client->lock);
if (!ret)
buffer->iommu_map_cnt++;
*size = buffer->size;
+ trace_ion_iommu_map(client->display_name, (unsigned int)buffer, buffer->size,
+ dev_name(iommu_dev), *iova, *size, buffer->iommu_map_cnt);
out:
mutex_unlock(&buffer->lock);
mutex_unlock(&client->lock);
ref);
struct ion_buffer *buffer = map->buffer;
+ trace_ion_iommu_release("", (unsigned int)buffer, buffer->size,
+ "", map->iova_addr, map->mapped_size, buffer->iommu_map_cnt);
+
rb_erase(&map->node, &buffer->iommu_maps);
buffer->heap->ops->unmap_iommu((struct device*)map->key, map);
kfree(map);
buffer->iommu_map_cnt--;
+ trace_ion_iommu_unmap(client->display_name, (unsigned int)buffer, buffer->size,
+ dev_name(iommu_dev), iommu_map->iova_addr,
+ iommu_map->mapped_size, buffer->iommu_map_cnt);
out:
mutex_unlock(&buffer->lock);
mutex_unlock(&client->lock);
path, client->display_name);
}
+ trace_ion_client_create(client->display_name);
+
up_write(&dev->lock);
return client;
debugfs_remove_recursive(client->debug_root);
up_write(&dev->lock);
+ trace_ion_client_destroy(client->display_name);
+
kfree(client->display_name);
kfree(client->name);
kfree(client);
if (fd < 0)
dma_buf_put(dmabuf);
+ trace_ion_buffer_share(client->display_name, (unsigned int)handle->buffer,
+ handle->buffer->size, fd);
return fd;
}
EXPORT_SYMBOL(ion_share_dma_buf_fd);
handle = ERR_PTR(ret);
}
+ trace_ion_buffer_import(client->display_name, (unsigned int)buffer,
+ buffer->size);
end:
dma_buf_put(dmabuf);
return handle;
--- /dev/null
+#undef TRACE_SYSTEM
+#define TRACE_INCLUDE_PATH ../../drivers/staging/android/trace
+#define TRACE_SYSTEM ion
+
+#if !defined(_TRACE_ION_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_ION_H
+
+#include <linux/tracepoint.h>
+
+DECLARE_EVENT_CLASS(ion_buffer_op,
+ TP_PROTO(const char* client, unsigned int buf, unsigned int size),
+ TP_ARGS(client, buf, size),
+ TP_STRUCT__entry(
+ __string(client, client)
+ __field(unsigned int, buf)
+ __field(unsigned int, size)
+ ),
+ TP_fast_assign(
+ __assign_str(client, client);
+ __entry->buf = buf;
+ __entry->size = size;
+ ),
+ TP_printk("client=%s,buffer=%08x:%d",
+ __get_str(client), __entry->buf, __entry->size)
+);
+DEFINE_EVENT(ion_buffer_op, ion_buffer_alloc,
+ TP_PROTO(const char* client, unsigned int buffer, unsigned int size),
+ TP_ARGS(client, buffer, size));
+
+DEFINE_EVENT(ion_buffer_op, ion_buffer_free,
+ TP_PROTO(const char* client, unsigned int buffer, unsigned int size),
+ TP_ARGS(client, buffer, size));
+
+DEFINE_EVENT(ion_buffer_op, ion_buffer_import,
+ TP_PROTO(const char* client, unsigned int buffer, unsigned int size),
+ TP_ARGS(client, buffer, size));
+
+DEFINE_EVENT(ion_buffer_op, ion_buffer_destroy,
+ TP_PROTO(const char* client, unsigned int buffer, unsigned int size),
+ TP_ARGS(client, buffer, size));
+
+DEFINE_EVENT(ion_buffer_op, ion_kernel_unmap,
+ TP_PROTO(const char* client, unsigned int buffer, unsigned int size),
+ TP_ARGS(client, buffer, size));
+
+TRACE_EVENT(ion_buffer_share,
+ TP_PROTO(const char* client, unsigned int buf, unsigned int size, int fd),
+ TP_ARGS(client, buf, size, fd),
+ TP_STRUCT__entry(
+ __string(client, client)
+ __field(unsigned int, buf)
+ __field(unsigned int, size)
+ __field(int, fd)
+ ),
+ TP_fast_assign(
+ __assign_str(client, client);
+ __entry->buf = buf;
+ __entry->size = size;
+ __entry->fd = fd;
+ ),
+ TP_printk("client=%s,buffer=%08x:%d,fd=%d",
+ __get_str(client), __entry->buf, __entry->size, __entry->fd)
+);
+
+DECLARE_EVENT_CLASS(ion_client_op,
+ TP_PROTO(const char* client),
+ TP_ARGS(client),
+ TP_STRUCT__entry(
+ __string(client, client)
+ ),
+ TP_fast_assign(
+ __assign_str(client, client);
+ ),
+ TP_printk("client=%s", __get_str(client))
+);
+DEFINE_EVENT(ion_client_op, ion_client_create,
+ TP_PROTO(const char* client),
+ TP_ARGS(client));
+DEFINE_EVENT(ion_client_op, ion_client_destroy,
+ TP_PROTO(const char* client),
+ TP_ARGS(client));
+
+DECLARE_EVENT_CLASS(ion_iommu_op,
+ TP_PROTO(const char* client, unsigned int buf, unsigned int size,
+ const char* iommu_dev, unsigned int iommu_addr,
+ unsigned int iommu_size, unsigned int map_cnt),
+ TP_ARGS(client, buf, size, iommu_dev, iommu_addr, iommu_size, map_cnt),
+ TP_STRUCT__entry(
+ __string(client, client)
+ __field(unsigned int, buf)
+ __field(unsigned int, size)
+ __string(iommu_dev, iommu_dev)
+ __field(unsigned int, iommu_addr)
+ __field(unsigned int, iommu_size)
+ __field(unsigned int, map_cnt)
+ ),
+ TP_fast_assign(
+ __assign_str(client, client);
+ __entry->buf = buf;
+ __entry->size = size;
+ __assign_str(iommu_dev, iommu_dev);
+ __entry->iommu_addr = iommu_addr;
+ __entry->iommu_size = iommu_size;
+ __entry->map_cnt = map_cnt;
+ ),
+ TP_printk("client=%s,buffer=%08x:%d,iommu=%s,map=%08x:%d,map_count=%d",
+ __get_str(client), __entry->buf, __entry->size,
+ __get_str(iommu_dev), __entry->iommu_addr, __entry->iommu_size,
+ __entry->map_cnt)
+);
+DEFINE_EVENT(ion_iommu_op, ion_iommu_map,
+ TP_PROTO(const char* client, unsigned int buf, unsigned int size,
+ const char* iommu_dev, unsigned int iommu_addr,
+ unsigned int iommu_size, unsigned int map_cnt),
+ TP_ARGS(client, buf, size, iommu_dev, iommu_addr, iommu_size, map_cnt));
+DEFINE_EVENT(ion_iommu_op, ion_iommu_unmap,
+ TP_PROTO(const char* client, unsigned int buf, unsigned int size,
+ const char* iommu_dev, unsigned int iommu_addr,
+ unsigned int iommu_size, unsigned int map_cnt),
+ TP_ARGS(client, buf, size, iommu_dev, iommu_addr, iommu_size, map_cnt));
+DEFINE_EVENT(ion_iommu_op, ion_iommu_release,
+ TP_PROTO(const char* client, unsigned int buf, unsigned int size,
+ const char* iommu_dev, unsigned int iommu_addr,
+ unsigned int iommu_size, unsigned int map_cnt),
+ TP_ARGS(client, buf, size, iommu_dev, iommu_addr, iommu_size, map_cnt));
+
+DECLARE_EVENT_CLASS(ion_kmap_op,
+ TP_PROTO(const char* client, unsigned int buf, unsigned int size, unsigned int kaddr),
+ TP_ARGS(client, buf, size, kaddr),
+ TP_STRUCT__entry(
+ __string(client, client)
+ __field(unsigned int, buf)
+ __field(unsigned int, size)
+ __field(unsigned int, kaddr)
+ ),
+ TP_fast_assign(
+ __assign_str(client, client);
+ __entry->buf = buf;
+ __entry->size = size;
+ __entry->kaddr = kaddr;
+ ),
+ TP_printk("client=%s,buffer=%08x:%d,kaddr=%08x",
+ __get_str(client), __entry->buf, __entry->size, __entry->kaddr)
+);
+DEFINE_EVENT(ion_kmap_op, ion_kernel_map,
+ TP_PROTO(const char* client, unsigned int buffer, unsigned int size, unsigned int kaddr),
+ TP_ARGS(client, buffer, size, kaddr));
+
+
+
+#endif /* _TRACE_ION_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>