drm/tegra: Implement subsystem-level suspend/resume
authorThierry Reding <treding@nvidia.com>
Tue, 11 Aug 2015 11:11:49 +0000 (13:11 +0200)
committerThierry Reding <treding@nvidia.com>
Mon, 14 Dec 2015 09:50:39 +0000 (10:50 +0100)
Use the drm_atomic_helper_suspend() and drm_atomic_helper_resume()
helpers to implement subsystem-level suspend/resume.

v2: suspend framebuffer device to avoid concurrency issues
v3: resume fbdev on failure to suspend (Emil Velikov)

Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/gpu/drm/tegra/drm.c
drivers/gpu/drm/tegra/drm.h
drivers/gpu/drm/tegra/fb.c

index c4910d5284115e941f995ac25f0050117fc128e7..ced5a095d2ad5a881ab72a9b3dedd6d48a48111e 100644 (file)
@@ -1021,8 +1021,17 @@ static int host1x_drm_remove(struct host1x_device *dev)
 static int host1x_drm_suspend(struct device *dev)
 {
        struct drm_device *drm = dev_get_drvdata(dev);
+       struct tegra_drm *tegra = drm->dev_private;
 
        drm_kms_helper_poll_disable(drm);
+       tegra_drm_fb_suspend(drm);
+
+       tegra->state = drm_atomic_helper_suspend(drm);
+       if (IS_ERR(tegra->state)) {
+               tegra_drm_fb_resume(drm);
+               drm_kms_helper_poll_enable(drm);
+               return PTR_ERR(tegra->state);
+       }
 
        return 0;
 }
@@ -1030,7 +1039,10 @@ static int host1x_drm_suspend(struct device *dev)
 static int host1x_drm_resume(struct device *dev)
 {
        struct drm_device *drm = dev_get_drvdata(dev);
+       struct tegra_drm *tegra = drm->dev_private;
 
+       drm_atomic_helper_resume(drm, tegra->state);
+       tegra_drm_fb_resume(drm);
        drm_kms_helper_poll_enable(drm);
 
        return 0;
index 5bf696c993acdabe6d8c249830561440c5d5fe47..c088f2f67eda7cebb50c3c54ac7849fced67d5cb 100644 (file)
@@ -57,6 +57,8 @@ struct tegra_drm {
                struct work_struct work;
                struct mutex lock;
        } commit;
+
+       struct drm_atomic_state *state;
 };
 
 struct tegra_drm_client;
@@ -272,6 +274,8 @@ int tegra_drm_fb_prepare(struct drm_device *drm);
 void tegra_drm_fb_free(struct drm_device *drm);
 int tegra_drm_fb_init(struct drm_device *drm);
 void tegra_drm_fb_exit(struct drm_device *drm);
+void tegra_drm_fb_suspend(struct drm_device *drm);
+void tegra_drm_fb_resume(struct drm_device *drm);
 #ifdef CONFIG_DRM_FBDEV_EMULATION
 void tegra_fbdev_restore_mode(struct tegra_fbdev *fbdev);
 void tegra_fb_output_poll_changed(struct drm_device *drm);
index ede9e94f33120c2f397ac8b10498e0740d1340a6..a7213f30fb207879bdf5b8db92ac408b694bc3c4 100644 (file)
@@ -10,6 +10,8 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/console.h>
+
 #include "drm.h"
 #include "gem.h"
 
@@ -413,3 +415,25 @@ void tegra_drm_fb_exit(struct drm_device *drm)
        tegra_fbdev_exit(tegra->fbdev);
 #endif
 }
+
+void tegra_drm_fb_suspend(struct drm_device *drm)
+{
+#ifdef CONFIG_DRM_FBDEV_EMULATION
+       struct tegra_drm *tegra = drm->dev_private;
+
+       console_lock();
+       drm_fb_helper_set_suspend(&tegra->fbdev->base, 1);
+       console_unlock();
+#endif
+}
+
+void tegra_drm_fb_resume(struct drm_device *drm)
+{
+#ifdef CONFIG_DRM_FBDEV_EMULATION
+       struct tegra_drm *tegra = drm->dev_private;
+
+       console_lock();
+       drm_fb_helper_set_suspend(&tegra->fbdev->base, 0);
+       console_unlock();
+#endif
+}