All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Sharma, Shashank" <shashank.sharma@amd.com>
To: "amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>
Cc: "Deucher, Alexander" <Alexander.Deucher@amd.com>,
	"Somalapuram Amaranath" <Amaranath.Somalapuram@amd.com>,
	"Christian König" <Christian.Koenig@amd.com>
Subject: [PATCH 1/4] drm: add a new drm event for GPU reset
Date: Fri, 21 Jan 2022 21:31:21 +0100	[thread overview]
Message-ID: <0d298b2e-b0ba-160e-25b5-e324a88b06ad@amd.com> (raw)

 From 8144e60d9f80941dd9f8a53e4b468582aaa849b4 Mon Sep 17 00:00:00 2001
From: Shashank Sharma <shashank.sharma@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@amd.com>
Cc: Christian Koenig <christian.koenig@amd.com>
Signed-off-by: Shashank Sharma <shashank.sharma@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


                 reply	other threads:[~2022-01-21 20:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=0d298b2e-b0ba-160e-25b5-e324a88b06ad@amd.com \
    --to=shashank.sharma@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Amaranath.Somalapuram@amd.com \
    --cc=Christian.Koenig@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    /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 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.