: Add GPU work period support for Xe driver
Subsystems (3)
v3 cover : Add GPU work period support for Xe driver
This patch series implements the Android VSR requirement GPU work period event for the Intel Xe driver.
|GpuWorkPeriodEvent| defines a non-overlapping, non-zero period of time from |start_time_ns| (inclusive) until |end_time_ns| (exclusive) for a given |uid|, and includes details of how much work the GPU was performing for |uid| during the period. When GPU work for a given |uid| runs on the GPU, the driver must track
one or more periods that cover the time where the work was running, and emit events soon after.
Full requirement is defined in the following file:
https://cs.android.com/android/platform/superproject/main/+\
main:frameworks/native/services/gpuservice/gpuwork/bpfprogs/gpuWork.c;l=35
The requirement is implemented using a delayed worker thread per user id instance to accumulate its runtime on the gpu and emit the event. Each user id instance is tracked using an xe_user structure and the runtime is updated every time the kworker is executed for this uid. The delay period is hardcoded to 500 msecs.
The runtime on the gpu is collected for each xe file individually inside the function xe_exec_queue_update_run_ticks and accumulated into the corresponding xe_user active_duration_ns field. The HW Context timestamp field in the GTT is used to derive the runtime in clock ticks and then converted into nanosecs before updating the active duration.
Aakash Deep Sarkar (8):
Add a new xe_user structure
Add xe_gt_clock_interval_to_ns function drm/xe: Add a trace point for GPU work period drm/xe: Modify xe_exec_queue_update_run_ticks Handle xe_user creation and removal drm/xe: Implement xe_work_period_worker drm/xe: Add a Kconfig option for GPU work period Handle xe_work_period destruction
drivers/gpu/drm/xe/Makefile | 2 + drivers/gpu/drm/xe/xe_device.c | 32 ++++ drivers/gpu/drm/xe/xe_device_types.h | 19 +++ drivers/gpu/drm/xe/xe_exec_queue.c | 8 + drivers/gpu/drm/xe/xe_gt_clock.c | 14 ++ drivers/gpu/drm/xe/xe_gt_clock.h | 1 + drivers/gpu/drm/xe/xe_pm.c | 5 + drivers/gpu/drm/xe/xe_user.c | 246 +++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_user.h | 129 ++++++++++++++ drivers/gpu/trace/Kconfig | 12 ++ include/trace/gpu_work_period.h | 59 +++++++ 11 files changed, 527 insertions(+) create mode 100644 drivers/gpu/drm/xe/xe_user.c create mode 100644 drivers/gpu/drm/xe/xe_user.h create mode 100644 include/trace/gpu_work_period.h
Signature · 1 line
2.49.0
PATCH v3 1/8 Add a new xe_user structure
For Android GPU work period event we need to track the runtime on the GPU for each user id. This means we can have multiple xe files opened by different processes/threads belonging to the same user id. All these xe files need to be grouped together so that one can easily identify these while calculating the run time for the given user id.
Currently, the xe driver doesn't record the user id of the calling process. Also, all the xe files created using open call are clubbed together inside the xe device structure with no way to distinguish between them based on the user id of the calling process.
To remedy these limitations we are adding another layer of indirection between xe device and xe file. xe device will now have a list of xe users each with a given user id; and each xe user will have a list of xe files each of which is created by a process that is associated with this user id.
The lifetime of the xe user structure should be between when a process with a new user id has opened the xe device; and when the last xe file belonging to this user id is closed.
--- drivers/gpu/drm/xe/Makefile | 2 + drivers/gpu/drm/xe/xe_user.c | 59 ++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_user.h | 81 ++++++++++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 drivers/gpu/drm/xe/xe_user.c create mode 100644 drivers/gpu/drm/xe/xe_user.h
drivers/gpu/drm/xe/Makefile +2 -0
@@ -333,6 +333,8 @@ ifeq ($(CONFIG_DEBUG_FS),y) xe-$(CONFIG_PCI_IOV) += xe_gt_sriov_pf_debugfs.o + xe-y += xe_user.o + xe-$(CONFIG_DRM_XE_DISPLAY) += \ i915-display/intel_display_debugfs.o \ i915-display/intel_display_debugfs_params.o \
drivers/gpu/drm/xe/xe_user.c new file +59 -0
59 lines not on this page · raw message
drivers/gpu/drm/xe/xe_user.h new file +81 -0
81 lines not on this page · raw message
Signature · 1 line
2.49.0
PATCH v3 2/8 Add xe_gt_clock_interval_to_ns function
In reply to Aakash Deep SarkarThe runtime of a user id in the GPU work period event are required to be given in nanosec unit. Since we want to use the HW Context timestamp register to derive the runtime for a context, we need a way to convert from GT clock ticks to nano seconds.
--- drivers/gpu/drm/xe/xe_gt_clock.c | 14 ++++++++++++++ drivers/gpu/drm/xe/xe_gt_clock.h | 1 + 2 files changed, 15 insertions(+)
drivers/gpu/drm/xe/xe_gt_clock.c +14 -0
@@ -110,3 +110,17 @@ u64 xe_gt_clock_interval_to_ms(struct xe_gt *gt, u64 count) {return div_u64_roundup (count *MSEC_PER_SEC , gt->info.reference_clock); } + +/** +* xe_gt_clock_interval_to_ns - Convert sampled GT clock ticks to nanosec +* +* @gt: the &xe_gt +* @count: count of GT clock ticks +* +* Returns: time in nanosec +*/ +u64 xe_gt_clock_interval_to_ns (struct xe_gt *gt,u64 count) +{ +return div_u64_roundup (count *NSEC_PER_SEC , gt->info.reference_clock); +} +
drivers/gpu/drm/xe/xe_gt_clock.h +1 -0
@@ -12,5 +12,6 @@ struct xe_gt;int xe_gt_clock_init (struct xe_gt *gt);u64 xe_gt_clock_interval_to_ms (struct xe_gt *gt,u64 count); +u64 xe_gt_clock_interval_to_ns (struct xe_gt *gt,u64 count);#endif
Signature · 1 line
2.49.0
PATCH v3 3/8 drm/xe: Add a trace point for GPU work period
In reply to Aakash Deep SarkarThe GPU work period event is required to have the following format:
Defines the structure of the kernel tracepoint:/sys/kernel/tracing/events/power/gpu_work_period
A value that uniquely identifies the GPU within the system.
uint32_t gpu_id;
The UID of the application (i.e. persistent, unique ID of the Android app) that submitted work to the GPU.
uint32_t uid;
The start time of the period in nanoseconds. The clock must be CLOCK_MONOTONIC_RAW, as returned by the ktime_get_raw_ns(void) function.
uint64_t start_time_ns;
The end time of the period in nanoseconds. The clock must be CLOCK_MONOTONIC_RAW, as returned by the ktime_get_raw_ns(void) function.
uint64_t end_time_ns;
The amount of time the GPU was running GPU work for |uid| during the period, in nanoseconds, without double-counting parallel GPU work for the same |uid|. For example, this might include the amount of time the GPU spent performing shader work (vertex work, fragment work, etc.) for |uid|.
uint64_t total_active_duration_ns;
--- include/trace/gpu_work_period.h | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 include/trace/gpu_work_period.h
include/trace/gpu_work_period.h new file +59 -0
@@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2025 Intel Corporation +*/ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM power + +#if !defined(_TRACE_GPU_WORK_PERIOD_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_GPU_WORK_PERIOD_H + +#include <linux/tracepoint.h> + +TRACE_EVENT (gpu_work_period, + +TP_PROTO ( + u32 gpu_id, + u32 uid, + u64 start_time_ns, + u64 end_time_ns, + u64 total_active_duration_ns + ), + +TP_ARGS (gpu_id, uid, start_time_ns, end_time_ns, total_active_duration_ns), + +TP_STRUCT__entry ( + __field(u32, gpu_id) + __field(u32, uid) + __field(u64, start_time_ns) + __field(u64, end_time_ns) +__field (u64, total_active_duration_ns) + ), + +TP_fast_assign ( + __entry->gpu_id = gpu_id; + __entry->uid = uid; + __entry->start_time_ns = start_time_ns; + __entry->end_time_ns = end_time_ns; + __entry->total_active_duration_ns = total_active_duration_ns; + ), + +TP_printk ("gpu_id=%u uid=%u start_time_ns=%llu end_time_ns=%llu total_active_duration_ns=%llu" , + __entry->gpu_id, + __entry->uid, + __entry->start_time_ns, + __entry->end_time_ns, + __entry->total_active_duration_ns) +); + +#endif /* _TRACE_GPU_WORK_PERIOD_H */ + +/* This part must be outside protection */ + +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_FILE gpu_work_period +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . + +#include <trace/define_trace.h>
Signature · 1 line
2.49.0
PATCH v3 4/8 drm/xe: Modify xe_exec_queue_update_run_ticks
In reply to Aakash Deep SarkarFor GPU work period event we need to record the run time of a context on the GPU in nanosecs. In the present xe driver code, we only record the run time in clock ticks and separately for each engine class.
So, we are adding a uint64 variable |active_duration_ns| in the xe file structure where we can record the cumulative run time in ns of all the engines for this context. The intent here is to add up the |active_duration_ns| in all the xe files belonging to a given user id to derive the run time for that user id.
--- drivers/gpu/drm/xe/xe_device_types.h | 3 +++ drivers/gpu/drm/xe/xe_exec_queue.c | 7 +++++++ 2 files changed, 10 insertions(+)
drivers/gpu/drm/xe/xe_device_types.h +3 -0
@@ -678,6 +678,9 @@ struct xe_file {/** @run_ticks: hw engine class run time in ticks for this drm client */ u64 run_ticks[XE_ENGINE_CLASS_MAX ]; +/** @active_duration_ns: total run time in ns for this xe file */ +u64 active_duration_ns; +/** @client: drm client */ struct xe_drm_client *client;
drivers/gpu/drm/xe/xe_exec_queue.c +7 -0
@@ -15,6 +15,7 @@#include "xe_dep_scheduler.h" #include "xe_device.h" #include "xe_gt.h" +#include "xe_gt_clock.h" #include "xe_hw_engine_class_sysfs.h" #include "xe_hw_engine_group.h" #include "xe_hw_fence.h"
@@ -887,6 +888,8 @@ void xe_exec_queue_update_run_ticks(struct xe_exec_queue *q) {struct xe_device *xe =gt_to_xe (q->gt);struct xe_lrc *lrc; +struct xe_gt *gt = q->gt; +u64 old_ts, new_ts;int idx;
@@ -912,6 +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. + q->xef->active_duration_ns += +xe_gt_clock_interval_to_ns (gt, (new_ts - old_ts)); +drm_dev_exit (idx); }
Signature · 1 line
2.49.0
PATCH v3 5/8 Handle xe_user creation and removal
In reply to Aakash Deep SarkarWe want our xe user structure to be created when a new user id opens the xe device node and to be destroyed when the final xe file with this uid is closed. In other words the xe_user structure for a uid should remain in scope as long as any process with this uid has an open xe file descriptor.
To implement this we maintain an xarray of xe user structures inside our xe device instance. Whenever a new xe file is created via an open call, we check if the calling process' uid is already present in our xarray. If so, we increment the refcount for the associated xe user and add this xe file to the list of xe files belonging to this xe user. Otherwise, we allocate a new xe user structure for this uid and initialize its file list with this xe file.
Whenever an xe file is destroyed, we decrement the refcount of the associated xe user. When the last xe file in the xe user's file list is destroyed, the xe user refcount should drop to zero and the xe user should be cleaned up. During the cleanup path we remove the xarray entry for this xe user in our xe device and free up its memory.
--- drivers/gpu/drm/xe/xe_device.c | 23 +++++++++ drivers/gpu/drm/xe/xe_device_types.h | 16 ++++++ drivers/gpu/drm/xe/xe_user.c | 76 +++++++++++++++++++++++++++- drivers/gpu/drm/xe/xe_user.h | 12 ++++- 4 files changed, 124 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_device.c +23 -0
@@ -64,6 +64,7 @@#include "xe_tile.h" #include "xe_ttm_stolen_mgr.h" #include "xe_ttm_sys_mgr.h" +#include "xe_user.h" #include "xe_vm.h" #include "xe_vm_madvise.h" #include "xe_vram.h"
@@ -79,9 +80,13 @@ static int xe_file_open(struct drm_device *dev, struct drm_file *file) {struct xe_device *xe =to_xe_device (dev);struct xe_drm_client *client; +struct xe_user *user;struct xe_file *xef;int ret = -ENOMEM ; +int uid = -EINVAL ; +u32 idx;struct task_struct *task =NULL ; +const struct cred *cred =NULL ; xef =kzalloc (sizeof (*xef),GFP_KERNEL );if (!xef)
@@ -106,8 +111,16 @@ static int xe_file_open(struct drm_device *dev, struct drm_file *file) file->driver_priv = xef;kref_init (&xef->refcount); +INIT_LIST_HEAD (&xef->user_link); + task =get_pid_task (rcu_access_pointer (file->pid),PIDTYPE_PID );if (task) { + cred =get_task_cred (task); +if (cred) { + uid = (unsigned int ) cred->euid.val; +xe_user_init (xe, xef, uid); +put_cred (cred); + } xef->process_name =kstrdup (task->comm,GFP_KERNEL ); xef->pid = task->pid;put_task_struct (task);
@@ -127,6 +140,12 @@ static void xe_file_destroy(struct kref *ref)xe_drm_client_put (xef->client);kfree (xef->process_name); + +mutex_lock (&xef->user->filelist_lock); +list_del (&xef->user_link); +mutex_unlock (&xef->user->filelist_lock); + +xe_user_put (xef->user);kfree (xef); }
@@ -466,6 +485,10 @@ 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 )) {/* Trigger a large asid and an early asid wrap. */ u32 asid;
drivers/gpu/drm/xe/xe_device_types.h +16 -0
@@ -608,6 +608,16 @@ struct xe_device {atomic_t g2g_test_count;#endif +/** +* @xe_work_period: Support for GPU work period tracepoint +*/ +struct xe_work_period { +/** @users: list of users that have opened this xe device */ +struct xarray users; +/** @lock: lock protecting this structure */ +struct mutex lock; + } work_period; +/* private: */ #if IS_ENABLED (CONFIG_DRM_XE_DISPLAY )
@@ -681,6 +691,12 @@ struct xe_file {/** @active_duration_ns: total run time in ns for this xe file */ u64 active_duration_ns; +/** @user: pointer to struct xe_user associated with this xe file */ +struct xe_user *user; + +/** @user_link: link into xe_user::filelist */ +struct list_head user_link; +/** @client: drm client */ struct xe_drm_client *client;
drivers/gpu/drm/xe/xe_user.c +74 -2
100 lines not on this page · raw message
drivers/gpu/drm/xe/xe_user.h +11 -1
@@ -8,8 +8,12 @@#include <linux/kref.h> #include <linux/list.h> +#include <linux/mutex.h> #include <linux/workqueue.h> +#include "xe_device.h" + +/** * This is a per process/user id structure for a xe device * client. It is allocated when a new process/app opens the
@@ -43,6 +47,11 @@ struct xe_user {*/ struct work_struct work; +/** +* @id: index of this user into the xe device users array +*/ +u32 id; +/** * @uid: user id for this xe_user */
@@ -61,7 +70,8 @@ struct xe_user {u64 last_timestamp_ns; }; -struct xe_user *xe_user_alloc (void ); +int xe_user_init (struct xe_device *xe,struct xe_file *xef,unsigned int uid); +static inline struct xe_user *xe_user_get (struct xe_user *user)
Signature · 1 line
2.49.0
PATCH v3 6/8 drm/xe: Implement xe_work_period_worker
In reply to Aakash Deep SarkarThe work of collecting the GPU run time for a given xe_user and emitting its event, is done by the xe_work_period_worker kworker. At the time of creation of a new xe_user, we simultaneously start a delayed kworker thread. The delay of execution is set to be 500 ms. After the completion of the work, the kworker schedules itself for the next execution. This is done as long as the reference to the xe_user pointer is valid.
During each execution cycle the xe_work_period_worker iterates over all the xe files in the xe_user::filelist and accumulate their corresponding GPU runtime into the xe_user::active_duration_ns; while also updating each of the xe_file::active_duration_ns. The total runtime for this uid in the current sampling period is the delta between the previous xe_user::active_duration_ns and the current xe_user::active_duration_ns.
We also record the current timestamp at the end of each invocation to xe_work_period_worker function in the xe_user::last_timestamp_ns. The sampling period for this uid is the delta between the previous timestamp and the current timestamp.
--- drivers/gpu/drm/xe/xe_device.c | 13 ++-- drivers/gpu/drm/xe/xe_pm.c | 5 ++ drivers/gpu/drm/xe/xe_user.c | 127 +++++++++++++++++++++++++++++++-- drivers/gpu/drm/xe/xe_user.h | 21 ++++-- 4 files changed, 149 insertions(+), 17 deletions(-)
drivers/gpu/drm/xe/xe_device.c +6 -7
@@ -80,11 +80,9 @@ static int xe_file_open(struct drm_device *dev, struct drm_file *file) {struct xe_device *xe =to_xe_device (dev);struct xe_drm_client *client; -struct xe_user *user;struct xe_file *xef;int ret = -ENOMEM ;int uid = -EINVAL ; -u32 idx;struct task_struct *task =NULL ;const struct cred *cred =NULL ;
@@ -141,11 +139,12 @@ static void xe_file_destroy(struct kref *ref)xe_drm_client_put (xef->client);kfree (xef->process_name); -mutex_lock (&xef->user->filelist_lock); -list_del (&xef->user_link); -mutex_unlock (&xef->user->filelist_lock); - -xe_user_put (xef->user); +if (xef->user) { +mutex_lock (&xef->user->lock); +list_del (&xef->user_link); +xe_user_put (xef->user); +mutex_unlock (&xef->user->lock); + }kfree (xef); }
drivers/gpu/drm/xe/xe_pm.c +5 -0
@@ -26,6 +26,7 @@#include "xe_pxp.h" #include "xe_sriov_vf_ccs.h" #include "xe_trace.h" +#include "xe_user.h" #include "xe_vm.h" #include "xe_wa.h"
@@ -532,6 +533,8 @@ int xe_pm_runtime_suspend(struct xe_device *xe)xe_i2c_pm_suspend (xe); +xe_user_cancel_workers (xe); +xe_rpm_lockmap_release (xe);xe_pm_write_callback_task (xe,NULL );return 0 ;
@@ -584,6 +587,8 @@ int xe_pm_runtime_resume(struct xe_device *xe)xe_i2c_pm_resume (xe, xe->d3cold.allowed); +xe_user_resume_workers (xe); +xe_irq_resume (xe);for_each_gt (gt, xe, id)
drivers/gpu/drm/xe/xe_user.c +121 -6
159 lines not on this page · raw message
drivers/gpu/drm/xe/xe_user.h +17 -4
@@ -11,9 +11,11 @@#include <linux/mutex.h> #include <linux/workqueue.h> -#include "xe_device.h" +#include "xe_device_types.h" +#define XE_WORK_PERIOD_INTERVAL 500 +/** * This is a per process/user id structure for a xe device * client. It is allocated when a new process/app opens the
@@ -32,9 +34,9 @@ struct xe_user {struct xe_device *xe;/** -* @filelist_lock: lock protecting the filelist +* @filelist_lock: lock protecting this structure */ -struct mutex filelist_lock; +struct mutex lock;/** * @filelist: list of xe files belonging to this xe user
@@ -45,7 +47,7 @@ struct xe_user {* @work: work to emit the gpu work period event for this * xe user */ -struct work_struct work; +struct delayed_work delay_work;/** * @id: index of this user into the xe device users array
@@ -72,6 +74,17 @@ struct xe_user {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); + +static inline struct xe_user * +xe_user_get_unless_zero (struct xe_user *user) +{ +if (kref_get_unless_zero (&user->refcount)) +return user; +return NULL ; +}static inline struct xe_user *xe_user_get (struct xe_user *user)
Signature · 1 line
2.49.0
PATCH v3 7/8 drm/xe: Add a Kconfig option for GPU work period
In reply to Aakash Deep SarkarSince 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.
--- 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(-)
drivers/gpu/drm/xe/Makefile +1 -1
@@ -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 \
drivers/gpu/drm/xe/xe_device.c +0 -1
@@ -485,7 +485,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 )) {
drivers/gpu/drm/xe/xe_exec_queue.c +3 -2
@@ -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); }
drivers/gpu/drm/xe/xe_user.h +26 -1
@@ -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) +{ +} + +void xe_user_cancel_workers (struct xe_device *xe) +{ +} + +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) {
drivers/gpu/trace/Kconfig +12 -0
@@ -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".
Signature · 1 line
2.49.0
PATCH v3 8/8 Handle xe_work_period destruction
In reply to Aakash Deep SarkarThis adds the xe_work_period destruction procedure. We iterate over all entries in the xe::work_period::users xarray and cancel any pending delayed work. Then destroy the xarray itself.
--- drivers/gpu/drm/xe/xe_device.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/gpu/drm/xe/xe_device.c +11 -0
@@ -418,6 +418,8 @@ static struct drm_driver driver = {static void xe_device_destroy (struct drm_device *dev,void *dummy) {struct xe_device *xe =to_xe_device (dev); +struct xe_user *user =NULL ; +unsigned long i;xe_bo_dev_fini (&xe->bo_device);
@@ -433,6 +435,15 @@ static void xe_device_destroy(struct drm_device *dev, void *dummy)if (xe->destroy_wq)destroy_workqueue (xe->destroy_wq); + +mutex_lock (&xe->work_period.lock); +xa_for_each (&xe->work_period.users, i, user) { +if (cancel_delayed_work_sync (&user->delay_work)) +xe_user_put (user); + } +xa_destroy (&xe->work_period.users); +mutex_unlock (&xe->work_period.lock); +ttm_device_fini (&xe->ttm); }
Signature · 1 line
2.49.0