Skip to content

Commit

Permalink
EDAC: Correct scrub rate API
Browse files Browse the repository at this point in the history
The original scrub rate API definition states that if scrub rate
accessors are not implemented, a negative value (-1) should be written
to the sysfs file (/sys/devices/system/edac/mc/mc<N>/sdram_scrub_rate,
where N is the memory controller number on the system). This is
counter-intuitive and awkward at the very least because, when setting
the scrub rate, userspace has to write to sysfs and then read it back to
check error status of the operation.

As Tony notes, best it would be to not have the sdram_scrub_rate in
sysfs if scrub rate support is not implemented. It is too late about
that and a bunch of drivers on a bunch of arches would need to be
changed and tested which is not a trivial task ATM.

Instead, settle for the next best thing of returning -ENODEV when
implementation is missing and -EINVAL when there was an error
encountered while setting the scrub rate.

Reported-by: Han Pingtian <phan@redhat.com>
Cc: Tony Luck <tony.luck@intel.com>
Link: http://lkml.kernel.org/r/20110916105856.GA13253@hpt.nay.redhat.com
Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
  • Loading branch information
Borislav Petkov authored and Borislav Petkov committed Mar 19, 2012
1 parent 11b0a31 commit 5e8e19b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Documentation/edac.txt
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ Sdram memory scrubbing rate:

Reading the file will return the actual scrubbing rate employed.

If configuration fails or memory scrubbing is not implemented, the value
of the attribute file will be -1.
If configuration fails or memory scrubbing is not implemented, accessing
that attribute will fail.



Expand Down
4 changes: 2 additions & 2 deletions drivers/edac/edac_mc_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ static ssize_t mci_sdram_scrub_rate_store(struct mem_ctl_info *mci,
int new_bw = 0;

if (!mci->set_sdram_scrub_rate)
return -EINVAL;
return -ENODEV;

if (strict_strtoul(data, 10, &bandwidth) < 0)
return -EINVAL;
Expand All @@ -475,7 +475,7 @@ static ssize_t mci_sdram_scrub_rate_show(struct mem_ctl_info *mci, char *data)
int bandwidth = 0;

if (!mci->get_sdram_scrub_rate)
return -EINVAL;
return -ENODEV;

bandwidth = mci->get_sdram_scrub_rate(mci);
if (bandwidth < 0) {
Expand Down

0 comments on commit 5e8e19b

Please sign in to comment.