From patchwork Wed May 16 12:56: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: 8685 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 C89F123EAB for ; Wed, 16 May 2012 12:58:06 +0000 (UTC) Received: from mail-pz0-f52.google.com (mail-pz0-f52.google.com [209.85.210.52]) by fiordland.canonical.com (Postfix) with ESMTP id 55C20A18A69 for ; Wed, 16 May 2012 12:58:06 +0000 (UTC) Received: by dano14 with SMTP id o14so1142245dan.11 for ; Wed, 16 May 2012 05:58: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=8wv8uis2+zMA+YwUHnD4S71UmgbGWQH6ghx3GnYGIeY=; b=E2LUQ8mWKNW92EFRbvdE5QTDk+rviTbgKxDoH+t1G/C6AGdtWeLHdrH6FN9bCvQzJm EABK0lKqlDyBLWLxdObweOg/q6Baxp9+XfaE9NYq2TRoBIfmQpUVodPSnarUYHtFqLBe 9mWru2ZuDJasreJBOFAqJbH5YFi4gjZ2w/Xc9wuiZUAGnuIXdXfG3gnj11iKuvBbvSo5 ijrI7xBcUks+o//f/2AjlnynTheowz+6+CFQleHtKfklCzUqC/Cixlnm5e+YruEnSnQH Lo+QW1Q5SLPbRDSxKl4fWB3eHka/c7Me/GbReohvcNaqGt67Y5CR7X1y9f3A4O1lUtG2 HsKQ== Received: by 10.50.163.99 with SMTP id yh3mr1861142igb.53.1337173085157; Wed, 16 May 2012 05:58: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 o8csp491458ibd; Wed, 16 May 2012 05:58:04 -0700 (PDT) Received: by 10.68.216.225 with SMTP id ot1mr15828884pbc.46.1337173084370; Wed, 16 May 2012 05:58: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 oh8si938141pbb.95.2012.05.16.05.58.04 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 16 May 2012 05:58: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 h15so1186259dan.37 for ; Wed, 16 May 2012 05:58:04 -0700 (PDT) Received: by 10.68.138.161 with SMTP id qr1mr16323366pbb.37.1337173083973; Wed, 16 May 2012 05:58:03 -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 pj5sm5396690pbb.51.2012.05.16.05.58.01 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 16 May 2012 05:58:03 -0700 (PDT) Date: Wed, 16 May 2012 05:56: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 2/6] pstore/ram: Add console messages handling Message-ID: <20120516125634.GB20475@lizard> References: <20120516125330.GA15460@lizard> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120516125330.GA15460@lizard> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQmYBGml9ofl9Su7GfzkKNehpyiH4KILgsTOC6iBkjFIrz+5RqljjHXfN3a5V5v4qewuPTrD This is all straightforward: we just use the last region for console logging. If there's just one region, we fall-back to the old behaviour: just a oops/dumps logging. Signed-off-by: Anton Vorontsov --- fs/pstore/ram.c | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 9123cce..54213eb 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -63,6 +63,7 @@ MODULE_PARM_DESC(ramoops_ecc, struct ramoops_context { struct persistent_ram_zone **przs; + struct persistent_ram_zone *cprz; phys_addr_t phys_addr; unsigned long size; size_t record_size; @@ -70,6 +71,7 @@ struct ramoops_context { bool ecc; unsigned int count; unsigned int max_count; + unsigned int max_dump_count; unsigned int read_count; struct pstore_info pstore; }; @@ -92,16 +94,20 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type, { ssize_t size; struct ramoops_context *cxt = psi->data; - struct persistent_ram_zone *prz; - - if (cxt->read_count >= cxt->max_count) - return -EINVAL; + struct persistent_ram_zone *prz = cxt->przs[cxt->read_count]; *id = cxt->read_count++; - prz = cxt->przs[*id]; - /* Only supports dmesg output so far. */ - *type = PSTORE_TYPE_DMESG; + if (*id < cxt->max_dump_count && persistent_ram_old_size(prz)) { + *type = PSTORE_TYPE_DMESG; + } else if (*id < cxt->max_count) { + *type = PSTORE_TYPE_CONSOLE; + prz = cxt->cprz; + cxt->read_count = cxt->max_count; + } else { + return 0; + } + /* TODO(kees): Bogus time for the moment. */ time->tv_sec = 0; time->tv_nsec = 0; @@ -142,7 +148,12 @@ static int ramoops_pstore_write(enum pstore_type_id type, struct persistent_ram_zone *prz = cxt->przs[cxt->count]; size_t hlen; - /* Currently ramoops is designed to only store dmesg dumps. */ + if (type == PSTORE_TYPE_CONSOLE) { + if (!cxt->cprz) + return -ENOMEM; + persistent_ram_write(cxt->cprz, cxt->pstore.buf, size); + } + if (type != PSTORE_TYPE_DMESG) return -EINVAL; @@ -170,7 +181,7 @@ static int ramoops_pstore_write(enum pstore_type_id type, size = prz->buffer_size - hlen; persistent_ram_write(prz, cxt->pstore.buf, size); - cxt->count = (cxt->count + 1) % cxt->max_count; + cxt->count = (cxt->count + 1) % cxt->max_dump_count; return 0; } @@ -264,6 +275,16 @@ static int __init ramoops_probe(struct platform_device *pdev) } } + /* + * The last zone is for TYPE_CONSOLE, unless we have only + * one, in which case we use it for oops/panic logging. + */ + cxt->max_dump_count = cxt->max_count; + if (cxt->max_count > 1) { + cxt->max_dump_count--; + cxt->cprz = cxt->przs[cxt->max_count - 1]; + } + cxt->pstore.data = cxt; cxt->pstore.bufsize = cxt->przs[0]->buffer_size; cxt->pstore.buf = kmalloc(cxt->pstore.bufsize, GFP_KERNEL);