From b24d8263d00d6ce8a7bb9bcd960c767470c77ccc Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 4 Nov 2025 11:43:07 -0800 Subject: [PATCH] UPSTREAM: ANDROID: tracing: add power/gpu_frequency From Android 16 CDD: [7.1.4.6/H-1-4] MUST report a GPU Frequency tracepoint as specified by the format: power/gpu_frequency. Bug: 457797217 Test: cat /sys/kernel/tracing/events/power/gpu_frequency/format Change-Id: Ie8cd95cb8fe8471c2de19c48cdf57c8cf59f2370 Signed-off-by: Chia-I Wu Signed-off-by: Sorayukii --- drivers/gpu/Makefile | 3 +-- drivers/gpu/trace/Kconfig | 12 ++++++++++ drivers/gpu/trace/Makefile | 1 + drivers/gpu/trace/trace_gpu_power.c | 11 ++++++++++ include/trace/events/gpu_power.h | 34 +++++++++++++++++++++++++++++ 5 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/trace/trace_gpu_power.c create mode 100644 include/trace/events/gpu_power.h diff --git a/drivers/gpu/Makefile b/drivers/gpu/Makefile index 3c9f24d7b2ef..c941c79d6a8e 100644 --- a/drivers/gpu/Makefile +++ b/drivers/gpu/Makefile @@ -2,7 +2,6 @@ # taken to initialize them in the correct order. Link order is the only way # to ensure this currently. obj-$(CONFIG_TEGRA_HOST1X) += host1x/ -obj-y += drm/ vga/ +obj-y += drm/ vga/ trace/ obj-$(CONFIG_IMX_IPUV3_CORE) += ipu-v3/ obj-$(CONFIG_QCOM_KGSL) += msm/ -obj-$(CONFIG_TRACE_GPU_MEM) += trace/ diff --git a/drivers/gpu/trace/Kconfig b/drivers/gpu/trace/Kconfig index cd3d19c4a201..aeaf4c3e88ee 100644 --- a/drivers/gpu/trace/Kconfig +++ b/drivers/gpu/trace/Kconfig @@ -11,3 +11,15 @@ config TRACE_GPU_MEM Tracepoint availability varies by GPU driver. If in doubt, say "N". + +config TRACE_GPU_POWER + bool "Enable GPU power usage tracepoints" + default n + help + Choose this option to enable tracepoints for tracking + global and per-process GPU power usage. Intended for + performance profiling and required for Android. + + Tracepoint availability varies by GPU driver. + + If in doubt, say "N". diff --git a/drivers/gpu/trace/Makefile b/drivers/gpu/trace/Makefile index b70fbdc5847f..aa86cfaa557d 100644 --- a/drivers/gpu/trace/Makefile +++ b/drivers/gpu/trace/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_TRACE_GPU_MEM) += trace_gpu_mem.o +obj-$(CONFIG_TRACE_GPU_POWER) += trace_gpu_power.o diff --git a/drivers/gpu/trace/trace_gpu_power.c b/drivers/gpu/trace/trace_gpu_power.c new file mode 100644 index 000000000000..502e9f19e698 --- /dev/null +++ b/drivers/gpu/trace/trace_gpu_power.c @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2025 Google LLC + */ + +#include + +#define CREATE_TRACE_POINTS +#include + +EXPORT_TRACEPOINT_SYMBOL(gpu_frequency); diff --git a/include/trace/events/gpu_power.h b/include/trace/events/gpu_power.h new file mode 100644 index 000000000000..0a8a17954148 --- /dev/null +++ b/include/trace/events/gpu_power.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM power // just "power" for historical reasons + +#if !defined(_TRACE_GPU_POWER_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_GPU_POWER_H + +#include + +TRACE_EVENT(gpu_frequency, + + TP_PROTO(unsigned int state, unsigned int gpu_id), + + TP_ARGS(state, gpu_id), + + TP_STRUCT__entry( + __field(unsigned int, state) + __field(unsigned int, gpu_id) + ), + + TP_fast_assign( + __entry->state = state; + __entry->gpu_id = gpu_id; + ), + + TP_printk("state=%u gpu_id=%u", __entry->state, __entry->gpu_id) +); + +#endif /* _TRACE_GPU_POWER_H */ + +/* This part must be outside protection */ +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_FILE gpu_power +#include