Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: S Sebinraj <s.sebinraj@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <jeevaka.badrappan@intel.com>
Subject: Re: [PATCH v2 1/2] drm: Add GPU frequency tracepoint at DRM level
Date: Tue, 9 Sep 2025 10:24:29 -0400	[thread overview]
Message-ID: <aMA4nSKHJ8fJQ1yY@intel.com> (raw)
In-Reply-To: <20250908125633.2680617-2-s.sebinraj@intel.com>

On Mon, Sep 08, 2025 at 06:26:32PM +0530, 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.

This needs to be sent to dri-devel@lists.freedesktop.org with
drm maintainers in cc.

> 
> 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
> 

  reply	other threads:[~2025-09-09 14:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-08 12:56 [PATCH v2 0/2] drm: Add GPU frequency tracepoint S Sebinraj
2025-09-08 12:56 ` [PATCH v2 1/2] drm: Add GPU frequency tracepoint at DRM level S Sebinraj
2025-09-09 14:24   ` Rodrigo Vivi [this message]
2025-09-08 12:56 ` [PATCH v2 2/2] drm/xe: Add DRM GPU frequency tracepoint to Xe S Sebinraj
2025-09-08 13:50 ` [PATCH v2 0/2] drm: Add GPU frequency tracepoint Dixit, Ashutosh
2025-09-08 23:32 ` ✗ CI.checkpatch: warning for " Patchwork
2025-09-08 23:34 ` ✓ CI.KUnit: success " Patchwork
2025-09-09  5:06 ` ✗ Xe.CI.Full: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aMA4nSKHJ8fJQ1yY@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jeevaka.badrappan@intel.com \
    --cc=s.sebinraj@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox