Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp206251rwe; Wed, 31 Aug 2022 01:01:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR4f0taOu2amFuHzbIqgcy3h96qR9qvMA7WVM50cWQ0y0Wmeg3wDXUgIQ6VHTGdRJWMGvy7o X-Received: by 2002:a63:6cc7:0:b0:42b:7d8f:7136 with SMTP id h190-20020a636cc7000000b0042b7d8f7136mr19473779pgc.15.1661932876131; Wed, 31 Aug 2022 01:01:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661932876; cv=none; d=google.com; s=arc-20160816; b=s7DMlNIu9F5/wnduTE8ginr1h6o/6O0p7FFmUmnzPmqfQhmU5SEsSeQFCGBnFnLydl aZ4z3ynDldtDcxApExN1j6e3cIAvQcokojKex5T3s6VtAtvO8QNKNFIAz4PZS6kZsxPn 1b8LVxCnIreHatqSQolCisQx8PQ1mfjD6/VaTIunUilEe+ACMhoWK5ST8DYTcPlDLtNN iutoEukXzF82m/YupT3Jk3dg6mYRR+suWrab3a8ESnzM6zTVuF8wkgVgNd28ZdKIyDah 33z6/r1kuQj375NegacpXI7pTfv0apqhr+2XkpWGGhZ6hwzV9EDcctfPUkVnXRWuc/Ne egLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=1ORImxFz5I4WZkJF3F8OgtXVCM/coZg/PQoHYn7XdDU=; b=Cbh/OOEfOyV3zUTabQWcQO6JO4mNU2sWF4JK2FbdX4ULxEEk8rVsoafa6IXOA72GZg pghMntOE8wLnIE9Dzv4ZCnywuehwSLEQsNr552Omki1K0SnhjXfJ9IGDpZ5I72uvtg/7 SBgOdDqd18DELoAheVpOIYvNA6vxI39NlOPSvHztNdEn0FYsPfRWC+YnJkyF30I3IHSJ qTDP0G4aXaSMFOmgp6L2RKEol/RnVJxui5e/pRue7+nrhAB5zDKHHLVIaGxMIZokUQ7G czze3sLYgJ8Ab9YXX0lsUyxYcd3xVaqAZyvgzR5DKacz7A4tr4hCusZrl2CmZ0QBNRC4 mKKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ix7-20020a170902f80700b0017540816378si1615269plb.48.2022.08.31.01.01.05; Wed, 31 Aug 2022 01:01:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230408AbiHaHmO (ORCPT + 99 others); Wed, 31 Aug 2022 03:42:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230207AbiHaHlc (ORCPT ); Wed, 31 Aug 2022 03:41:32 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F1EA5BD29F; Wed, 31 Aug 2022 00:41:19 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CEAD5ED1; Wed, 31 Aug 2022 00:41:25 -0700 (PDT) Received: from entos-ampere-02.shanghai.arm.com (entos-ampere-02.shanghai.arm.com [10.169.212.212]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 962143F766; Wed, 31 Aug 2022 00:41:41 -0700 (PDT) From: Jia He To: Len Brown , James Morse , Tony Luck , Borislav Petkov , Mauro Carvalho Chehab , Robert Richter , Robert Moore , Qiuxu Zhuo , Yazen Ghannam , Jan Luebbe , Khuong Dinh , Kani Toshi Cc: Ard Biesheuvel , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, devel@acpica.org, "Rafael J . Wysocki" , Shuai Xue , Jarkko Sakkinen , linux-efi@vger.kernel.org, nd@arm.com, Jia He Subject: [PATCH v4 4/8] ghes: Introduce a helper ghes_edac_preferred() Date: Wed, 31 Aug 2022 07:40:23 +0000 Message-Id: <20220831074027.13849-5-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220831074027.13849-1-justin.he@arm.com> References: <20220831074027.13849-1-justin.he@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce a flag ghes_present to differentiate between the system ROM really not offering GHES vs. the ghes module not running. ghes-present is latched on ghes_probe() and never unlatched since ACPI GHES table is static. Introduce a helper ghes_edac_preferred() and it is true if the platform-check passes. Suggested-by: Toshi Kani Signed-off-by: Jia He --- drivers/acpi/apei/ghes.c | 29 +++++++++++++++++++++++++++++ include/acpi/ghes.h | 2 ++ 2 files changed, 31 insertions(+) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 6bc9c78f916b..d798a58fbbd9 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -117,6 +117,8 @@ bool ghes_edac_force_load; module_param_named(edac_force_load, ghes_edac_force_load, bool, 0); EXPORT_SYMBOL(ghes_edac_force_load); +static bool ghes_present; + /* * All error sources notified with HED (Hardware Error Device) share a * single notifier callback, so they need to be linked and checked one @@ -1388,6 +1390,8 @@ static int ghes_probe(struct platform_device *ghes_dev) ghes_edac_register(ghes, &ghes_dev->dev); + ghes_present = true; + /* Handle any pending errors right away */ spin_lock_irqsave(&ghes_notify_lock_irq, flags); ghes_proc(ghes); @@ -1511,6 +1515,31 @@ void __init acpi_ghes_init(void) pr_info(GHES_PFX "Failed to enable APEI firmware first mode.\n"); } +/* + * Known x86 systems that prefer GHES error reporting: + */ +static struct acpi_platform_list plat_list[] = { + {"HPE ", "Server ", 0, ACPI_SIG_FADT, all_versions}, + { } /* End */ +}; + +bool ghes_edac_preferred(void) +{ + int idx = -1; + + if (!ghes_present) + return false; + + if (IS_ENABLED(CONFIG_X86)) { + idx = acpi_match_platform_list(plat_list); + if (idx < 0 && !ghes_edac_force_load) + return false; + } + + return true; +} +EXPORT_SYMBOL_GPL(ghes_edac_preferred); + void ghes_register_report_chain(struct notifier_block *nb) { atomic_notifier_chain_register(&ghes_report_chain, nb); diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h index 5cbd38b6e4e1..7ce91c0ff3eb 100644 --- a/include/acpi/ghes.h +++ b/include/acpi/ghes.h @@ -80,6 +80,7 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev); void ghes_edac_unregister(struct ghes *ghes); +bool ghes_edac_preferred(void); #else static inline int ghes_edac_register(struct ghes *ghes, struct device *dev) { @@ -89,6 +90,7 @@ static inline int ghes_edac_register(struct ghes *ghes, struct device *dev) static inline void ghes_edac_unregister(struct ghes *ghes) { } +static bool ghes_edac_preferred(void) { return false; } #endif static inline int acpi_hest_get_version(struct acpi_hest_generic_data *gdata) -- 2.25.1