[PATCH 1/4] drm: add a new drm event for GPU reset

Sharma, Shashank shashank.sharma at amd.com
Fri Jan 21 20:31:21 UTC 2022


 From 8144e60d9f80941dd9f8a53e4b468582aaa849b4 Mon Sep 17 00:00:00 2001
From: Shashank Sharma <shashank.sharma at amd.com>
Date: Fri, 21 Jan 2022 17:23:41 +0100
Subject: [PATCH 1/4] drm: add a new drm event for GPU reset

This patch adds a DRM uevent to indicate GPU reset event. A
userspace can register to this event and do some postprocessing
if supported by native driver.

An example usage has been added into AMDGPU driver in this series.

Cc: Alexander Deucher <alexander.deucher at amd.com>
Cc: Christian Koenig <christian.koenig at amd.com>
Signed-off-by: Shashank Sharma <shashank.sharma at amd.com>
---
  drivers/gpu/drm/drm_sysfs.c | 19 +++++++++++++++++++
  include/drm/drm_sysfs.h     |  1 +
  2 files changed, 20 insertions(+)

diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 968a9560b4aa..0d721d536bb1 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -343,6 +343,25 @@ void drm_sysfs_hotplug_event(struct drm_device *dev)
  }
  EXPORT_SYMBOL(drm_sysfs_hotplug_event);

+/**
+ * drm_sysfs_gpu_reset_event - generate a GPU reset uevent
+ * @dev: DRM device
+ *
+ * Send a uevent for the DRM device specified by @dev. This event will
+ * inform userspace that a GPU reset happened, and it can do some
+ * postprocessing (eg: data collecting from a trace event).
+ */
+void drm_sysfs_gpu_reset_event(struct drm_device *dev)
+{
+	char *event_string = "RESET=1";
+	char *envp[] = { event_string, NULL };
+
+	DRM_DEBUG("generating gpu reset event\n");
+
+	kobject_uevent_env(&dev->primary->kdev->kobj, KOBJ_CHANGE, envp);
+}
+EXPORT_SYMBOL(drm_sysfs_gpu_reset_event);
+
  /**
   * drm_sysfs_connector_status_event - generate a DRM uevent for connector
   * property status change
diff --git a/include/drm/drm_sysfs.h b/include/drm/drm_sysfs.h
index d454ef617b2c..312956a0a1bf 100644
--- a/include/drm/drm_sysfs.h
+++ b/include/drm/drm_sysfs.h
@@ -11,6 +11,7 @@ int drm_class_device_register(struct device *dev);
  void drm_class_device_unregister(struct device *dev);

  void drm_sysfs_hotplug_event(struct drm_device *dev);
+void drm_sysfs_gpu_reset_event(struct drm_device *dev);
  void drm_sysfs_connector_status_event(struct drm_connector *connector,
  				      struct drm_property *property);
  #endif
-- 
2.32.0



More information about the amd-gfx mailing list