Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3265078rwb; Mon, 5 Sep 2022 08:50:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Zx2skDCngAq8Z2Vbo8mPHQRQDGlsYLokkDq69mGeE6l74ucuxKdRs+ZZaixKjafFC+5dT X-Received: by 2002:a17:906:9bd9:b0:73d:da74:120c with SMTP id de25-20020a1709069bd900b0073dda74120cmr33355371ejc.412.1662393005219; Mon, 05 Sep 2022 08:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662393005; cv=none; d=google.com; s=arc-20160816; b=ZOyaQm2dUnWwWxji92D5zOxbyqxezWZNGJxLl4eUn0QtqqMRb4kPjF5lTeE+qQ1/tx 8jcLrxgV5GYgvZrkNGOctiKhU9PFDXsoxVgvADPtAmQbahhASqIvjA1/UFIRovVS2o9e 6PF+GuhuZ2aWT7+SXUdOHKtNiPZjprr38uIw+YjMHx2B2gLk28ZLS4pxeQ6qKwPTzM+A BwHbWelxMhnOgzFEvQjoy8pO2hzpS2vYQ56xJJot0jyJ8GGMIpe1vAlgpVGVfgNQgyKu o/q9ABQL2UMQMO9QC5jw1u4K12TNbTYb7s7RFoI7YY1gjva2rXDJcnfZpk4K0FfRwGhD OWlw== 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=R7vO2mumsAKZbS11AcF+Pgn2FqpobnQQDkRRHUBNS/I=; b=WpwVKy5UEMdEWLQFkPiYpISsiUY5ygfSKGBQnayhzc7nAUOkMlxbadE3ijuz5u8ISI PZQPk42n6gwH0CtEXhhlxvA2vrnMvqamXQMY5G5+zekjREvWuaxsqmg2qtfQPWynF5Iz kKJLFvjxGMtHzO6KencUdCqSl1mwNNjwENQSSJ7i6DP2ggueGwhVgJq/ttjameIApJLh g4/iHMRXhbWWsFdiLcFIzsY4dBN6qpRwKh4dt6tflwf6B9KEYzg9weWwSbZ056ZAQ+X1 7qLE96NlY50UHLRuENcD/QLBzJfRT31XxFNaHi8+Jk8I3sx7XQee+r6vKXiXG6WFIQOl jXAg== 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 js22-20020a17090797d600b0072f38ecf74asi9170929ejc.794.2022.09.05.08.49.39; Mon, 05 Sep 2022 08:50:05 -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 S238955AbiIEP03 (ORCPT + 99 others); Mon, 5 Sep 2022 11:26:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238854AbiIEPZd (ORCPT ); Mon, 5 Sep 2022 11:25:33 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E2F28248CB; Mon, 5 Sep 2022 08:25:31 -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 DABF4ED1; Mon, 5 Sep 2022 08:25:37 -0700 (PDT) Received: from entos-ampere-02.shanghai.arm.com (unknown [10.169.212.212]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 30A1C3F534; Mon, 5 Sep 2022 08:25:24 -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 v5 4/8] ghes: Introduce a helper ghes_edac_preferred() Date: Mon, 5 Sep 2022 15:24:35 +0000 Message-Id: <20220905152439.77770-5-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220905152439.77770-1-justin.he@arm.com> References: <20220905152439.77770-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 helper ghes_edac_preferred(), which returns true when ACPI GHES table is present and the platform-check passes on the system. ghes_present is set once in ghes_probe() since ACPI GHES table is static. Suggested-by: Toshi Kani Signed-off-by: Jia He Reviewed-by: Toshi Kani --- 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 b0a6445c6da2..0c2dbfffe22a 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -117,6 +117,8 @@ bool ghes_edac_force_enable; EXPORT_SYMBOL(ghes_edac_force_enable); module_param_named(edac_force_enable, ghes_edac_force_enable, bool, 0); +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); @@ -1508,6 +1512,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_enable) + 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