diff mbox series

[18/19] EDAC, ghes: Unify trace_mc_event() code with edac_mc driver

Message ID 20191010202418.25098-19-rrichter@marvell.com
State New
Headers show
Series EDAC: Rework edac_mc and ghes drivers | expand

Commit Message

Robert Richter Oct. 10, 2019, 8:25 p.m. UTC
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>

---
 drivers/edac/edac_mc.c   | 30 +++++++++++++++---------------
 drivers/edac/ghes_edac.c | 13 -------------
 2 files changed, 15 insertions(+), 28 deletions(-)

-- 
2.20.1

Comments

Mauro Carvalho Chehab Oct. 11, 2019, 11:23 a.m. UTC | #1
Em Thu, 10 Oct 2019 20:25:40 +0000
Robert Richter <rrichter@marvell.com> escreveu:

> 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>


Reviewed-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


> ---

>  drivers/edac/edac_mc.c   | 30 +++++++++++++++---------------

>  drivers/edac/ghes_edac.c | 13 -------------

>  2 files changed, 15 insertions(+), 28 deletions(-)

> 

> diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c

> index 3779204c0e21..e6c6e40dc760 100644

> --- a/drivers/edac/edac_mc.c

> +++ b/drivers/edac/edac_mc.c

> @@ -1070,6 +1070,21 @@ void edac_raw_mc_handle_error(struct edac_raw_error_desc *e,

>  {

>  	struct mem_ctl_info *mci = error_desc_to_mci(e);

>  	char detail[80];

> +	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(e->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 (e->type == HW_EVENT_ERR_CORRECTED) {

> @@ -1110,7 +1125,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;

>  	bool any_memory = true;

>  

> @@ -1242,20 +1256,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);

> -

>  	dimm = edac_get_dimm(mci, top_layer, mid_layer, low_layer);

>  

>  	edac_raw_mc_handle_error(e, dimm);

> diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c

> index 8d9d3c4dbebb..17d5b22fe000 100644

> --- a/drivers/edac/ghes_edac.c

> +++ b/drivers/edac/ghes_edac.c

> @@ -198,7 +198,6 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)

>  	struct ghes_edac_pvt *pvt = ghes_pvt;

>  	unsigned long flags;

>  	char *p;

> -	u8 grain_bits;

>  

>  	if (!pvt)

>  		return;

> @@ -430,18 +429,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(e->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);

> -

>  	dimm = edac_get_dimm_by_index(mci, e->top_layer);

>  

>  	edac_raw_mc_handle_error(e, dimm);




Thanks,
Mauro
diff mbox series

Patch

diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 3779204c0e21..e6c6e40dc760 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -1070,6 +1070,21 @@  void edac_raw_mc_handle_error(struct edac_raw_error_desc *e,
 {
 	struct mem_ctl_info *mci = error_desc_to_mci(e);
 	char detail[80];
+	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(e->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 (e->type == HW_EVENT_ERR_CORRECTED) {
@@ -1110,7 +1125,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;
 	bool any_memory = true;
 
@@ -1242,20 +1256,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);
-
 	dimm = edac_get_dimm(mci, top_layer, mid_layer, low_layer);
 
 	edac_raw_mc_handle_error(e, dimm);
diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c
index 8d9d3c4dbebb..17d5b22fe000 100644
--- a/drivers/edac/ghes_edac.c
+++ b/drivers/edac/ghes_edac.c
@@ -198,7 +198,6 @@  void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
 	struct ghes_edac_pvt *pvt = ghes_pvt;
 	unsigned long flags;
 	char *p;
-	u8 grain_bits;
 
 	if (!pvt)
 		return;
@@ -430,18 +429,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(e->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);
-
 	dimm = edac_get_dimm_by_index(mci, e->top_layer);
 
 	edac_raw_mc_handle_error(e, dimm);