OSDN Git Service

Merge tag 'edac_updates_for_v5.10' of git://git.kernel.org/pub/scm/linux/kernel/git...
[uclinux-h8/linux.git] / drivers / edac / ghes_edac.c
index 2c93837..dbbefd2 100644 (file)
@@ -55,6 +55,8 @@ static DEFINE_SPINLOCK(ghes_lock);
 static bool __read_mostly force_load;
 module_param(force_load, bool, 0);
 
+static bool system_scanned;
+
 /* Memory Device - Type 17 of SMBIOS spec */
 struct memdev_dmi_entry {
        u8 type;
@@ -225,14 +227,12 @@ static void enumerate_dimms(const struct dmi_header *dh, void *arg)
 
 static void ghes_scan_system(void)
 {
-       static bool scanned;
-
-       if (scanned)
+       if (system_scanned)
                return;
 
        dmi_walk(enumerate_dimms, &ghes_hw);
 
-       scanned = true;
+       system_scanned = true;
 }
 
 void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
@@ -508,6 +508,7 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev)
                if (!force_load && idx < 0)
                        return -ENODEV;
        } else {
+               force_load = true;
                idx = 0;
        }
 
@@ -629,8 +630,14 @@ 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;
+       memset(&ghes_hw, 0, sizeof(struct ghes_hw_desc));
+
        if (!refcount_dec_and_test(&ghes_refcount))
                goto unlock;