From 17fcda65fdffbfecd5026bbfc3e112c56764a4dd Mon Sep 17 00:00:00 2001 From: Sooyong Suk Date: Fri, 2 Aug 2024 17:54:45 +0900 Subject: [PATCH] ANDROID: dma-heap: add vendor hook for dma heap alloc Add start/end tracepoints around the allocate dma_heap_op call. Bug: 351175506 Change-Id: Iaff719c6b7a64ac05236990e1194f51cbb10448b Signed-off-by: Sooyong Suk --- drivers/android/vendor_hooks.c | 2 ++ drivers/dma-buf/dma-heap.c | 10 +++++++++- include/trace/hooks/dmabuf.h | 7 +++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 71c39666160c..29bfdb257cb1 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -345,3 +345,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_cache_readahead_start); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_cache_readahead_end); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_filemap_fault_start); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_filemap_fault_end); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dma_heap_buffer_alloc_start); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dma_heap_buffer_alloc_end); diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c index bf18aa205fdf..104430200586 100644 --- a/drivers/dma-buf/dma-heap.c +++ b/drivers/dma-buf/dma-heap.c @@ -17,6 +17,7 @@ #include #include #include +#include #define DEVNAME "dma_heap" @@ -79,6 +80,8 @@ struct dma_buf *dma_heap_buffer_alloc(struct dma_heap *heap, size_t len, u32 fd_flags, u64 heap_flags) { + struct dma_buf *dma_buf; + if (fd_flags & ~DMA_HEAP_VALID_FD_FLAGS) return ERR_PTR(-EINVAL); @@ -92,7 +95,12 @@ struct dma_buf *dma_heap_buffer_alloc(struct dma_heap *heap, size_t len, if (!len) return ERR_PTR(-EINVAL); - return heap->ops->allocate(heap, len, fd_flags, heap_flags); + trace_android_vh_dma_heap_buffer_alloc_start(heap->name, len, + fd_flags, heap_flags); + dma_buf = heap->ops->allocate(heap, len, fd_flags, heap_flags); + trace_android_vh_dma_heap_buffer_alloc_end(heap->name, len); + + return dma_buf; } EXPORT_SYMBOL_GPL(dma_heap_buffer_alloc); diff --git a/include/trace/hooks/dmabuf.h b/include/trace/hooks/dmabuf.h index aa58f36c6fb1..6b3233734ed4 100644 --- a/include/trace/hooks/dmabuf.h +++ b/include/trace/hooks/dmabuf.h @@ -15,6 +15,13 @@ struct dma_buf_sysfs_entry; DECLARE_RESTRICTED_HOOK(android_rvh_dma_buf_stats_teardown, TP_PROTO(struct dma_buf_sysfs_entry *sysfs_entry, bool *skip_sysfs_release), TP_ARGS(sysfs_entry, skip_sysfs_release), 1); +DECLARE_HOOK(android_vh_dma_heap_buffer_alloc_start, + TP_PROTO(const char *name, size_t len, + u32 fd_flags, u64 heap_flags), + TP_ARGS(name, len, fd_flags, heap_flags)); +DECLARE_HOOK(android_vh_dma_heap_buffer_alloc_end, + TP_PROTO(const char *name, size_t len), + TP_ARGS(name, len)); #endif /* _TRACE_HOOK_DMABUF_H */ /* This part must be outside protection */ #include