]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/sysfb: corebootdrm: Support power management
authorThomas Zimmermann <tzimmermann@suse.de>
Wed, 8 Apr 2026 12:03:14 +0000 (14:03 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Mon, 4 May 2026 12:30:58 +0000 (14:30 +0200)
Set PM ops for the corebootdrm 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-2-tzimmermann@suse.de
drivers/gpu/drm/sysfb/corebootdrm.c

index 5dc6f3c76f7bd97e5a2d63a7db0ed0489dcb32df..853da9a609dfb228abc1e7e5063bba2b6208de6e 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/coreboot.h>
 #include <linux/minmax.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 
 #include <drm/clients/drm_client_setup.h>
 #include <drm/drm_atomic.h>
@@ -18,6 +19,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>
@@ -286,6 +288,24 @@ static struct drm_driver corebootdrm_drm_driver = {
  * Coreboot driver
  */
 
+static int corebootdrm_pm_suspend(struct device *dev)
+{
+       struct corebootdrm_device *cdev = dev_get_drvdata(dev);
+       struct drm_device *drm = &cdev->sysfb.dev;
+
+       return drm_mode_config_helper_suspend(drm);
+}
+
+static int corebootdrm_pm_resume(struct device *dev)
+{
+       struct corebootdrm_device *cdev = dev_get_drvdata(dev);
+       struct drm_device *drm = &cdev->sysfb.dev;
+
+       return drm_mode_config_helper_resume(drm);
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(corebootdrm_pm_ops, corebootdrm_pm_suspend, corebootdrm_pm_resume);
+
 static int corebootdrm_probe(struct platform_device *pdev)
 {
        const struct lb_framebuffer *fb = dev_get_platdata(&pdev->dev);
@@ -423,6 +443,7 @@ static void corebootdrm_remove(struct platform_device *pdev)
 static struct platform_driver corebootdrm_platform_driver = {
        .driver = {
                .name = "coreboot-framebuffer",
+               .pm = pm_sleep_ptr(&corebootdrm_pm_ops),
        },
        .probe = corebootdrm_probe,
        .remove = corebootdrm_remove,