From patchwork Sat May 26 13:39:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 9003 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 03D3B23F00 for ; Sat, 26 May 2012 13:41:18 +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 C7D5DA18441 for ; Sat, 26 May 2012 13:41:17 +0000 (UTC) Received: by mail-yx0-f180.google.com with SMTP id q6so1080455yen.11 for ; Sat, 26 May 2012 06:41:17 -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=Ww0dAy9OExQQ/B04s6kWygX6G/TMPuAfjVEVBVsWMUo=; b=ENuR70D7H1wf1+xHWFGH6uAlM6V8qnGCOVdxt2q7cXERR1BpCv2AOND1e1fMlYgXoc q3VjJCdiVGXeatLsYqldIz3AA3+0jtfVFAkYqAEGICiqQSYpVol5Lfd2yjBgRvfcx90U 4AphAgqfhudkN4zjcEDaDKpsmlfv1arWC9V4O5g0l2tKstvhgbOmnYrKFqI7JRIkvxsB 1W9b7BiqnlFjlLQCZy/o01Xk6k1UZqBrsD5F2C02cAvwxe8a6op2Oj3L22WN8qBILzL2 RAIH4MQTdpYQLK51sQJ8PtqM5hp/WJKFe70EE7EOCl9Hb9OCLOxk4W/ryJcbh38XPKyn 6Llg== Received: by 10.42.163.129 with SMTP id c1mr829118icy.57.1338039677433; Sat, 26 May 2012 06:41:17 -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 v20csp87063ibb; Sat, 26 May 2012 06:41:16 -0700 (PDT) Received: by 10.68.213.101 with SMTP id nr5mr7768790pbc.131.1338039676711; Sat, 26 May 2012 06:41:16 -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 sl1si12145431pbc.84.2012.05.26.06.41.16 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 26 May 2012 06:41:16 -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 rr4so3306520pbb.37 for ; Sat, 26 May 2012 06:41:16 -0700 (PDT) Received: by 10.68.217.233 with SMTP id pb9mr8154522pbc.59.1338039676459; Sat, 26 May 2012 06:41:16 -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 u5sm12559123pbu.76.2012.05.26.06.41.13 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 26 May 2012 06:41:15 -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/5] pstore: Introduce write_buf backend callback Date: Sat, 26 May 2012 06:39:06 -0700 Message-Id: <1338039549-24498-2-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.9.2 In-Reply-To: <20120526133412.GA18001@lizard> References: <20120526133412.GA18001@lizard> X-Gm-Message-State: ALoCoQnfxhsdSDN4fW0P7ZlP7jFNRuwMN4N8POOmlbC/Ky5YM05GPGaCBloei5aIvcHlYmtB+hKc 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;