Re: SYSFS "errors"
From: Mauro Carvalho Chehab
Date: Mon Feb 18 2013 - 16:48:33 EST
Em Mon, 18 Feb 2013 22:05:42 +0200
Felipe Balbi <balbi@xxxxxx> escreveu:
> Hi,
>
> On Mon, Feb 18, 2013 at 04:46:38PM -0300, Mauro Carvalho Chehab wrote:
> > > > > No such device - /sys/devices/system/edac/mc/mc0/sdram_scrub_rate
> > > >
> > > > Odd, go ask the edac developers
> > >
> > > will do ;-)
> >
> > Well, the question is missing ;) /me assumes that you want to talk about
> > suspending/resume and EDAC, right?
>
> oops, my bad. The thing is that file has read permission but reading it
> isn't allowed ;-)
That depends on the driver. See drivers/edac/edac_mc_sysfs.c:
static ssize_t mci_sdram_scrub_rate_show(struct device *dev,
struct device_attribute *mattr,
char *data)
{
struct mem_ctl_info *mci = to_mci(dev);
int bandwidth = 0;
if (!mci->get_sdram_scrub_rate)
return -ENODEV;
bandwidth = mci->get_sdram_scrub_rate(mci);
if (bandwidth < 0) {
edac_printk(KERN_DEBUG, EDAC_MC, "Error reading scrub rate\n");
return bandwidth;
}
return sprintf(data, "%d\n", bandwidth);
}
/* memory scrubber attribute file */
DEVICE_ATTR(sdram_scrub_rate, S_IRUGO | S_IWUSR, mci_sdram_scrub_rate_show,
mci_sdram_scrub_rate_store);
static struct attribute *mci_attrs[] = {
&dev_attr_reset_counters.attr,
&dev_attr_mc_name.attr,
&dev_attr_size_mb.attr,
&dev_attr_seconds_since_reset.attr,
&dev_attr_ue_noinfo_count.attr,
&dev_attr_ce_noinfo_count.attr,
&dev_attr_ue_count.attr,
&dev_attr_ce_count.attr,
&dev_attr_sdram_scrub_rate.attr,
&dev_attr_max_location.attr,
NULL
};
The capability of get and/or set the scrub rate is edac-driver specific.
Drivers that support it need to fill those callbacks:
mci->get_sdram_scrub_rate
mci->set_sdram_scrub_rate
In any case, the sysfs attribute is created even if the device doesn't
have support for read/set the scrub rate.
On devices where this is not supported, reading (and/or writing) to this
sysfs node will return -ENODEV.
In the past, the sysfs node creation was done using the raw sysfs support.
Doing dynamic creation with the old code were much more complex. I guess
that's the reason why the code was written this way. Now that the code
uses struct device, it shouldn't be hard to change the code to only
create this attribute if the device has support for scrub rate setting.
Yet, that would change the userspace API. I'm not sure what
applications would rely on the current behavior. So, changing it
would require some investigation in order to avoid regressions.
Regards,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/