rk: ion: add event tracer

This commit is contained in:
CMY
2014-10-07 11:49:02 +08:00
parent 73f665afc9
commit a7500ac9e9
2 changed files with 184 additions and 0 deletions

View File

@@ -42,6 +42,9 @@
#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
@@ -282,6 +285,8 @@ err2:
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);
@@ -546,6 +551,9 @@ struct ion_handle *ion_alloc(struct ion_client *client, size_t len,
handle = ERR_PTR(ret);
}
trace_ion_buffer_alloc(client->display_name, (unsigned int)buffer,
buffer->size);
return handle;
}
EXPORT_SYMBOL(ion_alloc);
@@ -565,6 +573,8 @@ void ion_free(struct ion_client *client, struct ion_handle *handle)
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);
@@ -674,6 +684,8 @@ void *ion_map_kernel(struct ion_client *client, struct ion_handle *handle)
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);
@@ -685,6 +697,8 @@ void ion_unmap_kernel(struct ion_client *client, struct ion_handle *handle)
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);
@@ -834,6 +848,8 @@ int ion_map_iommu(struct device *iommu_dev, struct ion_client *client,
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);
@@ -847,6 +863,9 @@ static void ion_iommu_release(struct kref *kref)
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);
@@ -899,6 +918,9 @@ void ion_unmap_iommu(struct device *iommu_dev, struct ion_client *client,
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);
@@ -1109,6 +1131,8 @@ struct ion_client *ion_client_create(struct ion_device *dev,
path, client->display_name);
}
trace_ion_client_create(client->display_name);
up_write(&dev->lock);
return client;
@@ -1145,6 +1169,8 @@ void ion_client_destroy(struct ion_client *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);
@@ -1442,6 +1468,8 @@ int ion_share_dma_buf_fd(struct ion_client *client, struct ion_handle *handle)
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);
@@ -1488,6 +1516,8 @@ struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd)
handle = ERR_PTR(ret);
}
trace_ion_buffer_import(client->display_name, (unsigned int)buffer,
buffer->size);
end:
dma_buf_put(dmabuf);
return handle;

View File

@@ -0,0 +1,154 @@
#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>