Skip to contentSkip to conversation

drm/sysfb: Support basic power management

PATCH In review Thomas Zimmermann 2 participants 16 messages Apr 8 – May 5

Subsystems (3)
lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

cover drm/sysfb: Support basic power management

Add callbacks for suspending and resuming to the sysfb drivers. The helpers store and restore DRM state across the suspend/resume cycle.

While most hardware loses the system framebuffer setup on suspends, some systems do retain the configuration; notable emulators. Adding PM support makes it work with DRM.

Tested with vesadrm on qemu's bochs device.

Thomas Zimmermann (5):
drm/sysfb: corebootdrm: Support power management drm/sysfb: efidrm: Support power management drm/sysfb: ofdrm: Support power management drm/sysfb: simpledrm: Support power management drm/sysfb: vesadrm: Support power management

 drivers/gpu/drm/sysfb/corebootdrm.c | 21 +++++++++++++++++++++
 drivers/gpu/drm/sysfb/efidrm.c      | 19 +++++++++++++++++++
 drivers/gpu/drm/sysfb/ofdrm.c       | 19 +++++++++++++++++++
 drivers/gpu/drm/sysfb/simpledrm.c   | 21 +++++++++++++++++++++
 drivers/gpu/drm/sysfb/vesadrm.c     | 19 +++++++++++++++++++
 5 files changed, 99 insertions(+)
Signature · 1 line
2.53.0
author maintainer
#1 lore raw

PATCH 1/5 drm/sysfb: corebootdrm: Support power management

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.

---
 drivers/gpu/drm/sysfb/corebootdrm.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/gpu/drm/sysfb/corebootdrm.c +21 -0
index 5dc6f3c76f7b..853da9a609df 100644
@@ -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,
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] drm/sysfb: corebootdrm: Support power management

Quoted 11 lines · Thomas Zimmermann

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.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#3 lore raw

PATCH 2/5 drm/sysfb: efidrm: Support power management

In reply to Thomas Zimmermann

Set PM ops for the efidrm 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.

---
 drivers/gpu/drm/sysfb/efidrm.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/gpu/drm/sysfb/efidrm.c +19 -0
index a335c94a7bd7..1a1e36700976 100644
@@ -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>
@@ -20,6 +21,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>
@@ -371,6 +373,22 @@ static struct drm_driver efidrm_driver = {
  * Platform driver
  */
 
+static int efidrm_pm_suspend(struct device *dev)
+{
+	struct drm_device *drm = dev_get_drvdata(dev);
+
+	return drm_mode_config_helper_suspend(drm);
+}
+
+static int efidrm_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(efidrm_pm_ops, efidrm_pm_suspend, efidrm_pm_resume);
+
 static int efidrm_probe(struct platform_device *pdev)
 {
 	struct efidrm_device *efi;
@@ -403,6 +421,7 @@ static void efidrm_remove(struct platform_device *pdev)
 static struct platform_driver efidrm_platform_driver = {
 	.driver = {
 		.name = "efi-framebuffer",
+		.pm = pm_sleep_ptr(&efidrm_pm_ops),
 	},
 	.probe = efidrm_probe,
 	.remove = efidrm_remove,
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 2/5
#4 lore raw

Re: [PATCH 2/5] drm/sysfb: efidrm: Support power management

Quoted 11 lines · Thomas Zimmermann

Set PM ops for the efidrm 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.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#5 lore raw

PATCH 3/5 drm/sysfb: ofdrm: Support power management

In reply to Thomas Zimmermann

Set PM ops for the ofdrm 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.

---
 drivers/gpu/drm/sysfb/ofdrm.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/gpu/drm/sysfb/ofdrm.c +19 -0
index d38ba70f4e0d..8822ebcbc081 100644
@@ -4,6 +4,7 @@
 #include <linux/of_address.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 
 #include <drm/clients/drm_client_setup.h>
 #include <drm/drm_atomic.h>
@@ -20,6 +21,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>
@@ -1095,6 +1097,22 @@ static struct drm_driver ofdrm_driver = {
  * Platform driver
  */
 
+static int ofdrm_pm_suspend(struct device *dev)
+{
+	struct drm_device *drm = dev_get_drvdata(dev);
+
+	return drm_mode_config_helper_suspend(drm);
+}
+
+static int ofdrm_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(ofdrm_pm_ops, ofdrm_pm_suspend, ofdrm_pm_resume);
+
 static int ofdrm_probe(struct platform_device *pdev)
 {
 	struct ofdrm_device *odev;
@@ -1134,6 +1152,7 @@ static struct platform_driver ofdrm_platform_driver = {
 	.driver = {
 		.name = "of-display",
 		.of_match_table = ofdrm_of_match_display,
+		.pm = pm_sleep_ptr(&ofdrm_pm_ops),
 	},
 	.probe = ofdrm_probe,
 	.remove = ofdrm_remove,
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 3/5
#6 lore raw

Re: [PATCH 3/5] drm/sysfb: ofdrm: Support power management

Quoted 11 lines · Thomas Zimmermann

Set PM ops for the ofdrm 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.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#7 lore raw

PATCH 4/5 drm/sysfb: simpledrm: Support power management

In reply to Thomas Zimmermann

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.

---
 drivers/gpu/drm/sysfb/simpledrm.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/gpu/drm/sysfb/simpledrm.c +21 -0
index 7a95d2dacd9d..fc168920f2c6 100644
@@ -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,
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 4/5
#8 lore raw

Re: [PATCH 4/5] drm/sysfb: simpledrm: Support power management

Quoted 11 lines · Thomas Zimmermann

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.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#9 lore raw

PATCH 5/5 drm/sysfb: vesadrm: Support power management

In reply to Thomas Zimmermann

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.

---
 drivers/gpu/drm/sysfb/vesadrm.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/gpu/drm/sysfb/vesadrm.c +19 -0
index 4e00113e5c77..255b90a200b0 100644
@@ -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,
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 5/5
#10 lore raw

Re: [PATCH 5/5] drm/sysfb: vesadrm: Support power management

Quoted 11 lines · Thomas Zimmermann

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.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
#11 lore raw
In reply to Thomas Zimmermann

Thomas Zimmermann <[email protected]> writes:

Hello Thomas,

Quoted 7 lines

Add callbacks for suspending and resuming to the sysfb drivers. The helpers store and restore DRM state across the suspend/resume cycle.

While most hardware loses the system framebuffer setup on suspends, some systems do retain the configuration; notable emulators. Adding PM support makes it work with DRM.

Interesting addition, I wouldn't had thought that the state would be retained during a suspend/resume cycle. But I guess that makes sense for emulated devices.

Quoted 2 lines

Tested with vesadrm on qemu's bochs device.

You tested with vesadrm, do you know if would work for the other drivers too ? I guess that there is value in adding these to all these even if it might not work outside of emulators.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#12 lore raw

Hi Javier

Am 27.04.26 um 09:37 schrieb Javier Martinez Canillas:

Quoted 7 lines

Thomas Zimmermann <[email protected]> writes:

Hello Thomas,

Quoted 3 lines

Add callbacks for suspending and resuming to the sysfb drivers. The helpers store and restore DRM state across the suspend/resume cycle.

Quoted 7 lines
Quoted 4 lines

While most hardware loses the system framebuffer setup on suspends, some systems do retain the configuration; notable emulators. Adding PM support makes it work with DRM.

Interesting addition, I wouldn't had thought that the state would be retained during a suspend/resume cycle. But I guess that makes sense for emulated devices.

I only discovered this recently.

Quoted 6 lines
Quoted 3 lines

Tested with vesadrm on qemu's bochs device.

You tested with vesadrm, do you know if would work for the other drivers too ? I guess that there is value in adding these to all these even if it might not work outside of emulators.

Agreed. The drivers currently do nothing on suspend/resume, but pretend that hardware is still running afterwards. Since we haven't heard about problems with this, we can also try to suspend/resume DRM state correctly as it won't make things worse.

However, I only know that it works with vesadrm.

Best regards
Thomas

Quoted 1 line
Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
#13 lore raw
Quoted 27 lines · Thomas Zimmermann

Hi Javier

Am 27.04.26 um 09:37 schrieb Javier Martinez Canillas:

Quoted 7 lines

Thomas Zimmermann <[email protected]> writes:

Hello Thomas,

Quoted 3 lines

Add callbacks for suspending and resuming to the sysfb drivers. The helpers store and restore DRM state across the suspend/resume cycle.

Quoted 7 lines
Quoted 4 lines

While most hardware loses the system framebuffer setup on suspends, some systems do retain the configuration; notable emulators. Adding PM support makes it work with DRM.

Interesting addition, I wouldn't had thought that the state would be retained during a suspend/resume cycle. But I guess that makes sense for emulated devices.

I only discovered this recently.

Quoted 6 lines
Quoted 3 lines

Tested with vesadrm on qemu's bochs device.

You tested with vesadrm, do you know if would work for the other drivers too ? I guess that there is value in adding these to all these even if it might not work outside of emulators.

Quoted 7 lines

Agreed. The drivers currently do nothing on suspend/resume, but pretend that hardware is still running afterwards. Since we haven't heard about problems with this, we can also try to suspend/resume DRM state correctly as it won't make things worse.

However, I only know that it works with vesadrm.

Got it. Are you planning to merge this series then ?

Quoted 3 lines

Best regards
Thomas

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#14 lore raw

Am 05.05.26 um 11:27 schrieb Javier Martinez Canillas:

Quoted 26 lines
Quoted 24 lines · Thomas Zimmermann

Hi Javier

Am 27.04.26 um 09:37 schrieb Javier Martinez Canillas:

Quoted 7 lines

Thomas Zimmermann <[email protected]> writes:

Hello Thomas,

Quoted 3 lines

Add callbacks for suspending and resuming to the sysfb drivers. The helpers store and restore DRM state across the suspend/resume cycle.

Quoted 7 lines
Quoted 4 lines

While most hardware loses the system framebuffer setup on suspends, some systems do retain the configuration; notable emulators. Adding PM support makes it work with DRM.

Interesting addition, I wouldn't had thought that the state would be retained during a suspend/resume cycle. But I guess that makes sense for emulated devices.

I only discovered this recently.

Quoted 5 lines
Quoted 2 lines

Tested with vesadrm on qemu's bochs device.

You tested with vesadrm, do you know if would work for the other drivers too ? I guess that there is value in adding these to all these even if it might not work outside of emulators.

Quoted 8 lines
Quoted 7 lines

Agreed. The drivers currently do nothing on suspend/resume, but pretend that hardware is still running afterwards. Since we haven't heard about problems with this, we can also try to suspend/resume DRM state correctly as it won't make things worse.

However, I only know that it works with vesadrm.

Got it. Are you planning to merge this series then ?

Already done :)

Quoted 4 lines
Quoted 4 lines

Best regards
Thomas

Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
#15 lore raw
Quoted 1 line · Thomas Zimmermann

Am 05.05.26 um 11:27 schrieb Javier Martinez Canillas:

[...]

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

You tested with vesadrm, do you know if would work for the other drivers too ? I guess that there is value in adding these to all these even if it might not work outside of emulators.

Agreed. The drivers currently do nothing on suspend/resume, but pretend that hardware is still running afterwards. Since we haven't heard about problems with this, we can also try to suspend/resume DRM state correctly as it won't make things worse.

Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

However, I only know that it works with vesadrm.

Got it. Are you planning to merge this series then ?

Already done :)

Ah, great!

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat