]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/sysfb: vesadrm: Support power management
authorThomas Zimmermann <tzimmermann@suse.de>
Wed, 8 Apr 2026 12:03:18 +0000 (14:03 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Mon, 4 May 2026 12:31:00 +0000 (14:31 +0200)
Set PM ops for the vesadrm driver. Suspend and resume the DRM state
on systems that support it.

Many systems lose the hardware's framebuffer settings on suspend,
hence resuming doesn't work there. Yet some systems, most notably
emulators, keep the hardware state across suspend/resume cycles.
There, DRM's suspend and resume helpers bring back the display on
resume.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patch.msgid.link/20260408120722.328769-6-tzimmermann@suse.de
drivers/gpu/drm/sysfb/vesadrm.c

index 4e00113e5c770043377ce243709371022d9a837b..255b90a200b0252694da51835f7d36fca31b4a5e 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/limits.h>
 #include <linux/platform_device.h>
 #include <linux/sysfb.h>
+#include <linux/pm.h>
 
 #include <drm/clients/drm_client_setup.h>
 #include <drm/drm_atomic.h>
@@ -21,6 +22,7 @@
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_gem_shmem_helper.h>
 #include <drm/drm_managed.h>
+#include <drm/drm_modeset_helper.h>
 #include <drm/drm_modeset_helper_vtables.h>
 #include <drm/drm_print.h>
 #include <drm/drm_probe_helper.h>
@@ -617,6 +619,22 @@ static struct drm_driver vesadrm_driver = {
  * Platform driver
  */
 
+static int vesadrm_pm_suspend(struct device *dev)
+{
+       struct drm_device *drm = dev_get_drvdata(dev);
+
+       return drm_mode_config_helper_suspend(drm);
+}
+
+static int vesadrm_pm_resume(struct device *dev)
+{
+       struct drm_device *drm = dev_get_drvdata(dev);
+
+       return drm_mode_config_helper_resume(drm);
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(vesadrm_pm_ops, vesadrm_pm_suspend, vesadrm_pm_resume);
+
 static int vesadrm_probe(struct platform_device *pdev)
 {
        struct vesadrm_device *vesa;
@@ -649,6 +667,7 @@ static void vesadrm_remove(struct platform_device *pdev)
 static struct platform_driver vesadrm_platform_driver = {
        .driver = {
                .name = "vesa-framebuffer",
+               .pm = pm_sleep_ptr(&vesadrm_pm_ops),
        },
        .probe = vesadrm_probe,
        .remove = vesadrm_remove,