Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp2535655rwa; Mon, 22 Aug 2022 09:11:17 -0700 (PDT) X-Google-Smtp-Source: AA6agR54TtJhbNEvvSTIV9EGb6VjwhlLk6gnzaRGJMzghqHugqnKPtUoDtBsbpbylwREgo9t74LN X-Received: by 2002:a17:90b:4a0e:b0:1fb:5583:57a5 with SMTP id kk14-20020a17090b4a0e00b001fb558357a5mr1489588pjb.124.1661184677551; Mon, 22 Aug 2022 09:11:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661184677; cv=none; d=google.com; s=arc-20160816; b=T+YoTiRotl7ah0zJbU7XAqLIbM1JIrBW8yqQEDpIxWOONcnMjS1zDa7dNi11DlcEch qSTJy43gKgejGuR+VC2jlmIAnj6AGL5U3+HTVcYH3E9wBJ4Yfxhv/yyaxiiU4CuEPy7f Zs46Qw42OxSoQDzLbjDDT3IsIvYG39isEhj9uWFlKwHKG7Qil6PNL5eh2dkGXp7Oat6K Weh6dLEWzAhOBbMRDsqP8lgmNM3meFoTuDSCkACceVMtTGDlflXMFOeJfueHZ32Tv/wT 1I06N/pjfRn36CSz1bcdLUYiHi2IISDQoSpNkpVkCMa32RHpTWJT/PVA6/+pWwGi04gE aqjg== 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=Oa6SSZPCt2YRLYqpqRIYXU1RRO3EMDNMn/xed/zL1Zs=; b=ZaD56+G+1xxYl26EzdmoUb33FQEJo/OTTAEGLo3d7ISch3HyMUHbwZqNa6mSV7KXJi S5qbRmGxpipQzXHPoDmE4jAsJ5F9gvAgjDC2KKdPE1SQYXIRJwr3B2zVLAg+//HNwZV2 7d1AqOTUFOF9WR0NUvUt6HYepVTZHqpdqoX6DQoXfu79B+VBqmbl9kBHPg7PBpbYtBus /wmu5LNeaSYsj89P5Y+X1adQcP+bwEpQGqqQykGfqFyHRQRoJMjjvnteKNiNll0KS41o ooBTNOIqhYfpSxWUJJ8X0ayTIdsdbeIVSK6t7LKHeH+1sVWvXMMkbDtsppnH5zV4UVE6 /lXg== 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 v202-20020a6361d3000000b0041bdae7558esi12926014pgb.653.2022.08.22.09.11.06; Mon, 22 Aug 2022 09:11:17 -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 S236832AbiHVPmf (ORCPT + 99 others); Mon, 22 Aug 2022 11:42:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236750AbiHVPls (ORCPT ); Mon, 22 Aug 2022 11:41:48 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2CA971EEF3; Mon, 22 Aug 2022 08:41:45 -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 1E823ED1; Mon, 22 Aug 2022 08:41:48 -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 6049E3F70D; Mon, 22 Aug 2022 08:41:36 -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 , Jonathan Corbet , 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, "Paul E. McKenney" , Andrew Morton , Neeraj Upadhyay , Randy Dunlap , Damien Le Moal , Muchun Song , linux-doc@vger.kernel.org, Jia He Subject: [RESEND PATCH v3 4/9] EDAC/ghes: Move ghes_edac.force_load to setup parameter Date: Mon, 22 Aug 2022 15:40:43 +0000 Message-Id: <20220822154048.188253-5-justin.he@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220822154048.188253-1-justin.he@arm.com> References: <20220822154048.188253-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 ghes_edac_init() is too late to set this module flag ghes_edac.force_load. Also, other edac drivers should not be able to control this flag. Move this flag to setup parameter in ghes. Suggested-by: Toshi Kani Signed-off-by: Jia He --- .../admin-guide/kernel-parameters.txt | 5 +++ drivers/acpi/apei/ghes.c | 24 +++++++++++- drivers/edac/ghes_edac.c | 38 +++++++------------ include/acpi/ghes.h | 7 +++- 4 files changed, 46 insertions(+), 28 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index d7f30902fda0..a5f0ee0d7727 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1593,6 +1593,11 @@ When zero, profiling data is discarded and associated debugfs files are removed at module unload time. + ghes_edac_force= [X86] Skip the platform check and forcibly load the + ghes_edac modules. + Format: + default: false (0) + goldfish [X86] Enable the goldfish android emulator platform. Don't use this when you are not running on the android emulator diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 9c52183e3ad9..e17e0ee8f842 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -94,6 +94,26 @@ #define FIX_APEI_GHES_SDEI_CRITICAL __end_of_fixed_addresses #endif +/* + * "ghes_edac_force=1" forcibly loads ghes_edac and skips the platform + * check. + */ +bool __read_mostly ghes_edac_force; +EXPORT_SYMBOL(ghes_edac_force); + +static int __init setup_ghes_edac_load(char *str) +{ + if (str) + if (!strcmp("true", str) || !strcmp("1", str)) + ghes_edac_force = true; + + if (!IS_ENABLED(CONFIG_X86)) + ghes_edac_force = true; + + return 1; +} +__setup("ghes_edac_force=", setup_ghes_edac_load); + static ATOMIC_NOTIFIER_HEAD(ghes_report_chain); static inline bool is_hest_type_generic_v2(struct ghes *ghes) @@ -1517,13 +1537,13 @@ static struct acpi_platform_list plat_list[] = { { } /* End */ }; -struct list_head *ghes_get_devices(bool force) +struct list_head *ghes_get_devices(void) { int idx = -1; if (IS_ENABLED(CONFIG_X86)) { idx = acpi_match_platform_list(plat_list); - if (idx < 0 && !force) + if (idx < 0 && !ghes_edac_force) return NULL; } diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c index bb3ea42ba70b..6a2b54cc7240 100644 --- a/drivers/edac/ghes_edac.c +++ b/drivers/edac/ghes_edac.c @@ -54,10 +54,6 @@ static DEFINE_MUTEX(ghes_reg_mutex); */ static DEFINE_SPINLOCK(ghes_lock); -/* "ghes_edac.force_load=1" skips the platform check */ -static bool __read_mostly force_load; -module_param(force_load, bool, 0); - static bool system_scanned; static struct list_head *ghes_devs; @@ -437,23 +433,12 @@ static int ghes_edac_register(struct device *dev) mci->ctl_name = "ghes_edac"; mci->dev_name = "ghes"; - if (fake) { - pr_info("This system has a very crappy BIOS: It doesn't even list the DIMMS.\n"); - pr_info("Its SMBIOS info is wrong. It is doubtful that the error report would\n"); - pr_info("work on such system. Use this driver with caution\n"); - } else if (force_load) { - pr_info("This EDAC driver relies on BIOS to enumerate memory and get error reports.\n"); - pr_info("Unfortunately, not all BIOSes reflect the memory layout correctly.\n"); - pr_info("So, the end result of using this driver varies from vendor to vendor.\n"); - pr_info("If you find incorrect reports, please contact your hardware vendor\n"); - pr_info("to correct its BIOS.\n"); - pr_info("This system has %d DIMM sockets.\n", ghes_hw.num_dimms); - } - if (!fake) { struct dimm_info *src, *dst; int i = 0; + pr_info("This system has %d DIMM sockets.\n", ghes_hw.num_dimms); + mci_for_each_dimm(mci, dst) { src = &ghes_hw.dimms[i]; @@ -478,6 +463,17 @@ static int ghes_edac_register(struct device *dev) } else { struct dimm_info *dimm = edac_get_dimm(mci, 0, 0, 0); + pr_info("This system has a very crappy BIOS: It doesn't even list the DIMMS.\n"); + pr_info("Its SMBIOS info is wrong. It is doubtful that the error report would\n"); + pr_info("work on such system. Use this driver with caution\n"); + + if (ghes_edac_force) { + pr_info("This EDAC driver relies on BIOS to enumerate memory and get\n"); + pr_info("error reports. Unfortunately, not all BIOSes reflect the\n"); + pr_info("memory layout correctly. If you find incorrect reports, please\n"); + pr_info("contact your hardware vendor for its in correct BIOS.\n"); + } + dimm->nr_pages = 1; dimm->grain = 128; dimm->mtype = MEM_UNKNOWN; @@ -518,9 +514,6 @@ static void ghes_edac_unregister(struct ghes *ghes) struct mem_ctl_info *mci; unsigned long flags; - if (!force_load) - return; - mutex_lock(&ghes_reg_mutex); system_scanned = false; @@ -554,10 +547,7 @@ static int __init ghes_edac_init(void) { struct ghes *g, *g_tmp; - if (!IS_ENABLED(CONFIG_X86)) - force_load = true; - - ghes_devs = ghes_get_devices(force_load); + ghes_devs = ghes_get_devices(); if (!ghes_devs) return -ENODEV; diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h index 150c0b9500d6..e29327ee0b83 100644 --- a/include/acpi/ghes.h +++ b/include/acpi/ghes.h @@ -71,9 +71,12 @@ int ghes_register_vendor_record_notifier(struct notifier_block *nb); * @nb: pointer to the notifier_block structure of the vendor record handler. */ void ghes_unregister_vendor_record_notifier(struct notifier_block *nb); -struct list_head *ghes_get_devices(bool force); + +struct list_head *ghes_get_devices(void); +extern bool ghes_edac_force; #else -static inline struct list_head *ghes_get_devices(bool force) { return NULL; } +static inline struct list_head *ghes_get_devices(void) { return NULL; } +static bool ghes_edac_force; #endif int ghes_estatus_pool_init(int num_ghes); -- 2.25.1