public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peiyong Lin <lpy@google.com>
To: brian.starkey@arm.com
Cc: alexdeucher@gmail.com, android-kernel@google.com,
	dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org,
	linux-kernel@vger.kernel.org, lpy@google.com, mingo@redhat.com,
	nd@arm.com, paul.walmsley@sifive.com, pavel@ucw.cz,
	prahladk@google.com, rafael.j.wysocki@intel.com,
	rostedt@goodmis.org, sidaths@google.com, ulf.hansson@linaro.org,
	yamada.masahiro@socionext.com, zzyiwei@android.com
Subject: [PATCH v5] Add power/gpu_frequency tracepoint.
Date: Mon, 21 Dec 2020 12:10:19 -0800	[thread overview]
Message-ID: <20201221201019.2897731-1-lpy@google.com> (raw)
In-Reply-To: <20201202123420.g3ivr5le4imcrdsa@DESKTOP-E1NTVVP.localdomain>

Historically there is no common trace event for GPU frequency, in
downstream Android each different hardware vendor implements their own
way to expose GPU frequency, for example as a debugfs node.  This patch
standardize it as a common trace event in upstream linux kernel to help
the ecosystem have a common implementation across hardware vendors.
Toolings in the Linux ecosystem will benefit from this especially in the
downstream Android, where this information is critical to graphics
developers.

Signed-off-by: Peiyong Lin <lpy@google.com>
---

Changelog since v4:
 - Explicitly use class id and instance id to identify a GPU instance.
 - Change gpu_id to clock_id to call out its the clock domain in
   the GPU instance.

Changelog since v3:
 - Correct copyright title.

Changelog since v2:
 - Add more comments to indicate when the event should be emitted.
 - Change state to frequency.

Changelog since v1:
 - Use %u in TP_printk

 drivers/gpu/Makefile                    |  1 +
 drivers/gpu/trace/Kconfig               |  3 ++
 drivers/gpu/trace/Makefile              |  1 +
 drivers/gpu/trace/trace_gpu_frequency.c | 13 ++++++++
 include/trace/events/power.h            | 41 +++++++++++++++++++++++++
 5 files changed, 59 insertions(+)
 create mode 100644 drivers/gpu/trace/trace_gpu_frequency.c

diff --git a/drivers/gpu/Makefile b/drivers/gpu/Makefile
index 835c88318cec..f289a47eb031 100644
--- a/drivers/gpu/Makefile
+++ b/drivers/gpu/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_TEGRA_HOST1X)	+= host1x/
 obj-y			+= drm/ vga/
 obj-$(CONFIG_IMX_IPUV3_CORE)	+= ipu-v3/
 obj-$(CONFIG_TRACE_GPU_MEM)		+= trace/
+obj-$(CONFIG_TRACE_GPU_FREQUENCY)		+= trace/
diff --git a/drivers/gpu/trace/Kconfig b/drivers/gpu/trace/Kconfig
index c24e9edd022e..ac4aec8d5845 100644
--- a/drivers/gpu/trace/Kconfig
+++ b/drivers/gpu/trace/Kconfig
@@ -2,3 +2,6 @@
 
 config TRACE_GPU_MEM
 	bool
+
+config TRACE_GPU_FREQUENCY
+	bool
diff --git a/drivers/gpu/trace/Makefile b/drivers/gpu/trace/Makefile
index b70fbdc5847f..2b7ae69327d6 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_FREQUENCY) += trace_gpu_frequency.o
diff --git a/drivers/gpu/trace/trace_gpu_frequency.c b/drivers/gpu/trace/trace_gpu_frequency.c
new file mode 100644
index 000000000000..668fabd6b77a
--- /dev/null
+++ b/drivers/gpu/trace/trace_gpu_frequency.c
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * GPU frequency trace points
+ *
+ * Copyright (C) 2020 Google LLC
+ */
+
+#include <linux/module.h>
+
+#define CREATE_TRACE_POINTS
+#include <trace/events/power.h>
+
+EXPORT_TRACEPOINT_SYMBOL(gpu_frequency);
diff --git a/include/trace/events/power.h b/include/trace/events/power.h
index af5018aa9517..590e16169dd1 100644
--- a/include/trace/events/power.h
+++ b/include/trace/events/power.h
@@ -500,6 +500,47 @@ DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_remove_request,
 
 	TP_ARGS(name, type, new_value)
 );
+
+/**
+ * gpu_frequency - Reports the GPU frequency in GPU clock domains.
+ *
+ * This event should be emitted whenever there's a GPU frequency change happens,
+ * or a GPU goes from idle state to active state, or vice versa.
+ *
+ * When the GPU goes from idle state to active state, this event should report
+ * the GPU frequency of the active state. When the GPU goes from active state to
+ * idle state, this event should report a zero frequency value.
+ *
+ * @frequency:  New frequency (in KHz)
+ * @gpu_class_id: Id representing the class of the GPU
+ * @gpu_instance_id: Id representing the instance of class &gpu_class_id
+ * @clock_id: Id for the clock domain in &gpu_instance_id running at &frequency
+ */
+TRACE_EVENT(gpu_frequency,
+
+	TP_PROTO(unsigned int frequency, unsigned int gpu_class_id,
+		 unsigned int gpu_instance_id, unsigned int clock_id),
+
+	TP_ARGS(frequency, gpu_class_id, gpu_instance_id, clock_id),
+
+	TP_STRUCT__entry(
+		__field(unsigned int, frequency)
+		__field(unsigned int, gpu_class_id)
+		__field(unsigned int, gpu_instance_id)
+		__field(unsigned int, clock_id)
+	),
+
+	TP_fast_assign(
+		__entry->frequency = frequency;
+		__entry->gpu_class_id = gpu_class_id;
+		__entry->gpu_instance_id = gpu_instance_id;
+		__entry->clock_id = clock_id;
+	),
+
+	TP_printk("frequency=%u gpu_class_id=%u gpu_instance_id=%u clock_id=%u",
+		__entry->frequency, __entry->gpu_class_id,
+		__entry->gpu_instance_id, __entry->clock_id)
+);
 #endif /* _TRACE_POWER_H */
 
 /* This part must be outside protection */
-- 
2.29.2.684.gfbc64c5ab5-goog


  reply	other threads:[~2020-12-21 20:11 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-13 21:03 [PATCH] Add power/gpu_frequency tracepoint Peiyong Lin
2020-08-13 21:22 ` Steven Rostedt
2020-08-13 21:37   ` [PATCH v2] " Peiyong Lin
2020-08-13 21:50     ` Steven Rostedt
2020-08-20 19:41       ` [PATCH v3] " Peiyong Lin
2020-08-20 20:27         ` Steven Rostedt
2020-10-22 16:59           ` [PATCH] " Peiyong Lin
2020-10-22 17:34           ` [PATCH v4] " Peiyong Lin
2020-10-26 22:25             ` Peiyong Lin
2020-10-27  6:16               ` Greg Kroah-Hartman
2020-11-16 20:55             ` Peiyong Lin
2020-11-16 21:05               ` Steven Rostedt
2020-11-17 18:00                 ` Rafael J. Wysocki
2020-11-17 18:10                   ` Alex Deucher
2020-11-17 21:31             ` Peiyong Lin
2020-11-30 22:33               ` Peiyong Lin
2020-12-02 12:34                 ` Brian Starkey
2020-12-21 20:10                   ` Peiyong Lin [this message]
2021-03-10 21:56                     ` [PATCH v5] " Peiyong Lin
2021-03-12 18:08                       ` Pavel Machek
     [not found] ` <159741850487.10342.14268227307882225260@build.alporthouse.com>
2020-08-14 19:25   ` [PATCH] " Peiyong Lin

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=20201221201019.2897731-1-lpy@google.com \
    --to=lpy@google.com \
    --cc=alexdeucher@gmail.com \
    --cc=android-kernel@google.com \
    --cc=brian.starkey@arm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=nd@arm.com \
    --cc=paul.walmsley@sifive.com \
    --cc=pavel@ucw.cz \
    --cc=prahladk@google.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rostedt@goodmis.org \
    --cc=sidaths@google.com \
    --cc=ulf.hansson@linaro.org \
    --cc=yamada.masahiro@socionext.com \
    --cc=zzyiwei@android.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