All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm: Add GPU reset sysfs event
@ 2022-03-07 16:26 Shashank Sharma
  2022-03-07 16:26 ` [PATCH 2/2] drm/amdgpu: add work function for GPU reset event Shashank Sharma
                   ` (3 more replies)
  0 siblings, 4 replies; 32+ messages in thread
From: Shashank Sharma @ 2022-03-07 16:26 UTC (permalink / raw)
  To: amd-gfx
  Cc: Alexandar Deucher, amaranath.somalapuram, Christian Koenig,
	shashank.sharma

From: Shashank Sharma <shashank.sharma@amd.com>

This patch adds a new sysfs event, which will indicate
the userland about a GPU reset, and can also provide
some information like:
- which PID was involved in the GPU reset
- what was the GPU status (using flags)

This patch also introduces the first flag of the flags
bitmap, which can be appended as and when required.

Cc: Alexandar Deucher <alexander.deucher@amd.com>
Cc: Christian Koenig <christian.koenig@amd.com>
Signed-off-by: Shashank Sharma <shashank.sharma@amd.com>
---
 drivers/gpu/drm/drm_sysfs.c | 24 ++++++++++++++++++++++++
 include/drm/drm_sysfs.h     |  3 +++
 2 files changed, 27 insertions(+)

diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 430e00b16eec..52a015161431 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -409,6 +409,30 @@ void drm_sysfs_hotplug_event(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_sysfs_hotplug_event);
 
+/**
+ * drm_sysfs_reset_event - generate a DRM uevent to indicate GPU reset
+ * @dev: DRM device
+ * @pid: The process ID involve with the reset
+ * @flags: Any other information about the GPU status
+ *
+ * Send a uevent for the DRM device specified by @dev. This indicates
+ * user that a GPU reset has occurred, so that the interested client
+ * can take any recovery or profiling measure, when required.
+ */
+void drm_sysfs_reset_event(struct drm_device *dev, uint64_t pid, uint32_t flags)
+{
+	unsigned char pid_str[21], flags_str[15];
+	unsigned char reset_str[] = "RESET=1";
+	char *envp[] = { reset_str, pid_str, flags_str, NULL };
+
+	DRM_DEBUG("generating reset event\n");
+
+	snprintf(pid_str, ARRAY_SIZE(pid_str), "PID=%lu", pid);
+	snprintf(flags_str, ARRAY_SIZE(flags_str), "FLAGS=%u", flags);
+	kobject_uevent_env(&dev->primary->kdev->kobj, KOBJ_CHANGE, envp);
+}
+EXPORT_SYMBOL(drm_sysfs_reset_event);
+
 /**
  * drm_sysfs_connector_hotplug_event - generate a DRM uevent for any connector
  * change
diff --git a/include/drm/drm_sysfs.h b/include/drm/drm_sysfs.h
index 6273cac44e47..63f00fe8054c 100644
--- a/include/drm/drm_sysfs.h
+++ b/include/drm/drm_sysfs.h
@@ -2,6 +2,8 @@
 #ifndef _DRM_SYSFS_H_
 #define _DRM_SYSFS_H_
 
+#define DRM_GPU_RESET_FLAG_VRAM_VALID (1 << 0)
+
 struct drm_device;
 struct device;
 struct drm_connector;
@@ -11,6 +13,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_reset_event(struct drm_device *dev, uint64_t pid, uint32_t reset_flags);
 void drm_sysfs_connector_hotplug_event(struct drm_connector *connector);
 void drm_sysfs_connector_status_event(struct drm_connector *connector,
 				      struct drm_property *property);
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2022-03-09  8:05 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-07 16:26 [PATCH 1/2] drm: Add GPU reset sysfs event Shashank Sharma
2022-03-07 16:26 ` [PATCH 2/2] drm/amdgpu: add work function for GPU reset event Shashank Sharma
2022-03-07 16:46   ` Somalapuram, Amaranath
2022-03-07 17:05     ` Sharma, Shashank
2022-03-08  7:15   ` Christian König
2022-03-08  9:35     ` Sharma, Shashank
2022-03-08 16:26   ` Andrey Grodzovsky
2022-03-08 16:30     ` Sharma, Shashank
2022-03-08 17:20       ` Somalapuram, Amaranath
2022-03-08 18:53         ` Andrey Grodzovsky
2022-03-08  6:32 ` [PATCH 1/2] drm: Add GPU reset sysfs event Somalapuram, Amaranath
2022-03-08  7:06 ` Christian König
2022-03-08  9:31   ` Sharma, Shashank
2022-03-08 10:32     ` Christian König
2022-03-08 11:56       ` Sharma, Shashank
2022-03-08 15:37         ` Somalapuram, Amaranath
2022-03-09  8:02           ` Christian König
2022-03-08 16:40         ` Sharma, Shashank
2022-03-09  8:05           ` Christian König
2022-03-08 16:25 ` Andrey Grodzovsky
2022-03-08 16:35   ` Sharma, Shashank
2022-03-08 16:36     ` Andrey Grodzovsky
2022-03-08 16:36   ` Lazar, Lijo
2022-03-08 16:39     ` Andrey Grodzovsky
2022-03-08 16:46       ` Sharma, Shashank
2022-03-08 16:55         ` Andrey Grodzovsky
2022-03-08 16:57           ` Sharma, Shashank
2022-03-08 17:04             ` Somalapuram, Amaranath
2022-03-08 17:17               ` Andrey Grodzovsky
2022-03-08 17:27             ` Limonciello, Mario
2022-03-08 18:08               ` Sharma, Shashank
2022-03-08 18:10                 ` Limonciello, Mario

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.