Skip to contentSkip to conversation

Sync Android pstore updates

PATCH In review Anton Vorontsov 2 participants 6 messages Apr 1, 2013 – Apr 4, 2013 Pstore filesystem

lore
Share & tools
lore
#0 lore raw

cover Sync Android pstore updates

Hi all,

Here are a few updates from the Android dev tree. Thanks to Arve Hjønnevåg for the code, and John Stultz for actually preparing commits for submission.

Unless there are objections, I'll push these updates to linux-pstore.git.

Thanks!

Anton

#1 lore raw

PATCH 1/3 pstore/ram: Include ecc_size when calculating ecc_block

From: Arve Hjønnevåg <[email protected]>

Wastes less memory and allows using more memory for ecc than data.

[jstultz: Tweaked commit subject]
---
 fs/pstore/ram_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/pstore/ram_core.c +2 -1
index 0306303..e5afa22 100644
@@ -187,7 +187,8 @@ static int persistent_ram_init_ecc(struct persistent_ram_zone *prz,
 	prz->ecc_block_size = 128;
 	prz->ecc_size = ecc_size;
 
-	ecc_blocks = DIV_ROUND_UP(prz->buffer_size, prz->ecc_block_size);
+	ecc_blocks = DIV_ROUND_UP(prz->buffer_size - prz->ecc_size,
+				  prz->ecc_block_size + prz->ecc_size);
 	ecc_total = (ecc_blocks + 1) * prz->ecc_size;
 	if (ecc_total >= prz->buffer_size) {
 		pr_err("%s: invalid ecc_size %u (total %zu, buffer size %zu)\n",
Signature · 1 line
1.8.1.4
#2 lore raw

PATCH 2/3 pstore/ram: Allow specifying ecc parameters in platform data

In reply to Anton Vorontsov

From: Arve Hjønnevåg <[email protected]>

Allow specifying ecc parameters in platform data

[jstultz: Tweaked commit subject & add commit message]
---
 fs/pstore/ram.c            | 15 ++++++-----
 fs/pstore/ram_core.c       | 64 ++++++++++++++++++++++++----------------------
 include/linux/pstore_ram.h | 14 +++++++---
 3 files changed, 52 insertions(+), 41 deletions(-)
fs/pstore/ram.c +8 -7
index 38babb3..a5ee252 100644
@@ -83,7 +83,7 @@ struct ramoops_context {
 	size_t console_size;
 	size_t ftrace_size;
 	int dump_oops;
-	int ecc_size;
+	struct persistent_ram_ecc_info ecc_info;
 	unsigned int max_dump_cnt;
 	unsigned int dump_write_cnt;
 	unsigned int dump_read_cnt;
@@ -322,7 +322,8 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt,
 	for (i = 0; i < cxt->max_dump_cnt; i++) {
 		size_t sz = cxt->record_size;
 
-		cxt->przs[i] = persistent_ram_new(*paddr, sz, 0, cxt->ecc_size);
+		cxt->przs[i] = persistent_ram_new(*paddr, sz, 0,
+						  &cxt->ecc_info);
 		if (IS_ERR(cxt->przs[i])) {
 			err = PTR_ERR(cxt->przs[i]);
 			dev_err(dev, "failed to request mem region (0x%zx@0x%llx): %d\n",
@@ -352,7 +353,7 @@ static int ramoops_init_prz(struct device *dev, struct ramoops_context *cxt,
 		return -ENOMEM;
 	}
 
-	*prz = persistent_ram_new(*paddr, sz, sig, cxt->ecc_size);
+	*prz = persistent_ram_new(*paddr, sz, sig, &cxt->ecc_info);
 	if (IS_ERR(*prz)) {
 		int err = PTR_ERR(*prz);
 
@@ -406,7 +407,7 @@ static int ramoops_probe(struct platform_device *pdev)
 	cxt->console_size = pdata->console_size;
 	cxt->ftrace_size = pdata->ftrace_size;
 	cxt->dump_oops = pdata->dump_oops;
-	cxt->ecc_size = pdata->ecc_size;
+	cxt->ecc_info = pdata->ecc_info;
 
 	paddr = cxt->phys_addr;
 
@@ -464,9 +465,9 @@ static int ramoops_probe(struct platform_device *pdev)
 	record_size = pdata->record_size;
 	dump_oops = pdata->dump_oops;
 
-	pr_info("attached 0x%lx@0x%llx, ecc: %d\n",
+	pr_info("attached 0x%lx@0x%llx, ecc: %d/%d\n",
 		cxt->size, (unsigned long long)cxt->phys_addr,
-		cxt->ecc_size);
+		cxt->ecc_info.ecc_size, cxt->ecc_info.block_size);
 
 	return 0;
 
@@ -538,7 +539,7 @@ static void ramoops_register_dummy(void)
 	 * For backwards compatibility ramoops.ecc=1 means 16 bytes ECC
 	 * (using 1 byte for ECC isn't much of use anyway).
 	 */
-	dummy_data->ecc_size = ramoops_ecc == 1 ? 16 : ramoops_ecc;
+	dummy_data->ecc_info.ecc_size = ramoops_ecc == 1 ? 16 : ramoops_ecc;
 
 	dummy = platform_device_register_data(NULL, "ramoops", -1,
 			dummy_data, sizeof(struct ramoops_platform_data));
fs/pstore/ram_core.c +34 -30

161 lines not on this page · raw message

include/linux/pstore_ram.h +10 -4
index cb6ab5f..9974975 100644
@@ -26,6 +26,13 @@
 struct persistent_ram_buffer;
 struct rs_control;
 
+struct persistent_ram_ecc_info {
+	int block_size;
+	int ecc_size;
+	int symsize;
+	int poly;
+};
+
 struct persistent_ram_zone {
 	phys_addr_t paddr;
 	size_t size;
@@ -39,15 +46,14 @@ struct persistent_ram_zone {
 	struct rs_control *rs_decoder;
 	int corrected_bytes;
 	int bad_blocks;
-	int ecc_block_size;
-	int ecc_size;
+	struct persistent_ram_ecc_info ecc_info;
 
 	char *old_log;
 	size_t old_log_size;
 };
 
 struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
-					       u32 sig, int ecc_size);
+			u32 sig, struct persistent_ram_ecc_info *ecc_info);
 void persistent_ram_free(struct persistent_ram_zone *prz);
 void persistent_ram_zap(struct persistent_ram_zone *prz);
 
@@ -74,7 +80,7 @@ struct ramoops_platform_data {
 	unsigned long	console_size;
 	unsigned long	ftrace_size;
 	int		dump_oops;
-	int		ecc_size;
+	struct persistent_ram_ecc_info ecc_info;
 };
 
 #endif
Signature · 1 line
1.8.1.4
#3 lore raw

PATCH 3/3 pstore/ram: Restore ecc information block

In reply to Anton Vorontsov

From: Arve Hjønnevåg <[email protected]>

This was lost when proc/last_kmsg moved to pstore/console-ramoops.

---
 fs/pstore/ram.c      | 12 ++++++++++--
 fs/pstore/ram_core.c |  3 +++
 2 files changed, 13 insertions(+), 2 deletions(-)
fs/pstore/ram.c +10 -2
index a5ee252..32cbd7c 100644
@@ -136,6 +136,7 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
 				   char **buf, struct pstore_info *psi)
 {
 	ssize_t size;
+	ssize_t ecc_notice_size;
 	struct ramoops_context *cxt = psi->data;
 	struct persistent_ram_zone *prz;
 
@@ -156,11 +157,18 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
 	time->tv_nsec = 0;
 
 	size = persistent_ram_old_size(prz);
-	*buf = kmemdup(persistent_ram_old(prz), size, GFP_KERNEL);
+
+	/* ECC correction notice */
+	ecc_notice_size = persistent_ram_ecc_string(prz, NULL, 0);
+
+	*buf = kmalloc(size + ecc_notice_size + 1, GFP_KERNEL);
 	if (*buf == NULL)
 		return -ENOMEM;
 
-	return size;
+	memcpy(*buf, persistent_ram_old(prz), size);
+	persistent_ram_ecc_string(prz, *buf + size, ecc_notice_size + 1);
+
+	return size + ecc_notice_size;
 }
 
 static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz)
fs/pstore/ram_core.c +3 -0
index c6f641c..5933732 100644
@@ -235,6 +235,9 @@ ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz,
 {
 	ssize_t ret;
 
+	if (!prz->ecc_info.ecc_size)
+		return 0;
+
 	if (prz->corrected_bytes || prz->bad_blocks)
 		ret = snprintf(str, len, ""
 			"\n%d Corrected bytes, %d unrecoverable blocks\n",
Signature · 1 line
1.8.1.4
Acked-by on the v1 series
#4 lore raw
In reply to Anton Vorontsov
Quoted 7 lines · Anton Vorontsov

Hi all,

Here are a few updates from the Android dev tree. Thanks to Arve Hjønnevåg for the code, and John Stultz for actually preparing commits for submission.

Unless there are objections, I'll push these updates to linux-pstore.git.

These look good; thanks. Feel free to add my ack if you want:

Thanks!

-Kees

--
Kees Cook
Chrome OS Security

#5 lore raw
Quoted 7 lines · Kees Cook
Quoted 6 lines · Anton Vorontsov

Hi all,

Here are a few updates from the Android dev tree. Thanks to Arve Hjønnevåg for the code, and John Stultz for actually preparing commits for submission.

Quoted 5 lines
Quoted 1 line

Unless there are objections, I'll push these updates to linux-pstore.git.

These look good; thanks. Feel free to add my ack if you want:

Added and applied to linux-pstore. Thanks a lot!

Anton