Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp5357641rwn; Mon, 12 Sep 2022 07:58:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR6SiJphbyt1SFQXwhKyQs1lg4dgHMfTf+vfepsNx/s/G6c8uGQWotC24Hcq9kPa8K1qDU3j X-Received: by 2002:a17:907:c05:b0:73d:6e0a:8d22 with SMTP id ga5-20020a1709070c0500b0073d6e0a8d22mr18946073ejc.646.1662994732541; Mon, 12 Sep 2022 07:58:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662994732; cv=none; d=google.com; s=arc-20160816; b=jLzDmVQ4spu5JcYQ2G3jANN9L6WcymE0VJl7WiB2oNevuTbdJclp2eI39GwE37NHnX cJUyz//GZSHj+BMiipBeZkHsyS/urEzKZzjW4Gd/R4L8/nTclaJQLOTg5hdZqxaIMvWR oaGESBpqUYZ3IjB6oIWNyFDibyLXT6X5Gi8QJ7UsWo6O3n2vJUliPemDC2NDW+QPmw4/ DnO5SeabWGFHXr/cXP/25pT9evl5u83LpQ9zBoCaXS9PqI775dOKnkHghAzuSCnGxe5i BkqtTIGj/4ETreA79IGpUnDMJU5S8+ja9C8zWz3z2rgHhsj3WAzj4Yp5RRIRpOt9yVa/ MvDg== 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=uYjnaMhbSuvZXCIS6rT8q/8oxsyyonynqxue4r39PtVQaOvOHNtrHCcFwV6QXYnW5q xwTj/DuXGBk4fIovwnboW6lM6gchExjCOvHyzMQjqmYVkz151B4LBH2OGoLzw/IkIU9g iLtv4H9u1crf1RyydUqDjrRGKLVEe7V+pWhgofXCLbcAh3+SGfLRJ/yD6orn55Z7MZWV WNbjP9x2s1ogdbbfR3B2ACyrnz25aPCmlgNwYk5l6q+cH9m/C2AhA0EL+O952tS+o3j3 ftqf3bcIIWlJWK5wg44pwPe7lAb053ZlIk9GHnhmhMA65baPcWnFhCu16R78+W4Ah6RY x59w== 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 cx18-20020a05640222b200b0044e9d23ef0fsi5941919edb.170.2022.09.12.07.58.26; Mon, 12 Sep 2022 07:58:52 -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 S229790AbiILOmL (ORCPT + 99 others); Mon, 12 Sep 2022 10:42:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230262AbiILOlr (ORCPT ); Mon, 12 Sep 2022 10:41:47 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1D15737F93; Mon, 12 Sep 2022 07:41:36 -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 59064113E; Mon, 12 Sep 2022 07:41:42 -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 85B603F73D; Mon, 12 Sep 2022 07:41:29 -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 v6 4/8] ghes: Introduce a helper ghes_edac_preferred() Date: Mon, 12 Sep 2022 14:40:01 +0000 Message-Id: <20220912144005.212624-5-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220912144005.212624-1-justin.he@arm.com> References: <20220912144005.212624-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