]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/sysfb: simpledrm: Support power management
authorThomas Zimmermann <tzimmermann@suse.de>
Wed, 8 Apr 2026 12:03:17 +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 simpledrm 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-5-tzimmermann@suse.de
drivers/gpu/drm/sysfb/simpledrm.c

index 7a95d2dacd9d27db3d39ce3b6ca1dd37a9f3df92..fc168920f2c641b8d2389734de3e6cb6438a909f 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/of_reserved_mem.h>
 #include <linux/platform_data/simplefb.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 #include <linux/pm_domain.h>
 #include <linux/regulator/consumer.h>
 
@@ -24,6 +25,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>
@@ -834,6 +836,24 @@ static struct drm_driver simpledrm_driver = {
  * Platform driver
  */
 
+static int simpledrm_pm_suspend(struct device *dev)
+{
+       struct simpledrm_device *sdev = dev_get_drvdata(dev);
+       struct drm_device *drm = &sdev->sysfb.dev;
+
+       return drm_mode_config_helper_suspend(drm);
+}
+
+static int simpledrm_pm_resume(struct device *dev)
+{
+       struct simpledrm_device *sdev = dev_get_drvdata(dev);
+       struct drm_device *drm = &sdev->sysfb.dev;
+
+       return drm_mode_config_helper_resume(drm);
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(simpledrm_pm_ops, simpledrm_pm_suspend, simpledrm_pm_resume);
+
 static int simpledrm_probe(struct platform_device *pdev)
 {
        struct simpledrm_device *sdev;
@@ -874,6 +894,7 @@ static struct platform_driver simpledrm_platform_driver = {
        .driver = {
                .name = "simple-framebuffer", /* connect to sysfb */
                .of_match_table = simpledrm_of_match_table,
+               .pm = pm_sleep_ptr(&simpledrm_pm_ops),
        },
        .probe = simpledrm_probe,
        .remove = simpledrm_remove,