From 1d3cdeb464ce95d74494c87ca07c3d1ac17cadf1 Mon Sep 17 00:00:00 2001 From: Gaofeng Sheng Date: Mon, 18 Apr 2022 14:28:04 +0800 Subject: [PATCH] ANDROID: GKI: dma-buf: add vendor hook for dma_buf_release The main function is to check whether the corresponding IOMMU buffer is unmapped when dmabuf is released, so as to avoid memory coverage caused by IOMMU. Bug: 438090847 Change-Id: I56ae3f0994cd4f3d24494b7972e4d89d0f004da8 Signed-off-by: Gaofeng Sheng (cherry picked from commit 8879650556ed747baf5a4d3037d687a76ccb986f) --- drivers/android/vendor_hooks.c | 1 + drivers/dma-buf/dma-buf.c | 5 +++++ include/trace/hooks/dmabuf.h | 3 +++ 3 files changed, 9 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 34764706c6e9..4006efb35833 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -584,6 +584,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_shrink_node); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_customize_thp_gfp_orders); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_customize_pmd_gfp_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_thp_vma_allowable_orders); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dma_buf_release); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpuset_fork); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_uid); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_user); diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index ac5f78b88792..618c1174e851 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -33,6 +33,10 @@ #include "dma-buf-sysfs-stats.h" +#include +#include +ANDROID_KABI_DECLONLY(trace_eval_map); + #if IS_ENABLED(CONFIG_DEBUG_FS) static DEFINE_MUTEX(debugfs_list_mutex); static LIST_HEAD(debugfs_list); @@ -126,6 +130,7 @@ static void dma_buf_release(struct dentry *dentry) dma_buf_stats_teardown(dmabuf); dmabuf->ops->release(dmabuf); + trace_android_vh_dma_buf_release(dmabuf); if (dmabuf->resv == (struct dma_resv *)&dmabuf[1]) dma_resv_fini(dmabuf->resv); diff --git a/include/trace/hooks/dmabuf.h b/include/trace/hooks/dmabuf.h index 3b637ef1c3ea..22aca69f8513 100644 --- a/include/trace/hooks/dmabuf.h +++ b/include/trace/hooks/dmabuf.h @@ -29,6 +29,9 @@ DECLARE_HOOK(android_vh_dma_buf_attr_show_start, DECLARE_HOOK(android_vh_dma_buf_attr_show_end, TP_PROTO(struct dma_buf *dmabuf), TP_ARGS(dmabuf)); +DECLARE_HOOK(android_vh_dma_buf_release, + TP_PROTO(struct dma_buf *data), + TP_ARGS(data)); #endif /* _TRACE_HOOK_DMABUF_H */ /* This part must be outside protection */ #include