Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1708056 > unrolled thread

[PATCH] drm/rockchip: Skip suspend/resume if no display is attached

Started byMatthias Kaehlcke <mka@chromium.org>
First post2017-08-10 01:10 +0200
Last post2017-08-10 02:00 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] drm/rockchip: Skip suspend/resume if no display is attached Matthias Kaehlcke <mka@chromium.org> - 2017-08-10 01:10 +0200
    Re: [PATCH] drm/rockchip: Skip suspend/resume if no display is  attached Brian Norris <briannorris@chromium.org> - 2017-08-10 02:00 +0200

#1708056 — [PATCH] drm/rockchip: Skip suspend/resume if no display is attached

FromMatthias Kaehlcke <mka@chromium.org>
Date2017-08-10 01:10 +0200
Subject[PATCH] drm/rockchip: Skip suspend/resume if no display is attached
Message-ID<ucIgV-5AE-3@gated-at.bofh.it>
rockchip_drm_sys_suspend/resume() obains a struct drm_device pointer
from drvdata, the pointer is then dereferenced to obtain private data.
drvdata is set when a display is bound, on systems without a
(successfully probed) display drvdata is NULL and the PM functions
try to dereference a NULL pointer.

The suspend/resume code relies on a valid drm_device object, skip it if
the pointer is NULL.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index c6b1b7f3a2a3..6228145d9496 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -275,11 +275,16 @@ static void rockchip_drm_fb_resume(struct drm_device *drm)
 static int rockchip_drm_sys_suspend(struct device *dev)
 {
 	struct drm_device *drm = dev_get_drvdata(dev);
-	struct rockchip_drm_private *priv = drm->dev_private;
+	struct rockchip_drm_private *priv;
+
+	if (!drm)
+		/* no display attached */
+		return 0;
 
 	drm_kms_helper_poll_disable(drm);
 	rockchip_drm_fb_suspend(drm);
 
+	priv = drm->dev_private;
 	priv->state = drm_atomic_helper_suspend(drm);
 	if (IS_ERR(priv->state)) {
 		rockchip_drm_fb_resume(drm);
@@ -293,8 +298,13 @@ static int rockchip_drm_sys_suspend(struct device *dev)
 static int rockchip_drm_sys_resume(struct device *dev)
 {
 	struct drm_device *drm = dev_get_drvdata(dev);
-	struct rockchip_drm_private *priv = drm->dev_private;
+	struct rockchip_drm_private *priv;
+
+	if (!drm)
+		/* no display attached */
+		return 0;
 
+	priv = drm->dev_private;
 	drm_atomic_helper_resume(drm, priv->state);
 	rockchip_drm_fb_resume(drm);
 	drm_kms_helper_poll_enable(drm);
-- 
2.14.0.434.g98096fd7a8-goog

[toc] | [next] | [standalone]


#1708080 — Re: [PATCH] drm/rockchip: Skip suspend/resume if no display is attached

FromBrian Norris <briannorris@chromium.org>
Date2017-08-10 02:00 +0200
SubjectRe: [PATCH] drm/rockchip: Skip suspend/resume if no display is attached
Message-ID<ucJ3k-63J-7@gated-at.bofh.it>
In reply to#1708056
On Wed, Aug 09, 2017 at 04:07:24PM -0700, Matthias Kaehlcke wrote:
> rockchip_drm_sys_suspend/resume() obains a struct drm_device pointer
> from drvdata, the pointer is then dereferenced to obtain private data.
> drvdata is set when a display is bound, on systems without a
> (successfully probed) display drvdata is NULL and the PM functions
> try to dereference a NULL pointer.
> 
> The suspend/resume code relies on a valid drm_device object, skip it if
> the pointer is NULL.
> 
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>

For the record (I believe you found this already), Jeffy sent the same
patch out (to the wrong mailing lists), but it got applied a bit ago:

https://cgit.freedesktop.org/drm/drm-misc/log/?h=drm-misc-fixes

commit 0fa375e6bc9023211eead30a6a79963c45a563da 
drm/rockchip: Fix suspend crash when drm is not bound
https://cgit.freedesktop.org/drm/drm-misc/commit/?h=drm-misc-fixes&id=0fa375e6bc9023211eead30a6a79963c45a563da

Thanks,
Brian

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web