[RESEND PATCH v3 4/9] EDAC/ghes: Move ghes_edac.force_load to setup parameter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <toshi.kani@xxxxxxx>
Signed-off-by: Jia He <justin.he@xxxxxxx>
---
 .../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: <bool>
+			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




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux