From: Aakash Deep Sarkar <aakash.deep.sarkar@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: jeevaka.badrappan@intel.com, rodrigo.vivi@intel.com,
matthew.brost@intel.com, carlos.santa@intel.com,
matthew.auld@intel.com,
Aakash Deep Sarkar <aakash.deep.sarkar@intel.com>
Subject: [PATCH v4 7/9] drm/xe: Add a Kconfig option for GPU work period
Date: Fri, 26 Sep 2025 10:45:18 +0000 [thread overview]
Message-ID: <20250926104521.1815428-8-aakash.deep.sarkar@intel.com> (raw)
In-Reply-To: <20250926104521.1815428-1-aakash.deep.sarkar@intel.com>
Since this requirement is intended only for Android, there's
no reason to have it enabled by default in other distributions.
So, better to have it guarded by a Kconfig option.
Signed-off-by: Aakash Deep Sarkar <aakash.deep.sarkar@intel.com>
---
drivers/gpu/drm/xe/Makefile | 2 +-
drivers/gpu/drm/xe/xe_device.c | 1 -
drivers/gpu/drm/xe/xe_exec_queue.c | 5 +++--
drivers/gpu/drm/xe/xe_user.h | 27 ++++++++++++++++++++++++++-
drivers/gpu/trace/Kconfig | 12 ++++++++++++
5 files changed, 42 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
index ff6b584f3293..6fc23367bdfe 100644
--- a/drivers/gpu/drm/xe/Makefile
+++ b/drivers/gpu/drm/xe/Makefile
@@ -333,7 +333,7 @@ ifeq ($(CONFIG_DEBUG_FS),y)
xe-$(CONFIG_PCI_IOV) += xe_gt_sriov_pf_debugfs.o
- xe-y += xe_user.o
+ xe-$(CONFIG_TRACE_GPU_WORK_PERIOD) += xe_user.o
xe-$(CONFIG_DRM_XE_DISPLAY) += \
i915-display/intel_display_debugfs.o \
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index 5569a27abb09..c34da72e5c9a 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -486,7 +486,6 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
xa_init_flags(&xe->usm.asid_to_vm, XA_FLAGS_ALLOC);
xa_init_flags(&xe->work_period.users, XA_FLAGS_ALLOC1);
-
mutex_init(&xe->work_period.lock);
if (IS_ENABLED(CONFIG_DRM_XE_DEBUG)) {
diff --git a/drivers/gpu/drm/xe/xe_exec_queue.c b/drivers/gpu/drm/xe/xe_exec_queue.c
index 6eb34c62c779..d5013d546348 100644
--- a/drivers/gpu/drm/xe/xe_exec_queue.c
+++ b/drivers/gpu/drm/xe/xe_exec_queue.c
@@ -915,9 +915,10 @@ void xe_exec_queue_update_run_ticks(struct xe_exec_queue *q)
new_ts = xe_lrc_update_timestamp(lrc, &old_ts);
q->xef->run_ticks[q->class] += (new_ts - old_ts) * q->width;
- // Accumulate the runtime in nanosec for this queue into the xe file.
+
+ // Accumulate the runtime in ns for this queue
q->xef->active_duration_ns +=
- xe_gt_clock_interval_to_ns(gt, (new_ts - old_ts));
+ xe_gt_clock_interval_to_ns(gt, (new_ts - old_ts));
drm_dev_exit(idx);
}
diff --git a/drivers/gpu/drm/xe/xe_user.h b/drivers/gpu/drm/xe/xe_user.h
index ded816be7334..e4b726f989a4 100644
--- a/drivers/gpu/drm/xe/xe_user.h
+++ b/drivers/gpu/drm/xe/xe_user.h
@@ -72,12 +72,38 @@ struct xe_user {
u64 last_timestamp_ns;
};
+#if IS_ENABLED(CONFIG_TRACE_GPU_WORK_PERIOD)
+
int xe_user_init(struct xe_device *xe, struct xe_file *xef, unsigned int uid);
void xe_user_cancel_workers(struct xe_device *xe);
void xe_user_resume_workers(struct xe_device *xe);
+void __xe_user_free(struct kref *kref);
+
+#else
+
+static inline
+int xe_user_init(struct xe_device *xe, struct xe_file *xef, unsigned int uid)
+{
+ return 0;
+}
+
+static inline void __xe_user_free(struct kref *kref)
+{
+}
+
+static inline void xe_user_cancel_workers(struct xe_device *xe)
+{
+}
+
+static inline void xe_user_resume_workers(struct xe_device *xe)
+{
+}
+
+#endif // CONFIG_TRACE_GPU_WORK_PERIOD
+
static inline struct xe_user *
xe_user_get_unless_zero(struct xe_user *user)
{
@@ -93,7 +119,6 @@ xe_user_get(struct xe_user *user)
return user;
}
-void __xe_user_free(struct kref *kref);
static inline void xe_user_put(struct xe_user *user)
{
diff --git a/drivers/gpu/trace/Kconfig b/drivers/gpu/trace/Kconfig
index cd3d19c4a201..34f2e08cf1be 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_WORK_PERIOD
+ bool "Enable GPU work period tracepoint"
+ default n
+ help
+ Choose this option to enable tracepoint for tracking
+ GPU usage based on the UID. Intended for performance
+ profiling and required for Android.
+
+ Tracepoint availability varies by GPU driver.
+
+ If in doubt, say "N".
--
2.49.0
next prev parent reply other threads:[~2025-09-26 11:20 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-26 10:45 [PATCH v4 0/9] [ANDROID]: Add GPU work period support for Xe driver Aakash Deep Sarkar
2025-09-26 10:45 ` [PATCH v4 1/9] drm/xe: Add a new xe_user structure Aakash Deep Sarkar
2025-10-02 14:40 ` Rodrigo Vivi
2025-09-26 10:45 ` [PATCH v4 2/9] drm/xe: Add xe_gt_clock_interval_to_ns function Aakash Deep Sarkar
2025-09-26 10:45 ` [PATCH v4 3/9] drm/xe: Add a trace point for GPU work period Aakash Deep Sarkar
2025-10-02 14:42 ` Rodrigo Vivi
2025-10-03 21:41 ` Dixit, Ashutosh
2025-09-26 10:45 ` [PATCH v4 4/9] drm/xe: Modify xe_exec_queue_update_run_ticks Aakash Deep Sarkar
2025-09-26 10:45 ` [PATCH v4 5/9] drm/xe: Handle xe_user creation and removal Aakash Deep Sarkar
2025-09-26 11:29 ` Jani Nikula
2025-09-26 10:45 ` [PATCH v4 6/9] drm/xe: Implement xe_work_period_worker Aakash Deep Sarkar
2025-09-26 11:31 ` Jani Nikula
2025-09-26 10:45 ` Aakash Deep Sarkar [this message]
2025-09-26 10:45 ` [PATCH v4 8/9] drm/xe: Handle xe_work_period destruction Aakash Deep Sarkar
2025-09-26 11:32 ` Jani Nikula
2025-09-26 10:45 ` [PATCH v4 9/9] Hack patch: Do not merge Aakash Deep Sarkar
2025-09-26 11:59 ` ✗ CI.checkpatch: warning for : Add GPU work period support for Xe driver (rev4) Patchwork
2025-09-26 12:01 ` ✓ CI.KUnit: success " Patchwork
2025-09-26 12:51 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-09-26 18:04 ` ✗ Xe.CI.Full: " 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=20250926104521.1815428-8-aakash.deep.sarkar@intel.com \
--to=aakash.deep.sarkar@intel.com \
--cc=carlos.santa@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=jeevaka.badrappan@intel.com \
--cc=matthew.auld@intel.com \
--cc=matthew.brost@intel.com \
--cc=rodrigo.vivi@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