Merge branch 'linux-linaro-lsk-v4.4' into linux-linaro-lsk-v4.4-android
[firefly-linux-kernel-4.4.55.git] / arch / arm64 / kernel / suspend.c
index b616e365cee33fdb2e61520943e2d8a9ae372861..5a0b1088c17c0fa0d9998ee03a67791d111b2e75 100644 (file)
@@ -1,7 +1,9 @@
 #include <linux/ftrace.h>
 #include <linux/percpu.h>
 #include <linux/slab.h>
+#include <asm/alternative.h>
 #include <asm/cacheflush.h>
+#include <asm/cpufeature.h>
 #include <asm/debug-monitors.h>
 #include <asm/pgtable.h>
 #include <asm/memory.h>
@@ -88,11 +90,16 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
                ret = fn(arg);
 
                /*
-                * Never gets here, unless the suspend finisher fails.
-                * Successful cpu_suspend() should return from cpu_resume(),
-                * returning through this code path is considered an error
-                * If the return value is set to 0 force ret = -EOPNOTSUPP
-                * to make sure a proper error condition is propagated
+                * PSTATE was not saved over suspend/resume, re-enable any
+                * detected features that might not have been set correctly.
+                */
+               asm(ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN,
+                               CONFIG_ARM64_PAN));
+
+               /*
+                * Restore HW breakpoint registers to sane values
+                * before debug exceptions are possibly reenabled
+                * through local_dbg_restore.
                 */
                if (!ret)
                        ret = -EOPNOTSUPP;