Re: [PATCH] EDAC: expose per-dimm error counts in sysfs

2016-10-28 Thread Aaron Miller
Whoops, I meant only the 0th slot in each channel.

On 10/27/16, 2:23 PM, "Aaron Miller"  wrote:

If your system is like the one I’m testing on, only the channel 0 DIMM 
slots are populated, and you injected an error for an unpopulated slot, for 
which no dimmX directory gets created.

In edac_mc_sysfs.c:

for (i = 0; i < mci->tot_dimms; i++) {
struct dimm_info *dimm = mci->dimms[i];
/* Only expose populated DIMMs */
if (!dimm->nr_pages)
continue;


I can repro what you saw here: 

$ cd /sys/devices/system/edac/mc/mc0
$ grep . dimm*/*location
dimm0/dimm_location:channel 0 slot 0
dimm3/dimm_location:channel 1 slot 0
dimm6/dimm_location:channel 2 slot 0
dimm9/dimm_location:channel 3 slot 0

$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject_channel
$ echo 2 > /sys/kernel/debug/edac/mc0/fake_inject_slot
$ echo 3 > /sys/kernel/debug/edac/mc0/fake_inject_count
$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject
$ cat ce_count
3

$ grep . dimm*/*ce_count
dimm0/dimm_ce_count:0
dimm3/dimm_ce_count:0
dimm6/dimm_ce_count:0
dimm9/dimm_ce_count:0


And I get what I expect for a populated slot:

$ echo 0 > /sys/kernel/debug/edac/mc0/fake_inject_slot
$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject
$ cat ce_count
6

$ grep . dimm*/*ce_count
dimm0/dimm_ce_count:0
dimm3/dimm_ce_count:3
dimm6/dimm_ce_count:0
dimm9/dimm_ce_count:0



On 10/27/16, 11:07 AM, "Borislav Petkov"  wrote:

On Tue, Oct 25, 2016 at 04:25:51PM -0700, Aaron Miller wrote:

<--- This patch needs a commit message.

Especially as to *why* we need this.

> Signed-off-by: Aaron Miller 
> ---
>  drivers/edac/edac_mc_sysfs.c | 38 
++
>  1 file changed, 38 insertions(+)

Regardless, something's still not right yet:

$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject_channel
$ echo 2 > /sys/kernel/debug/edac/mc0/fake_inject_slot
$ echo 3 > /sys/kernel/debug/edac/mc0/fake_inject_count
   ^

$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject

$ grep . /sys/devices/system/edac/mc/mc0/*count
/sys/devices/system/edac/mc/mc0/ce_count:3
 ^

/sys/devices/system/edac/mc/mc0/ce_noinfo_count:0
/sys/devices/system/edac/mc/mc0/ue_count:0
/sys/devices/system/edac/mc/mc0/ue_noinfo_count:0

$ grep -r . /sys/devices/system/edac/mc/mc0/dimm*/* 2>/dev/null | grep 
ce_count
/sys/devices/system/edac/mc/mc0/dimm0/dimm_ce_count:0
/sys/devices/system/edac/mc/mc0/dimm3/dimm_ce_count:0
/sys/devices/system/edac/mc/mc0/dimm6/dimm_ce_count:0
/sys/devices/system/edac/mc/mc0/dimm9/dimm_ce_count:0
^

There should be 3 somewhere in the DIMM counters...

-- 
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.






Re: [PATCH] EDAC: expose per-dimm error counts in sysfs

2016-10-28 Thread Aaron Miller
Whoops, I meant only the 0th slot in each channel.

On 10/27/16, 2:23 PM, "Aaron Miller"  wrote:

If your system is like the one I’m testing on, only the channel 0 DIMM 
slots are populated, and you injected an error for an unpopulated slot, for 
which no dimmX directory gets created.

In edac_mc_sysfs.c:

for (i = 0; i < mci->tot_dimms; i++) {
struct dimm_info *dimm = mci->dimms[i];
/* Only expose populated DIMMs */
if (!dimm->nr_pages)
continue;


I can repro what you saw here: 

$ cd /sys/devices/system/edac/mc/mc0
$ grep . dimm*/*location
dimm0/dimm_location:channel 0 slot 0
dimm3/dimm_location:channel 1 slot 0
dimm6/dimm_location:channel 2 slot 0
dimm9/dimm_location:channel 3 slot 0

$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject_channel
$ echo 2 > /sys/kernel/debug/edac/mc0/fake_inject_slot
$ echo 3 > /sys/kernel/debug/edac/mc0/fake_inject_count
$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject
$ cat ce_count
3

$ grep . dimm*/*ce_count
dimm0/dimm_ce_count:0
dimm3/dimm_ce_count:0
dimm6/dimm_ce_count:0
dimm9/dimm_ce_count:0


And I get what I expect for a populated slot:

$ echo 0 > /sys/kernel/debug/edac/mc0/fake_inject_slot
$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject
$ cat ce_count
6

$ grep . dimm*/*ce_count
dimm0/dimm_ce_count:0
dimm3/dimm_ce_count:3
dimm6/dimm_ce_count:0
dimm9/dimm_ce_count:0



On 10/27/16, 11:07 AM, "Borislav Petkov"  wrote:

On Tue, Oct 25, 2016 at 04:25:51PM -0700, Aaron Miller wrote:

<--- This patch needs a commit message.

Especially as to *why* we need this.

> Signed-off-by: Aaron Miller 
> ---
>  drivers/edac/edac_mc_sysfs.c | 38 
++
>  1 file changed, 38 insertions(+)

Regardless, something's still not right yet:

$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject_channel
$ echo 2 > /sys/kernel/debug/edac/mc0/fake_inject_slot
$ echo 3 > /sys/kernel/debug/edac/mc0/fake_inject_count
   ^

$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject

$ grep . /sys/devices/system/edac/mc/mc0/*count
/sys/devices/system/edac/mc/mc0/ce_count:3
 ^

/sys/devices/system/edac/mc/mc0/ce_noinfo_count:0
/sys/devices/system/edac/mc/mc0/ue_count:0
/sys/devices/system/edac/mc/mc0/ue_noinfo_count:0

$ grep -r . /sys/devices/system/edac/mc/mc0/dimm*/* 2>/dev/null | grep 
ce_count
/sys/devices/system/edac/mc/mc0/dimm0/dimm_ce_count:0
/sys/devices/system/edac/mc/mc0/dimm3/dimm_ce_count:0
/sys/devices/system/edac/mc/mc0/dimm6/dimm_ce_count:0
/sys/devices/system/edac/mc/mc0/dimm9/dimm_ce_count:0
^

There should be 3 somewhere in the DIMM counters...

-- 
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.






Re: [PATCH] EDAC: expose per-dimm error counts in sysfs

2016-10-27 Thread Aaron Miller
If your system is like the one I’m testing on, only the channel 0 DIMM slots 
are populated, and you injected an error for an unpopulated slot, for which no 
dimmX directory gets created.

In edac_mc_sysfs.c:

for (i = 0; i < mci->tot_dimms; i++) {
struct dimm_info *dimm = mci->dimms[i];
/* Only expose populated DIMMs */
if (!dimm->nr_pages)
continue;


I can repro what you saw here: 

$ cd /sys/devices/system/edac/mc/mc0
$ grep . dimm*/*location
dimm0/dimm_location:channel 0 slot 0
dimm3/dimm_location:channel 1 slot 0
dimm6/dimm_location:channel 2 slot 0
dimm9/dimm_location:channel 3 slot 0

$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject_channel
$ echo 2 > /sys/kernel/debug/edac/mc0/fake_inject_slot
$ echo 3 > /sys/kernel/debug/edac/mc0/fake_inject_count
$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject
$ cat ce_count
3

$ grep . dimm*/*ce_count
dimm0/dimm_ce_count:0
dimm3/dimm_ce_count:0
dimm6/dimm_ce_count:0
dimm9/dimm_ce_count:0


And I get what I expect for a populated slot:

$ echo 0 > /sys/kernel/debug/edac/mc0/fake_inject_slot
$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject
$ cat ce_count
6

$ grep . dimm*/*ce_count
dimm0/dimm_ce_count:0
dimm3/dimm_ce_count:3
dimm6/dimm_ce_count:0
dimm9/dimm_ce_count:0



On 10/27/16, 11:07 AM, "Borislav Petkov"  wrote:

On Tue, Oct 25, 2016 at 04:25:51PM -0700, Aaron Miller wrote:

<--- This patch needs a commit message.

Especially as to *why* we need this.

> Signed-off-by: Aaron Miller 
> ---
>  drivers/edac/edac_mc_sysfs.c | 38 ++
>  1 file changed, 38 insertions(+)

Regardless, something's still not right yet:

$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject_channel
$ echo 2 > /sys/kernel/debug/edac/mc0/fake_inject_slot
$ echo 3 > /sys/kernel/debug/edac/mc0/fake_inject_count
   ^

$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject

$ grep . /sys/devices/system/edac/mc/mc0/*count
/sys/devices/system/edac/mc/mc0/ce_count:3
 ^

/sys/devices/system/edac/mc/mc0/ce_noinfo_count:0
/sys/devices/system/edac/mc/mc0/ue_count:0
/sys/devices/system/edac/mc/mc0/ue_noinfo_count:0

$ grep -r . /sys/devices/system/edac/mc/mc0/dimm*/* 2>/dev/null | grep 
ce_count
/sys/devices/system/edac/mc/mc0/dimm0/dimm_ce_count:0
/sys/devices/system/edac/mc/mc0/dimm3/dimm_ce_count:0
/sys/devices/system/edac/mc/mc0/dimm6/dimm_ce_count:0
/sys/devices/system/edac/mc/mc0/dimm9/dimm_ce_count:0
^

There should be 3 somewhere in the DIMM counters...

-- 
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.




Re: [PATCH] EDAC: expose per-dimm error counts in sysfs

2016-10-27 Thread Aaron Miller
If your system is like the one I’m testing on, only the channel 0 DIMM slots 
are populated, and you injected an error for an unpopulated slot, for which no 
dimmX directory gets created.

In edac_mc_sysfs.c:

for (i = 0; i < mci->tot_dimms; i++) {
struct dimm_info *dimm = mci->dimms[i];
/* Only expose populated DIMMs */
if (!dimm->nr_pages)
continue;


I can repro what you saw here: 

$ cd /sys/devices/system/edac/mc/mc0
$ grep . dimm*/*location
dimm0/dimm_location:channel 0 slot 0
dimm3/dimm_location:channel 1 slot 0
dimm6/dimm_location:channel 2 slot 0
dimm9/dimm_location:channel 3 slot 0

$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject_channel
$ echo 2 > /sys/kernel/debug/edac/mc0/fake_inject_slot
$ echo 3 > /sys/kernel/debug/edac/mc0/fake_inject_count
$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject
$ cat ce_count
3

$ grep . dimm*/*ce_count
dimm0/dimm_ce_count:0
dimm3/dimm_ce_count:0
dimm6/dimm_ce_count:0
dimm9/dimm_ce_count:0


And I get what I expect for a populated slot:

$ echo 0 > /sys/kernel/debug/edac/mc0/fake_inject_slot
$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject
$ cat ce_count
6

$ grep . dimm*/*ce_count
dimm0/dimm_ce_count:0
dimm3/dimm_ce_count:3
dimm6/dimm_ce_count:0
dimm9/dimm_ce_count:0



On 10/27/16, 11:07 AM, "Borislav Petkov"  wrote:

On Tue, Oct 25, 2016 at 04:25:51PM -0700, Aaron Miller wrote:

<--- This patch needs a commit message.

Especially as to *why* we need this.

> Signed-off-by: Aaron Miller 
> ---
>  drivers/edac/edac_mc_sysfs.c | 38 ++
>  1 file changed, 38 insertions(+)

Regardless, something's still not right yet:

$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject_channel
$ echo 2 > /sys/kernel/debug/edac/mc0/fake_inject_slot
$ echo 3 > /sys/kernel/debug/edac/mc0/fake_inject_count
   ^

$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject

$ grep . /sys/devices/system/edac/mc/mc0/*count
/sys/devices/system/edac/mc/mc0/ce_count:3
 ^

/sys/devices/system/edac/mc/mc0/ce_noinfo_count:0
/sys/devices/system/edac/mc/mc0/ue_count:0
/sys/devices/system/edac/mc/mc0/ue_noinfo_count:0

$ grep -r . /sys/devices/system/edac/mc/mc0/dimm*/* 2>/dev/null | grep 
ce_count
/sys/devices/system/edac/mc/mc0/dimm0/dimm_ce_count:0
/sys/devices/system/edac/mc/mc0/dimm3/dimm_ce_count:0
/sys/devices/system/edac/mc/mc0/dimm6/dimm_ce_count:0
/sys/devices/system/edac/mc/mc0/dimm9/dimm_ce_count:0
^

There should be 3 somewhere in the DIMM counters...

-- 
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.




Re: [PATCH] EDAC: expose per-dimm error counts in sysfs

2016-10-27 Thread Mauro Carvalho Chehab
Em Thu, 27 Oct 2016 20:07:16 +0200
Borislav Petkov  escreveu:

> On Tue, Oct 25, 2016 at 04:25:51PM -0700, Aaron Miller wrote:
> 
> <--- This patch needs a commit message.
> 
> Especially as to *why* we need this.

Also, if you're changing the sysfs ABI, you need to update the EDAC
documentation accordingly.

> 
> > Signed-off-by: Aaron Miller 
> > ---
> >  drivers/edac/edac_mc_sysfs.c | 38 ++
> >  1 file changed, 38 insertions(+)  
> 
> Regardless, something's still not right yet:
> 
> $ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject_channel
> $ echo 2 > /sys/kernel/debug/edac/mc0/fake_inject_slot
> $ echo 3 > /sys/kernel/debug/edac/mc0/fake_inject_count
>^
> 
> $ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject
> 
> $ grep . /sys/devices/system/edac/mc/mc0/*count
> /sys/devices/system/edac/mc/mc0/ce_count:3
>^
> 
> /sys/devices/system/edac/mc/mc0/ce_noinfo_count:0
> /sys/devices/system/edac/mc/mc0/ue_count:0
> /sys/devices/system/edac/mc/mc0/ue_noinfo_count:0
> 
> $ grep -r . /sys/devices/system/edac/mc/mc0/dimm*/* 2>/dev/null | grep 
> ce_count
> /sys/devices/system/edac/mc/mc0/dimm0/dimm_ce_count:0
> /sys/devices/system/edac/mc/mc0/dimm3/dimm_ce_count:0
> /sys/devices/system/edac/mc/mc0/dimm6/dimm_ce_count:0
> /sys/devices/system/edac/mc/mc0/dimm9/dimm_ce_count:0
>   ^
> 
> There should be 3 somewhere in the DIMM counters...
> 



Thanks,
Mauro


Re: [PATCH] EDAC: expose per-dimm error counts in sysfs

2016-10-27 Thread Mauro Carvalho Chehab
Em Thu, 27 Oct 2016 20:07:16 +0200
Borislav Petkov  escreveu:

> On Tue, Oct 25, 2016 at 04:25:51PM -0700, Aaron Miller wrote:
> 
> <--- This patch needs a commit message.
> 
> Especially as to *why* we need this.

Also, if you're changing the sysfs ABI, you need to update the EDAC
documentation accordingly.

> 
> > Signed-off-by: Aaron Miller 
> > ---
> >  drivers/edac/edac_mc_sysfs.c | 38 ++
> >  1 file changed, 38 insertions(+)  
> 
> Regardless, something's still not right yet:
> 
> $ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject_channel
> $ echo 2 > /sys/kernel/debug/edac/mc0/fake_inject_slot
> $ echo 3 > /sys/kernel/debug/edac/mc0/fake_inject_count
>^
> 
> $ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject
> 
> $ grep . /sys/devices/system/edac/mc/mc0/*count
> /sys/devices/system/edac/mc/mc0/ce_count:3
>^
> 
> /sys/devices/system/edac/mc/mc0/ce_noinfo_count:0
> /sys/devices/system/edac/mc/mc0/ue_count:0
> /sys/devices/system/edac/mc/mc0/ue_noinfo_count:0
> 
> $ grep -r . /sys/devices/system/edac/mc/mc0/dimm*/* 2>/dev/null | grep 
> ce_count
> /sys/devices/system/edac/mc/mc0/dimm0/dimm_ce_count:0
> /sys/devices/system/edac/mc/mc0/dimm3/dimm_ce_count:0
> /sys/devices/system/edac/mc/mc0/dimm6/dimm_ce_count:0
> /sys/devices/system/edac/mc/mc0/dimm9/dimm_ce_count:0
>   ^
> 
> There should be 3 somewhere in the DIMM counters...
> 



Thanks,
Mauro


Re: [PATCH] EDAC: expose per-dimm error counts in sysfs

2016-10-27 Thread Borislav Petkov
On Tue, Oct 25, 2016 at 04:25:51PM -0700, Aaron Miller wrote:

<--- This patch needs a commit message.

Especially as to *why* we need this.

> Signed-off-by: Aaron Miller 
> ---
>  drivers/edac/edac_mc_sysfs.c | 38 ++
>  1 file changed, 38 insertions(+)

Regardless, something's still not right yet:

$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject_channel
$ echo 2 > /sys/kernel/debug/edac/mc0/fake_inject_slot
$ echo 3 > /sys/kernel/debug/edac/mc0/fake_inject_count
   ^

$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject

$ grep . /sys/devices/system/edac/mc/mc0/*count
/sys/devices/system/edac/mc/mc0/ce_count:3
 ^

/sys/devices/system/edac/mc/mc0/ce_noinfo_count:0
/sys/devices/system/edac/mc/mc0/ue_count:0
/sys/devices/system/edac/mc/mc0/ue_noinfo_count:0

$ grep -r . /sys/devices/system/edac/mc/mc0/dimm*/* 2>/dev/null | grep ce_count
/sys/devices/system/edac/mc/mc0/dimm0/dimm_ce_count:0
/sys/devices/system/edac/mc/mc0/dimm3/dimm_ce_count:0
/sys/devices/system/edac/mc/mc0/dimm6/dimm_ce_count:0
/sys/devices/system/edac/mc/mc0/dimm9/dimm_ce_count:0
^

There should be 3 somewhere in the DIMM counters...

-- 
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.


Re: [PATCH] EDAC: expose per-dimm error counts in sysfs

2016-10-27 Thread Borislav Petkov
On Tue, Oct 25, 2016 at 04:25:51PM -0700, Aaron Miller wrote:

<--- This patch needs a commit message.

Especially as to *why* we need this.

> Signed-off-by: Aaron Miller 
> ---
>  drivers/edac/edac_mc_sysfs.c | 38 ++
>  1 file changed, 38 insertions(+)

Regardless, something's still not right yet:

$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject_channel
$ echo 2 > /sys/kernel/debug/edac/mc0/fake_inject_slot
$ echo 3 > /sys/kernel/debug/edac/mc0/fake_inject_count
   ^

$ echo 1 > /sys/kernel/debug/edac/mc0/fake_inject

$ grep . /sys/devices/system/edac/mc/mc0/*count
/sys/devices/system/edac/mc/mc0/ce_count:3
 ^

/sys/devices/system/edac/mc/mc0/ce_noinfo_count:0
/sys/devices/system/edac/mc/mc0/ue_count:0
/sys/devices/system/edac/mc/mc0/ue_noinfo_count:0

$ grep -r . /sys/devices/system/edac/mc/mc0/dimm*/* 2>/dev/null | grep ce_count
/sys/devices/system/edac/mc/mc0/dimm0/dimm_ce_count:0
/sys/devices/system/edac/mc/mc0/dimm3/dimm_ce_count:0
/sys/devices/system/edac/mc/mc0/dimm6/dimm_ce_count:0
/sys/devices/system/edac/mc/mc0/dimm9/dimm_ce_count:0
^

There should be 3 somewhere in the DIMM counters...

-- 
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.


[PATCH] EDAC: expose per-dimm error counts in sysfs

2016-10-25 Thread Aaron Miller
Signed-off-by: Aaron Miller 
---
 drivers/edac/edac_mc_sysfs.c | 38 ++
 1 file changed, 38 insertions(+)

diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 4e0f8e720ad9..11440462a3f2 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -569,6 +569,40 @@ static ssize_t dimmdev_edac_mode_show(struct device *dev,
return sprintf(data, "%s\n", edac_caps[dimm->edac_mode]);
 }
 
+static ssize_t dimmdev_ce_count_show(struct device *dev,
+ struct device_attribute *mattr,
+ char *data)
+{
+   struct dimm_info *dimm = to_dimm(dev);
+   u32 count;
+   int off;
+
+   off = EDAC_DIMM_OFF(dimm->mci->layers,
+   dimm->mci->n_layers,
+   dimm->location[0],
+   dimm->location[1],
+   dimm->location[2]);
+   count = dimm->mci->ce_per_layer[dimm->mci->n_layers-1][off];
+   return sprintf(data, "%u\n", count);
+}
+
+static ssize_t dimmdev_ue_count_show(struct device *dev,
+ struct device_attribute *mattr,
+ char *data)
+{
+   struct dimm_info *dimm = to_dimm(dev);
+   u32 count;
+   int off;
+
+   off = EDAC_DIMM_OFF(dimm->mci->layers,
+   dimm->mci->n_layers,
+   dimm->location[0],
+   dimm->location[1],
+   dimm->location[2]);
+   count = dimm->mci->ue_per_layer[dimm->mci->n_layers-1][off];
+   return sprintf(data, "%u\n", count);
+}
+
 /* dimm/rank attribute files */
 static DEVICE_ATTR(dimm_label, S_IRUGO | S_IWUSR,
   dimmdev_label_show, dimmdev_label_store);
@@ -577,6 +611,8 @@ static DEVICE_ATTR(size, S_IRUGO, dimmdev_size_show, NULL);
 static DEVICE_ATTR(dimm_mem_type, S_IRUGO, dimmdev_mem_type_show, NULL);
 static DEVICE_ATTR(dimm_dev_type, S_IRUGO, dimmdev_dev_type_show, NULL);
 static DEVICE_ATTR(dimm_edac_mode, S_IRUGO, dimmdev_edac_mode_show, NULL);
+static DEVICE_ATTR(dimm_ce_count, S_IRUGO, dimmdev_ce_count_show, NULL);
+static DEVICE_ATTR(dimm_ue_count, S_IRUGO, dimmdev_ue_count_show, NULL);
 
 /* attributes of the dimm/rank object */
 static struct attribute *dimm_attrs[] = {
@@ -586,6 +622,8 @@ static struct attribute *dimm_attrs[] = {
_attr_dimm_mem_type.attr,
_attr_dimm_dev_type.attr,
_attr_dimm_edac_mode.attr,
+   _attr_dimm_ce_count.attr,
+   _attr_dimm_ue_count.attr,
NULL,
 };
 
-- 
2.9.3



[PATCH] EDAC: expose per-dimm error counts in sysfs

2016-10-25 Thread Aaron Miller
Signed-off-by: Aaron Miller 
---
 drivers/edac/edac_mc_sysfs.c | 38 ++
 1 file changed, 38 insertions(+)

diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 4e0f8e720ad9..11440462a3f2 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -569,6 +569,40 @@ static ssize_t dimmdev_edac_mode_show(struct device *dev,
return sprintf(data, "%s\n", edac_caps[dimm->edac_mode]);
 }
 
+static ssize_t dimmdev_ce_count_show(struct device *dev,
+ struct device_attribute *mattr,
+ char *data)
+{
+   struct dimm_info *dimm = to_dimm(dev);
+   u32 count;
+   int off;
+
+   off = EDAC_DIMM_OFF(dimm->mci->layers,
+   dimm->mci->n_layers,
+   dimm->location[0],
+   dimm->location[1],
+   dimm->location[2]);
+   count = dimm->mci->ce_per_layer[dimm->mci->n_layers-1][off];
+   return sprintf(data, "%u\n", count);
+}
+
+static ssize_t dimmdev_ue_count_show(struct device *dev,
+ struct device_attribute *mattr,
+ char *data)
+{
+   struct dimm_info *dimm = to_dimm(dev);
+   u32 count;
+   int off;
+
+   off = EDAC_DIMM_OFF(dimm->mci->layers,
+   dimm->mci->n_layers,
+   dimm->location[0],
+   dimm->location[1],
+   dimm->location[2]);
+   count = dimm->mci->ue_per_layer[dimm->mci->n_layers-1][off];
+   return sprintf(data, "%u\n", count);
+}
+
 /* dimm/rank attribute files */
 static DEVICE_ATTR(dimm_label, S_IRUGO | S_IWUSR,
   dimmdev_label_show, dimmdev_label_store);
@@ -577,6 +611,8 @@ static DEVICE_ATTR(size, S_IRUGO, dimmdev_size_show, NULL);
 static DEVICE_ATTR(dimm_mem_type, S_IRUGO, dimmdev_mem_type_show, NULL);
 static DEVICE_ATTR(dimm_dev_type, S_IRUGO, dimmdev_dev_type_show, NULL);
 static DEVICE_ATTR(dimm_edac_mode, S_IRUGO, dimmdev_edac_mode_show, NULL);
+static DEVICE_ATTR(dimm_ce_count, S_IRUGO, dimmdev_ce_count_show, NULL);
+static DEVICE_ATTR(dimm_ue_count, S_IRUGO, dimmdev_ue_count_show, NULL);
 
 /* attributes of the dimm/rank object */
 static struct attribute *dimm_attrs[] = {
@@ -586,6 +622,8 @@ static struct attribute *dimm_attrs[] = {
_attr_dimm_mem_type.attr,
_attr_dimm_dev_type.attr,
_attr_dimm_edac_mode.attr,
+   _attr_dimm_ce_count.attr,
+   _attr_dimm_ue_count.attr,
NULL,
 };
 
-- 
2.9.3