Skip to contentSkip to conversation

EDAC, ghes: Do not register instance if platform is not whitelisted

PATCH Borislav Petkov 1 participant 1 message Apr 27, 2018

Subsystems (4)
lore
Share & tools
lore

Borislav Petkov

author maintainer
#0 lore raw
Quoted 15 lines · Toshi
Quoted 14 lines · Borislav Petkov
Quoted 8 lines · Toshi

Umm..., I do not think this change is correct. This causes an error to ghes_probe(), which disables GHES itself. ghes and ghes_edac are separate modules. That is, ghes_edac works on top of ghes as an optional module.

I think the right fix is to simply remove the error message. This will make it consistent with the case of CONFIG_EDAC_GHES disabled. Please see include/acpi/ghes.h.

I guess. Although an even right-er fix would be to not call ghes_edac_report_mem_error() at all, if there's no ghes_edac module registered.

Quoted 5 lines
Quoted 1 line

That would need more dissecting though....

That's cleaner, but will lead to a module ordering issue... For now, I'd simply fix ghes_edac_report_mem_error() to handle the !pvt case as a normal case.

Well, the !pvt case is not a normal case. The only justification for removing the pr_err() because of the hack how ghes_edac is grafted onto ghes.c

Actually, what I'm thinking is the below along with taking Sughosh's patch here:

https://marc.info/?l=linux-edac&m=152473783708615

Also, ghes_edac_register() needs to return an error when it does not hit the whitelist - there's no other way to see it.

Which means, ghes.c can register ghes_edac as the last thing it does and the outcome of that registration should not have any influence on GHES itself because ghes_edac does only reporting.

---
 drivers/acpi/apei/ghes.c | 14 ++++++--------
 drivers/edac/ghes_edac.c |  6 ++----
 2 files changed, 8 insertions(+), 12 deletions(-)
drivers/acpi/apei/ghes.c +6 -8
index 1efefe919555..88103333ee1b 100644
@@ -1087,10 +1087,6 @@ static int ghes_probe(struct platform_device *ghes_dev)
 		goto err;
 	}
 
-	rc = ghes_edac_register(ghes, &ghes_dev->dev);
-	if (rc < 0)
-		goto err;
-
 	switch (generic->notify.type) {
 	case ACPI_HEST_NOTIFY_POLLED:
 		timer_setup(&ghes->timer, ghes_poll_func, TIMER_DEFERRABLE);
@@ -1102,14 +1098,14 @@ static int ghes_probe(struct platform_device *ghes_dev)
 		if (rc) {
 			pr_err(GHES_PFX "Failed to map GSI to IRQ for generic hardware error source: %d\n",
 			       generic->header.source_id);
-			goto err_edac_unreg;
+			goto err;
 		}
 		rc = request_irq(ghes->irq, ghes_irq_func, IRQF_SHARED,
 				 "GHES IRQ", ghes);
 		if (rc) {
 			pr_err(GHES_PFX "Failed to register IRQ for generic hardware error source: %d\n",
 			       generic->header.source_id);
-			goto err_edac_unreg;
+			goto err;
 		}
 		break;
 
@@ -1132,14 +1128,16 @@ static int ghes_probe(struct platform_device *ghes_dev)
 	default:
 		BUG();
 	}
+
 	platform_set_drvdata(ghes_dev, ghes);
 
+	ghes_edac_register(ghes, &ghes_dev->dev);
+
 	/* Handle any pending errors right away */
 	ghes_proc(ghes);
 
 	return 0;
-err_edac_unreg:
-	ghes_edac_unregister(ghes);
+
 err:
 	if (ghes) {
 		ghes_fini(ghes);
drivers/edac/ghes_edac.c +2 -4
index 68b6ee18bea6..7fdbfe871f5c 100644
@@ -183,10 +183,8 @@ void ghes_edac_report_mem_error(struct ghes *ghes, int sev,
 	char *p;
 	u8 grain_bits;
 
-	if (!pvt) {
-		pr_err("Internal error: Can't find EDAC structure\n");
+	if (!pvt)
 		return;
-	}
 
 	/*
 	 * We can do the locking below because GHES defers error processing
@@ -439,7 +437,7 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev)
 	/* Check if safe to enable on this system */
 	idx = acpi_match_platform_list(plat_list);
 	if (!force_load && idx < 0)
-		return 0;
+		return -ENODEV;
 
 	/*
 	 * We have only one logical memory controller to which all DIMMs belong.