drm/log: Implement suspend/resume
authorJocelyn Falempe <jfalempe@redhat.com>
Wed, 4 Dec 2024 15:45:04 +0000 (16:45 +0100)
committerJocelyn Falempe <jfalempe@redhat.com>
Tue, 10 Dec 2024 13:36:54 +0000 (14:36 +0100)
Normally the console is already suspended when the graphic driver
suspend callback is called, but if the parameter no_console_suspend
is set, it might still be active.
So call console_stop()/console_start() in the suspend/resume
callbacks, to make sure it won't try to write to the framebuffer
while the graphic driver is suspended.

Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
Reviewed-by: John Ogness <john.ogness@linutronix.de>
Acked-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20241204160014.1171469-6-jfalempe@redhat.com
drivers/gpu/drm/clients/drm_log.c

index 5a995742aec5c7065216893403b0c2b4a97a9c5e..d5f9c679f2c03cbf6a3551278c7c4c249dc134c4 100644 (file)
@@ -310,10 +310,30 @@ static int drm_log_client_hotplug(struct drm_client_dev *client)
        return 0;
 }
 
+static int drm_log_client_suspend(struct drm_client_dev *client, bool _console_lock)
+{
+       struct drm_log *dlog = client_to_drm_log(client);
+
+       console_stop(&dlog->con);
+
+       return 0;
+}
+
+static int drm_log_client_resume(struct drm_client_dev *client, bool _console_lock)
+{
+       struct drm_log *dlog = client_to_drm_log(client);
+
+       console_start(&dlog->con);
+
+       return 0;
+}
+
 static const struct drm_client_funcs drm_log_client_funcs = {
        .owner          = THIS_MODULE,
        .unregister     = drm_log_client_unregister,
        .hotplug        = drm_log_client_hotplug,
+       .suspend        = drm_log_client_suspend,
+       .resume         = drm_log_client_resume,
 };
 
 static void drm_log_write_thread(struct console *con, struct nbcon_write_context *wctxt)