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