[PATCH 3/4] watch_queue: Add a DRM_XE_NOTIFY watch type and export init_watch()
From: Thomas Hellström
Date: Fri Jun 12 2026 - 09:54:53 EST
Add a DRM_XE_NOTIFY watch type for asynchronous error notifications
from the DRM_XE kernel module.
The reason for not registering a DRM - wide notification type is
that the notification type is 24 bits wide, the subtype is only 8,
If this is a concern one could define the DRM - wide subtypes
to be per driver, not common across DRM.
Also export the init_watch() function for use from kernel drivers.
Use EXPORT_SYMBOL() to align with other exports from the same file.
Assisted-by: GitHub_Copilot:claude-sonnet-4.6
Signed-off-by: Thomas Hellström <thomas.hellstrom@xxxxxxxxxxxxxxx>
---
include/uapi/drm/xe_drm.h | 4 ++--
include/uapi/linux/watch_queue.h | 3 ++-
kernel/watch_queue.c | 13 ++++++++++---
3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/include/uapi/drm/xe_drm.h b/include/uapi/drm/xe_drm.h
index bebb0167bd31..8d5e3f06b8d4 100644
--- a/include/uapi/drm/xe_drm.h
+++ b/include/uapi/drm/xe_drm.h
@@ -2550,8 +2550,8 @@ struct drm_xe_exec_queue_set_property {
* preempt-fence mode or not restartable.
*
* An optional @timestamp_ns can be provided to measure the latency between
- * event delivery and the point the worker is queued; the driver logs this
- * once all sanity checks have passed.
+ * event delivery and locking; the driver logs this regardless of whether the
+ * VM was paused.
*/
/**
diff --git a/include/uapi/linux/watch_queue.h b/include/uapi/linux/watch_queue.h
index c3d8320b5d3a..c800c153989d 100644
--- a/include/uapi/linux/watch_queue.h
+++ b/include/uapi/linux/watch_queue.h
@@ -14,7 +14,8 @@
enum watch_notification_type {
WATCH_TYPE_META = 0, /* Special record */
WATCH_TYPE_KEY_NOTIFY = 1, /* Key change event notification */
- WATCH_TYPE__NR = 2
+ WATCH_TYPE_DRM_XE_NOTIFY = 2, /* DRM device event notification */
+ WATCH_TYPE__NR = 3
};
enum watch_meta_notification_subtype {
diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c
index 538520861e8b..701b5c388808 100644
--- a/kernel/watch_queue.c
+++ b/kernel/watch_queue.c
@@ -445,11 +445,17 @@ static void put_watch(struct watch *watch)
}
/**
- * init_watch - Initialise a watch
+ * init_watch() - Initialise a watch subscription
* @watch: The watch to initialise.
- * @wqueue: The queue to assign.
+ * @wqueue: The watch queue (notification pipe) to associate with the watch.
*
- * Initialise a watch and set the watch queue.
+ * Initialise a newly allocated watch object and associate it with @wqueue.
+ * The caller must subsequently set @watch->id and @watch->info_id before
+ * calling add_watch_to_object() to subscribe the watch to a notification
+ * source.
+ *
+ * The watch queue reference is held internally; call put_watch_queue() if
+ * the watch is not successfully passed to add_watch_to_object().
*/
void init_watch(struct watch *watch, struct watch_queue *wqueue)
{
@@ -458,6 +464,7 @@ void init_watch(struct watch *watch, struct watch_queue *wqueue)
INIT_HLIST_NODE(&watch->queue_node);
rcu_assign_pointer(watch->queue, wqueue);
}
+EXPORT_SYMBOL(init_watch);
static int add_one_watch(struct watch *watch, struct watch_list *wlist, struct watch_queue *wqueue)
{
--
2.54.0