From patchwork Fri Jun 13 11:02:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 31872 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f199.google.com (mail-pd0-f199.google.com [209.85.192.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B34252054B for ; Fri, 13 Jun 2014 11:04:14 +0000 (UTC) Received: by mail-pd0-f199.google.com with SMTP id fp1sf8244200pdb.2 for ; Fri, 13 Jun 2014 04:04:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=Oux995mGxg2Q1EM/1YIi5XTEOh4/7DlSGeRSqIFiglg=; b=BXmMBzTCpIxJJy4JQx1s2SsFmy4lvwAlajx0AswmCuTXJG/Nx6pyU26kE1iFNSWcFH yDweHyZlMZ++2Cyunmz6EOusp/SJjWx+Aic8DLoiOvgp5aje769vQnPRBur5Sn2xY7kh H5TH+qvq+RQ93DVSRkhJvYRmRwYspoe432mo00cw6+bVnoC4z7xjSs99L7qjP/ZHO+oe btq0+Trk/aEHpJkH603rRNfzU9F/VzyK3X+8ZTep6PbDWPWqlQjBVWyVJfQIqvb9Ra9e mpfignSNKx/4Yfw93s1193Wwbe0tOygYgTtrGz+JZ99cKiH8LUyBLW/feeYguVh5ZaTz OISw== X-Gm-Message-State: ALoCoQlvoQRx8su8CPQaMEgEjhSAQV4vtNdcNjMca23p2TOUbOa+icUWLmWLefneSrRJx8t3C8dM X-Received: by 10.66.160.34 with SMTP id xh2mr675803pab.6.1402657454017; Fri, 13 Jun 2014 04:04:14 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.87.148 with SMTP id r20ls559018qgd.12.gmail; Fri, 13 Jun 2014 04:04:13 -0700 (PDT) X-Received: by 10.220.119.18 with SMTP id x18mr372302vcq.68.1402657453826; Fri, 13 Jun 2014 04:04:13 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id 6si1284234vct.68.2014.06.13.04.04.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Jun 2014 04:04:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id hy4so2117630vcb.33 for ; Fri, 13 Jun 2014 04:04:13 -0700 (PDT) X-Received: by 10.58.106.104 with SMTP id gt8mr415939veb.46.1402657453733; Fri, 13 Jun 2014 04:04:13 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp477701vcb; Fri, 13 Jun 2014 04:04:13 -0700 (PDT) X-Received: by 10.66.120.201 with SMTP id le9mr2348267pab.98.1402657452613; Fri, 13 Jun 2014 04:04:12 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hk10si4379550pac.55.2014.06.13.04.04.11 for ; Fri, 13 Jun 2014 04:04:11 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753291AbaFMLDh (ORCPT + 26 others); Fri, 13 Jun 2014 07:03:37 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:35134 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753188AbaFMLD3 (ORCPT ); Fri, 13 Jun 2014 07:03:29 -0400 Received: by mail-wi0-f169.google.com with SMTP id hi2so2113159wib.4 for ; Fri, 13 Jun 2014 04:03:27 -0700 (PDT) X-Received: by 10.194.86.164 with SMTP id q4mr3270595wjz.88.1402657407689; Fri, 13 Jun 2014 04:03:27 -0700 (PDT) Received: from tn-HP3-PC.semihalf.com ([80.82.22.190]) by mx.google.com with ESMTPSA id w6sm11206942eef.20.2014.06.13.04.03.26 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Jun 2014 04:03:27 -0700 (PDT) From: Tomasz Nowicki To: rjw@rjwysocki.net, lenb@kernel.org, tony.luck@intel.com, bp@alien8.de, m.chehab@samsung.com, bp@suse.de Cc: linux-edac@vger.kernel.org, x86@kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org, rric@kernel.org, Tomasz Nowicki Subject: [PATCH v3 4/5] apei, ghes, nmi: Factor out NMI arch-specific calls. Date: Fri, 13 Jun 2014 13:02:59 +0200 Message-Id: <1402657380-18539-5-git-send-email-tomasz.nowicki@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1402657380-18539-1-git-send-email-tomasz.nowicki@linaro.org> References: <1402657380-18539-1-git-send-email-tomasz.nowicki@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: tomasz.nowicki@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Similar to MCE related patch, all NMI architectural calls are abstracted. Also, we are providing corresponding X86 functions' content. Signed-off-by: Tomasz Nowicki --- arch/x86/kernel/acpi/apei.c | 25 +++++++++++++++++++++++++ drivers/acpi/apei/apei-base.c | 19 +++++++++++++++++++ drivers/acpi/apei/ghes.c | 14 ++++++-------- include/acpi/apei.h | 7 +++++++ 4 files changed, 57 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/acpi/apei.c b/arch/x86/kernel/acpi/apei.c index dca2852..221a3a6 100644 --- a/arch/x86/kernel/acpi/apei.c +++ b/arch/x86/kernel/acpi/apei.c @@ -12,9 +12,12 @@ * GNU General Public License for more details. */ +#include #include #include +#include +#include int apei_arch_enable_cmcff(struct acpi_hest_header *hest_hdr, void *data) { @@ -54,3 +57,25 @@ void apei_arch_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) apei_mce_report_mem_error(sev, mem_err); #endif } + +int arch_apei_register_nmi(int (*nmi_handler)(unsigned int, struct pt_regs *), + const char *name) +{ + struct nmiaction apei_nmi_action = { + .handler = nmi_handler, + .name = name, + .flags = 0, + }; + + return __register_nmi_handler(NMI_LOCAL, &apei_nmi_action); +} + +void arch_apei_unregister_nmi(const char *name) +{ + unregister_nmi_handler(NMI_LOCAL, name); +} + +void arch_apei_nmi_oops_begin(void) +{ + oops_begin(); +} diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c index 4a11c1a..78c2a26 100644 --- a/drivers/acpi/apei/apei-base.c +++ b/drivers/acpi/apei/apei-base.c @@ -758,6 +758,25 @@ void __weak apei_arch_report_mem_error(int sev, } EXPORT_SYMBOL_GPL(apei_arch_report_mem_error); +int __weak arch_apei_register_nmi( + __attribute__((unused)) int (*nmi_handler)(unsigned int, + struct pt_regs *), + const char *name) +{ + return -ENOSYS; +} +EXPORT_SYMBOL_GPL(arch_apei_register_nmi); + +void __weak arch_apei_unregister_nmi(const char *name) +{ +} +EXPORT_SYMBOL_GPL(arch_apei_unregister_nmi); + +void __weak arch_apei_nmi_oops_begin(void) +{ +} +EXPORT_SYMBOL_GPL(arch_apei_nmi_oops_begin); + int apei_osc_setup(void) { static u8 whea_uuid_str[] = "ed855e0c-6c90-47bf-a62a-26de0fc5ad5c"; diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 6db5110..21aeac5 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -51,7 +51,6 @@ #include #include #include -#include #include "apei-internal.h" @@ -817,7 +816,7 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs) { struct ghes *ghes, *ghes_global = NULL; int sev, sev_global = -1; - int ret = NMI_DONE; + int ret = APEI_NMI_DONE; BUG_ON(!IS_ENABLED(ARCH_HAS_ACPI_APEI_NMI)); @@ -832,14 +831,14 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs) sev_global = sev; ghes_global = ghes; } - ret = NMI_HANDLED; + ret = APEI_NMI_HANDLED; } - if (ret == NMI_DONE) + if (ret == APEI_NMI_DONE) goto out; if (sev_global >= GHES_SEV_PANIC) { - oops_begin(); + arch_apei_nmi_oops_begin(); ghes_print_queued_estatus(); __ghes_print_estatus(KERN_EMERG, ghes_global->generic, ghes_global->estatus); @@ -909,8 +908,7 @@ static int ghes_notify_init_nmi(struct ghes *ghes) ghes_estatus_pool_expand(len); mutex_lock(&ghes_list_mutex); if (list_empty(&ghes_nmi)) - status = register_nmi_handler(NMI_LOCAL, ghes_notify_nmi, 0, - "ghes"); + status = arch_apei_register_nmi(ghes_notify_nmi, "ghes"); list_add_rcu(&ghes->list, &ghes_nmi); mutex_unlock(&ghes_list_mutex); @@ -924,7 +922,7 @@ static void ghes_notify_remove_nmi(struct ghes *ghes) mutex_lock(&ghes_list_mutex); list_del_rcu(&ghes->list); if (list_empty(&ghes_nmi)) - unregister_nmi_handler(NMI_LOCAL, "ghes"); + arch_apei_unregister_nmi("ghes"); mutex_unlock(&ghes_list_mutex); /* * To synchronize with NMI handler, ghes can only be diff --git a/include/acpi/apei.h b/include/acpi/apei.h index 62b9d1c..348e1ea 100644 --- a/include/acpi/apei.h +++ b/include/acpi/apei.h @@ -14,6 +14,9 @@ #define APEI_ERST_CLEAR_RECORD _IOW('E', 1, u64) #define APEI_ERST_GET_RECORD_COUNT _IOR('E', 2, u32) +#define APEI_NMI_DONE 0 +#define APEI_NMI_HANDLED 1 + #ifdef __KERNEL__ extern bool hest_disable; @@ -44,6 +47,10 @@ int erst_clear(u64 record_id); int apei_arch_enable_cmcff(struct acpi_hest_header *hest_hdr, void *data); void apei_arch_report_mem_error(int sev, struct cper_sec_mem_err *mem_err); +int arch_apei_register_nmi(int (*nmi_handler)(unsigned int, struct pt_regs *), + const char *name); +void arch_apei_unregister_nmi(const char *name); +void arch_apei_nmi_oops_begin(void); #endif #endif