From patchwork Thu Apr 17 06:28:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Gong X-Patchwork-Id: 4005941 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0EF1ABFF02 for ; Thu, 17 Apr 2014 06:54:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 309CD2034A for ; Thu, 17 Apr 2014 06:54:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C9FE120328 for ; Thu, 17 Apr 2014 06:54:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751992AbaDQGyL (ORCPT ); Thu, 17 Apr 2014 02:54:11 -0400 Received: from mga09.intel.com ([134.134.136.24]:30938 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751090AbaDQGyK (ORCPT ); Thu, 17 Apr 2014 02:54:10 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 16 Apr 2014 23:49:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,877,1389772800"; d="scan'208";a="494597421" Received: from gchen-sby.bj.intel.com (HELO localhost) ([10.238.158.82]) by orsmga001.jf.intel.com with ESMTP; 16 Apr 2014 23:54:07 -0700 From: "Chen, Gong" To: tony.luck@intel.com, bp@alien8.de, m.chehab@samsung.com Cc: rostedt@goodmis.org, linux-acpi@vger.kernel.org, arozansk@redhat.com, "Chen, Gong" Subject: [PATCH 4/5 v2] trace, eMCA: Add a knob to adjust where to save event log Date: Thu, 17 Apr 2014 02:28:38 -0400 Message-Id: <1397716119-6164-5-git-send-email-gong.chen@linux.intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1397716119-6164-1-git-send-email-gong.chen@linux.intel.com> References: <1397716119-6164-1-git-send-email-gong.chen@linux.intel.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To avoid saving two copies for one H/W event, add a new file under debugfs to control how to save event log. Once this file is opened, the perf/trace will be used, in the meanwhile, kernel will stop to print event log to the console. On the other hand, if this file is closed, kernel will print event log to the console again. v2 -> v1: move counter operation from *read* function to *open* function Signed-off-by: Chen, Gong --- drivers/acpi/acpi_extlog.c | 74 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 59 insertions(+), 15 deletions(-) diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c index 6192ec1..860d5ce 100644 --- a/drivers/acpi/acpi_extlog.c +++ b/drivers/acpi/acpi_extlog.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -65,6 +66,9 @@ static void *elog_buf; static u64 *l1_entry_base; static u32 l1_percpu_entry; +static struct dentry *extlog_debug_dir; +static atomic_t trace_on; + #define ELOG_IDX(cpu, bank) \ (cpu_physical_id(cpu) * l1_percpu_entry + (bank)) @@ -180,21 +184,24 @@ static int extlog_print(struct notifier_block *nb, unsigned long val, estatus->block_status = 0; tmp = (struct acpi_generic_status *)elog_buf; - print_extlog_rcd(NULL, tmp, cpu); - - /* log event via trace */ - err_count++; - gdata = (struct acpi_generic_data *)(tmp + 1); - if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID) - fru_id = (uuid_le *)gdata->fru_id; - if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT) - fru_text = gdata->fru_text; - sec_type = (uuid_le *)gdata->section_type; - if (!uuid_le_cmp(*sec_type, CPER_SEC_PLATFORM_MEM)) { - struct cper_sec_mem_err *mem_err = (void *)(gdata + 1); - if (gdata->error_data_length >= sizeof(*mem_err)) - __trace_mem_error(fru_id, fru_text, err_count, - gdata->error_severity, mem_err); + if (!atomic_read(&trace_on)) + print_extlog_rcd(NULL, tmp, cpu); + else { + /* log event via trace */ + err_count++; + gdata = (struct acpi_generic_data *)(tmp + 1); + if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID) + fru_id = (uuid_le *)gdata->fru_id; + if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT) + fru_text = gdata->fru_text; + sec_type = (uuid_le *)gdata->section_type; + if (!uuid_le_cmp(*sec_type, CPER_SEC_PLATFORM_MEM)) { + struct cper_sec_mem_err *mem_err = (void *)(gdata + 1); + if (gdata->error_data_length >= sizeof(*mem_err)) + __trace_mem_error(fru_id, fru_text, err_count, + gdata->error_severity, + mem_err); + } } return NOTIFY_STOP; @@ -230,6 +237,31 @@ static bool __init extlog_get_l1addr(void) return true; } + +static int extlog_trace_show(struct seq_file *m, void *v) +{ + return 0; +} + +static int trace_open(struct inode *inode, struct file *file) +{ + atomic_inc(&trace_on); + return single_open(file, extlog_trace_show, NULL); +} + +static int trace_release(struct inode *inode, struct file *file) +{ + atomic_dec(&trace_on); + return single_release(inode, file); +} + +static const struct file_operations trace_fops = { + .open = trace_open, + .read = seq_read, + .llseek = seq_lseek, + .release = trace_release, +}; + static struct notifier_block extlog_mce_dec = { .notifier_call = extlog_print, }; @@ -240,6 +272,7 @@ static int __init extlog_init(void) void __iomem *extlog_l1_hdr; size_t l1_hdr_size; struct resource *r; + struct dentry *fentry; u64 cap; int rc; @@ -303,6 +336,14 @@ static int __init extlog_init(void) if (elog_buf == NULL) goto err_release_elog; + extlog_debug_dir = debugfs_create_dir("extlog", NULL); + if (!extlog_debug_dir) + goto err_cleanup; + fentry = debugfs_create_file("suppress_console", S_IRUSR, + extlog_debug_dir, NULL, &trace_fops); + if (!fentry) + goto err_cleanup; + /* * eMCA event report method has higher priority than EDAC method, * unless EDAC event report method is mandatory. @@ -315,6 +356,8 @@ static int __init extlog_init(void) return 0; +err_cleanup: + debugfs_remove_recursive(extlog_debug_dir); err_release_elog: if (elog_addr) acpi_os_unmap_memory(elog_addr, elog_size); @@ -340,6 +383,7 @@ static void __exit extlog_exit(void) release_mem_region(elog_base, elog_size); release_mem_region(l1_dirbase, l1_size); kfree(elog_buf); + debugfs_remove_recursive(extlog_debug_dir); } module_init(extlog_init);