Skip to content

Commit 2148054

Browse files
author
Mauro Carvalho Chehab
committed
ghes: add the needed hooks for EDAC error report
In order to allow reporting errors via EDAC, add hooks for: 1) register an EDAC driver; 2) unregister an EDAC driver; 3) report errors via EDAC. As the EDAC driver will need to access the ghes structure, adds it as one of the parameters for ghes_do_proc. Acked-by: Huang Ying <ying.huang@intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
1 parent 40e0641 commit 2148054

2 files changed

Lines changed: 46 additions & 5 deletions

File tree

‎drivers/acpi/apei/ghes.c‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,8 @@ static void ghes_clear_estatus(struct ghes *ghes)
409409
ghes->flags &= ~GHES_TO_CLEAR;
410410
}
411411

412-
static void ghes_do_proc(const struct acpi_hest_generic_status *estatus)
412+
static void ghes_do_proc(struct ghes *ghes,
413+
const struct acpi_hest_generic_status *estatus)
413414
{
414415
int sev, sec_sev;
415416
struct acpi_hest_generic_data *gdata;
@@ -421,6 +422,8 @@ static void ghes_do_proc(const struct acpi_hest_generic_status *estatus)
421422
CPER_SEC_PLATFORM_MEM)) {
422423
struct cper_sec_mem_err *mem_err;
423424
mem_err = (struct cper_sec_mem_err *)(gdata+1);
425+
ghes_edac_report_mem_error(ghes, sev, mem_err);
426+
424427
#ifdef CONFIG_X86_MCE
425428
apei_mce_report_mem_error(sev == GHES_SEV_CORRECTED,
426429
mem_err);
@@ -639,7 +642,7 @@ static int ghes_proc(struct ghes *ghes)
639642
if (ghes_print_estatus(NULL, ghes->generic, ghes->estatus))
640643
ghes_estatus_cache_add(ghes->generic, ghes->estatus);
641644
}
642-
ghes_do_proc(ghes->estatus);
645+
ghes_do_proc(ghes, ghes->estatus);
643646
out:
644647
ghes_clear_estatus(ghes);
645648
return 0;
@@ -732,7 +735,7 @@ static void ghes_proc_in_irq(struct irq_work *irq_work)
732735
estatus = GHES_ESTATUS_FROM_NODE(estatus_node);
733736
len = apei_estatus_len(estatus);
734737
node_len = GHES_ESTATUS_NODE_LEN(len);
735-
ghes_do_proc(estatus);
738+
ghes_do_proc(estatus_node->ghes, estatus);
736739
if (!ghes_estatus_cached(estatus)) {
737740
generic = estatus_node->generic;
738741
if (ghes_print_estatus(NULL, generic, estatus))
@@ -821,6 +824,7 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs)
821824
estatus_node = (void *)gen_pool_alloc(ghes_estatus_pool,
822825
node_len);
823826
if (estatus_node) {
827+
estatus_node->ghes = ghes;
824828
estatus_node->generic = ghes->generic;
825829
estatus = GHES_ESTATUS_FROM_NODE(estatus_node);
826830
memcpy(estatus, ghes->estatus, len);
@@ -899,6 +903,11 @@ static int ghes_probe(struct platform_device *ghes_dev)
899903
ghes = NULL;
900904
goto err;
901905
}
906+
907+
rc = ghes_edac_register(ghes, &ghes_dev->dev);
908+
if (rc < 0)
909+
goto err;
910+
902911
switch (generic->notify.type) {
903912
case ACPI_HEST_NOTIFY_POLLED:
904913
ghes->timer.function = ghes_poll_func;
@@ -911,13 +920,13 @@ static int ghes_probe(struct platform_device *ghes_dev)
911920
if (acpi_gsi_to_irq(generic->notify.vector, &ghes->irq)) {
912921
pr_err(GHES_PFX "Failed to map GSI to IRQ for generic hardware error source: %d\n",
913922
generic->header.source_id);
914-
goto err;
923+
goto err_edac_unreg;
915924
}
916925
if (request_irq(ghes->irq, ghes_irq_func,
917926
0, "GHES IRQ", ghes)) {
918927
pr_err(GHES_PFX "Failed to register IRQ for generic hardware error source: %d\n",
919928
generic->header.source_id);
920-
goto err;
929+
goto err_edac_unreg;
921930
}
922931
break;
923932
case ACPI_HEST_NOTIFY_SCI:
@@ -943,6 +952,8 @@ static int ghes_probe(struct platform_device *ghes_dev)
943952
platform_set_drvdata(ghes_dev, ghes);
944953

945954
return 0;
955+
err_edac_unreg:
956+
ghes_edac_unregister(ghes);
946957
err:
947958
if (ghes) {
948959
ghes_fini(ghes);
@@ -995,6 +1006,9 @@ static int ghes_remove(struct platform_device *ghes_dev)
9951006
}
9961007

9971008
ghes_fini(ghes);
1009+
1010+
ghes_edac_unregister(ghes);
1011+
9981012
kfree(ghes);
9991013

10001014
platform_set_drvdata(ghes_dev, NULL);

‎include/acpi/ghes.h‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct ghes {
2727
struct ghes_estatus_node {
2828
struct llist_node llnode;
2929
struct acpi_hest_generic *generic;
30+
struct ghes *ghes;
3031
};
3132

3233
struct ghes_estatus_cache {
@@ -43,3 +44,29 @@ enum {
4344
GHES_SEV_RECOVERABLE = 0x2,
4445
GHES_SEV_PANIC = 0x3,
4546
};
47+
48+
/* From drivers/edac/ghes_edac.c */
49+
50+
#ifdef CONFIG_EDAC_GHES
51+
void ghes_edac_report_mem_error(struct ghes *ghes, int sev,
52+
struct cper_sec_mem_err *mem_err);
53+
54+
int ghes_edac_register(struct ghes *ghes, struct device *dev);
55+
56+
void ghes_edac_unregister(struct ghes *ghes);
57+
58+
#else
59+
static inline void ghes_edac_report_mem_error(struct ghes *ghes, int sev,
60+
struct cper_sec_mem_err *mem_err)
61+
{
62+
}
63+
64+
static inline int ghes_edac_register(struct ghes *ghes, struct device *dev)
65+
{
66+
return 0;
67+
}
68+
69+
static inline void ghes_edac_unregister(struct ghes *ghes)
70+
{
71+
}
72+
#endif

0 commit comments

Comments
 (0)