From patchwork Fri Jun 15 17:08:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 9323 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 D0D1423E5A for ; Fri, 15 Jun 2012 17:10:45 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 89525A18810 for ; Fri, 15 Jun 2012 17:10:45 +0000 (UTC) Received: by ghbz12 with SMTP id z12so2723876ghb.11 for ; Fri, 15 Jun 2012 10:10:45 -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=hbW6ByXINZvz5E7OrFu3IFBoLyZB1NFpdGPcywgvtsU=; b=GlyuZPCNISg89+tF75ThCMPAh2oFLWEXUiE/7NiNCPpxjoRtrCphiK+qM3R4SNNYUf wZ2MoL8NzSQeUy5cFaw4a+I3wVJinTC70tHHdIpz8R5uV6OeuISOW77OAhUl2clDl3Gb okZHTPOd38+WjKXkhUHuvAgo5vWz8CDxpC9YM7GpdHYm2/DNl+HrI7YE8+CKEFDpXZu9 imeoTL98P6i2A+e6BKz6DiMCYCBv8ylkX+UUACtlY8hKNl3letYCv2QxP/FTo5Inx3wN dkFV3W6FxeCH1cd501mw7XoaaWjgcGo9cewQYEcUCwUtQr1s4d8HD6q7YEU+JYkkwpxt 255w== Received: by 10.50.195.234 with SMTP id ih10mr2836590igc.0.1339780244811; Fri, 15 Jun 2012 10:10:44 -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 v20csp158948ibb; Fri, 15 Jun 2012 10:10:44 -0700 (PDT) Received: by 10.42.80.129 with SMTP id v1mr191887ick.21.1339780244295; Fri, 15 Jun 2012 10:10:44 -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 gg3si6714088pbc.49.2012.06.15.10.10.44 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Jun 2012 10:10:44 -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 rr4so6362707pbb.37 for ; Fri, 15 Jun 2012 10:10:44 -0700 (PDT) Received: by 10.68.135.66 with SMTP id pq2mr8665487pbb.156.1339780244038; Fri, 15 Jun 2012 10:10:44 -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 jz4sm13830510pbc.17.2012.06.15.10.10.41 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Jun 2012 10:10:43 -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/6] pstore: Introduce write_buf backend callback Date: Fri, 15 Jun 2012 10:08:27 -0700 Message-Id: <1339780111-12075-2-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <20120615170659.GA4060@lizard> References: <20120615170659.GA4060@lizard> X-Gm-Message-State: ALoCoQnca3BX0PCEqND91TjOuqsw9fZ+GGO2XoEREVW8iBQfQywuowgVpkTI5WvJQj4ySATXecgz 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 be4614f..e7c0a52 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -198,6 +198,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 @@ -222,6 +230,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;