msm: Add support to dump the caches on panic

During the normal course of panic, caches are flushed.
In most regular cases, this behavior is fine. If the
cache itself is suspect, it is important to store whatever
data is there before restart. A suspect cache may manifest
as a kernel panic due to an abort. Dump the caches during
the panic code path to save for analysis later.

Change-Id: Iaa7194027f2f589a60bfade896cd455eb4cc8989
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
diff --git a/arch/arm/mach-msm/board-8960.c b/arch/arm/mach-msm/board-8960.c
index 724dd80..3f0d8df 100644
--- a/arch/arm/mach-msm/board-8960.c
+++ b/arch/arm/mach-msm/board-8960.c
@@ -612,6 +612,7 @@
 #ifdef CONFIG_MSM_CACHE_DUMP
 	unsigned int spare;
 	unsigned int l1_size;
+	unsigned int l2_size;
 	unsigned int total;
 	int ret;
 
@@ -622,10 +623,18 @@
 		/* Fall back to something reasonable here */
 		l1_size = L1_BUFFER_SIZE;
 
-	total = l1_size + L2_BUFFER_SIZE;
+	ret = scm_call(L1C_SERVICE_ID, L2C_BUFFER_GET_SIZE_COMMAND_ID, &spare,
+		sizeof(spare), &l2_size, sizeof(l2_size));
+
+	if (ret)
+		/* Fall back to something reasonable here */
+		l2_size = L2_BUFFER_SIZE;
+
+	total = l1_size + l2_size;
 
 	msm8960_reserve_table[MEMTYPE_EBI1].size += total;
 	msm_cache_dump_pdata.l1_size = l1_size;
+	msm_cache_dump_pdata.l2_size = l2_size;
 #endif
 }