From patchwork Tue Aug 1 13:36:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 9874613 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C2E6760361 for ; Tue, 1 Aug 2017 13:37:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE718283CB for ; Tue, 1 Aug 2017 13:37:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A34982867E; Tue, 1 Aug 2017 13:37:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E897283CB for ; Tue, 1 Aug 2017 13:37:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752279AbdHANhI (ORCPT ); Tue, 1 Aug 2017 09:37:08 -0400 Received: from foss.arm.com ([217.140.101.70]:40906 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752202AbdHANhG (ORCPT ); Tue, 1 Aug 2017 09:37:06 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 83D8280D; Tue, 1 Aug 2017 06:37:06 -0700 (PDT) Received: from localhost (e105922-lin.cambridge.arm.com [10.1.207.56]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 033983F540; Tue, 1 Aug 2017 06:37:05 -0700 (PDT) From: Punit Agrawal To: linux-acpi@vger.kernel.org Cc: Punit Agrawal , lorenzo.pieralisi@arm.com, sudeep.holla@arm.com, linux-kernel@vger.kernel.org, Borislav Petkov , "Rafael J . Wysocki" , Punit Agrawal , James Morse Subject: [PATCH 2/3] GHES: Move memory initialisation to ghes_probe() Date: Tue, 1 Aug 2017 14:36:07 +0100 Message-Id: <20170801133608.21017-3-punit.agrawal@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170801133608.21017-1-punit.agrawal@arm.com> References: <20170801133608.21017-1-punit.agrawal@arm.com> X-ARM-No-Footer: FoSSMail Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP During the driver init, the ghes driver initialises some data structures which are only used if a GHES platform device is probed. Similarly, the init function also checks for support for firmware first mode. Create a function, ghes_common_init(), that performs the initialisations and checks that are currently performed on driver init. The function is called when the GHES device is probed. Delaying initialisation and checks until probe has the added benefit of reducing driver prints on systems that do not support ACPI APEI. Signed-off-by: Punit Agrawal Cc: Borislav Petkov Cc: James Morse --- drivers/acpi/apei/ghes.c | 77 +++++++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 34 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 007b38abcb34..befb18338acb 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -1088,12 +1088,53 @@ static inline void ghes_nmi_init_cxt(void) } #endif /* CONFIG_HAVE_ACPI_APEI_NMI */ +static int ghes_common_init(void) +{ + int rc; + static bool initialised; + + if (initialised) + return 0; + + ghes_nmi_init_cxt(); + + rc = ghes_ioremap_init(); + if (rc) + goto err; + + rc = ghes_estatus_pool_init(); + if (rc) + goto err_ioremap_exit; + + rc = apei_osc_setup(); + if (rc == 0 && osc_sb_apei_support_acked) + pr_info(GHES_PFX "APEI firmware first mode is enabled by APEI bit and WHEA _OSC.\n"); + else if (rc == 0 && !osc_sb_apei_support_acked) + pr_info(GHES_PFX "APEI firmware first mode is enabled by WHEA _OSC.\n"); + else if (rc && osc_sb_apei_support_acked) + pr_info(GHES_PFX "APEI firmware first mode is enabled by APEI bit.\n"); + else + pr_info(GHES_PFX "Failed to enable APEI firmware first mode.\n"); + + initialised = true; + return 0; + +err_ioremap_exit: + ghes_ioremap_exit(); +err: + return rc; +} + static int ghes_probe(struct platform_device *ghes_dev) { struct acpi_hest_generic *generic; struct ghes *ghes = NULL; - int rc = -EINVAL; + int rc; + + rc = ghes_common_init(); + if (rc) + return rc; generic = *(struct acpi_hest_generic **)ghes_dev->dev.platform_data; if (!generic->enabled) @@ -1268,8 +1309,6 @@ static struct platform_driver ghes_platform_driver = { static int __init ghes_init(void) { - int rc; - if (acpi_disabled) return -ENODEV; @@ -1283,36 +1322,6 @@ static int __init ghes_init(void) return -EINVAL; } - ghes_nmi_init_cxt(); - - rc = ghes_ioremap_init(); - if (rc) - goto err; - - rc = ghes_estatus_pool_init(); - if (rc) - goto err_ioremap_exit; - - rc = platform_driver_register(&ghes_platform_driver); - if (rc) - goto err_pool_exit; - - rc = apei_osc_setup(); - if (rc == 0 && osc_sb_apei_support_acked) - pr_info(GHES_PFX "APEI firmware first mode is enabled by APEI bit and WHEA _OSC.\n"); - else if (rc == 0 && !osc_sb_apei_support_acked) - pr_info(GHES_PFX "APEI firmware first mode is enabled by WHEA _OSC.\n"); - else if (rc && osc_sb_apei_support_acked) - pr_info(GHES_PFX "APEI firmware first mode is enabled by APEI bit.\n"); - else - pr_info(GHES_PFX "Failed to enable APEI firmware first mode.\n"); - - return 0; -err_pool_exit: - ghes_estatus_pool_exit(); -err_ioremap_exit: - ghes_ioremap_exit(); -err: - return rc; + return platform_driver_register(&ghes_platform_driver); } device_initcall(ghes_init);