rk: ion: add buffer mmap/munmap trace

This commit is contained in:
CMY
2014-10-28 16:17:57 +08:00
parent 028772b4ef
commit 1d2449231f
4 changed files with 61 additions and 0 deletions

View File

@@ -90,6 +90,13 @@ static inline int is_dma_buf_file(struct file *file)
return file->f_op == &dma_buf_fops;
}
#ifdef CONFIG_ARCH_ROCKCHIP
int dma_buf_is_dma_buf(struct file *file)
{
return is_dma_buf_file(file);
}
#endif
/**
* dma_buf_export_named - Creates a new dma_buf, and associates an anon file
* with this buffer, so it can be exported.

View File

@@ -1361,9 +1361,22 @@ static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
pr_err("%s: failure mapping buffer to userspace\n",
__func__);
trace_ion_buffer_mmap("", (unsigned int)buffer, buffer->size,
vma->vm_start, vma->vm_end);
return ret;
}
int ion_munmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
{
struct ion_buffer *buffer = dmabuf->priv;
trace_ion_buffer_munmap("", (unsigned int)buffer, buffer->size,
vma->vm_start, vma->vm_end);
return 0;
}
static void ion_dma_buf_release(struct dma_buf *dmabuf)
{
struct ion_buffer *buffer = dmabuf->priv;

View File

@@ -146,7 +146,38 @@ 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));
DECLARE_EVENT_CLASS(ion_mmap_op,
TP_PROTO(const char* client, unsigned int buf, unsigned int size,
unsigned long vm_start, unsigned long vm_end),
TP_ARGS(client, buf, size, vm_start, vm_end),
TP_STRUCT__entry(
__string(client, client)
__field(unsigned int, buf)
__field(unsigned int, size)
__field(unsigned long, vm_start)
__field(unsigned long, vm_end)
),
TP_fast_assign(
__assign_str(client, client);
__entry->buf = buf;
__entry->size = size;
__entry->vm_start = vm_start;
__entry->vm_end = vm_end;
),
TP_printk("client=%s,buffer=%08x:%d,vma[%08lx:%08lx]",
__get_str(client), __entry->buf, __entry->size,
__entry->vm_start, __entry->vm_end)
);
DEFINE_EVENT(ion_mmap_op, ion_buffer_mmap,
TP_PROTO(const char* client, unsigned int buf, unsigned int size,
unsigned long vm_start, unsigned long vm_end),
TP_ARGS(client, buf, size, vm_start, vm_end));
DEFINE_EVENT(ion_mmap_op, ion_buffer_munmap,
TP_PROTO(const char* client, unsigned int buf, unsigned int size,
unsigned long vm_start, unsigned long vm_end),
TP_ARGS(client, buf, size, vm_start, vm_end));
#endif /* _TRACE_ION_H */

View File

@@ -2571,6 +2571,16 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
detach_vmas_to_be_unmapped(mm, vma, prev, end);
unmap_region(mm, vma, prev, start, end);
#ifdef CONFIG_ARCH_ROCKCHIP
{
extern int ion_munmap(void *dmabuf, struct vm_area_struct *vma);
extern int dma_buf_is_dma_buf(struct file *file);
if (vma->vm_file && dma_buf_is_dma_buf(vma->vm_file)) {
ion_munmap(vma->vm_file->private_data, vma);
}
}
#endif
/* Fix up all other VM information */
remove_vma_list(mm, vma);