From patchwork Tue Jun 26 23:23:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 9629 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 A02B823F28 for ; Tue, 26 Jun 2012 23:25:36 +0000 (UTC) Received: from mail-yw0-f50.google.com (mail-yw0-f50.google.com [209.85.213.50]) by fiordland.canonical.com (Postfix) with ESMTP id 59A0AA1888A for ; Tue, 26 Jun 2012 23:25:36 +0000 (UTC) Received: by yhjj63 with SMTP id j63so596075yhj.37 for ; Tue, 26 Jun 2012 16:25:35 -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=CetECtzvXhlbn9SoNb/dhJUoDTHXJc+AmkOIMzolwLO3lWN+fLrOEmrvEkF09bNJLx 0yexQVUfmPNG8FsWXiQbnQXcB3PmbJ9adsxWB8yBy/x9j1v04hRD89W9JJQFDf4+VAP/ POzxlsonE5NB4ostFKQ+m5guJjcEg3cM/2K+/IPmhvdqhBzDPCNKBYxay1JwXQ6sqMqQ cdlmhjPS2V+zIBK9Fgfr02m+uPd6RDWAWGFI/tACVkjcw6uMUACIzaZimjvjKfYdbrQd thvIc/ab1wV/Isgw0yXtPqA25lo3m87zo7bwRZxpyeBv/DA42h0nV37L5NSPNxlzKjIM aX1Q== Received: by 10.50.57.167 with SMTP id j7mr12743930igq.53.1340753135342; Tue, 26 Jun 2012 16:25:35 -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 v20csp91705ibb; Tue, 26 Jun 2012 16:25:34 -0700 (PDT) Received: by 10.68.221.10 with SMTP id qa10mr56254873pbc.154.1340753134373; Tue, 26 Jun 2012 16:25:34 -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 qr7si17761053pbc.10.2012.06.26.16.25.34 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 26 Jun 2012 16:25:34 -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 rr4so846637pbb.37 for ; Tue, 26 Jun 2012 16:25:34 -0700 (PDT) Received: by 10.68.203.40 with SMTP id kn8mr56130504pbc.162.1340753134110; Tue, 26 Jun 2012 16:25:34 -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 pq5sm13203149pbb.30.2012.06.26.16.25.32 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 26 Jun 2012 16:25:33 -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/7] pstore: Introduce write_buf backend callback Date: Tue, 26 Jun 2012 16:23:24 -0700 Message-Id: <1340753009-12483-2-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <20120626232210.GA11549@lizard> References: <20120626232210.GA11549@lizard> X-Gm-Message-State: ALoCoQkTlYk7qnZwWAzV0s+qH/QoPuyhqGsaL6R0uHsHW+hisbTwfaex4Rk0NN/ns8/k6/dtgzPg 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;