]> git.karo-electronics.de Git - linux-beck.git/commitdiff
drm/tilcdc: fix kernel panic on suspend when no hdmi monitor connected
authorDarren Etheridge <detheridge@ti.com>
Fri, 19 Sep 2014 01:42:57 +0000 (01:42 +0000)
committerJyri Sarha <jsarha@ti.com>
Thu, 25 Feb 2016 14:39:31 +0000 (16:39 +0200)
On BeagleBone Black if no HDMI monitor is connected and suspend
is requested a kernel panic will result:

root@am335x-evm:~# echo mem > /sys/power/state
[ 65.548710] PM: Syncing filesystems ... done.
[ 65.631311] Freezing user space processes ... (elapsed 0.006 seconds) done.
[ 65.648619] Freezing remaining freezable tasks ... (elapsed 0.005 seconds) done.
[ 65.833500] Unhandled fault: external abort on non-linefetch (0x1028) at 0xfa30e004
[ 65.841692] Internal error: : 1028 [#1] SMP ARM
  <snip>
[ 66.105287] [<c03765f0>] (platform_pm_suspend) from [<c037b6d4>] (dpm_run_callback+0x34/0x70)
[ 66.114370] [<c037b6d4>] (dpm_run_callback) from [<c037ba84>] (__device_suspend+0x10c/0x2f4)
[ 66.123357] [<c037ba84>] (__device_suspend) from [<c037d004>] (dpm_suspend+0x58/0x218)
[ 66.131796] [<c037d004>] (dpm_suspend) from [<c008d948>] (suspend_devices_and_enter+0x9c/0x3c0)
[ 66.141055] [<c008d948>] (suspend_devices_and_enter) from [<c008de7c>] (pm_suspend+0x210/0x24c)
[ 66.150312] [<c008de7c>] (pm_suspend) from [<c008cabc>] (state_store+0x68/0xb8)
[ 66.158103] [<c008cabc>] (state_store) from [<c02e9654>] (kobj_attr_store+0x14/0x20)
[ 66.166355] [<c02e9654>] (kobj_attr_store) from [<c0185c70>] (sysfs_kf_write+0x4c/0x50)
[ 66.174883] [<c0185c70>] (sysfs_kf_write) from [<c018926c>] (kernfs_fop_write+0xb4/0x150)
[ 66.183598] [<c018926c>] (kernfs_fop_write) from [<c0122638>] (vfs_write+0xa8/0x180)
[ 66.191846] [<c0122638>] (vfs_write) from [<c01229f8>] (SyS_write+0x40/0x8c)
[ 66.199365] [<c01229f8>] (SyS_write) from [<c000e580>] (ret_fast_syscall+0x0/0x48)
[ 66.207426] Code: e595c210 e5932000 e59cc000 e08c2002 (e592c000)

This is because the lcdc module is not enabled when no monitor is detected
to save power.  However the suspend handler just blindly tries to save the
lcdc state by copying out the pertinent registers. However module is off
so no good things happen when you try and access it.

This patch only saves off the registers if the module is enabled, and
then only restores the registers on resume if they were saved off during
suspend.

Signed-off-by: Darren Etheridge <detheridge@ti.com>
Tested-by: Dave Gerlach <d-gerlach@ti.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
drivers/gpu/drm/tilcdc/tilcdc_drv.c
drivers/gpu/drm/tilcdc/tilcdc_drv.h

index 420a237a99fc611805850f035a9a67e3946dbe18..67ed9f7fe19792cdbd9abfb0860bc7d39148ee10 100644 (file)
@@ -582,13 +582,20 @@ static int tilcdc_pm_suspend(struct device *dev)
 
        drm_kms_helper_poll_disable(ddev);
 
+       /* Select sleep pin state */
+       pinctrl_pm_select_sleep_state(dev);
+
+       if (pm_runtime_suspended(dev)) {
+               priv->ctx_valid = false;
+               return 0;
+       }
+
        /* Save register state: */
        for (i = 0; i < ARRAY_SIZE(registers); i++)
                if (registers[i].save && (priv->rev >= registers[i].rev))
                        priv->saved_register[n++] = tilcdc_read(ddev, registers[i].reg);
 
-       /* Select sleep pin state */
-       pinctrl_pm_select_sleep_state(dev);
+       priv->ctx_valid = true;
 
        return 0;
 }
@@ -602,10 +609,14 @@ static int tilcdc_pm_resume(struct device *dev)
        /* Select default pin state */
        pinctrl_pm_select_default_state(dev);
 
-       /* Restore register state: */
-       for (i = 0; i < ARRAY_SIZE(registers); i++)
-               if (registers[i].save && (priv->rev >= registers[i].rev))
-                       tilcdc_write(ddev, registers[i].reg, priv->saved_register[n++]);
+       if (priv->ctx_valid == true) {
+               /* Restore register state: */
+               for (i = 0; i < ARRAY_SIZE(registers); i++)
+                       if (registers[i].save &&
+                           (priv->rev >= registers[i].rev))
+                               tilcdc_write(ddev, registers[i].reg,
+                                            priv->saved_register[n++]);
+       }
 
        drm_kms_helper_poll_enable(ddev);
 
index 62a1d688e6b36e7bb1a71ea3ff5f007953f05bc1..55d17b3466c47f108447f2211f29b4f72c463e75 100644 (file)
@@ -67,6 +67,7 @@ struct tilcdc_drm_private {
 
        /* register contents saved across suspend/resume: */
        u32 saved_register[12];
+       bool ctx_valid;
 
 #ifdef CONFIG_CPU_FREQ
        struct notifier_block freq_transition;