From: Daniel Vetter <daniel@ffwll.ch>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 3/3] drm/tegra: Implement subsystem-level suspend/resume
Date: Wed, 12 Aug 2015 17:08:37 +0200 [thread overview]
Message-ID: <20150812150837.GF17734@phenom.ffwll.local> (raw)
In-Reply-To: <1439390250-1402-3-git-send-email-thierry.reding@gmail.com>
On Wed, Aug 12, 2015 at 04:37:30PM +0200, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> 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
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
> drivers/gpu/drm/tegra/drm.c | 11 +++++++++++
> drivers/gpu/drm/tegra/drm.h | 4 ++++
> drivers/gpu/drm/tegra/fb.c | 24 ++++++++++++++++++++++++
> 3 files changed, 39 insertions(+)
>
> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
> index b5f24c0f93dc..10d62e3077de 100644
> --- a/drivers/gpu/drm/tegra/drm.c
> +++ b/drivers/gpu/drm/tegra/drm.c
> @@ -1022,8 +1022,16 @@ 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)) {
> + drm_kms_helper_poll_enable(drm);
> + return PTR_ERR(tegra->state);
> + }
>
> return 0;
> }
> @@ -1031,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;
> diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h
> index 567831191f8b..112e07d81557 100644
> --- a/drivers/gpu/drm/tegra/drm.h
> +++ b/drivers/gpu/drm/tegra/drm.h
> @@ -57,6 +57,8 @@ struct tegra_drm {
> struct work_struct work;
> struct mutex lock;
> } commit;
> +
> + struct drm_atomic_state *state;
> };
>
> struct tegra_drm_client;
> @@ -267,6 +269,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);
> diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
> index 9b8aa967fa71..6c60795a2622 100644
> --- a/drivers/gpu/drm/tegra/fb.c
> +++ b/drivers/gpu/drm/tegra/fb.c
> @@ -10,6 +10,8 @@
> * published by the Free Software Foundation.
> */
>
> +#include <linux/console.h>
> +
> #include "drm.h"
> #include "gem.h"
>
> @@ -414,3 +416,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
Should we move console_lock/unlock into the helper to avoid ugly ifdefery
like here? Just an aside really. We would need an _unlocked version then
though for i915, which tries to avoid the console_lock overhead with a
trylock and async worker. Or we could just move this into the fbdev helper
library too.
-Daniel
> +}
> +
> +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
> +}
> --
> 2.4.5
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2015-08-12 15:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-12 14:37 [PATCH v2 1/3] drm/atomic-helper: Implement drm_atomic_helper_duplicate_state() Thierry Reding
2015-08-12 14:37 ` [PATCH v2 2/3] drm/atomic-helper: Implement subsystem-level suspend/resume Thierry Reding
2015-08-12 15:06 ` Daniel Vetter
2015-08-12 14:37 ` [PATCH v2 3/3] drm/tegra: " Thierry Reding
2015-08-12 15:08 ` Daniel Vetter [this message]
2015-08-12 15:50 ` Emil Velikov
2015-08-12 15:02 ` [PATCH v2 1/3] drm/atomic-helper: Implement drm_atomic_helper_duplicate_state() Daniel Vetter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150812150837.GF17734@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox