rk: ion: add buffer mmap/munmap trace
authorCMY <cmy@rock-chips.com>
Tue, 28 Oct 2014 08:17:57 +0000 (16:17 +0800)
committerCMY <cmy@rock-chips.com>
Tue, 28 Oct 2014 08:17:57 +0000 (16:17 +0800)
drivers/base/dma-buf.c
drivers/staging/android/ion/ion.c
drivers/staging/android/trace/ion.h
mm/mmap.c

index 08fe897c0b4cfcdc4c2eed939870cf46ddf57735..303afaa43ce73309329f20c64908464a55b63cfd 100644 (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.
index 99030be56d1bf3b97278bc7bd9701f3ac089db59..837f51104aefc001bd5653ed237cf8710e356a6b 100755 (executable)
@@ -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;
index 88a0d69a3dc4e9bdf907066f9b2bab840c43309f..2dcc34cf2a815094f48e0e6f86282245df2d2917 100644 (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 */
 
index 9aa554b7e620e1c0596a45035fbf0ebc3372dd0e..2e768e37c2a78ba4e56b5c26c7c72829cc271996 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -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);