From patchwork Mon May 26 13:26:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 30928 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 26C0D20491 for ; Mon, 26 May 2014 13:25:22 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id m1sf42019397oag.2 for ; Mon, 26 May 2014 06:25:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:cc:subject:references:in-reply-to:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe :content-type:content-transfer-encoding; bh=yKrG7IyLOVwsM6ZqIsFCZMEhBEKD+hat5fO48mCve0k=; b=GGoFGJnLcZdkgC/a0mHvRZRJlf3Zi1n+wTNVgSFQcKSI1z/LBpmq7m6Yf12gTSEjxG sTcg+rs10wjez0JizwhTHjHWFVXG9sxNkT4zDpLxwrMbZyuLe4svxJry1HfZTlI11Sib L7kbDgLhDa9BgUYVvV4z/qnd+QHpKUT2i/1PL4iV6oQpWfQoOUW0jA8mSgDbfEppHzkg 0w2psFEJ4zGJFFI6G4mAIwqvyGsl5BMKwZfj497EKnEmICFq98VPyfz317Iuc7UCB1Ep V+xauK+NsW6ur+kddN7RTIjwJGjVL/tZNSbadyCUU9zIIhEg7liDQFMA16u8cLn8R96m WoEQ== X-Gm-Message-State: ALoCoQlzlA9cNZEhmr0Sw8qpXk8ptKgCoInzPi9RqhqACctr17MDHfFpNTAc472NC2ENgsrozj1D X-Received: by 10.182.246.7 with SMTP id xs7mr10275939obc.15.1401110721460; Mon, 26 May 2014 06:25:21 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.105.54 with SMTP id b51ls2846505qgf.48.gmail; Mon, 26 May 2014 06:25:21 -0700 (PDT) X-Received: by 10.220.82.133 with SMTP id b5mr21398393vcl.13.1401110721349; Mon, 26 May 2014 06:25:21 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id lt1si6272487vec.15.2014.05.26.06.25.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 May 2014 06:25:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id id10so5846612vcb.34 for ; Mon, 26 May 2014 06:25:21 -0700 (PDT) X-Received: by 10.220.53.72 with SMTP id l8mr21622934vcg.16.1401110721158; Mon, 26 May 2014 06:25:21 -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.220.221.72 with SMTP id ib8csp44144vcb; Mon, 26 May 2014 06:25:20 -0700 (PDT) X-Received: by 10.66.222.100 with SMTP id ql4mr27946027pac.109.1401110719888; Mon, 26 May 2014 06:25:19 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ah3si14893589pad.52.2014.05.26.06.25.19; Mon, 26 May 2014 06:25:19 -0700 (PDT) Received-SPF: none (google.com: linux-acpi-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 S1752244AbaEZNZR (ORCPT + 8 others); Mon, 26 May 2014 09:25:17 -0400 Received: from mail-we0-f179.google.com ([74.125.82.179]:43955 "EHLO mail-we0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751998AbaEZNZQ (ORCPT ); Mon, 26 May 2014 09:25:16 -0400 Received: by mail-we0-f179.google.com with SMTP id q59so7880833wes.24 for ; Mon, 26 May 2014 06:25:14 -0700 (PDT) X-Received: by 10.194.216.162 with SMTP id or2mr1837675wjc.0.1401110714505; Mon, 26 May 2014 06:25:14 -0700 (PDT) Received: from [10.0.2.212] ([80.82.22.190]) by mx.google.com with ESMTPSA id ey3sm10919391wib.18.2014.05.26.06.25.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 May 2014 06:25:13 -0700 (PDT) Message-ID: <538340EE.7070408@linaro.org> Date: Mon, 26 May 2014 15:26:06 +0200 From: Tomasz Nowicki User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Borislav Petkov CC: rjw@rjwysocki.net, lenb@kernel.org, tony.luck@intel.com, bp@suse.de, m.chehab@samsung.com, linux-edac@vger.kernel.org, x86@kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org Subject: Re: [PATCH 4/7] acpi, apei, ghes: Factor out NMI error notification context. References: <1397056476-9183-1-git-send-email-tomasz.nowicki@linaro.org> <1397056476-9183-5-git-send-email-tomasz.nowicki@linaro.org> <20140513194125.GD8760@pd.tnic> <537F39D7.6090309@linaro.org> <20140523164824.GG21332@pd.tnic> In-Reply-To: <20140523164824.GG21332@pd.tnic> Sender: linux-acpi-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-acpi@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.175 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: , On 23.05.2014 18:48, Borislav Petkov wrote: > On Fri, May 23, 2014 at 02:06:47PM +0200, Tomasz Nowicki wrote: >> I had that thoughts too. Looking at simple MCE calls, yes, it does >> make sense to create corresponding arch-specific version and provide >> logic as needed. I think that NMI is much more complicated.... > > How about this ontop of your patches. It builds here but it is not > trivial for me to try it on !X86. Maybe you can test it quicker than me > finding some other arch box first... :) > Now I do follow :) Nicely done, I have applied your patch and indeed there are more arch dependencies for !X86. I created another patch (it can be applied on top of last patch set). Does it look reasonable? Regards, Tomasz --- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h index 86f9301..0f03ab6 100644 --- a/arch/x86/include/asm/nmi.h +++ b/arch/x86/include/asm/nmi.h @@ -54,7 +54,18 @@ struct nmiaction { int __register_nmi_handler(unsigned int, struct nmiaction *); -void unregister_nmi_handler(unsigned int, const char *); +void unregister_nmi_handler(unsigned int type, const char *name); + +static inline int arch_apei_register_nmi(nmi_handler_t fn, + const char *name) +{ + return register_nmi_handler(NMI_LOCAL, fn, 0, name); +} + +static inline void arch_apei_unregister_nmi(const char *name) +{ + unregister_nmi_handler(NMI_LOCAL, name); +} void stop_nmi(void); void restart_nmi(void); diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 35a44d9..84c79af 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -47,13 +47,11 @@ #include #include #include +#include #include #include #include -#ifdef CONFIG_ACPI_APEI_NMI -#include -#endif #include "apei-internal.h" @@ -718,7 +716,6 @@ static int ghes_notify_sci(struct notifier_block *this, return ret; } -#ifdef CONFIG_ACPI_APEI_NMI /* * printk is not safe in NMI context. So in NMI handler, we allocate * required memory from lock-less memory allocator @@ -817,7 +814,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(CONFIG_ACPI_APEI_NMI)); @@ -832,14 +829,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); @@ -914,7 +911,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); @@ -928,7 +925,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 @@ -941,17 +938,14 @@ static void ghes_notify_remove_nmi(struct ghes *ghes) static void ghes_init_nmi(void) { + if (!IS_ENABLED(CONFIG_ACPI_APEI_NMI)) + return; + init_irq_work(&ghes_proc_irq_work, ghes_proc_in_irq); ghes_notify_tab[ACPI_HEST_NOTIFY_NMI].init_call = ghes_notify_init_nmi; ghes_notify_tab[ACPI_HEST_NOTIFY_NMI].remove_call = ghes_notify_remove_nmi; } -#else -static inline void ghes_init_nmi(void) -{ - -} -#endif static int ghes_notify_init_polled(struct ghes *ghes) { diff --git a/include/linux/nmi.h b/include/linux/nmi.h index 084b4c5..1aa351c 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -56,4 +56,19 @@ extern int proc_dowatchdog(struct ctl_table *, int , void __user *, size_t *, loff_t *); #endif +#define APEI_NMI_DONE 0 +#define APEI_NMI_HANDLED 1 + +#ifdef CONFIG_ACPI_APEI_NMI +#include +#define arch_apei_nmi_oops_begin() oops_begin() +#else +#define arch_apei_register_nmi(fn, n) ({ \ + void __attribute__((unused)) *dummy = fn; \ + (-ENOSYS); \ +}); +#define arch_apei_unregister_nmi(n) +#define arch_apei_nmi_oops_begin() +#endif /* CONFIG_ACPI_APEI_NMI */ + #endif