EDAC: Unify the mc_event tracepoint call
authorRobert Richter <rrichter@marvell.com>
Wed, 6 Nov 2019 09:33:27 +0000 (09:33 +0000)
committerBorislav Petkov <bp@suse.de>
Sun, 10 Nov 2019 11:40:14 +0000 (12:40 +0100)
The code in ghes_edac.c and edac_mc.c for grain_bits calculation and
calling trace_mc_event() is now the same. Move it to a single location
in edac_raw_mc_handle_error().

The only difference is the missing IS_ENABLED(CONFIG_RAS) switch, but
this is needed for ghes too.

Signed-off-by: Robert Richter <rrichter@marvell.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Cc: "linux-edac@vger.kernel.org" <linux-edac@vger.kernel.org>
Cc: James Morse <james.morse@arm.com>
Cc: Tony Luck <tony.luck@intel.com>
Link: https://lkml.kernel.org/r/20191106093239.25517-13-rrichter@marvell.com
drivers/edac/edac_mc.c
drivers/edac/ghes_edac.c

index 614841035bfeb38e497e682145f0ca48f3dbed3f..7243b88f81d889cd64b63d3ffc7991d05ab5e1a2 100644 (file)
@@ -1058,6 +1058,21 @@ void edac_raw_mc_handle_error(const enum hw_event_mc_err_type type,
 {
        char detail[80];
        int pos[EDAC_MAX_LAYERS] = { e->top_layer, e->mid_layer, e->low_layer };
+       u8 grain_bits;
+
+       /* Sanity-check driver-supplied grain value. */
+       if (WARN_ON_ONCE(!e->grain))
+               e->grain = 1;
+
+       grain_bits = fls_long(e->grain - 1);
+
+       /* Report the error via the trace interface */
+       if (IS_ENABLED(CONFIG_RAS))
+               trace_mc_event(type, e->msg, e->label, e->error_count,
+                              mci->mc_idx, e->top_layer, e->mid_layer,
+                              e->low_layer,
+                              (e->page_frame_number << PAGE_SHIFT) | e->offset_in_page,
+                              grain_bits, e->syndrome, e->other_detail);
 
        /* Memory type dependent details about the error */
        if (type == HW_EVENT_ERR_CORRECTED) {
@@ -1098,7 +1113,6 @@ void edac_mc_handle_error(const enum hw_event_mc_err_type type,
        int row = -1, chan = -1;
        int pos[EDAC_MAX_LAYERS] = { top_layer, mid_layer, low_layer };
        int i, n_labels = 0;
-       u8 grain_bits;
        struct edac_raw_error_desc *e = &mci->error_desc;
 
        edac_dbg(3, "MC%d\n", mci->mc_idx);
@@ -1236,20 +1250,6 @@ void edac_mc_handle_error(const enum hw_event_mc_err_type type,
        if (p > e->location)
                *(p - 1) = '\0';
 
-       /* Sanity-check driver-supplied grain value. */
-       if (WARN_ON_ONCE(!e->grain))
-               e->grain = 1;
-
-       grain_bits = fls_long(e->grain - 1);
-
-       /* Report the error via the trace interface */
-       if (IS_ENABLED(CONFIG_RAS))
-               trace_mc_event(type, e->msg, e->label, e->error_count,
-                              mci->mc_idx, e->top_layer, e->mid_layer,
-                              e->low_layer,
-                              (e->page_frame_number << PAGE_SHIFT) | e->offset_in_page,
-                              grain_bits, e->syndrome, e->other_detail);
-
        edac_raw_mc_handle_error(type, mci, e);
 }
 EXPORT_SYMBOL_GPL(edac_mc_handle_error);
index 1fd782c73a35658735829145b6ed6a4c09ebe6a0..47f4e7f90ef0a112bef602eb417c559000259eb4 100644 (file)
@@ -207,7 +207,6 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
        struct ghes_edac_pvt *pvt;
        unsigned long flags;
        char *p;
-       u8 grain_bits;
 
        /*
         * We can do the locking below because GHES defers error processing
@@ -443,18 +442,6 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
        if (p > pvt->other_detail)
                *(p - 1) = '\0';
 
-       /* Sanity-check driver-supplied grain value. */
-       if (WARN_ON_ONCE(!e->grain))
-               e->grain = 1;
-
-       grain_bits = fls_long(e->grain - 1);
-
-       /* Generate the trace event */
-       trace_mc_event(type, e->msg, e->label, e->error_count,
-                      mci->mc_idx, e->top_layer, e->mid_layer, e->low_layer,
-                      (e->page_frame_number << PAGE_SHIFT) | e->offset_in_page,
-                      grain_bits, e->syndrome, e->other_detail);
-
        edac_raw_mc_handle_error(type, mci, e);
 
 unlock: