From patchwork Tue Jul 10 00:10:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 9908 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 02AB823E01 for ; Tue, 10 Jul 2012 00:13:10 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id C5C24A18102 for ; Tue, 10 Jul 2012 00:13:09 +0000 (UTC) Received: by mail-yx0-f180.google.com with SMTP id q6so11476663yen.11 for ; Mon, 09 Jul 2012 17:13:09 -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:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=w47qN/96OSK5TzIUd4u5tvu7wfFyjtSxLKMpNOg1Y8o=; b=DCNbAMnR0vC91ESAEGI7faG15Uknr/30nUazRh8mJJRt+VklHlNeLcTBIqpHMghgQp /9dy+21hiaCHEvq1Jp3pgbF0TvuYkPfIHz284NzyyE+vus8Qs6f0p/3vCEdm9zlK+dZy dHlc5dsgeXK2YMX0uPtY0KtipJnJhsWGn/GgjspeG9iAN4QpuACUPKjWiqeIG8ENQtB2 XBF+UKJjCxPGVITojDD5lrNQAR4D9u0wKOwCcNM9XxyVfbELsNaxrjfhJvEdExZXycTQ xHxKfv6x2l6AY+s8x2obPomWgVipUdJ17dgqqzakHZcX50Zd3wnW1qWxa8rF+wOwTGdq HCXA== Received: by 10.50.160.198 with SMTP id xm6mr10082691igb.0.1341879189441; Mon, 09 Jul 2012 17:13:09 -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.24.148 with SMTP id v20csp42688ibb; Mon, 9 Jul 2012 17:13:08 -0700 (PDT) Received: by 10.68.217.100 with SMTP id ox4mr63683360pbc.87.1341879188216; Mon, 09 Jul 2012 17:13:08 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id rd4si34987071pbc.100.2012.07.09.17.13.07 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 09 Jul 2012 17:13:08 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.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-pb0-f50.google.com with SMTP id rr4so23733901pbb.37 for ; Mon, 09 Jul 2012 17:13:07 -0700 (PDT) Received: by 10.66.74.3 with SMTP id p3mr69163703pav.49.1341879187730; Mon, 09 Jul 2012 17:13:07 -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 ku7sm28649692pbc.31.2012.07.09.17.13.05 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 09 Jul 2012 17:13:07 -0700 (PDT) From: Anton Vorontsov To: Greg Kroah-Hartman , Kees Cook , Colin Cross , Tony Luck , Steven Rostedt , Frederic Weisbecker , Ingo Molnar 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/8] pstore: Introduce write_buf backend callback Date: Mon, 9 Jul 2012 17:10:40 -0700 Message-Id: <1341879046-5197-2-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <20120710001004.GA22744@lizard> References: <20120710001004.GA22744@lizard> X-Gm-Message-State: ALoCoQkUr0FhAztl2EbQ3GxnJk2U8SXv0XMAXsqta6w5p+9UfbdkmHqrHKjsnmk1Mll08OtlQObh For function tracing we need to stop using pstore.buf directly, since in a tracing callback we can't use spinlocks, and thus we can't safely use the global buffer. With write_buf callback, backends no longer need to access pstore.buf directly, and thus we can pass any buffers (e.g. allocated on stack). Signed-off-by: Anton Vorontsov --- fs/pstore/platform.c | 10 ++++++++++ include/linux/pstore.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 6b3ff04..ef5ca8a 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -188,6 +188,14 @@ static void pstore_register_console(void) static void pstore_register_console(void) {} #endif +static int pstore_write_compat(enum pstore_type_id type, + enum kmsg_dump_reason reason, + u64 *id, unsigned int part, + size_t size, struct pstore_info *psi) +{ + return psi->write_buf(type, reason, id, part, psinfo->buf, size, psi); +} + /* * platform specific persistent storage driver registers with * us here. If pstore is already mounted, call the platform @@ -212,6 +220,8 @@ int pstore_register(struct pstore_info *psi) return -EINVAL; } + if (!psi->write) + psi->write = pstore_write_compat; psinfo = psi; mutex_init(&psinfo->read_mutex); spin_unlock(&pstore_lock); diff --git a/include/linux/pstore.h b/include/linux/pstore.h index 1bd014b..b107484 100644 --- a/include/linux/pstore.h +++ b/include/linux/pstore.h @@ -48,6 +48,10 @@ struct pstore_info { int (*write)(enum pstore_type_id type, enum kmsg_dump_reason reason, u64 *id, unsigned int part, size_t size, struct pstore_info *psi); + int (*write_buf)(enum pstore_type_id type, + enum kmsg_dump_reason reason, u64 *id, + unsigned int part, const char *buf, size_t size, + struct pstore_info *psi); int (*erase)(enum pstore_type_id type, u64 id, struct pstore_info *psi); void *data;