[ARM] S3C: Do not kmalloc/kfree during inner suspend code.
authorBen Dooks <ben-linux@fluff.org>
Fri, 12 Dec 2008 00:24:34 +0000 (00:24 +0000)
committerBen Dooks <ben-linux@fluff.org>
Sun, 8 Mar 2009 13:19:54 +0000 (13:19 +0000)
The PM CRC checking code kmallocs an area to save a set of
CRC values during suspend. This triggers a warning due to the
call of a function that might sleep whilst the system is not
in a valid state to do so.

Move the allocation and free to points in the suspend and resume
process where they can call a function that might-sleep.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
arch/arm/plat-s3c/include/plat/pm.h
arch/arm/plat-s3c/pm-check.c
arch/arm/plat-s3c/pm.c

index c27b8cf5d8918abaed8d1a03057c0e75ee76f29e..5ee26da27028dff142fcd0e190995b6bd74b527b 100644 (file)
@@ -129,10 +129,12 @@ extern void s3c_pm_dbg(const char *msg, ...);
 #ifdef CONFIG_S3C2410_PM_CHECK
 extern void s3c_pm_check_prepare(void);
 extern void s3c_pm_check_restore(void);
+extern void s3c_pm_check_cleanup(void);
 extern void s3c_pm_check_store(void);
 #else
 #define s3c_pm_check_prepare() do { } while(0)
 #define s3c_pm_check_restore() do { } while(0)
+#define s3c_pm_check_cleanup() do { } while(0)
 #define s3c_pm_check_store()   do { } while(0)
 #endif
 
index 183f1304bf58be88f4fb24b7c29e97faac09c735..39f2555564da1d0e8e504964ec796c51ee87bc00 100644 (file)
@@ -222,9 +222,21 @@ static u32 *s3c_pm_runcheck(struct resource *res, u32 *val)
 */
 void s3c_pm_check_restore(void)
 {
-       if (crcs != NULL) {
+       if (crcs != NULL)
                s3c_pm_run_sysram(s3c_pm_runcheck, crcs);
-               kfree(crcs);
-               crcs = NULL;
-       }
 }
+
+/**
+ * s3c_pm_check_cleanup() - free memory resources
+ *
+ * Free the resources that where allocated by the suspend
+ * memory check code. We do this separately from the
+ * s3c_pm_check_restore() function as we cannot call any
+ * functions that might sleep during that resume.
+ */
+void s3c_pm_check_cleanup(void)
+{
+       kfree(crcs);
+       crcs = NULL;
+}
+
index 78bf50a140273f8f8a29e79929cdb38d36ea2670..a0ca18a75b0e924f81a7d8e668453342d9411477 100644 (file)
@@ -254,10 +254,6 @@ static int s3c_pm_enter(suspend_state_t state)
                return -EINVAL;
        }
 
-       /* prepare check area if configured */
-
-       s3c_pm_check_prepare();
-
        /* store the physical address of the register recovery block */
 
        s3c_sleep_save_phys = virt_to_phys(regs_save);
@@ -329,8 +325,23 @@ static int s3c_pm_enter(suspend_state_t state)
        return 0;
 }
 
+static int s3c_pm_prepare(void)
+{
+       /* prepare check area if configured */
+
+       s3c_pm_check_prepare();
+       return 0;
+}
+
+static void s3c_pm_finish(void)
+{
+       s3c_pm_check_cleanup();
+}
+
 static struct platform_suspend_ops s3c_pm_ops = {
        .enter          = s3c_pm_enter,
+       .prepare        = s3c_pm_prepare,
+       .finish         = s3c_pm_finish,
        .valid          = suspend_valid_only_mem,
 };