From patchwork Thu May 17 07:15:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 8701 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id F060023E37 for ; Thu, 17 May 2012 07:17:05 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id C068BA186A5 for ; Thu, 17 May 2012 07:17:05 +0000 (UTC) Received: by mail-yw0-f52.google.com with SMTP id p61so1810427yhp.11 for ; Thu, 17 May 2012 00:17:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:date:from :to:cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent:x-gm-message-state; bh=i1Vq6wfQV6EcjnIeyC+HsmPvEQDFHmcZQq2E1RlGqcQ=; b=TGUgbbkj55NK3ND4lHUyfqtTiORy61ymwycJLfuNlcjZdy6mS6wXVhFj6neFlgB/lv LdqKH9dOyEeh5aMsh/DsCF1mEVySH11bkdZZ6XMUg4hnLbMV+yaVujcSSyZxy0FgEkt3 H0OkLyBBcdgrYLTOkMDzV8dKb44c/+rprZn1Ku7ik8Dv9CIz/rCbsD7k9Lk5KlctNlU3 t9/P0O1OWH5W3Nx4O3O8kzmAWOFbhcxAmll8FSyUjnOXnFLyt3phveP8JmIXK0x/05RR 33KUxfQ9Gb+MZRidkltF6tpQZE6Oc4DuwORbFnS7smiaSa4qQvybAGECFPryL+lSTssB 9abQ== Received: by 10.50.154.169 with SMTP id vp9mr12178552igb.53.1337239025269; Thu, 17 May 2012 00:17:05 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.35.72 with SMTP id o8csp7316ibd; Thu, 17 May 2012 00:17:04 -0700 (PDT) Received: by 10.68.200.202 with SMTP id ju10mr24608589pbc.54.1337239024401; Thu, 17 May 2012 00:17:04 -0700 (PDT) Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id ux8si10204391pbc.232.2012.05.17.00.17.04 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 May 2012 00:17:04 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) smtp.mail=anton.vorontsov@linaro.org Received: by mail-pz0-f50.google.com with SMTP id h15so2490818dan.37 for ; Thu, 17 May 2012 00:17:04 -0700 (PDT) Received: by 10.68.234.73 with SMTP id uc9mr5837862pbc.65.1337239024125; Thu, 17 May 2012 00:17:04 -0700 (PDT) Received: from localhost (c-71-204-165-222.hsd1.ca.comcast.net. [71.204.165.222]) by mx.google.com with ESMTPS id ve6sm8182590pbc.75.2012.05.17.00.17.01 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 May 2012 00:17:03 -0700 (PDT) Date: Thu, 17 May 2012 00:15:34 -0700 From: Anton Vorontsov To: Greg Kroah-Hartman , Kees Cook , Colin Cross , Tony Luck Cc: Arnd Bergmann , John Stultz , Shuah Khan , arve@android.com, Rebecca Schultz Zavin , Jesper Juhl , Randy Dunlap , Stephen Boyd , Thomas Meyer , Andrew Morton , Marco Stornelli , WANG Cong , linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, linaro-kernel@lists.linaro.org, patches@linaro.org, kernel-team@android.com Subject: [PATCH 3/3] pstore/ram: Add ECC support Message-ID: <20120517071534.GC19999@lizard> References: <20120517071148.GA16946@lizard> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120517071148.GA16946@lizard> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQlBF0KE2hea2CcWt1EtRnKNVxswv+9qUp8uTkOgs/tjfSSn56h4zf84x7e5VdPdo6XT+ffp This is now straightforward: just introduce a module parameter and pass the needed value to persistent_ram_new(). Signed-off-by: Anton Vorontsov Acked-by: Marco Stornelli Acked-by: Kees Cook --- Documentation/ramoops.txt | 6 ++++++ fs/pstore/ram.c | 15 ++++++++++++--- include/linux/pstore_ram.h | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Documentation/ramoops.txt b/Documentation/ramoops.txt index 470d2c4..4ba7db2 100644 --- a/Documentation/ramoops.txt +++ b/Documentation/ramoops.txt @@ -30,6 +30,11 @@ variable while setting 0 in that variable dumps only the panics. The module uses a counter to record multiple dumps but the counter gets reset on restart (i.e. new dumps after the restart will overwrite old ones). +Ramoops also supports software ECC protection of persistent memory regions. +This might be useful when a hardware reset was used to bring the machine back +to life (i.e. a watchdog triggered). In such cases, RAM may be somewhat +corrupt, but usually it is restorable. + 2. Setting the parameters Setting the ramoops parameters can be done in 2 different manners: @@ -46,6 +51,7 @@ static struct ramoops_platform_data ramoops_data = { .mem_address = <...>, .record_size = <...>, .dump_oops = <...>, + .ecc = <...>, }; static struct platform_device ramoops_dev = { diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 62b13ed..9123cce 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -56,12 +56,18 @@ module_param(dump_oops, int, 0600); MODULE_PARM_DESC(dump_oops, "set to 1 to dump oopses, 0 to only dump panics (default 1)"); +static int ramoops_ecc; +module_param_named(ecc, ramoops_ecc, int, 0600); +MODULE_PARM_DESC(ramoops_ecc, + "set to 1 to enable ECC support"); + struct ramoops_context { struct persistent_ram_zone **przs; phys_addr_t phys_addr; unsigned long size; size_t record_size; int dump_oops; + bool ecc; unsigned int count; unsigned int max_count; unsigned int read_count; @@ -236,6 +242,7 @@ static int __init ramoops_probe(struct platform_device *pdev) cxt->phys_addr = pdata->mem_address; cxt->record_size = pdata->record_size; cxt->dump_oops = pdata->dump_oops; + cxt->ecc = pdata->ecc; cxt->przs = kzalloc(sizeof(*cxt->przs) * cxt->max_count, GFP_KERNEL); if (!cxt->przs) { @@ -248,7 +255,7 @@ static int __init ramoops_probe(struct platform_device *pdev) size_t sz = cxt->record_size; phys_addr_t start = cxt->phys_addr + sz * i; - cxt->przs[i] = persistent_ram_new(start, sz, 0); + cxt->przs[i] = persistent_ram_new(start, sz, cxt->ecc); 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", @@ -281,9 +288,10 @@ static int __init ramoops_probe(struct platform_device *pdev) record_size = pdata->record_size; dump_oops = pdata->dump_oops; - pr_info("attached 0x%lx@0x%llx (%ux0x%zx)\n", + pr_info("attached 0x%lx@0x%llx (%ux0x%zx), ecc: %s\n", cxt->size, (unsigned long long)cxt->phys_addr, - cxt->max_count, cxt->record_size); + cxt->max_count, cxt->record_size, + ramoops_ecc ? "on" : "off"); return 0; @@ -347,6 +355,7 @@ static int __init ramoops_init(void) dummy_data->mem_address = mem_address; dummy_data->record_size = record_size; dummy_data->dump_oops = dump_oops; + dummy_data->ecc = ramoops_ecc; dummy = platform_create_bundle(&ramoops_driver, ramoops_probe, NULL, 0, dummy_data, sizeof(struct ramoops_platform_data)); diff --git a/include/linux/pstore_ram.h b/include/linux/pstore_ram.h index ffe24a5..7ed7fd4 100644 --- a/include/linux/pstore_ram.h +++ b/include/linux/pstore_ram.h @@ -92,6 +92,7 @@ struct ramoops_platform_data { unsigned long mem_address; unsigned long record_size; int dump_oops; + bool ecc; }; #endif