linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@amd64.org>
To: "Luck, Tony" <tony.luck@intel.com>
Cc: Han Pingtian <phan@redhat.com>,
	"mchehab@redhat.com" <mchehab@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	edac-devel <linux-edac@vger.kernel.org>,
	Mark Grondona <mgrondona@llnl.gov>,
	Doug Thompson <norsk5@yahoo.com>
Subject: Re: [PATCH v2] Fix EDAC sdram_scrub_rate read/write failure
Date: Wed, 21 Sep 2011 14:33:13 +0200	[thread overview]
Message-ID: <20110921123313.GA29970@aftab> (raw)
In-Reply-To: <987664A83D2D224EAE907B061CE93D5301EAB8A5C8@orsmsx505.amr.corp.intel.com>

Adding some more EDAC people.

On Mon, Sep 19, 2011 at 04:23:35PM -0400, Luck, Tony wrote:
> > @Tony, do you think the above makes sense? Anything against changing
> > that part of the EDAC API to say:
> 
> > Sdram memory scrubbing rate:
> 
> >     If configuration fails or memory scrubbing is not implemented,
> >	the access to that attribute from userspace will fail.
> 
> Ideally we'd not have the file there at all if memory scrubbing isn't
> implemented.

Haa, it'll be great if we could do that. But it doesn't look simple
- the whole sysfs thing comes up along the edac_mc_alloc path and
the ->[gs]et_sdram_scrub_rate func ptrs get assigned after the sysfs
hierarchy is up.

Which means, in order to fix that, we have to change it to support
dynamic sysfs assignment and change a bunch of edac drivers (probably
all, at least the couple I looked at will have to). Which is not a
very big deal but testing them would be a much more formidable task
especially if one doesn't have the hardware to test it on.

> I like having the write fail if the driver cannot set the chosen
> scrub rate ... though there seems to be some wiggle room ... scrub
> rates aren't exact, the user can try to set one and then read back
> to find out what the rate was actually rounded to. If you have to
> read back anyway, then reading back to find out if you failed doesn't
> look quite so odd (still odd, but with some sort of logic).

Agreed, I still think "fail the write" is much more intuitive than what
we have now. And I think we should change it if we're not breaking a
bunch of userspace (which I seriously doubt). Originally I thought
edac-utils might use the scrub rate thing but grepping through v0.16
sources doesn't say anything about scrub rate.

So how about the following - people should scream now if they see
problem with it and if we're breaking their userspace stuff (they should
fix them anyway though :-)

If scrub rate setting is not implemented, we say "No such device." and
otherwise on error we say "Invalid argument" which should be clear,
IMHO.

--
From: Borislav Petkov <borislav.petkov@amd.com>
Date: Wed, 21 Sep 2011 14:10:43 +0200
Subject: [PATCH] EDAC: Correct scrub rate API

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>
---
 Documentation/edac.txt       |    4 ++--
 drivers/edac/edac_mc_sysfs.c |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Documentation/edac.txt b/Documentation/edac.txt
index 249822c..fdcc49f 100644
--- a/Documentation/edac.txt
+++ b/Documentation/edac.txt
@@ -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.
 
 
 
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 29ffa35..deb91fd 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -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;
@@ -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) {
-- 
1.7.4.rc2



-- 
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551

  reply	other threads:[~2011-09-21 12:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-16 10:58 [PATCH] Fix EDAC sdram_scrub_rate read failure Han Pingtian
2011-09-16 12:53 ` Borislav Petkov
2011-09-19  7:37   ` [PATCH v2] Fix EDAC sdram_scrub_rate read/write failure Han Pingtian
2011-09-19 14:20     ` Borislav Petkov
2011-09-19 20:23       ` Luck, Tony
2011-09-21 12:33         ` Borislav Petkov [this message]
2011-09-21 15:41           ` Luck, Tony

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110921123313.GA29970@aftab \
    --to=bp@amd64.org \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@redhat.com \
    --cc=mgrondona@llnl.gov \
    --cc=norsk5@yahoo.com \
    --cc=phan@redhat.com \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).