From patchwork Tue Apr 8 07:59:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Gong X-Patchwork-Id: 3948011 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 350FE9F371 for ; Tue, 8 Apr 2014 08:24:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4F2162037D for ; Tue, 8 Apr 2014 08:24:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 544132037E for ; Tue, 8 Apr 2014 08:24:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756451AbaDHIYH (ORCPT ); Tue, 8 Apr 2014 04:24:07 -0400 Received: from mga11.intel.com ([192.55.52.93]:19890 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756426AbaDHIYF (ORCPT ); Tue, 8 Apr 2014 04:24:05 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 08 Apr 2014 01:24:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,816,1389772800"; d="scan'208";a="509092723" Received: from gchen-sby.bj.intel.com (HELO localhost) ([10.238.158.82]) by fmsmga001.fm.intel.com with ESMTP; 08 Apr 2014 01:24:02 -0700 From: "Chen, Gong" To: tony.luck@gmail.com Cc: bp@alien8.de, m.chehab@samsung.com, 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: Tue, 8 Apr 2014 03:59:22 -0400 Message-Id: <1396943962-25624-1-git-send-email-gong.chen@linux.intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: References: 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.2 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 0ee2c38..7e8f9ed 100644 --- a/drivers/acpi/acpi_extlog.c +++ b/drivers/acpi/acpi_extlog.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -62,6 +63,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)) @@ -183,21 +187,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; @@ -233,6 +240,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, }; @@ -243,6 +275,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; @@ -306,6 +339,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. @@ -318,6 +359,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); @@ -343,6 +386,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);