From patchwork Fri Aug 12 02:54:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 1059512 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7C2seO5027365 for ; Fri, 12 Aug 2011 02:54:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753957Ab1HLCye (ORCPT ); Thu, 11 Aug 2011 22:54:34 -0400 Received: from mga01.intel.com ([192.55.52.88]:37737 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752626Ab1HLCyd (ORCPT ); Thu, 11 Aug 2011 22:54:33 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 11 Aug 2011 19:54:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.67,360,1309762800"; d="scan'208";a="38564559" Received: from yhuang-dev.sh.intel.com (HELO [10.239.13.105]) ([10.239.13.105]) by fmsmga002.fm.intel.com with ESMTP; 11 Aug 2011 19:54:31 -0700 Message-ID: <4E4495E7.3050305@intel.com> Date: Fri, 12 Aug 2011 10:54:31 +0800 From: Huang Ying User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110626 Iceowl/1.0b2 Icedove/3.1.11 MIME-Version: 1.0 To: "Nath, Arindam" CC: "linux-acpi@vger.kernel.org" , "Su, Henry" Subject: Re: Linux ACPI BERT implementation References: <6C03668EAF45B747AF947A1603D1B300018F85B9D6@SAUSEXMBP01.amd.com> <4E1FE749.2080707@intel.com> <6C03668EAF45B747AF947A1603D1B3000197F3F448@SAUSEXMBP01.amd.com> In-Reply-To: <6C03668EAF45B747AF947A1603D1B3000197F3F448@SAUSEXMBP01.amd.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 12 Aug 2011 02:54:41 +0000 (UTC) Hi, Arindam, The bert patch is attached with the mail. The testing steps 1. Build kernel with APEI enabled. 2. Trigger some hardware error so that BERT will be filled 3. Reboot system, and check whether there are some kernel message (dmesg) begin with [Hardware Error] Error record from previous boot: We don't know how to do (2). That is key for this testing. Best Regards, Huang Ying On 08/10/2011 02:36 PM, Nath, Arindam wrote: > Hi Huang, > >> -----Original Message----- >> From: Huang Ying [mailto:ying.huang@intel.com] >> Sent: Friday, July 15, 2011 12:38 PM >> To: Nath, Arindam >> Cc: linux-acpi@vger.kernel.org; Su, Henry >> Subject: Re: Linux ACPI BERT implementation >> >> On 07/15/2011 02:45 PM, Nath, Arindam wrote: >>> Hi Huang, >>> >>> >>> >>> Since you have already added some support for APEI into the ACPI >>> subsystem, are you planning to add support for BERT too? >> >> Yes. I have the code. But have not found a way to test it on my >> testing >> machine. Do you have any machine to test it? > > Sorry for the late response. We do have platform with ACPI BERT support, but it has not been tested. So if you provide me the patch, it would help if you could also provide me the steps to test the patch. > > Thanks, > Arindam > >> >> Best Regards, >> Huang Ying > > Subject: [PATCH] ACPI, APEI, Boot Error Record Table (BERT) support Under normal circumstances, when a hardware error occurs, kernel will be notified via NMI, MCE or some other method, then kernel will process the error condition, report it, and recover it if possible. But sometime, the situation is so bad, so that firmware may choose to reset directly without notifying Linux kernel. Linux kernel can use the Boot Error Record Table (BERT) to get the un-notified hardware errors that occurred in a previous boot. In this patch, the error information is reported via printk. For more information about ERST, please refer to ACPI Specification version 4.0, section 17.3.1 Signed-off-by: Huang Ying --- Documentation/kernel-parameters.txt | 3 drivers/acpi/apei/Makefile | 2 drivers/acpi/apei/bert.c | 169 ++++++++++++++++++++++++++++++++++++ include/acpi/apei.h | 1 4 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 drivers/acpi/apei/bert.c --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -402,6 +402,9 @@ bytes respectively. Such letter suffixes bootmem_debug [KNL] Enable bootmem allocator debug messages. + bert_disable [ACPI] + Disable Boot Error Record Table (BEST) support. + bttv.card= [HW,V4L] bttv (bt848 + bt878 based grabber cards) bttv.radio= Most important insmod options are available as kernel args too. --- a/drivers/acpi/apei/Makefile +++ b/drivers/acpi/apei/Makefile @@ -3,4 +3,4 @@ obj-$(CONFIG_ACPI_APEI_GHES) += ghes.o obj-$(CONFIG_ACPI_APEI_EINJ) += einj.o obj-$(CONFIG_ACPI_APEI_ERST_DEBUG) += erst-dbg.o -apei-y := apei-base.o hest.o cper.o erst.o +apei-y := apei-base.o hest.o cper.o erst.o bert.o --- /dev/null +++ b/drivers/acpi/apei/bert.c @@ -0,0 +1,169 @@ +/* + * APEI Boot Error Record Table (BERT) support + * + * Copyright 2011 Intel Corp. + * Author: Huang Ying + * + * Under normal circumstances, when a hardware error occurs, kernel + * will be notified via NMI, MCE or some other method, then kernel + * will process the error condition, report it, and recover it if + * possible. But sometime, the situation is so bad, so that firmware + * may choose to reset directly without notifying Linux kernel. + * + * Linux kernel can use the Boot Error Record Table (BERT) to get the + * un-notified hardware errors that occurred in a previous boot. + * + * For more information about ERST, please refer to ACPI Specification + * version 4.0, section 17.3.1 + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version + * 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include + +#include "apei-internal.h" + +#define BERT_PFX "BERT: " + +int bert_disable; +EXPORT_SYMBOL_GPL(bert_disable); + +static void __init bert_print_all(struct acpi_hest_generic_status *region, + unsigned int region_len) +{ + int remain, first = 1; + u32 estatus_len; + struct acpi_hest_generic_status *estatus; + + remain = region_len; + estatus = region; + while (remain > sizeof(struct acpi_hest_generic_status)) { + /* No more error record */ + if (!estatus->block_status) + break; + + estatus_len = apei_estatus_len(estatus); + if (estatus_len < sizeof(struct acpi_hest_generic_status) || + remain < estatus_len) { + pr_err(FW_BUG BERT_PFX "Invalid error status block with length %u\n", + estatus_len); + return; + } + + if (apei_estatus_check(estatus)) { + pr_err(FW_BUG BERT_PFX "Invalid Error status block\n"); + goto next; + } + + if (first) { + pr_info(HW_ERR "Error record from previous boot:\n"); + first = 0; + } + apei_estatus_print(KERN_INFO HW_ERR, estatus); +next: + estatus = (void *)estatus + estatus_len; + remain -= estatus_len; + } +} + +static int __init setup_bert_disable(char *str) +{ + bert_disable = 1; + return 0; +} +__setup("bert_disable", setup_bert_disable); + +static int __init bert_check_table(struct acpi_table_bert *bert_tab) +{ + if (bert_tab->header.length < sizeof(struct acpi_table_bert)) + return -EINVAL; + if (bert_tab->region_length != 0 && + bert_tab->region_length < sizeof(struct acpi_bert_region)) + return -EINVAL; + + return 0; +} + +static int __init bert_init(void) +{ + acpi_status status; + struct acpi_table_bert *bert_tab; + struct resource *r; + struct acpi_hest_generic_status *bert_region; + unsigned int region_len; + int rc = -EINVAL; + + if (acpi_disabled) + goto out; + + if (bert_disable) { + pr_info(BERT_PFX "Boot Error Record Table (BERT) support is disabled.\n"); + goto out; + } + + status = acpi_get_table(ACPI_SIG_BERT, 0, + (struct acpi_table_header **)&bert_tab); + if (status == AE_NOT_FOUND) { + pr_err(BERT_PFX "Table is not found!\n"); + goto out; + } else if (ACPI_FAILURE(status)) { + const char *msg = acpi_format_exception(status); + pr_err(BERT_PFX "Failed to get table, %s\n", msg); + goto out; + } + + rc = bert_check_table(bert_tab); + if (rc) { + pr_err(FW_BUG BERT_PFX "BERT table is invalid\n"); + goto out; + } + + region_len = bert_tab->region_length; + if (!region_len) { + rc = 0; + goto out; + } + + r = request_mem_region(bert_tab->address, region_len, "APEI BERT"); + if (!r) { + pr_err(BERT_PFX "Can not request iomem region <%016llx-%016llx> for BERT.\n", + (unsigned long long)bert_tab->address, + (unsigned long long)bert_tab->address + region_len); + rc = -EIO; + goto out; + } + + bert_region = ioremap_cache(bert_tab->address, region_len); + if (!bert_region) { + rc = -ENOMEM; + goto out_release; + } + + bert_print_all(bert_region, region_len); + + iounmap(bert_region); + +out_release: + release_mem_region(bert_tab->address, region_len); +out: + if (rc) + bert_disable = 1; + + return rc; +} +late_initcall(bert_init); --- a/include/acpi/apei.h +++ b/include/acpi/apei.h @@ -23,6 +23,7 @@ extern int ghes_disable; #else #define ghes_disable 1 #endif +extern int bert_disable; #ifdef CONFIG_ACPI_APEI void __init acpi_hest_init(void);