Commit 736f29cd authored by Tomi Valkeinen's avatar Tomi Valkeinen Committed by Florian Tobias Schandinat

OMAPDSS: Use PM notifiers for system suspend

The current way how omapdss handles system suspend and resume is that
omapdss device (a platform device, which is not part of the device
hierarchy of the DSS HW devices, like DISPC and DSI, or panels.) uses
the suspend and resume callbacks from platform_driver to handle system
suspend. It does this by disabling all enabled panels on suspend, and
resuming the previously disabled panels on resume.

This presents a few problems.

One is that as omapdss device is not related to the panel devices or the
DSS HW devices, there's no ordering in the suspend process. This means
that suspend could be first ran for DSS HW devices and panels, and only
then for omapdss device. Currently this is not a problem, as DSS HW
devices and panels do not handle suspend.

Another, more pressing problem, is that when suspending or resuming, the
runtime PM functions return -EACCES as runtime PM is disabled during
system suspend. This causes the driver to print warnings, and operations
to fail as they think that they failed to bring up the HW.

This patch changes the omapdss suspend handling to use PM notifiers,
which are called before suspend and after resume. This way we have a
normally functioning system when we are suspending and resuming the
panels.

This patch, I believe, creates a problem that somebody could enable or
disable a panel between PM_SUSPEND_PREPARE and the system suspend, and
similarly the other way around in resume. I choose to ignore the problem
for now, as it sounds rather unlikely, and if it happens, it's not
fatal.

In the long run the system suspend handling of omapdss and panels should
be thought out properly. The current approach feels rather hacky.
Perhaps the panel drivers should handle system suspend, or the users of
omapdss (omapfb, omapdrm) should handle system suspend.

Note that after this patch we could probably revert
0eaf9f52 (OMAPDSS: use sync versions of
pm_runtime_put). But as I said, this patch may be temporary, so let's
leave the sync version still in place.
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
Reported-by: default avatarJassi Brar <jaswinder.singh@linaro.org>
Tested-by: default avatarJassi Brar <jaswinder.singh@linaro.org>
Tested-by: default avatarJoe Woodward <jw@terrafix.co.uk>
Signed-off-by: default avatarArchit Taneja <archit@ti.com>
[fts: fixed 2 brace coding style issues]
Signed-off-by: default avatarFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>
parent b6798951
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/suspend.h>
#include <video/omapdss.h> #include <video/omapdss.h>
...@@ -201,6 +202,28 @@ int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *)) ...@@ -201,6 +202,28 @@ int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *))
#endif /* CONFIG_DEBUG_FS && CONFIG_OMAP2_DSS_DEBUG_SUPPORT */ #endif /* CONFIG_DEBUG_FS && CONFIG_OMAP2_DSS_DEBUG_SUPPORT */
/* PLATFORM DEVICE */ /* PLATFORM DEVICE */
static int omap_dss_pm_notif(struct notifier_block *b, unsigned long v, void *d)
{
DSSDBG("pm notif %lu\n", v);
switch (v) {
case PM_SUSPEND_PREPARE:
DSSDBG("suspending displays\n");
return dss_suspend_all_devices();
case PM_POST_SUSPEND:
DSSDBG("resuming displays\n");
return dss_resume_all_devices();
default:
return 0;
}
}
static struct notifier_block omap_dss_pm_notif_block = {
.notifier_call = omap_dss_pm_notif,
};
static int __init omap_dss_probe(struct platform_device *pdev) static int __init omap_dss_probe(struct platform_device *pdev)
{ {
struct omap_dss_board_info *pdata = pdev->dev.platform_data; struct omap_dss_board_info *pdata = pdev->dev.platform_data;
...@@ -224,6 +247,8 @@ static int __init omap_dss_probe(struct platform_device *pdev) ...@@ -224,6 +247,8 @@ static int __init omap_dss_probe(struct platform_device *pdev)
else if (pdata->default_device) else if (pdata->default_device)
core.default_display_name = pdata->default_device->name; core.default_display_name = pdata->default_device->name;
register_pm_notifier(&omap_dss_pm_notif_block);
return 0; return 0;
err_debugfs: err_debugfs:
...@@ -233,6 +258,8 @@ static int __init omap_dss_probe(struct platform_device *pdev) ...@@ -233,6 +258,8 @@ static int __init omap_dss_probe(struct platform_device *pdev)
static int omap_dss_remove(struct platform_device *pdev) static int omap_dss_remove(struct platform_device *pdev)
{ {
unregister_pm_notifier(&omap_dss_pm_notif_block);
dss_uninitialize_debugfs(); dss_uninitialize_debugfs();
dss_uninit_overlays(pdev); dss_uninit_overlays(pdev);
...@@ -247,25 +274,9 @@ static void omap_dss_shutdown(struct platform_device *pdev) ...@@ -247,25 +274,9 @@ static void omap_dss_shutdown(struct platform_device *pdev)
dss_disable_all_devices(); dss_disable_all_devices();
} }
static int omap_dss_suspend(struct platform_device *pdev, pm_message_t state)
{
DSSDBG("suspend %d\n", state.event);
return dss_suspend_all_devices();
}
static int omap_dss_resume(struct platform_device *pdev)
{
DSSDBG("resume\n");
return dss_resume_all_devices();
}
static struct platform_driver omap_dss_driver = { static struct platform_driver omap_dss_driver = {
.remove = omap_dss_remove, .remove = omap_dss_remove,
.shutdown = omap_dss_shutdown, .shutdown = omap_dss_shutdown,
.suspend = omap_dss_suspend,
.resume = omap_dss_resume,
.driver = { .driver = {
.name = "omapdss", .name = "omapdss",
.owner = THIS_MODULE, .owner = THIS_MODULE,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment