* [PATCH v4 0/2] drm: Add GPU frequency tracepoint
@ 2025-09-17 8:41 S Sebinraj
2025-09-17 8:41 ` [PATCH v4 1/2] drm: Add GPU frequency tracepoint at DRM level S Sebinraj
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: S Sebinraj @ 2025-09-17 8:41 UTC (permalink / raw)
To: intel-gfx, dri-devel, intel-xe; +Cc: jeevaka.badrappan, S Sebinraj
Add a GPU frequency tracepoint at the DRM subsystem level.
Integrates with the Xe PMU to provide frequency tracing.
The tracepoint is exposed at:
/sys/kernel/debug/tracing/events/power/gpu_frequency
Format: {unsigned int state, unsigned int gpu_id}
- state: GPU frequency in KHz
- gpu_id: GPU clock domain identifier
S Sebinraj (2):
drm: Add GPU frequency tracepoint at DRM level
drm/xe: Add DRM GPU frequency tracepoint to Xe
drivers/gpu/drm/Kconfig | 11 ++++++
drivers/gpu/drm/Makefile | 1 +
drivers/gpu/drm/drm_gpu_frequency_trace.c | 16 ++++++++
drivers/gpu/drm/xe/xe_gpu_freq_trace.h | 14 +++++++
drivers/gpu/drm/xe/xe_pmu.c | 26 ++++++++++++-
drivers/gpu/drm/xe/xe_pmu_types.h | 4 ++
include/drm/drm_gpu_frequency_trace.h | 47 +++++++++++++++++++++++
7 files changed, 117 insertions(+), 2 deletions(-)
create mode 100644 drivers/gpu/drm/drm_gpu_frequency_trace.c
create mode 100644 drivers/gpu/drm/xe/xe_gpu_freq_trace.h
create mode 100644 include/drm/drm_gpu_frequency_trace.h
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v4 1/2] drm: Add GPU frequency tracepoint at DRM level
2025-09-17 8:41 [PATCH v4 0/2] drm: Add GPU frequency tracepoint S Sebinraj
@ 2025-09-17 8:41 ` S Sebinraj
2025-09-17 9:17 ` Tvrtko Ursulin
2025-09-17 8:41 ` [PATCH v4 2/2] drm/xe: Add DRM GPU frequency tracepoint to Xe S Sebinraj
2025-09-17 10:29 ` ✗ i915.CI.BAT: failure for drm: Add GPU frequency tracepoint (rev3) Patchwork
2 siblings, 1 reply; 6+ messages in thread
From: S Sebinraj @ 2025-09-17 8:41 UTC (permalink / raw)
To: intel-gfx, dri-devel, intel-xe; +Cc: jeevaka.badrappan, S Sebinraj
Add a GPU frequency tracepoint at the DRM subsystem level
The implementation includes:
- DRM-level tracepoint exposed at /sys/kernel/debug/tracing/events/power/gpu_frequency/
- CONFIG_DRM_GPU_FREQUENCY_TRACE Kconfig option (default=n)
The tracepoint follows kernel tracing and provides kHz frequency
values with GPU identification for power analysis and
performance monitoring tools.
The tracepoint is only active when CONFIG_DRM_GPU_FREQUENCY_TRACE=y
and can be integrated by GPU drivers for frequency reporting.
Signed-off-by: S Sebinraj <s.sebinraj@intel.com>
---
drivers/gpu/drm/Kconfig | 11 ++++++
drivers/gpu/drm/Makefile | 1 +
drivers/gpu/drm/drm_gpu_frequency_trace.c | 16 ++++++++
drivers/gpu/drm/drm_gpu_frequency_trace.h | 47 +++++++++++++++++++++++
4 files changed, 75 insertions(+)
create mode 100644 drivers/gpu/drm/drm_gpu_frequency_trace.c
create mode 100644 drivers/gpu/drm/drm_gpu_frequency_trace.h
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index f7ea8e895c0c..975cc7b2581d 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -53,6 +53,17 @@ config DRM_DRAW
bool
depends on DRM
+config DRM_GPU_FREQUENCY_TRACE
+ bool "Enable GPU frequency tracepoints"
+ depends on DRM && TRACEPOINTS
+ default n
+ help
+ Enable GPU frequency tracepoints in the power trace subsystem.
+ This provides kernel tracing support for GPU frequency changes
+ that will be exposed at /sys/kernel/debug/tracing/events/power/gpu_frequency/.
+
+ If unsure, say N.
+
config DRM_PANIC
bool "Display a user-friendly message when a kernel panic occurs"
depends on DRM
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 4dafbdc8f86a..12c81b6a750d 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -77,6 +77,7 @@ drm-$(CONFIG_DRM_CLIENT) += \
drm_client.o \
drm_client_event.o \
drm_client_modeset.o
+drm-$(CONFIG_DRM_GPU_FREQUENCY_TRACE) += drm_gpu_frequency_trace.o
drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o
drm-$(CONFIG_COMPAT) += drm_ioc32.o
drm-$(CONFIG_DRM_PANEL) += drm_panel.o
diff --git a/drivers/gpu/drm/drm_gpu_frequency_trace.c b/drivers/gpu/drm/drm_gpu_frequency_trace.c
new file mode 100644
index 000000000000..b5fa5134226d
--- /dev/null
+++ b/drivers/gpu/drm/drm_gpu_frequency_trace.c
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * GPU frequency trace points for DRM subsystem
+ *
+ * This provides GPU frequency tracing support that will be exposed at:
+ * /sys/kernel/debug/tracing/events/power/gpu_frequency/
+ */
+
+#ifdef CONFIG_DRM_GPU_FREQUENCY_TRACE
+
+#define CREATE_TRACE_POINTS
+#include "drm_gpu_frequency_trace.h"
+
+EXPORT_TRACEPOINT_SYMBOL_GPL(gpu_frequency);
+
+#endif /* CONFIG_DRM_GPU_FREQUENCY_TRACE */
diff --git a/drivers/gpu/drm/drm_gpu_frequency_trace.h b/drivers/gpu/drm/drm_gpu_frequency_trace.h
new file mode 100644
index 000000000000..cf6337847b3a
--- /dev/null
+++ b/drivers/gpu/drm/drm_gpu_frequency_trace.h
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#if !defined(_GPU_FREQUENCY_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _GPU_FREQUENCY_TRACE_H
+
+#include <linux/tracepoint.h>
+
+#ifdef CONFIG_DRM_GPU_FREQUENCY_TRACE
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM power
+#define TRACE_INCLUDE_FILE drm_gpu_frequency_trace
+
+/*
+ * Tracepoint for GPU frequency changes
+ * This tracepoint is exposed at /sys/kernel/debug/tracing/events/power/gpu_frequency
+ *
+ * location: /sys/kernel/debug/tracing/events/power/gpu_frequency
+ * format: {unsigned int state, unsigned int gpu_id}
+ * where state holds the frequency(in KHz) and the gpu_id holds the GPU clock domain.
+ */
+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)
+);
+
+#else /* !CONFIG_DRM_GPU_FREQUENCY_TRACE */
+
+static inline void trace_gpu_frequency(unsigned int state, unsigned int gpu_id) { }
+
+#endif /* CONFIG_DRM_GPU_FREQUENCY_TRACE */
+
+#endif /* _GPU_FREQUENCY_TRACE_H */
+
+#ifdef CONFIG_DRM_GPU_FREQUENCY_TRACE
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm
+#include <trace/define_trace.h>
+#endif
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 2/2] drm/xe: Add DRM GPU frequency tracepoint to Xe
2025-09-17 8:41 [PATCH v4 0/2] drm: Add GPU frequency tracepoint S Sebinraj
2025-09-17 8:41 ` [PATCH v4 1/2] drm: Add GPU frequency tracepoint at DRM level S Sebinraj
@ 2025-09-17 8:41 ` S Sebinraj
2025-09-17 9:19 ` Tvrtko Ursulin
2025-09-17 10:29 ` ✗ i915.CI.BAT: failure for drm: Add GPU frequency tracepoint (rev3) Patchwork
2 siblings, 1 reply; 6+ messages in thread
From: S Sebinraj @ 2025-09-17 8:41 UTC (permalink / raw)
To: intel-gfx, dri-devel, intel-xe; +Cc: jeevaka.badrappan, S Sebinraj
Integrate xe PMU with the DRM-level GPU frequency tracepoint to provide
efficient frequency monitoring with change detection.
Key changes:
- Add frequency change detection
- Implement per-GT frequency tracking using last_act_freq array
- Only trace when GPU frequency actually changes per GT
The integration traces actual GPU frequency changes from xe_pmu during
XE_PMU_EVENT_GT_ACTUAL_FREQUENCY reads.
Signed-off-by: S Sebinraj <s.sebinraj@intel.com>
---
drivers/gpu/drm/drm_gpu_frequency_trace.c | 2 +-
drivers/gpu/drm/xe/xe_gpu_freq_trace.h | 14 ++++++++++
drivers/gpu/drm/xe/xe_pmu.c | 26 +++++++++++++++++--
drivers/gpu/drm/xe/xe_pmu_types.h | 4 +++
.../drm/drm_gpu_frequency_trace.h | 2 +-
5 files changed, 44 insertions(+), 4 deletions(-)
create mode 100644 drivers/gpu/drm/xe/xe_gpu_freq_trace.h
rename {drivers/gpu => include}/drm/drm_gpu_frequency_trace.h (96%)
diff --git a/drivers/gpu/drm/drm_gpu_frequency_trace.c b/drivers/gpu/drm/drm_gpu_frequency_trace.c
index b5fa5134226d..e33df068752d 100644
--- a/drivers/gpu/drm/drm_gpu_frequency_trace.c
+++ b/drivers/gpu/drm/drm_gpu_frequency_trace.c
@@ -9,7 +9,7 @@
#ifdef CONFIG_DRM_GPU_FREQUENCY_TRACE
#define CREATE_TRACE_POINTS
-#include "drm_gpu_frequency_trace.h"
+#include <drm/drm_gpu_frequency_trace.h>
EXPORT_TRACEPOINT_SYMBOL_GPL(gpu_frequency);
diff --git a/drivers/gpu/drm/xe/xe_gpu_freq_trace.h b/drivers/gpu/drm/xe/xe_gpu_freq_trace.h
new file mode 100644
index 000000000000..c15d41761296
--- /dev/null
+++ b/drivers/gpu/drm/xe/xe_gpu_freq_trace.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * GPU frequency trace wrapper for xe_pmu.c
+ * This header provides access to the gpu_frequency tracepoint
+ */
+#ifndef _XE_GPU_FREQ_TRACE_H_
+#define _XE_GPU_FREQ_TRACE_H_
+
+#include <drm/drm_gpu_frequency_trace.h>
+
+/* Convert MHz to KHz for tracepoint */
+#define MHZ_TO_KHZ(freq_mhz) ((freq_mhz) * 1000)
+
+#endif /* _XE_GPU_FREQ_TRACE_H_ */
diff --git a/drivers/gpu/drm/xe/xe_pmu.c b/drivers/gpu/drm/xe/xe_pmu.c
index cab51d826345..7d5a6e149247 100644
--- a/drivers/gpu/drm/xe/xe_pmu.c
+++ b/drivers/gpu/drm/xe/xe_pmu.c
@@ -5,9 +5,11 @@
#include <drm/drm_drv.h>
#include <linux/device.h>
+#include <linux/types.h>
#include "xe_device.h"
#include "xe_force_wake.h"
+#include "xe_gpu_freq_trace.h"
#include "xe_gt_idle.h"
#include "xe_guc_engine_activity.h"
#include "xe_guc_pc.h"
@@ -291,6 +293,19 @@ static u64 read_engine_events(struct xe_gt *gt, struct perf_event *event)
return val;
}
+static void xe_pmu_trace_frequency_change(struct xe_gt *gt, u32 act_freq)
+{
+ struct xe_device *xe = gt_to_xe(gt);
+ struct xe_pmu *pmu = &xe->pmu;
+ u32 gt_id = gt->info.id;
+
+ /* Only trace if frequency changed for this GT */
+ if (gt_id < XE_PMU_MAX_GT && pmu->last_act_freq[gt_id] != act_freq) {
+ trace_gpu_frequency(MHZ_TO_KHZ(act_freq), gt_id);
+ pmu->last_act_freq[gt_id] = act_freq;
+ }
+}
+
static u64 __xe_pmu_event_read(struct perf_event *event)
{
struct xe_gt *gt = event_to_gt(event);
@@ -304,8 +319,12 @@ static u64 __xe_pmu_event_read(struct perf_event *event)
case XE_PMU_EVENT_ENGINE_ACTIVE_TICKS:
case XE_PMU_EVENT_ENGINE_TOTAL_TICKS:
return read_engine_events(gt, event);
- case XE_PMU_EVENT_GT_ACTUAL_FREQUENCY:
- return xe_guc_pc_get_act_freq(>->uc.guc.pc);
+ case XE_PMU_EVENT_GT_ACTUAL_FREQUENCY: {
+ u32 act_freq = xe_guc_pc_get_act_freq(>->uc.guc.pc);
+
+ xe_pmu_trace_frequency_change(gt, act_freq);
+ return act_freq;
+ }
case XE_PMU_EVENT_GT_REQUESTED_FREQUENCY:
return xe_guc_pc_get_cur_freq_fw(>->uc.guc.pc);
}
@@ -572,6 +591,9 @@ int xe_pmu_register(struct xe_pmu *pmu)
pmu->base.stop = xe_pmu_event_stop;
pmu->base.read = xe_pmu_event_read;
+ /* Initialize frequency tracking array */
+ memset(pmu->last_act_freq, 0, sizeof(pmu->last_act_freq));
+
set_supported_events(pmu);
ret = perf_pmu_register(&pmu->base, pmu->name, -1);
diff --git a/drivers/gpu/drm/xe/xe_pmu_types.h b/drivers/gpu/drm/xe/xe_pmu_types.h
index f5ba4d56622c..630da8442387 100644
--- a/drivers/gpu/drm/xe/xe_pmu_types.h
+++ b/drivers/gpu/drm/xe/xe_pmu_types.h
@@ -34,6 +34,10 @@ struct xe_pmu {
* @supported_events: Bitmap of supported events, indexed by event id
*/
u64 supported_events;
+ /**
+ * @last_act_freq: Last actual frequency for each GT (for tracing changes only)
+ */
+ u32 last_act_freq[XE_PMU_MAX_GT];
};
#endif
diff --git a/drivers/gpu/drm/drm_gpu_frequency_trace.h b/include/drm/drm_gpu_frequency_trace.h
similarity index 96%
rename from drivers/gpu/drm/drm_gpu_frequency_trace.h
rename to include/drm/drm_gpu_frequency_trace.h
index cf6337847b3a..47f32fd295a4 100644
--- a/drivers/gpu/drm/drm_gpu_frequency_trace.h
+++ b/include/drm/drm_gpu_frequency_trace.h
@@ -42,6 +42,6 @@ static inline void trace_gpu_frequency(unsigned int state, unsigned int gpu_id)
#ifdef CONFIG_DRM_GPU_FREQUENCY_TRACE
#undef TRACE_INCLUDE_PATH
-#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm
+#define TRACE_INCLUDE_PATH ../../include/drm
#include <trace/define_trace.h>
#endif
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v4 1/2] drm: Add GPU frequency tracepoint at DRM level
2025-09-17 8:41 ` [PATCH v4 1/2] drm: Add GPU frequency tracepoint at DRM level S Sebinraj
@ 2025-09-17 9:17 ` Tvrtko Ursulin
0 siblings, 0 replies; 6+ messages in thread
From: Tvrtko Ursulin @ 2025-09-17 9:17 UTC (permalink / raw)
To: S Sebinraj, intel-gfx, dri-devel, intel-xe; +Cc: jeevaka.badrappan
On 17/09/2025 09:41, S Sebinraj wrote:
> Add a GPU frequency tracepoint at the DRM subsystem level
>
> The implementation includes:
> - DRM-level tracepoint exposed at /sys/kernel/debug/tracing/events/power/gpu_frequency/
> - CONFIG_DRM_GPU_FREQUENCY_TRACE Kconfig option (default=n)
>
> The tracepoint follows kernel tracing and provides kHz frequency
> values with GPU identification for power analysis and
> performance monitoring tools.
>
> The tracepoint is only active when CONFIG_DRM_GPU_FREQUENCY_TRACE=y
> and can be integrated by GPU drivers for frequency reporting.
>
> Signed-off-by: S Sebinraj <s.sebinraj@intel.com>
> ---
> drivers/gpu/drm/Kconfig | 11 ++++++
> drivers/gpu/drm/Makefile | 1 +
> drivers/gpu/drm/drm_gpu_frequency_trace.c | 16 ++++++++
> drivers/gpu/drm/drm_gpu_frequency_trace.h | 47 +++++++++++++++++++++++
> 4 files changed, 75 insertions(+)
> create mode 100644 drivers/gpu/drm/drm_gpu_frequency_trace.c
> create mode 100644 drivers/gpu/drm/drm_gpu_frequency_trace.h
>
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index f7ea8e895c0c..975cc7b2581d 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -53,6 +53,17 @@ config DRM_DRAW
> bool
> depends on DRM
>
> +config DRM_GPU_FREQUENCY_TRACE
> + bool "Enable GPU frequency tracepoints"
> + depends on DRM && TRACEPOINTS
> + default n
> + help
> + Enable GPU frequency tracepoints in the power trace subsystem.
> + This provides kernel tracing support for GPU frequency changes
> + that will be exposed at /sys/kernel/debug/tracing/events/power/gpu_frequency/.
> +
> + If unsure, say N.
> +
> config DRM_PANIC
> bool "Display a user-friendly message when a kernel panic occurs"
> depends on DRM
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index 4dafbdc8f86a..12c81b6a750d 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -77,6 +77,7 @@ drm-$(CONFIG_DRM_CLIENT) += \
> drm_client.o \
> drm_client_event.o \
> drm_client_modeset.o
> +drm-$(CONFIG_DRM_GPU_FREQUENCY_TRACE) += drm_gpu_frequency_trace.o
> drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o
> drm-$(CONFIG_COMPAT) += drm_ioc32.o
> drm-$(CONFIG_DRM_PANEL) += drm_panel.o
> diff --git a/drivers/gpu/drm/drm_gpu_frequency_trace.c b/drivers/gpu/drm/drm_gpu_frequency_trace.c
> new file mode 100644
> index 000000000000..b5fa5134226d
> --- /dev/null
> +++ b/drivers/gpu/drm/drm_gpu_frequency_trace.c
> @@ -0,0 +1,16 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * GPU frequency trace points for DRM subsystem
> + *
> + * This provides GPU frequency tracing support that will be exposed at:
> + * /sys/kernel/debug/tracing/events/power/gpu_frequency/
> + */
> +
> +#ifdef CONFIG_DRM_GPU_FREQUENCY_TRACE
> +
> +#define CREATE_TRACE_POINTS
> +#include "drm_gpu_frequency_trace.h"
> +
> +EXPORT_TRACEPOINT_SYMBOL_GPL(gpu_frequency);
> +
> +#endif /* CONFIG_DRM_GPU_FREQUENCY_TRACE */
> diff --git a/drivers/gpu/drm/drm_gpu_frequency_trace.h b/drivers/gpu/drm/drm_gpu_frequency_trace.h
> new file mode 100644
> index 000000000000..cf6337847b3a
> --- /dev/null
> +++ b/drivers/gpu/drm/drm_gpu_frequency_trace.h
> @@ -0,0 +1,47 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#if !defined(_GPU_FREQUENCY_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
> +#define _GPU_FREQUENCY_TRACE_H
> +
> +#include <linux/tracepoint.h>
> +
> +#ifdef CONFIG_DRM_GPU_FREQUENCY_TRACE
> +
> +#undef TRACE_SYSTEM
> +#define TRACE_SYSTEM power
Not sure masquerading as a different subsystem will fly.
> +#define TRACE_INCLUDE_FILE drm_gpu_frequency_trace
> +
> +/*
> + * Tracepoint for GPU frequency changes
> + * This tracepoint is exposed at /sys/kernel/debug/tracing/events/power/gpu_frequency
> + *
> + * location: /sys/kernel/debug/tracing/events/power/gpu_frequency
> + * format: {unsigned int state, unsigned int gpu_id}
> + * where state holds the frequency(in KHz) and the gpu_id holds the GPU clock domain.
> + */
> +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)
Why is the frequency field not called frequency?
> + __field(unsigned int, gpu_id)
It is required to be able to identify which GPU in muti-GPU systems. See
how gpu_id is defined in gpu_mem.h.
Regards,
Tvrtko
> + ),
> + TP_fast_assign(
> + __entry->state = state;
> + __entry->gpu_id = gpu_id;
> + ),
> + TP_printk("state=%u gpu_id=%u", __entry->state, __entry->gpu_id)
> +);
> +
> +#else /* !CONFIG_DRM_GPU_FREQUENCY_TRACE */
> +
> +static inline void trace_gpu_frequency(unsigned int state, unsigned int gpu_id) { }
> +
> +#endif /* CONFIG_DRM_GPU_FREQUENCY_TRACE */
> +
> +#endif /* _GPU_FREQUENCY_TRACE_H */
> +
> +#ifdef CONFIG_DRM_GPU_FREQUENCY_TRACE
> +#undef TRACE_INCLUDE_PATH
> +#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm
> +#include <trace/define_trace.h>
> +#endif
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4 2/2] drm/xe: Add DRM GPU frequency tracepoint to Xe
2025-09-17 8:41 ` [PATCH v4 2/2] drm/xe: Add DRM GPU frequency tracepoint to Xe S Sebinraj
@ 2025-09-17 9:19 ` Tvrtko Ursulin
0 siblings, 0 replies; 6+ messages in thread
From: Tvrtko Ursulin @ 2025-09-17 9:19 UTC (permalink / raw)
To: S Sebinraj, intel-gfx, dri-devel, intel-xe; +Cc: jeevaka.badrappan
On 17/09/2025 09:41, S Sebinraj wrote:
> Integrate xe PMU with the DRM-level GPU frequency tracepoint to provide
> efficient frequency monitoring with change detection.
>
> Key changes:
> - Add frequency change detection
> - Implement per-GT frequency tracking using last_act_freq array
> - Only trace when GPU frequency actually changes per GT
>
> The integration traces actual GPU frequency changes from xe_pmu during
> XE_PMU_EVENT_GT_ACTUAL_FREQUENCY reads.
>
> Signed-off-by: S Sebinraj <s.sebinraj@intel.com>
> ---
> drivers/gpu/drm/drm_gpu_frequency_trace.c | 2 +-
> drivers/gpu/drm/xe/xe_gpu_freq_trace.h | 14 ++++++++++
> drivers/gpu/drm/xe/xe_pmu.c | 26 +++++++++++++++++--
> drivers/gpu/drm/xe/xe_pmu_types.h | 4 +++
> .../drm/drm_gpu_frequency_trace.h | 2 +-
> 5 files changed, 44 insertions(+), 4 deletions(-)
> create mode 100644 drivers/gpu/drm/xe/xe_gpu_freq_trace.h
> rename {drivers/gpu => include}/drm/drm_gpu_frequency_trace.h (96%)
>
> diff --git a/drivers/gpu/drm/drm_gpu_frequency_trace.c b/drivers/gpu/drm/drm_gpu_frequency_trace.c
> index b5fa5134226d..e33df068752d 100644
> --- a/drivers/gpu/drm/drm_gpu_frequency_trace.c
> +++ b/drivers/gpu/drm/drm_gpu_frequency_trace.c
> @@ -9,7 +9,7 @@
> #ifdef CONFIG_DRM_GPU_FREQUENCY_TRACE
>
> #define CREATE_TRACE_POINTS
> -#include "drm_gpu_frequency_trace.h"
> +#include <drm/drm_gpu_frequency_trace.h>
>
> EXPORT_TRACEPOINT_SYMBOL_GPL(gpu_frequency);
>
> diff --git a/drivers/gpu/drm/xe/xe_gpu_freq_trace.h b/drivers/gpu/drm/xe/xe_gpu_freq_trace.h
> new file mode 100644
> index 000000000000..c15d41761296
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/xe_gpu_freq_trace.h
> @@ -0,0 +1,14 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * GPU frequency trace wrapper for xe_pmu.c
> + * This header provides access to the gpu_frequency tracepoint
> + */
> +#ifndef _XE_GPU_FREQ_TRACE_H_
> +#define _XE_GPU_FREQ_TRACE_H_
> +
> +#include <drm/drm_gpu_frequency_trace.h>
> +
> +/* Convert MHz to KHz for tracepoint */
> +#define MHZ_TO_KHZ(freq_mhz) ((freq_mhz) * 1000)
> +
> +#endif /* _XE_GPU_FREQ_TRACE_H_ */
> diff --git a/drivers/gpu/drm/xe/xe_pmu.c b/drivers/gpu/drm/xe/xe_pmu.c
> index cab51d826345..7d5a6e149247 100644
> --- a/drivers/gpu/drm/xe/xe_pmu.c
> +++ b/drivers/gpu/drm/xe/xe_pmu.c
> @@ -5,9 +5,11 @@
>
> #include <drm/drm_drv.h>
> #include <linux/device.h>
> +#include <linux/types.h>
>
> #include "xe_device.h"
> #include "xe_force_wake.h"
> +#include "xe_gpu_freq_trace.h"
> #include "xe_gt_idle.h"
> #include "xe_guc_engine_activity.h"
> #include "xe_guc_pc.h"
> @@ -291,6 +293,19 @@ static u64 read_engine_events(struct xe_gt *gt, struct perf_event *event)
> return val;
> }
>
> +static void xe_pmu_trace_frequency_change(struct xe_gt *gt, u32 act_freq)
> +{
> + struct xe_device *xe = gt_to_xe(gt);
> + struct xe_pmu *pmu = &xe->pmu;
> + u32 gt_id = gt->info.id;
> +
> + /* Only trace if frequency changed for this GT */
> + if (gt_id < XE_PMU_MAX_GT && pmu->last_act_freq[gt_id] != act_freq) {
> + trace_gpu_frequency(MHZ_TO_KHZ(act_freq), gt_id);
> + pmu->last_act_freq[gt_id] = act_freq;
> + }
> +}
> +
> static u64 __xe_pmu_event_read(struct perf_event *event)
> {
> struct xe_gt *gt = event_to_gt(event);
> @@ -304,8 +319,12 @@ static u64 __xe_pmu_event_read(struct perf_event *event)
> case XE_PMU_EVENT_ENGINE_ACTIVE_TICKS:
> case XE_PMU_EVENT_ENGINE_TOTAL_TICKS:
> return read_engine_events(gt, event);
> - case XE_PMU_EVENT_GT_ACTUAL_FREQUENCY:
> - return xe_guc_pc_get_act_freq(>->uc.guc.pc);
> + case XE_PMU_EVENT_GT_ACTUAL_FREQUENCY: {
> + u32 act_freq = xe_guc_pc_get_act_freq(>->uc.guc.pc);
> +
> + xe_pmu_trace_frequency_change(gt, act_freq);
Not my driver but IMO it does not sound very useful to emit a tracepoint
*only if* someone has the PMU open and not on actual frequency changes
but at a frequency of userspace doing PMU reads. Not least that at this
point userspace already has the frequency information via PMU so
tracepoint is just adding kernel code for what purpose?
Regards,
Tvrtko
> + return act_freq;
> + }
> case XE_PMU_EVENT_GT_REQUESTED_FREQUENCY:
> return xe_guc_pc_get_cur_freq_fw(>->uc.guc.pc);
> }
> @@ -572,6 +591,9 @@ int xe_pmu_register(struct xe_pmu *pmu)
> pmu->base.stop = xe_pmu_event_stop;
> pmu->base.read = xe_pmu_event_read;
>
> + /* Initialize frequency tracking array */
> + memset(pmu->last_act_freq, 0, sizeof(pmu->last_act_freq));
> +
> set_supported_events(pmu);
>
> ret = perf_pmu_register(&pmu->base, pmu->name, -1);
> diff --git a/drivers/gpu/drm/xe/xe_pmu_types.h b/drivers/gpu/drm/xe/xe_pmu_types.h
> index f5ba4d56622c..630da8442387 100644
> --- a/drivers/gpu/drm/xe/xe_pmu_types.h
> +++ b/drivers/gpu/drm/xe/xe_pmu_types.h
> @@ -34,6 +34,10 @@ struct xe_pmu {
> * @supported_events: Bitmap of supported events, indexed by event id
> */
> u64 supported_events;
> + /**
> + * @last_act_freq: Last actual frequency for each GT (for tracing changes only)
> + */
> + u32 last_act_freq[XE_PMU_MAX_GT];
> };
>
> #endif
> diff --git a/drivers/gpu/drm/drm_gpu_frequency_trace.h b/include/drm/drm_gpu_frequency_trace.h
> similarity index 96%
> rename from drivers/gpu/drm/drm_gpu_frequency_trace.h
> rename to include/drm/drm_gpu_frequency_trace.h
> index cf6337847b3a..47f32fd295a4 100644
> --- a/drivers/gpu/drm/drm_gpu_frequency_trace.h
> +++ b/include/drm/drm_gpu_frequency_trace.h
> @@ -42,6 +42,6 @@ static inline void trace_gpu_frequency(unsigned int state, unsigned int gpu_id)
>
> #ifdef CONFIG_DRM_GPU_FREQUENCY_TRACE
> #undef TRACE_INCLUDE_PATH
> -#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm
> +#define TRACE_INCLUDE_PATH ../../include/drm
> #include <trace/define_trace.h>
> #endif
^ permalink raw reply [flat|nested] 6+ messages in thread
* ✗ i915.CI.BAT: failure for drm: Add GPU frequency tracepoint (rev3)
2025-09-17 8:41 [PATCH v4 0/2] drm: Add GPU frequency tracepoint S Sebinraj
2025-09-17 8:41 ` [PATCH v4 1/2] drm: Add GPU frequency tracepoint at DRM level S Sebinraj
2025-09-17 8:41 ` [PATCH v4 2/2] drm/xe: Add DRM GPU frequency tracepoint to Xe S Sebinraj
@ 2025-09-17 10:29 ` Patchwork
2 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2025-09-17 10:29 UTC (permalink / raw)
To: S Sebinraj; +Cc: intel-gfx
[-- Attachment #1: Type: text/plain, Size: 4202 bytes --]
== Series Details ==
Series: drm: Add GPU frequency tracepoint (rev3)
URL : https://patchwork.freedesktop.org/series/154231/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_17221 -> Patchwork_154231v3
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_154231v3 absolutely need to be
verified manually.
If you think the reported changes have nothing to do with the changes
introduced in Patchwork_154231v3, please notify your bug team (I915-ci-infra@lists.freedesktop.org) to allow them
to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_154231v3/index.html
Participating hosts (43 -> 42)
------------------------------
Missing (1): fi-snb-2520m
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_154231v3:
### IGT changes ###
#### Possible regressions ####
* igt@i915_selftest@live@requests:
- bat-arls-5: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_17221/bat-arls-5/igt@i915_selftest@live@requests.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_154231v3/bat-arls-5/igt@i915_selftest@live@requests.html
New tests
---------
New tests have been introduced between CI_DRM_17221 and Patchwork_154231v3:
### New IGT tests (2) ###
* igt@i915_selftest@bad-flink:
- Statuses :
- Exec time: [None] s
* igt@i915_selftest@double-flink:
- Statuses :
- Exec time: [None] s
Known issues
------------
Here are the changes found in Patchwork_154231v3 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@i915_selftest@live:
- bat-arls-5: [PASS][3] -> [INCOMPLETE][4] ([i915#14818])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_17221/bat-arls-5/igt@i915_selftest@live.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_154231v3/bat-arls-5/igt@i915_selftest@live.html
#### Possible fixes ####
* igt@dmabuf@all-tests:
- bat-apl-1: [ABORT][5] ([i915#12904]) -> [PASS][6] +1 other test pass
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_17221/bat-apl-1/igt@dmabuf@all-tests.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_154231v3/bat-apl-1/igt@dmabuf@all-tests.html
* igt@i915_selftest@live@workarounds:
- bat-arlh-3: [DMESG-FAIL][7] ([i915#12061]) -> [PASS][8] +1 other test pass
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_17221/bat-arlh-3/igt@i915_selftest@live@workarounds.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_154231v3/bat-arlh-3/igt@i915_selftest@live@workarounds.html
- bat-arls-6: [DMESG-FAIL][9] ([i915#12061]) -> [PASS][10] +1 other test pass
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_17221/bat-arls-6/igt@i915_selftest@live@workarounds.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_154231v3/bat-arls-6/igt@i915_selftest@live@workarounds.html
* igt@kms_pm_rpm@basic-rte:
- bat-rpls-4: [DMESG-WARN][11] ([i915#13400]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_17221/bat-rpls-4/igt@kms_pm_rpm@basic-rte.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_154231v3/bat-rpls-4/igt@kms_pm_rpm@basic-rte.html
[i915#12061]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/12061
[i915#12904]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/12904
[i915#13400]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/13400
[i915#14818]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14818
Build changes
-------------
* Linux: CI_DRM_17221 -> Patchwork_154231v3
CI-20190529: 20190529
CI_DRM_17221: 982ea59d889e38d422f37ff9cc2a41a713917ff6 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_8541: 8541
Patchwork_154231v3: 982ea59d889e38d422f37ff9cc2a41a713917ff6 @ git://anongit.freedesktop.org/gfx-ci/linux
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_154231v3/index.html
[-- Attachment #2: Type: text/html, Size: 5063 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-09-17 10:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-17 8:41 [PATCH v4 0/2] drm: Add GPU frequency tracepoint S Sebinraj
2025-09-17 8:41 ` [PATCH v4 1/2] drm: Add GPU frequency tracepoint at DRM level S Sebinraj
2025-09-17 9:17 ` Tvrtko Ursulin
2025-09-17 8:41 ` [PATCH v4 2/2] drm/xe: Add DRM GPU frequency tracepoint to Xe S Sebinraj
2025-09-17 9:19 ` Tvrtko Ursulin
2025-09-17 10:29 ` ✗ i915.CI.BAT: failure for drm: Add GPU frequency tracepoint (rev3) Patchwork
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox