Permalink
Browse files

[ARM] mach-msm: nand: Add Virtual kpanic mtd partition support.

Adds an option to snag a portion of a specified
partition into a virtual partition named 'kpanic' Useful
for platforms which do not have a kpanic partition but want
to take advantage of CONFIG_APANIC logging. As this is not a real
nand partition, both the snagged and new partitions should be
erased when switching to/from a kernel with this option enabled/disabled.

**** WARNING ****
DO NOT enable if you are using a Recovery/OTA scheme in which
the recovery kernel needs to access the partition you are snagging
from. If you do not heed this warning, you may end up with a
corrupted OTA image and there be dragons. Just don't do it.
**** WARNING ****

Signed-off-by: San Mehat <san@google.com>
  • Loading branch information...
1 parent 07ff822 commit 5883bd5ad743b0f9c5ce5ba60d1819ce548433ad San Mehat committed with Steve Kondik Sep 1, 2009
Showing with 64 additions and 0 deletions.
  1. +23 −0 arch/arm/mach-msm/Kconfig
  2. +41 −0 arch/arm/mach-msm/nand_partitions.c
View
23 arch/arm/mach-msm/Kconfig
@@ -343,4 +343,27 @@ config WIFI_MEM_PREALLOC
bool "Preallocate memory for WiFi buffers"
help
Preallocates memory buffers for WiFi driver
+
+config VIRTUAL_KPANIC_PARTITION
+ bool "Create virtual kpanic partition"
+ default n
+ help
+ Creates a virtual mtd partition named 'kpanic', stealing space from
+ the specified mtd partition label.
+ *** DO NOT USE IF YOU ARE USING OTA/RECOVERY ***
+
+config VIRTUAL_KPANIC_PSIZE
+ depends on VIRTUAL_KPANIC_PARTITION
+ int "Default kpanic partition size"
+ default 1048576
+ help
+ Sets the size of the virtual kpanic paritition to create.
+
+config VIRTUAL_KPANIC_SRC
+ depends on VIRTUAL_KPANIC_PARTITION
+ string "Partition to steal from"
+ default "cache"
+ help
+ Sets the partition to steal from to make the virtual one.
+
endif
View
41 arch/arm/mach-msm/nand_partitions.c
@@ -33,6 +33,7 @@
#include <mach/board.h>
+
/* configuration tags specific to msm */
#define ATAG_MSM_PARTITION 0x4d534D70 /* MSMp */
@@ -58,6 +59,7 @@ static int __init parse_tag_msm_partition(const struct tag *tag)
char *name = msm_nand_names;
struct msm_ptbl_entry *entry = (void *) &tag->u;
unsigned count, n;
+ unsigned have_kpanic = 0;
count = (tag->hdr.size - 2) /
(sizeof(struct msm_ptbl_entry) / sizeof(__u32));
@@ -69,6 +71,9 @@ static int __init parse_tag_msm_partition(const struct tag *tag)
memcpy(name, entry->name, 15);
name[15] = 0;
+ if (!strcmp(name, "kpanic"))
+ have_kpanic = 1;
+
ptn->name = name;
ptn->offset = entry->offset * 64 * 2048;
ptn->size = entry->size * 64 * 2048;
@@ -78,6 +83,42 @@ static int __init parse_tag_msm_partition(const struct tag *tag)
ptn++;
}
+#if CONFIG_VIRTUAL_KPANIC_PARTITION
+ if (!have_kpanic) {
+ int i;
+ uint64_t kpanic_off = 0;
+
+ if (count == MSM_MAX_PARTITIONS) {
+ printk("Cannot create virtual 'kpanic' partition\n");
+ goto out;
+ }
+
+ for (i = 0; i < count; i++) {
+ ptn = &msm_nand_partitions[i];
+ if (!strcmp(ptn->name, CONFIG_VIRTUAL_KPANIC_SRC)) {
+ ptn->size -= CONFIG_VIRTUAL_KPANIC_PSIZE;
+ kpanic_off = ptn->offset + ptn->size;
+ break;
+ }
+ }
+ if (i == count) {
+ printk(KERN_ERR "Partition %s not found\n",
+ CONFIG_VIRTUAL_KPANIC_SRC);
+ goto out;
+ }
+
+ ptn = &msm_nand_partitions[count];
+ ptn->name ="kpanic";
+ ptn->offset = kpanic_off;
+ ptn->size = CONFIG_VIRTUAL_KPANIC_PSIZE;
+
+ printk("Virtual mtd partition '%s' created @%llx (%llu)\n",
+ ptn->name, ptn->offset, ptn->size);
+
+ count++;
+ }
+#endif /* CONFIG_VIRTUAL_KPANIC_SRC */
+out:
msm_nand_data.nr_parts = count;
msm_nand_data.parts = msm_nand_partitions;

0 comments on commit 5883bd5

Please sign in to comment.