drm/sysfb: Support basic power management
Subsystems (3)
Thomas Zimmermann
maintainercover 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
Thomas Zimmermann
maintainerPATCH 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
@@ -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
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.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 2/5 drm/sysfb: efidrm: Support power management
In reply to Thomas ZimmermannSet 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
@@ -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
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.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 3/5 drm/sysfb: ofdrm: Support power management
In reply to Thomas ZimmermannSet 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
@@ -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
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.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 4/5 drm/sysfb: simpledrm: Support power management
In reply to Thomas ZimmermannSet 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
@@ -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
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.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH 5/5 drm/sysfb: vesadrm: Support power management
In reply to Thomas ZimmermannSet 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
@@ -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
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.
Signed-off-by Thomas Zimmermann <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Javier Martinez Canillas
maintainerThomas 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
Thomas Zimmermann
maintainerHi 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)
Javier Martinez Canillas
maintainerQuoted 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
Thomas Zimmermann
maintainerAm 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)
Javier Martinez Canillas
maintainerQuoted 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